mirror of
https://github.com/5vl/Staff.git
synced 2025-05-24 10:56:59 +00:00
added items to items, invsee command. <3 minimessage!
This commit is contained in:
parent
a3ba0b3f76
commit
5a2c10d7fd
@ -1,25 +1,25 @@
|
|||||||
package me.fivevl.staff
|
package me.fivevl.staff
|
||||||
|
|
||||||
import org.bukkit.configuration.file.FileConfiguration
|
|
||||||
|
|
||||||
object Config {
|
object Config {
|
||||||
private fun getConfig(): FileConfiguration {
|
val mustBePlayer = Utils.instance!!.config.getString("must-be-player")!!
|
||||||
return Utils.getConfig()
|
val noPermission = Utils.instance!!.config.getString("no-permission")!!
|
||||||
}
|
val toggleStaffmodeOn = Utils.instance!!.config.getString("toggle-staffmode-on")!!
|
||||||
val mustBePlayer = getConfig().getString("must-be-player")!!
|
val toggleStaffmodeOff = Utils.instance!!.config.getString("toggle-staffmode-off")!!
|
||||||
val noPermission = getConfig().getString("no-permission")!!
|
val toggleVanishOn = Utils.instance!!.config.getString("toggle-vanish-on")!!
|
||||||
val toggleStaffmodeOn = getConfig().getString("toggle-staffmode-on")!!
|
val toggleVanishOff = Utils.instance!!.config.getString("toggle-vanish-off")!!
|
||||||
val toggleStaffmodeOff = getConfig().getString("toggle-staffmode-off")!!
|
|
||||||
val toggleVanishOn = getConfig().getString("toggle-vanish-on")!!
|
|
||||||
val toggleVanishOff = getConfig().getString("toggle-vanish-off")!!
|
|
||||||
val staffmodeHotbar = HashMap<Int, String>().apply {
|
val staffmodeHotbar = HashMap<Int, String>().apply {
|
||||||
getConfig().getConfigurationSection("staffmode-hotbar")?.getKeys(false)?.forEach {
|
Utils.instance!!.config.getConfigurationSection("staffmode-hotbar")?.getKeys(false)?.forEach {
|
||||||
put(it.toInt(), getConfig().getString("staffmode-hotbar.$it")!!)
|
put(it.toInt(), Utils.instance!!.config.getString("staffmode-hotbar.$it")!!)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val disableStaffmodeItem = getConfig().getString("items.DISABLE_STAFFMODE")!!
|
val disableStaffmodeItemName = Utils.instance!!.config.getString("items.DISABLE_STAFFMODE.name")!!
|
||||||
val freezeWandItem = getConfig().getString("items.FREEZE_WAND")!!
|
val freezeWandItemName = Utils.instance!!.config.getString("items.FREEZE_WAND.name")!!
|
||||||
val inventoryWandItem = getConfig().getString("items.INVENTORY_WAND")!!
|
val inventoryWandItemName = Utils.instance!!.config.getString("items.INVENTORY_WAND.name")!!
|
||||||
val kbStickItem = getConfig().getString("items.KB_STICK")!!
|
val kbStickItemName = Utils.instance!!.config.getString("items.KB_STICK.name")!!
|
||||||
val vanishItem = getConfig().getString("items.VANISH_ITEM")!!
|
val vanishItemName = Utils.instance!!.config.getString("items.VANISH_ITEM.name")!!
|
||||||
|
val disableStaffmodeItem = Utils.instance!!.config.getString("items.DISABLE_STAFFMODE.item")!!
|
||||||
|
val freezeWandItem = Utils.instance!!.config.getString("items.FREEZE_WAND.item")!!
|
||||||
|
val inventoryWandItem = Utils.instance!!.config.getString("items.INVENTORY_WAND.item")!!
|
||||||
|
val kbStickItem = Utils.instance!!.config.getString("items.KB_STICK.item")!!
|
||||||
|
val vanishItem = Utils.instance!!.config.getString("items.VANISH_ITEM.item")!!
|
||||||
}
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package me.fivevl.staff
|
package me.fivevl.staff
|
||||||
|
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
|
import org.bukkit.enchantments.Enchantment
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
|
|
||||||
enum class Items(val item: ItemStack) {
|
enum class Items(val item: ItemStack) {
|
||||||
@ -12,41 +13,42 @@ enum class Items(val item: ItemStack) {
|
|||||||
}
|
}
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
private fun getStaffmodeItem(): ItemStack {
|
private fun getStaffmodeItem(): ItemStack {
|
||||||
val item = ItemStack(Material.LIME_DYE)
|
val item = ItemStack(Material.valueOf(Config.disableStaffmodeItem))
|
||||||
val meta = item.itemMeta
|
val meta = item.itemMeta
|
||||||
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.disableStaffmodeItem)))
|
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.disableStaffmodeItemName)))
|
||||||
item.itemMeta = meta
|
item.itemMeta = meta
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
private fun getFreezeWandItem(): ItemStack {
|
private fun getFreezeWandItem(): ItemStack {
|
||||||
val item = ItemStack(Material.CHAIN)
|
val item = ItemStack(Material.valueOf(Config.freezeWandItem))
|
||||||
val meta = item.itemMeta
|
val meta = item.itemMeta
|
||||||
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.freezeWandItem)))
|
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.freezeWandItemName)))
|
||||||
item.itemMeta = meta
|
item.itemMeta = meta
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
private fun getInventoryWandItem(): ItemStack {
|
private fun getInventoryWandItem(): ItemStack {
|
||||||
val item = ItemStack(Material.BLAZE_ROD)
|
val item = ItemStack(Material.valueOf(Config.inventoryWandItem))
|
||||||
val meta = item.itemMeta
|
val meta = item.itemMeta
|
||||||
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.inventoryWandItem)))
|
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.inventoryWandItemName)))
|
||||||
item.itemMeta = meta
|
item.itemMeta = meta
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
private fun getKbStickItem(): ItemStack {
|
private fun getKbStickItem(): ItemStack {
|
||||||
val item = ItemStack(Material.STICK)
|
val item = ItemStack(Material.valueOf(Config.kbStickItem))
|
||||||
val meta = item.itemMeta
|
val meta = item.itemMeta
|
||||||
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.kbStickItem)))
|
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.kbStickItemName)))
|
||||||
|
meta.addEnchant(Enchantment.KNOCKBACK, 10, true)
|
||||||
item.itemMeta = meta
|
item.itemMeta = meta
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
private fun getVanishItem(): ItemStack {
|
private fun getVanishItem(): ItemStack {
|
||||||
val item = ItemStack(Material.BARRIER)
|
val item = ItemStack(Material.valueOf(Config.vanishItem))
|
||||||
val meta = item.itemMeta
|
val meta = item.itemMeta
|
||||||
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.vanishItem)))
|
meta.setDisplayName(Utils.color(Utils.getPlaceholders(null, Config.vanishItemName)))
|
||||||
item.itemMeta = meta
|
item.itemMeta = meta
|
||||||
return item
|
return item
|
||||||
}
|
}
|
@ -1,5 +1,6 @@
|
|||||||
package me.fivevl.staff
|
package me.fivevl.staff
|
||||||
|
|
||||||
|
import me.fivevl.staff.commands.InvseeCommand
|
||||||
import me.fivevl.staff.commands.StaffModeCommand
|
import me.fivevl.staff.commands.StaffModeCommand
|
||||||
import me.fivevl.staff.commands.VanishCommand
|
import me.fivevl.staff.commands.VanishCommand
|
||||||
import me.fivevl.staff.listeners.JoinListener
|
import me.fivevl.staff.listeners.JoinListener
|
||||||
@ -14,6 +15,7 @@ class Main : JavaPlugin() {
|
|||||||
|
|
||||||
getCommand("staffmode")!!.setExecutor(StaffModeCommand())
|
getCommand("staffmode")!!.setExecutor(StaffModeCommand())
|
||||||
getCommand("vanish")!!.setExecutor(VanishCommand())
|
getCommand("vanish")!!.setExecutor(VanishCommand())
|
||||||
|
getCommand("invsee")!!.setExecutor(InvseeCommand())
|
||||||
|
|
||||||
Bukkit.getPluginManager().registerEvents(JoinListener(), this)
|
Bukkit.getPluginManager().registerEvents(JoinListener(), this)
|
||||||
logger.info("Staff plugin enabled.")
|
logger.info("Staff plugin enabled.")
|
||||||
|
@ -6,14 +6,13 @@ import net.kyori.adventure.text.minimessage.MiniMessage
|
|||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
import org.bukkit.ChatColor
|
import org.bukkit.ChatColor
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
import org.bukkit.configuration.file.FileConfiguration
|
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
import org.bukkit.inventory.Inventory
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.PlayerInventory
|
|
||||||
|
|
||||||
object Utils {
|
object Utils {
|
||||||
var instance: Main? = null
|
var instance: Main? = null
|
||||||
val inStaffmode = HashMap<Player, PlayerInventory>()
|
val inStaffmode = HashMap<Player, Inventory>()
|
||||||
val inVanish = ArrayList<Player>()
|
val inVanish = ArrayList<Player>()
|
||||||
@Suppress("deprecation")
|
@Suppress("deprecation")
|
||||||
fun mm(s: String): Component {
|
fun mm(s: String): Component {
|
||||||
@ -63,8 +62,4 @@ object Utils {
|
|||||||
p.sendMessage(mm(getPlaceholders(p, Config.toggleVanishOn)))
|
p.sendMessage(mm(getPlaceholders(p, Config.toggleVanishOn)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun getConfig(): FileConfiguration {
|
|
||||||
return instance!!.config
|
|
||||||
}
|
|
||||||
}
|
}
|
27
src/main/java/me/fivevl/staff/commands/InvseeCommand.kt
Normal file
27
src/main/java/me/fivevl/staff/commands/InvseeCommand.kt
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package me.fivevl.staff.commands
|
||||||
|
|
||||||
|
import me.fivevl.staff.Config
|
||||||
|
import me.fivevl.staff.Utils
|
||||||
|
import org.bukkit.command.Command
|
||||||
|
import org.bukkit.command.CommandExecutor
|
||||||
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
|
class InvseeCommand : CommandExecutor {
|
||||||
|
override fun onCommand(sender: CommandSender, command: Command, label: String, args: Array<out String>): Boolean {
|
||||||
|
if (sender !is Player) {
|
||||||
|
sender.sendMessage(Utils.mm(Utils.getPlaceholders(null, Config.mustBePlayer)))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
val p = sender.player!!
|
||||||
|
if (!p.hasPermission("staff.invsee")) {
|
||||||
|
p.sendMessage(Utils.mm(Utils.getPlaceholders(p, Config.noPermission)))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if (args.size != 1) {
|
||||||
|
p.sendMessage(Utils.mm("<red><hover:show_text:Click me to insert command!><click:suggest_command:/invsee >Usage: /invsee <player></click></hover></red>"))
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
@ -10,25 +10,30 @@ toggle-fly-on: "<green>Toggled fly on!</green>" # Message shown when a player to
|
|||||||
toggle-fly-off: "<red>Toggled fly off!</red>" # Message shown when a player toggles fly off
|
toggle-fly-off: "<red>Toggled fly off!</red>" # Message shown when a player toggles fly off
|
||||||
|
|
||||||
# In this section of the config you can change the items given to you in staffmode. Please do not use colors here.
|
# 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: "DISABLE_STAFFMODE", "FREEZE_WAND", "INVENTORY_WAND", "KB_STICK", "VANISH_ITEM"
|
||||||
1: "DISABLE_STAFFMODE"
|
1: "DISABLE_STAFFMODE"
|
||||||
2: "AIR"
|
2: ""
|
||||||
3: "FREEZE_WAND"
|
3: "FREEZE_WAND"
|
||||||
4: "AIR"
|
4: ""
|
||||||
5: "INVENTORY_WAND"
|
5: "INVENTORY_WAND"
|
||||||
6: "AIR"
|
6: ""
|
||||||
7: "KB_STICK"
|
7: "KB_STICK"
|
||||||
8: "AIR"
|
8: ""
|
||||||
9: "VANISH_ITEM"
|
9: "VANISH_ITEM"
|
||||||
# For items, please use `&` color codes.
|
# For items, please use `&` color codes.
|
||||||
items:
|
items:
|
||||||
DISABLE_STAFFMODE:
|
DISABLE_STAFFMODE:
|
||||||
|
item: "LIME_DYE"
|
||||||
name: "&cDisable Staffmode"
|
name: "&cDisable Staffmode"
|
||||||
FREEZE_WAND:
|
FREEZE_WAND:
|
||||||
name: "&cFreeze Wand"
|
item: "CHAIN"
|
||||||
|
name: "&bFreeze Wand"
|
||||||
INVENTORY_WAND:
|
INVENTORY_WAND:
|
||||||
|
item: "BLAZE_ROD"
|
||||||
name: "&cInventory Wand"
|
name: "&cInventory Wand"
|
||||||
KB_STICK:
|
KB_STICK:
|
||||||
|
item: "STICK"
|
||||||
name: "&cKnockback Stick"
|
name: "&cKnockback Stick"
|
||||||
VANISH_ITEM:
|
VANISH_ITEM:
|
||||||
name: "&cVanish"
|
item: "BARRIER"
|
||||||
|
name: "&rVanish"
|
@ -13,3 +13,5 @@ commands:
|
|||||||
description: Vanish from all players!
|
description: Vanish from all players!
|
||||||
aliases:
|
aliases:
|
||||||
- v
|
- v
|
||||||
|
invsee:
|
||||||
|
description: View someones inventory.
|
Loading…
x
Reference in New Issue
Block a user