mirror of
				https://github.com/5vl/Staff.git
				synced 2025-10-31 07:43:36 +00:00 
			
		
		
		
	Made staff mode work for the most part
This commit is contained in:
		| @@ -11,9 +11,11 @@ I made this plugin by request of a friend, and because I didn't have anything to | |||||||
| - /staffmode - staff.staffmode | - /staffmode - staff.staffmode | ||||||
| - /freeze - staff.freeze | - /freeze - staff.freeze | ||||||
| - /openinv - staff.openinv | - /openinv - staff.openinv | ||||||
|  | - /vanish - /v - staff.vanish | ||||||
|  |  | ||||||
| # Staff mode items: | # Staff mode items: | ||||||
| - Disable staffmode - staff.staffmode | - Disable staffmode item - staff.staffmode | ||||||
| - Freeze wand - staff.freeze.wand | - Freeze wand - staff.freeze.wand | ||||||
| - Inventory wand - staff.openinv.wand | - Inventory wand - staff.openinv.wand | ||||||
| - Knockback Stick - staff.kbstick | - Knockback Stick - staff.kbstick | ||||||
|  | - Vanish item - staff.vanish.item | ||||||
| @@ -6,4 +6,10 @@ object Config { | |||||||
|     var config: FileConfiguration? = null |     var config: FileConfiguration? = null | ||||||
|     val mustBePlayer = config?.getString("must-be-player") |     val mustBePlayer = config?.getString("must-be-player") | ||||||
|     val noPermission = config?.getString("no-permission") |     val noPermission = config?.getString("no-permission") | ||||||
|  |     val toggleStaffmode = config?.getString("toggle-staffmode") | ||||||
|  |     val staffmodeHotbar = HashMap<Int, String>().apply { | ||||||
|  |         config?.getConfigurationSection("staffmode-hotbar")?.getKeys(false)?.forEach { | ||||||
|  |             put(it.toInt(), config?.getString("staffmode-hotbar.$it")!!) | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
| @@ -1,12 +1,15 @@ | |||||||
| 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.md_5.bungee.api.ChatColor | ||||||
|  | import org.bukkit.Material | ||||||
| import org.bukkit.entity.Player | import org.bukkit.entity.Player | ||||||
|  | import org.bukkit.inventory.ItemStack | ||||||
|  | import org.bukkit.inventory.PlayerInventory | ||||||
| import java.util.regex.Pattern | import java.util.regex.Pattern | ||||||
|  |  | ||||||
| object Utils { | object Utils { | ||||||
|  |     private val inStaffmode = HashMap<Player, PlayerInventory>() | ||||||
|     @Suppress("deprecation") |     @Suppress("deprecation") | ||||||
|     fun hex(s: String): String { |     fun hex(s: String): String { | ||||||
|         var s2 = s |         var s2 = s | ||||||
| @@ -22,4 +25,26 @@ object Utils { | |||||||
|     fun getPlaceholders(p: Player?, s: String): String { |     fun getPlaceholders(p: Player?, s: String): String { | ||||||
|         return PlaceholderAPI.setPlaceholders(p, s) |         return PlaceholderAPI.setPlaceholders(p, s) | ||||||
|     } |     } | ||||||
|  |     fun toggleStaffmode(p: Player) { | ||||||
|  |         if (inStaffmode.containsKey(p)) { | ||||||
|  |             p.inventory.clear() | ||||||
|  |             p.inventory.contents = inStaffmode[p]!!.contents | ||||||
|  |             inStaffmode.remove(p) | ||||||
|  |         } else { | ||||||
|  |             inStaffmode[p] = p.inventory | ||||||
|  |             p.inventory.clear() | ||||||
|  |             for (i: Int in Config.staffmodeHotbar.keys) { | ||||||
|  |                 var item = ItemStack(Material.AIR) | ||||||
|  |                 when (Config.staffmodeHotbar[i]) { | ||||||
|  |                     "DISABLE_STAFFMODE" -> item = ItemStack(Material.AIR) | ||||||
|  |                     "FREEZE_WAND" -> item = ItemStack(Material.AIR) | ||||||
|  |                     "INVENTORY_WAND" -> item = ItemStack(Material.AIR) | ||||||
|  |                     "KB_STICK" -> item = ItemStack(Material.AIR) | ||||||
|  |                     "VANISH_ITEM" -> item = ItemStack(Material.AIR) | ||||||
|  |                 } | ||||||
|  |                 p.inventory.setItem(i - 1, item) | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         p.sendMessage(hex(getPlaceholders(p, Config.toggleStaffmode!!))) | ||||||
|  |     } | ||||||
| } | } | ||||||
| @@ -18,6 +18,7 @@ class StaffModeCommand : CommandExecutor { | |||||||
|             p.sendMessage(Utils.hex(Utils.getPlaceholders(p, Config.noPermission!!))) |             p.sendMessage(Utils.hex(Utils.getPlaceholders(p, Config.noPermission!!))) | ||||||
|             return true |             return true | ||||||
|         } |         } | ||||||
|  |         Utils.toggleStaffmode(p) | ||||||
|         return true |         return true | ||||||
|     } |     } | ||||||
| } | } | ||||||
| @@ -1,2 +1,13 @@ | |||||||
| must-be-player: "&cYou must be a player to use this command!" | 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 | ||||||
| no-permission: "&cYou don't have permission to use this command!" | 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 | ||||||
|  | toggle-staffmode: "&aToggled staffmode!" # Message shown when a player toggles staffmode | ||||||
|  | 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: "AIR" | ||||||
|  |   2: "AIR" | ||||||
|  |   3: "AIR" | ||||||
|  |   4: "AIR" | ||||||
|  |   5: "AIR" | ||||||
|  |   6: "AIR" | ||||||
|  |   7: "AIR" | ||||||
|  |   8: "AIR" | ||||||
|  |   9: "AIR" | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 5vl
					5vl