mirror of
https://github.com/5vl/Staff.git
synced 2025-05-24 10:56:59 +00:00
changed stuff
This commit is contained in:
parent
bdab267df1
commit
ebdfe8ae1f
@ -17,5 +17,5 @@ object Config {
|
|||||||
put(it.toInt(), getConfig().getString("staffmode-hotbar.$it")!!)
|
put(it.toInt(), getConfig().getString("staffmode-hotbar.$it")!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val disableStaffmodeItem = getConfig().getString("disable-staffmode-item")!!
|
val disableStaffmodeItem = getConfig().getString("items.DISABLE_STAFFMODE")!!
|
||||||
}
|
}
|
@ -14,6 +14,7 @@ enum class Items(val item: ItemStack) {
|
|||||||
private fun getStaffmodeItem(): ItemStack {
|
private fun getStaffmodeItem(): ItemStack {
|
||||||
val item = ItemStack(Material.LIME_DYE)
|
val item = ItemStack(Material.LIME_DYE)
|
||||||
val meta = item.itemMeta
|
val meta = item.itemMeta
|
||||||
meta.setDisplayName(Utils.hex(Utils.getPlaceholders(null, Config.disableStaffmodeItem)))
|
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.disableStaffmodeItem)))
|
||||||
|
item.itemMeta = meta
|
||||||
return item
|
return item
|
||||||
}
|
}
|
@ -1,30 +1,34 @@
|
|||||||
package me.fivevl.staff
|
package me.fivevl.staff
|
||||||
|
|
||||||
import me.clip.placeholderapi.PlaceholderAPI
|
import me.clip.placeholderapi.PlaceholderAPI
|
||||||
import net.md_5.bungee.api.ChatColor
|
import net.kyori.adventure.text.Component
|
||||||
|
import net.kyori.adventure.text.minimessage.MiniMessage
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.configuration.file.FileConfiguration
|
import org.bukkit.configuration.file.FileConfiguration
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.PlayerInventory
|
import org.bukkit.inventory.PlayerInventory
|
||||||
import java.util.regex.Pattern
|
|
||||||
|
|
||||||
object Utils {
|
object Utils {
|
||||||
var instance: Main? = null
|
var instance: Main? = null
|
||||||
val inStaffmode = HashMap<Player, PlayerInventory>()
|
val inStaffmode = HashMap<Player, PlayerInventory>()
|
||||||
val inVanish = ArrayList<Player>()
|
val inVanish = ArrayList<Player>()
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
fun hex(s: String): String {
|
fun mm(s: String): Component {
|
||||||
var s2 = s
|
/*val pattern = Pattern.compile("#[a-fA-F0-9]{6}")
|
||||||
val pattern = Pattern.compile("#[a-fA-F0-9]{6}")
|
|
||||||
var match = pattern.matcher(s)
|
var match = pattern.matcher(s)
|
||||||
while (match.find()) {
|
while (match.find()) {
|
||||||
val color = s.substring(match.start(), match.end())
|
val color = s.substring(match.start(), match.end())
|
||||||
s2 = s2.replace(color, ChatColor.of(color).toString())
|
s2 = s2.replace(color, ChatColor.of(color).toString())
|
||||||
match = pattern.matcher(s2)
|
match = pattern.matcher(s2)
|
||||||
}
|
}
|
||||||
return ChatColor.translateAlternateColorCodes('&', s2)
|
return ChatColor.translateAlternateColorCodes('&', s2)*/
|
||||||
|
return MiniMessage.miniMessage().deserialize(s)
|
||||||
|
}
|
||||||
|
fun color(s: String): String {
|
||||||
|
return ChatColor.translateAlternateColorCodes('&', s)
|
||||||
}
|
}
|
||||||
fun getPlaceholders(p: Player?, s: String): String {
|
fun getPlaceholders(p: Player?, s: String): String {
|
||||||
return PlaceholderAPI.setPlaceholders(p, s)
|
return PlaceholderAPI.setPlaceholders(p, s)
|
||||||
@ -34,7 +38,7 @@ object Utils {
|
|||||||
p.inventory.clear()
|
p.inventory.clear()
|
||||||
p.inventory.contents = inStaffmode[p]!!.contents
|
p.inventory.contents = inStaffmode[p]!!.contents
|
||||||
inStaffmode.remove(p)
|
inStaffmode.remove(p)
|
||||||
p.sendMessage(hex(getPlaceholders(p, Config.toggleStaffmodeOff)))
|
p.sendMessage(mm(getPlaceholders(p, Config.toggleStaffmodeOff)))
|
||||||
} else {
|
} else {
|
||||||
inStaffmode[p] = p.inventory
|
inStaffmode[p] = p.inventory
|
||||||
p.inventory.clear()
|
p.inventory.clear()
|
||||||
@ -49,7 +53,7 @@ object Utils {
|
|||||||
}
|
}
|
||||||
p.inventory.setItem(i - 1, item)
|
p.inventory.setItem(i - 1, item)
|
||||||
}
|
}
|
||||||
p.sendMessage(hex(getPlaceholders(p, Config.toggleStaffmodeOn)))
|
p.sendMessage(mm(getPlaceholders(p, Config.toggleStaffmodeOn)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fun toggleVanish(p: Player) {
|
fun toggleVanish(p: Player) {
|
||||||
@ -58,13 +62,13 @@ object Utils {
|
|||||||
ps.showPlayer(instance!!, p)
|
ps.showPlayer(instance!!, p)
|
||||||
}
|
}
|
||||||
inVanish.remove(p)
|
inVanish.remove(p)
|
||||||
p.sendMessage(hex(getPlaceholders(p, Config.toggleVanishOff)))
|
p.sendMessage(mm(getPlaceholders(p, Config.toggleVanishOff)))
|
||||||
} else {
|
} else {
|
||||||
for (ps in Bukkit.getOnlinePlayers()) {
|
for (ps in Bukkit.getOnlinePlayers()) {
|
||||||
ps.hidePlayer(instance!!, p)
|
ps.hidePlayer(instance!!, p)
|
||||||
}
|
}
|
||||||
inVanish.add(p)
|
inVanish.add(p)
|
||||||
p.sendMessage(hex(getPlaceholders(p, Config.toggleVanishOn)))
|
p.sendMessage(mm(getPlaceholders(p, Config.toggleVanishOn)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,12 +10,12 @@ import org.bukkit.entity.Player
|
|||||||
class StaffModeCommand : CommandExecutor {
|
class StaffModeCommand : CommandExecutor {
|
||||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
||||||
if (sender !is Player) {
|
if (sender !is Player) {
|
||||||
sender.sendMessage(Utils.hex(Utils.getPlaceholders(null, Config.mustBePlayer)))
|
sender.sendMessage(Utils.mm(Utils.getPlaceholders(null, Config.mustBePlayer)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
val p = sender.player!!
|
val p = sender.player!!
|
||||||
if (!p.hasPermission("staff.staffmode")) {
|
if (!p.hasPermission("staff.staffmode")) {
|
||||||
p.sendMessage(Utils.hex(Utils.getPlaceholders(p, Config.noPermission)))
|
p.sendMessage(Utils.mm(Utils.getPlaceholders(p, Config.noPermission)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
Utils.toggleStaffmode(p)
|
Utils.toggleStaffmode(p)
|
||||||
|
@ -10,12 +10,12 @@ import org.bukkit.entity.Player
|
|||||||
class VanishCommand : CommandExecutor {
|
class VanishCommand : CommandExecutor {
|
||||||
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
||||||
if (sender !is Player) {
|
if (sender !is Player) {
|
||||||
sender.sendMessage(Utils.hex(Utils.getPlaceholders(null, Config.mustBePlayer)))
|
sender.sendMessage(Utils.mm(Utils.getPlaceholders(null, Config.mustBePlayer)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
val p = sender.player!!
|
val p = sender.player!!
|
||||||
if (!p.hasPermission("staff.vanish")) {
|
if (!p.hasPermission("staff.vanish")) {
|
||||||
p.sendMessage(Utils.hex(Utils.getPlaceholders(p, Config.noPermission)))
|
p.sendMessage(Utils.mm(Utils.getPlaceholders(p, Config.noPermission)))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
Utils.toggleVanish(p)
|
Utils.toggleVanish(p)
|
||||||
|
@ -10,7 +10,6 @@ class JoinListener : Listener {
|
|||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onJoin(e: PlayerJoinEvent) {
|
fun onJoin(e: PlayerJoinEvent) {
|
||||||
e.joinMessage = null
|
|
||||||
val p = e.player
|
val p = e.player
|
||||||
for (ps in Utils.inVanish) {
|
for (ps in Utils.inVanish) {
|
||||||
p.hidePlayer(Utils.instance!!, ps)
|
p.hidePlayer(Utils.instance!!, ps)
|
||||||
@ -19,7 +18,6 @@ class JoinListener : Listener {
|
|||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onLeave (e: PlayerQuitEvent) {
|
fun onLeave (e: PlayerQuitEvent) {
|
||||||
e.quitMessage = null
|
|
||||||
val p = e.player
|
val p = e.player
|
||||||
if (Utils.inVanish.contains(p)) {
|
if (Utils.inVanish.contains(p)) {
|
||||||
Utils.inVanish.remove(p)
|
Utils.inVanish.remove(p)
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
# In this section of the config you can change all the messages in the plugin.
|
# In this section of the config you can change all the messages in the plugin.
|
||||||
must-be-player: "&cYou must be a player to use this command!" # Message shown when a player tries to use a command that requires them to be a player
|
# For messages please use the minimessage formatting, see https://docs.adventure.kyori.net/minimessage/format.html#minimessage-format
|
||||||
no-permission: "&cYou don't have permission to use this command!" # Message shown when a player tries to use a command that they don't have permission to use
|
must-be-player: "<red>You must be a player to use this command!" # Message shown when a player tries to use a command that requires them to be a player
|
||||||
toggle-staffmode-on: "&aToggled staffmode on!" # Message shown when a player toggles staffmode on
|
no-permission: "<red>You don't have permission to use this command!" # Message shown when a player tries to use a command that they don't have permission to use
|
||||||
toggle-staffmode-off: "&cToggled staffmode off!" # Message shown when a player toggles staffmode off
|
toggle-staffmode-on: "<green>Toggled staffmode on!" # Message shown when a player toggles staffmode on
|
||||||
toggle-vanish-on: "&aToggled vanish on!" # Message shown when a player toggles vanish on
|
toggle-staffmode-off: "<red>Toggled staffmode off!" # Message shown when a player toggles staffmode off
|
||||||
toggle-vanish-off: "&cToggled vanish off!" # Message shown when a player toggles vanish off
|
toggle-vanish-on: "<green>Toggled vanish on!" # Message shown when a player toggles vanish on
|
||||||
toggle-fly-on: "&aToggled fly on!" # Message shown when a player toggles fly on
|
toggle-vanish-off: "<red>Toggled vanish off!" # Message shown when a player toggles vanish off
|
||||||
toggle-fly-off: "&cToggled fly off!" # Message shown when a player toggles fly off
|
toggle-fly-on: "<green>Toggled fly on!" # Message shown when a player toggles fly on
|
||||||
|
toggle-fly-off: "<red>Toggled fly off!" # Message shown when a player toggles fly off
|
||||||
|
|
||||||
# In this section of the config you can change the items given to you in staffmode.
|
# In this section of the config you can change the items given to you in staffmode. Please do not use colors here.
|
||||||
staffmode-hotbar: # List of items to give the player when they toggle staffmode, available items: "AIR", "DISABLE_STAFFMODE", "FREEZE_WAND", "INVENTORY_WAND", "KB_STICK", "VANISH_ITEM"
|
staffmode-hotbar: # List of items to give the player when they toggle staffmode, available items: "AIR", "DISABLE_STAFFMODE", "FREEZE_WAND", "INVENTORY_WAND", "KB_STICK", "VANISH_ITEM"
|
||||||
1: "DISABLE_STAFFMODE"
|
1: "DISABLE_STAFFMODE"
|
||||||
2: "AIR"
|
2: "AIR"
|
||||||
@ -19,4 +20,15 @@ staffmode-hotbar: # List of items to give the player when they toggle staffmode,
|
|||||||
7: "KB_STICK"
|
7: "KB_STICK"
|
||||||
8: "AIR"
|
8: "AIR"
|
||||||
9: "VANISH_ITEM"
|
9: "VANISH_ITEM"
|
||||||
disable-staffmode-item: "&aDisable staffmode" # Item name of the item that disables staffmode
|
# For items, please use & color codes.
|
||||||
|
items:
|
||||||
|
DISABLE_STAFFMODE:
|
||||||
|
name: "&cDisable Staffmode"
|
||||||
|
FREEZE_WAND:
|
||||||
|
name: "&cFreeze Wand"
|
||||||
|
INVENTORY_WAND:
|
||||||
|
name: "&cInventory Wand"
|
||||||
|
KB_STICK:
|
||||||
|
name: "&cKnockback Stick"
|
||||||
|
VANISH_ITEM:
|
||||||
|
name: "&cVanish"
|
Loading…
x
Reference in New Issue
Block a user