nicer banning ; and some effects ; spectating ; generally overhauled!
All checks were successful
Maven Build / build (push) Successful in 10m43s
All checks were successful
Maven Build / build (push) Successful in 10m43s
This commit is contained in:
@@ -5,22 +5,29 @@ package org.easyadmin.easyadmin
|
|||||||
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.Particle
|
||||||
|
import org.bukkit.Sound
|
||||||
|
import org.bukkit.FireworkEffect
|
||||||
import org.bukkit.command.Command
|
import org.bukkit.command.Command
|
||||||
import org.bukkit.command.CommandSender
|
import org.bukkit.command.CommandSender
|
||||||
|
import org.bukkit.entity.Firework
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.EventHandler
|
import org.bukkit.event.EventHandler
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
import org.bukkit.event.inventory.InventoryClickEvent
|
import org.bukkit.event.inventory.InventoryClickEvent
|
||||||
|
import org.bukkit.event.player.PlayerChatEvent
|
||||||
|
import org.bukkit.event.EventPriority
|
||||||
import org.bukkit.inventory.ItemStack
|
import org.bukkit.inventory.ItemStack
|
||||||
import org.bukkit.inventory.meta.ItemMeta // Don't remove!
|
import org.bukkit.inventory.meta.ItemMeta
|
||||||
import org.bukkit.plugin.java.JavaPlugin // Don't remove!
|
import org.bukkit.inventory.meta.FireworkMeta
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
class Easyadmin : JavaPlugin(), Listener {
|
class Easyadmin : JavaPlugin(), Listener {
|
||||||
private val menuName = "${ChatColor.DARK_PURPLE}${ChatColor.BOLD}EasyAdmin"
|
private val menuName = "${ChatColor.DARK_PURPLE}${ChatColor.BOLD}EasyAdmin"
|
||||||
|
private val banReasons = mutableMapOf<UUID, Pair<String, Player>>()
|
||||||
|
|
||||||
override fun onEnable() {
|
override fun onEnable() {
|
||||||
// Register events and commands
|
|
||||||
server.pluginManager.registerEvents(this, this)
|
server.pluginManager.registerEvents(this, this)
|
||||||
logger.info("${ChatColor.GREEN}EasyAdmin plugin enabled!")
|
logger.info("${ChatColor.GREEN}EasyAdmin plugin enabled!")
|
||||||
}
|
}
|
||||||
@@ -51,31 +58,24 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
private fun openAdminMenu(player: Player) {
|
private fun openAdminMenu(player: Player) {
|
||||||
val inventory = Bukkit.createInventory(null, 27, menuName)
|
val inventory = Bukkit.createInventory(null, 27, menuName)
|
||||||
|
|
||||||
// Time control
|
|
||||||
inventory.setItem(10, createGuiItem(Material.CLOCK, "${ChatColor.YELLOW}Time Control",
|
inventory.setItem(10, createGuiItem(Material.CLOCK, "${ChatColor.YELLOW}Time Control",
|
||||||
"${ChatColor.GRAY}Click to cycle time"))
|
"${ChatColor.GRAY}Click to cycle time"))
|
||||||
|
|
||||||
// Weather control
|
|
||||||
inventory.setItem(11, createGuiItem(Material.WATER_BUCKET, "${ChatColor.BLUE}Weather Control",
|
inventory.setItem(11, createGuiItem(Material.WATER_BUCKET, "${ChatColor.BLUE}Weather Control",
|
||||||
"${ChatColor.GRAY}Click to cycle weather"))
|
"${ChatColor.GRAY}Click to cycle weather"))
|
||||||
|
|
||||||
// Kick all players
|
|
||||||
inventory.setItem(12, createGuiItem(Material.IRON_BOOTS, "${ChatColor.RED}Kick All",
|
inventory.setItem(12, createGuiItem(Material.IRON_BOOTS, "${ChatColor.RED}Kick All",
|
||||||
"${ChatColor.GRAY}Kick all non-admin players"))
|
"${ChatColor.GRAY}Kick all non-admin players"))
|
||||||
|
|
||||||
// Player management
|
|
||||||
inventory.setItem(13, createGuiItem(Material.PLAYER_HEAD, "${ChatColor.GREEN}Player Management",
|
inventory.setItem(13, createGuiItem(Material.PLAYER_HEAD, "${ChatColor.GREEN}Player Management",
|
||||||
"${ChatColor.GRAY}Manage online players"))
|
"${ChatColor.GRAY}Manage online players"))
|
||||||
|
|
||||||
// World management
|
|
||||||
inventory.setItem(14, createGuiItem(Material.GRASS_BLOCK, "${ChatColor.GOLD}World Management",
|
inventory.setItem(14, createGuiItem(Material.GRASS_BLOCK, "${ChatColor.GOLD}World Management",
|
||||||
"${ChatColor.GRAY}Manage worlds"))
|
"${ChatColor.GRAY}Manage worlds"))
|
||||||
|
|
||||||
// Server properties
|
|
||||||
inventory.setItem(15, createGuiItem(Material.COMMAND_BLOCK, "${ChatColor.LIGHT_PURPLE}Server Settings",
|
inventory.setItem(15, createGuiItem(Material.COMMAND_BLOCK, "${ChatColor.LIGHT_PURPLE}Server Settings",
|
||||||
"${ChatColor.GRAY}View and modify server properties"))
|
"${ChatColor.GRAY}View and modify server properties"))
|
||||||
|
|
||||||
// Plugin management
|
|
||||||
inventory.setItem(16, createGuiItem(Material.BOOK, "${ChatColor.AQUA}Plugin Management",
|
inventory.setItem(16, createGuiItem(Material.BOOK, "${ChatColor.AQUA}Plugin Management",
|
||||||
"${ChatColor.GRAY}Enable/disable plugins"))
|
"${ChatColor.GRAY}Enable/disable plugins"))
|
||||||
|
|
||||||
@@ -85,17 +85,100 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
private fun createGuiItem(material: Material, name: String, vararg lore: String): ItemStack {
|
private fun createGuiItem(material: Material, name: String, vararg lore: String): ItemStack {
|
||||||
val item = ItemStack(material, 1)
|
val item = ItemStack(material, 1)
|
||||||
val meta = item.itemMeta!!
|
val meta = item.itemMeta!!
|
||||||
|
|
||||||
meta.setDisplayName(name)
|
meta.setDisplayName(name)
|
||||||
|
if (lore.isNotEmpty()) meta.lore = lore.toList()
|
||||||
if (lore.isNotEmpty()) {
|
|
||||||
meta.lore = lore.toList()
|
|
||||||
}
|
|
||||||
|
|
||||||
item.itemMeta = meta
|
item.itemMeta = meta
|
||||||
return item
|
return item
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun getRandomKickMessage(playerName: String): String {
|
||||||
|
val messages = listOf(
|
||||||
|
/*
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
"$playerName, blalblalblsalablsbl",
|
||||||
|
"nexte",
|
||||||
|
"ende"
|
||||||
|
|
||||||
|
*/
|
||||||
|
"$playerName wurde von Marians Hund getreten",
|
||||||
|
"$playerName wurde rausgeschmissen",
|
||||||
|
"$playerName wurde von Temu versandt"
|
||||||
|
)
|
||||||
|
return "${ChatColor.GOLD}${messages.random()}"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getRandomBanMessage(playerName: String): String {
|
||||||
|
val messages = listOf(
|
||||||
|
|
||||||
|
/*
|
||||||
|
|
||||||
|
Schema:
|
||||||
|
"$playerName, blalblalblsalablsbl",
|
||||||
|
"nexte",
|
||||||
|
"ende"
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
"$playerName, Salvete Servus!",
|
||||||
|
"$playerName wurde von Marians Hund gegessen!",
|
||||||
|
"$playerName ist Analgefickt worden"
|
||||||
|
)
|
||||||
|
return "${ChatColor.RED}${messages.random()}"
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun spawnFireworks(player: Player) {
|
||||||
|
val loc = player.location
|
||||||
|
val firework = player.world.spawn(loc, Firework::class.java)
|
||||||
|
val meta = firework.fireworkMeta
|
||||||
|
|
||||||
|
val effect = FireworkEffect.builder()
|
||||||
|
.with(FireworkEffect.Type.BURST)
|
||||||
|
.withColor(org.bukkit.Color.RED)
|
||||||
|
.withFade(org.bukkit.Color.ORANGE)
|
||||||
|
.withFlicker()
|
||||||
|
.build()
|
||||||
|
|
||||||
|
meta.addEffect(effect)
|
||||||
|
meta.power = 1
|
||||||
|
firework.fireworkMeta = meta
|
||||||
|
|
||||||
|
player.world.playSound(loc, Sound.ENTITY_FIREWORK_ROCKET_BLAST, 1f, 1f)
|
||||||
|
player.world.spawnParticle(Particle.FIREWORK, loc, 100, 0.5, 0.5, 0.5, 0.1)
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
fun onPlayerChat(event: PlayerChatEvent) {
|
||||||
|
val player = event.player
|
||||||
|
val banData = banReasons[player.uniqueId] ?: return
|
||||||
|
|
||||||
|
event.isCancelled = true
|
||||||
|
val reason = event.message
|
||||||
|
|
||||||
|
val targetPlayer = banData.second
|
||||||
|
val targetName = targetPlayer.name
|
||||||
|
|
||||||
|
if (reason.equals("cancel", ignoreCase = true)) {
|
||||||
|
player.sendMessage("${ChatColor.RED}Cancelled ban for $targetName")
|
||||||
|
} else {
|
||||||
|
val banMessage = getRandomBanMessage(targetName)
|
||||||
|
Bukkit.broadcastMessage(banMessage)
|
||||||
|
|
||||||
|
if (targetPlayer.isOnline) spawnFireworks(targetPlayer)
|
||||||
|
|
||||||
|
targetPlayer.banPlayer("${ChatColor.RED}You have been banned by ${player.name}\n" +
|
||||||
|
"${ChatColor.RED}Reason: $reason")
|
||||||
|
player.sendMessage("${ChatColor.RED}Banned $targetName for: $reason")
|
||||||
|
|
||||||
|
if (targetPlayer.isOnline) {
|
||||||
|
targetPlayer.kickPlayer("${ChatColor.RED}You have been banned by ${player.name}\n" +
|
||||||
|
"${ChatColor.RED}Reason: $reason")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
banReasons.remove(player.uniqueId)
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
fun onInventoryClick(event: InventoryClickEvent) {
|
fun onInventoryClick(event: InventoryClickEvent) {
|
||||||
val title = event.view.title
|
val title = event.view.title
|
||||||
@@ -103,10 +186,9 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
|
|
||||||
if (!player.hasPermission("easyadmin.use")) return
|
if (!player.hasPermission("easyadmin.use")) return
|
||||||
|
|
||||||
// Handle clicks in the main menu
|
// Main menu
|
||||||
if (title == menuName) {
|
if (title == menuName) {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
|
|
||||||
when (event.slot) {
|
when (event.slot) {
|
||||||
10 -> handleTimeControl(player)
|
10 -> handleTimeControl(player)
|
||||||
11 -> handleWeatherControl(player)
|
11 -> handleWeatherControl(player)
|
||||||
@@ -119,44 +201,39 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle player management menu
|
// Player management
|
||||||
if (title == "${ChatColor.GREEN}${ChatColor.BOLD}Player Management") {
|
if (title == "${ChatColor.GREEN}${ChatColor.BOLD}Player Management") {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
|
if (event.slot == 53) { openAdminMenu(player); return }
|
||||||
|
|
||||||
val clickedItem = event.currentItem ?: return
|
val clickedItem = event.currentItem ?: return
|
||||||
if (clickedItem.type != Material.PLAYER_HEAD) return
|
if (clickedItem.type != Material.PLAYER_HEAD && clickedItem.type != Material.ARROW) return
|
||||||
|
if (clickedItem.type == Material.ARROW) { openAdminMenu(player); return }
|
||||||
|
|
||||||
val itemMeta = clickedItem.itemMeta ?: return
|
val itemMeta = clickedItem.itemMeta ?: return
|
||||||
val displayName = itemMeta.displayName
|
val targetPlayer = Bukkit.getPlayerExact(ChatColor.stripColor(itemMeta.displayName) ?: return) ?: return
|
||||||
val targetPlayerName = ChatColor.stripColor(displayName) ?: return
|
|
||||||
|
|
||||||
val targetPlayer = Bukkit.getPlayerExact(targetPlayerName) ?: return
|
|
||||||
|
|
||||||
// Left click: teleport to player
|
|
||||||
if (event.isLeftClick) {
|
if (event.isLeftClick) {
|
||||||
player.teleport(targetPlayer.location)
|
player.teleport(targetPlayer.location)
|
||||||
player.sendMessage("${ChatColor.GREEN}Teleported to ${targetPlayer.name}!")
|
player.sendMessage("${ChatColor.GREEN}Teleported to ${targetPlayer.name}!")
|
||||||
player.closeInventory()
|
player.closeInventory()
|
||||||
}
|
} else if (event.isRightClick) {
|
||||||
// Right click: open player options menu
|
|
||||||
else if (event.isRightClick) {
|
|
||||||
openPlayerOptionsMenu(player, targetPlayer)
|
openPlayerOptionsMenu(player, targetPlayer)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle world management menu
|
// World management
|
||||||
if (title == "${ChatColor.GOLD}${ChatColor.BOLD}World Management") {
|
if (title == "${ChatColor.GOLD}${ChatColor.BOLD}World Management") {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
|
if (event.slot == 26) { openAdminMenu(player); return }
|
||||||
|
|
||||||
val clickedItem = event.currentItem ?: return
|
val clickedItem = event.currentItem ?: return
|
||||||
if (clickedItem.type !in listOf(Material.GRASS_BLOCK, Material.NETHERRACK, Material.END_STONE)) return
|
if (clickedItem.type !in listOf(Material.GRASS_BLOCK, Material.NETHERRACK, Material.END_STONE, Material.ARROW)) return
|
||||||
|
if (clickedItem.type == Material.ARROW) { openAdminMenu(player); return }
|
||||||
|
|
||||||
val itemMeta = clickedItem.itemMeta ?: return
|
val itemMeta = clickedItem.itemMeta ?: return
|
||||||
val displayName = itemMeta.displayName
|
val world = Bukkit.getWorld(ChatColor.stripColor(itemMeta.displayName) ?: return) ?: return
|
||||||
val worldName = ChatColor.stripColor(displayName) ?: return
|
|
||||||
|
|
||||||
val world = Bukkit.getWorld(worldName) ?: return
|
|
||||||
|
|
||||||
player.teleport(world.spawnLocation)
|
player.teleport(world.spawnLocation)
|
||||||
player.sendMessage("${ChatColor.GREEN}Teleported to ${world.name}'s spawn point!")
|
player.sendMessage("${ChatColor.GREEN}Teleported to ${world.name}'s spawn point!")
|
||||||
@@ -164,9 +241,10 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle server settings menu
|
// Server settings
|
||||||
if (title == "${ChatColor.LIGHT_PURPLE}${ChatColor.BOLD}Server Settings") {
|
if (title == "${ChatColor.LIGHT_PURPLE}${ChatColor.BOLD}Server Settings") {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
|
if (event.slot == 26) { openAdminMenu(player); return }
|
||||||
|
|
||||||
when (event.slot) {
|
when (event.slot) {
|
||||||
10 -> cycleDifficulty(player)
|
10 -> cycleDifficulty(player)
|
||||||
@@ -177,24 +255,21 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
15 -> saveAllWorlds(player)
|
15 -> saveAllWorlds(player)
|
||||||
16 -> player.sendMessage("${ChatColor.YELLOW}Server restart requires additional configuration.")
|
16 -> player.sendMessage("${ChatColor.YELLOW}Server restart requires additional configuration.")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh the menu to show updated settings
|
|
||||||
openServerSettings(player)
|
openServerSettings(player)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle plugin management menu
|
// Plugin management
|
||||||
if (title == "${ChatColor.AQUA}${ChatColor.BOLD}Plugin Management") {
|
if (title == "${ChatColor.AQUA}${ChatColor.BOLD}Plugin Management") {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
|
if (event.slot == 53) { openAdminMenu(player); return }
|
||||||
|
|
||||||
val clickedItem = event.currentItem ?: return
|
val clickedItem = event.currentItem ?: return
|
||||||
if (clickedItem.type !in listOf(Material.LIME_DYE, Material.GRAY_DYE)) return
|
if (clickedItem.type !in listOf(Material.LIME_DYE, Material.GRAY_DYE, Material.ARROW)) return
|
||||||
|
if (clickedItem.type == Material.ARROW) { openAdminMenu(player); return }
|
||||||
|
|
||||||
val itemMeta = clickedItem.itemMeta ?: return
|
val itemMeta = clickedItem.itemMeta ?: return
|
||||||
val displayName = itemMeta.displayName
|
val plugin = Bukkit.getPluginManager().getPlugin(ChatColor.stripColor(itemMeta.displayName) ?: return) ?: return
|
||||||
val pluginName = ChatColor.stripColor(displayName) ?: return
|
|
||||||
|
|
||||||
val plugin = Bukkit.getPluginManager().getPlugin(pluginName) ?: return
|
|
||||||
|
|
||||||
if (plugin.name == "EasyAdmin") {
|
if (plugin.name == "EasyAdmin") {
|
||||||
player.sendMessage("${ChatColor.RED}You cannot disable the EasyAdmin plugin from within itself!")
|
player.sendMessage("${ChatColor.RED}You cannot disable the EasyAdmin plugin from within itself!")
|
||||||
@@ -208,16 +283,13 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
Bukkit.getPluginManager().enablePlugin(plugin)
|
Bukkit.getPluginManager().enablePlugin(plugin)
|
||||||
player.sendMessage("${ChatColor.GREEN}Enabled plugin: ${plugin.name}")
|
player.sendMessage("${ChatColor.GREEN}Enabled plugin: ${plugin.name}")
|
||||||
}
|
}
|
||||||
|
|
||||||
// Refresh the plugin management menu
|
|
||||||
openPluginManagement(player)
|
openPluginManagement(player)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle player options menu
|
// Player options
|
||||||
if (title.startsWith("${ChatColor.YELLOW}Player: ")) {
|
if (title.startsWith("${ChatColor.YELLOW}Player: ")) {
|
||||||
event.isCancelled = true
|
event.isCancelled = true
|
||||||
|
|
||||||
val targetPlayerName = title.substring("${ChatColor.YELLOW}Player: ".length)
|
val targetPlayerName = title.substring("${ChatColor.YELLOW}Player: ".length)
|
||||||
val targetPlayer = Bukkit.getPlayerExact(targetPlayerName) ?: return
|
val targetPlayer = Bukkit.getPlayerExact(targetPlayerName) ?: return
|
||||||
|
|
||||||
@@ -236,11 +308,22 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
13 -> healPlayer(player, targetPlayer)
|
13 -> healPlayer(player, targetPlayer)
|
||||||
14 -> kickPlayer(player, targetPlayer)
|
14 -> kickPlayer(player, targetPlayer)
|
||||||
15 -> {
|
15 -> {
|
||||||
// Open ban interface (simplified for this example)
|
banReasons[player.uniqueId] = Pair("", targetPlayer)
|
||||||
player.sendMessage("${ChatColor.YELLOW}Use /ban ${targetPlayer.name} <reason> to ban this player.")
|
player.closeInventory()
|
||||||
|
player.sendMessage("${ChatColor.YELLOW}Please enter a ban reason in chat.")
|
||||||
|
player.sendMessage("${ChatColor.YELLOW}Type 'cancel' to cancel the ban.")
|
||||||
|
}
|
||||||
|
16 -> {
|
||||||
|
if (targetPlayer == player) {
|
||||||
|
player.sendMessage("${ChatColor.RED}You can't spectate yourself!")
|
||||||
|
return
|
||||||
|
}
|
||||||
|
player.gameMode = org.bukkit.GameMode.SPECTATOR
|
||||||
|
player.teleport(targetPlayer)
|
||||||
|
player.sendMessage("${ChatColor.GREEN}Now spectating ${targetPlayer.name}!")
|
||||||
player.closeInventory()
|
player.closeInventory()
|
||||||
}
|
}
|
||||||
26 -> openPlayerManagement(player) // Back button
|
26 -> openPlayerManagement(player)
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -249,10 +332,10 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
private fun handleTimeControl(player: Player) {
|
private fun handleTimeControl(player: Player) {
|
||||||
val world = player.world
|
val world = player.world
|
||||||
when (world.time) {
|
when (world.time) {
|
||||||
in 0..6000 -> world.time = 6000 // Set to noon
|
in 0..6000 -> world.time = 6000
|
||||||
in 6001..12000 -> world.time = 12000 // Set to sunset
|
in 6001..12000 -> world.time = 12000
|
||||||
in 12001..18000 -> world.time = 18000 // Set to midnight
|
in 12001..18000 -> world.time = 18000
|
||||||
else -> world.time = 0 // Set to sunrise
|
else -> world.time = 0
|
||||||
}
|
}
|
||||||
player.sendMessage("${ChatColor.GREEN}Time changed in ${world.name}!")
|
player.sendMessage("${ChatColor.GREEN}Time changed in ${world.name}!")
|
||||||
}
|
}
|
||||||
@@ -283,6 +366,8 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
|
|
||||||
for (onlinePlayer in Bukkit.getOnlinePlayers()) {
|
for (onlinePlayer in Bukkit.getOnlinePlayers()) {
|
||||||
if (!onlinePlayer.hasPermission("easyadmin.exempt") && onlinePlayer != player) {
|
if (!onlinePlayer.hasPermission("easyadmin.exempt") && onlinePlayer != player) {
|
||||||
|
Bukkit.broadcastMessage(getRandomKickMessage(onlinePlayer.name))
|
||||||
|
spawnFireworks(onlinePlayer)
|
||||||
onlinePlayer.kickPlayer(kickMessage)
|
onlinePlayer.kickPlayer(kickMessage)
|
||||||
kickCount++
|
kickCount++
|
||||||
}
|
}
|
||||||
@@ -296,60 +381,59 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
|
|
||||||
var slot = 0
|
var slot = 0
|
||||||
for (onlinePlayer in Bukkit.getOnlinePlayers()) {
|
for (onlinePlayer in Bukkit.getOnlinePlayers()) {
|
||||||
if (slot >= 54) break
|
if (slot >= 53) break
|
||||||
|
|
||||||
val playerHead = ItemStack(Material.PLAYER_HEAD, 1)
|
val playerHead = ItemStack(Material.PLAYER_HEAD, 1)
|
||||||
val meta = playerHead.itemMeta!!
|
val meta = playerHead.itemMeta!!
|
||||||
meta.setDisplayName("${ChatColor.YELLOW}${onlinePlayer.name}")
|
meta.setDisplayName("${ChatColor.YELLOW}${onlinePlayer.name}")
|
||||||
|
|
||||||
val lore = mutableListOf<String>()
|
val lore = mutableListOf(
|
||||||
lore.add("${ChatColor.GRAY}Health: ${ChatColor.RED}${onlinePlayer.health}")
|
"${ChatColor.GRAY}Health: ${ChatColor.RED}${onlinePlayer.health}",
|
||||||
lore.add("${ChatColor.GRAY}Gamemode: ${ChatColor.GOLD}${onlinePlayer.gameMode}")
|
"${ChatColor.GRAY}Gamemode: ${ChatColor.GOLD}${onlinePlayer.gameMode}",
|
||||||
lore.add("${ChatColor.GRAY}World: ${ChatColor.GREEN}${onlinePlayer.world.name}")
|
"${ChatColor.GRAY}World: ${ChatColor.GREEN}${onlinePlayer.world.name}",
|
||||||
lore.add("")
|
"",
|
||||||
lore.add("${ChatColor.GREEN}Left-click: ${ChatColor.WHITE}Teleport to player")
|
"${ChatColor.GREEN}Left-click: ${ChatColor.WHITE}Teleport to player",
|
||||||
lore.add("${ChatColor.RED}Right-click: ${ChatColor.WHITE}More options")
|
"${ChatColor.RED}Right-click: ${ChatColor.WHITE}More options"
|
||||||
|
)
|
||||||
|
|
||||||
meta.lore = lore
|
meta.lore = lore
|
||||||
playerHead.itemMeta = meta
|
playerHead.itemMeta = meta
|
||||||
|
|
||||||
inventory.setItem(slot, playerHead)
|
inventory.setItem(slot, playerHead)
|
||||||
slot++
|
slot++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inventory.setItem(53, createGuiItem(Material.ARROW, "${ChatColor.YELLOW}Back",
|
||||||
|
"${ChatColor.GRAY}Return to main menu"))
|
||||||
|
|
||||||
player.openInventory(inventory)
|
player.openInventory(inventory)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openPlayerOptionsMenu(player: Player, targetPlayer: Player) {
|
private fun openPlayerOptionsMenu(player: Player, targetPlayer: Player) {
|
||||||
val inventory = Bukkit.createInventory(null, 27, "${ChatColor.YELLOW}Player: ${targetPlayer.name}")
|
val inventory = Bukkit.createInventory(null, 27, "${ChatColor.YELLOW}Player: ${targetPlayer.name}")
|
||||||
|
|
||||||
// Teleport to player
|
|
||||||
inventory.setItem(10, createGuiItem(Material.ENDER_PEARL, "${ChatColor.GREEN}Teleport to Player",
|
inventory.setItem(10, createGuiItem(Material.ENDER_PEARL, "${ChatColor.GREEN}Teleport to Player",
|
||||||
"${ChatColor.GRAY}Teleport to ${targetPlayer.name}"))
|
"${ChatColor.GRAY}Teleport to ${targetPlayer.name}"))
|
||||||
|
|
||||||
// Teleport player to you
|
|
||||||
inventory.setItem(11, createGuiItem(Material.ENDER_EYE, "${ChatColor.BLUE}Teleport Player to You",
|
inventory.setItem(11, createGuiItem(Material.ENDER_EYE, "${ChatColor.BLUE}Teleport Player to You",
|
||||||
"${ChatColor.GRAY}Teleport ${targetPlayer.name} to your location"))
|
"${ChatColor.GRAY}Teleport ${targetPlayer.name} to your location"))
|
||||||
|
|
||||||
// Change player gamemode
|
|
||||||
inventory.setItem(12, createGuiItem(Material.DIAMOND_SWORD, "${ChatColor.GOLD}Change Gamemode",
|
inventory.setItem(12, createGuiItem(Material.DIAMOND_SWORD, "${ChatColor.GOLD}Change Gamemode",
|
||||||
"${ChatColor.GRAY}Current: ${ChatColor.WHITE}${targetPlayer.gameMode}",
|
"${ChatColor.GRAY}Current: ${ChatColor.WHITE}${targetPlayer.gameMode}",
|
||||||
"${ChatColor.GRAY}Click to cycle"))
|
"${ChatColor.GRAY}Click to cycle"))
|
||||||
|
|
||||||
// Heal player
|
|
||||||
inventory.setItem(13, createGuiItem(Material.GOLDEN_APPLE, "${ChatColor.LIGHT_PURPLE}Heal Player",
|
inventory.setItem(13, createGuiItem(Material.GOLDEN_APPLE, "${ChatColor.LIGHT_PURPLE}Heal Player",
|
||||||
"${ChatColor.GRAY}Health: ${ChatColor.RED}${targetPlayer.health}/${targetPlayer.maxHealth}",
|
"${ChatColor.GRAY}Health: ${ChatColor.RED}${targetPlayer.health}/${targetPlayer.maxHealth}",
|
||||||
"${ChatColor.GRAY}Click to restore health and hunger"))
|
"${ChatColor.GRAY}Click to restore health and hunger"))
|
||||||
|
|
||||||
// Kick player
|
|
||||||
inventory.setItem(14, createGuiItem(Material.IRON_BOOTS, "${ChatColor.RED}Kick Player",
|
inventory.setItem(14, createGuiItem(Material.IRON_BOOTS, "${ChatColor.RED}Kick Player",
|
||||||
"${ChatColor.GRAY}Kick ${targetPlayer.name} from the server"))
|
"${ChatColor.GRAY}Kick ${targetPlayer.name} from the server"))
|
||||||
|
|
||||||
// Ban player
|
|
||||||
inventory.setItem(15, createGuiItem(Material.BARRIER, "${ChatColor.DARK_RED}Ban Player",
|
inventory.setItem(15, createGuiItem(Material.BARRIER, "${ChatColor.DARK_RED}Ban Player",
|
||||||
"${ChatColor.GRAY}Ban ${targetPlayer.name} from the server"))
|
"${ChatColor.GRAY}Ban ${targetPlayer.name} from the server"))
|
||||||
|
|
||||||
// Back button
|
inventory.setItem(16, createGuiItem(Material.ENDER_EYE, "${ChatColor.AQUA}Spectate Player",
|
||||||
|
"${ChatColor.GRAY}Spectate ${targetPlayer.name}"))
|
||||||
|
|
||||||
inventory.setItem(26, createGuiItem(Material.ARROW, "${ChatColor.YELLOW}Back",
|
inventory.setItem(26, createGuiItem(Material.ARROW, "${ChatColor.YELLOW}Back",
|
||||||
"${ChatColor.GRAY}Return to player list"))
|
"${ChatColor.GRAY}Return to player list"))
|
||||||
|
|
||||||
@@ -357,9 +441,7 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun cycleGamemode(player: Player, targetPlayer: Player) {
|
private fun cycleGamemode(player: Player, targetPlayer: Player) {
|
||||||
val currentGamemode = targetPlayer.gameMode
|
val newGamemode = when (targetPlayer.gameMode) {
|
||||||
|
|
||||||
val newGamemode = when (currentGamemode) {
|
|
||||||
org.bukkit.GameMode.SURVIVAL -> org.bukkit.GameMode.CREATIVE
|
org.bukkit.GameMode.SURVIVAL -> org.bukkit.GameMode.CREATIVE
|
||||||
org.bukkit.GameMode.CREATIVE -> org.bukkit.GameMode.ADVENTURE
|
org.bukkit.GameMode.CREATIVE -> org.bukkit.GameMode.ADVENTURE
|
||||||
org.bukkit.GameMode.ADVENTURE -> org.bukkit.GameMode.SPECTATOR
|
org.bukkit.GameMode.ADVENTURE -> org.bukkit.GameMode.SPECTATOR
|
||||||
@@ -369,8 +451,6 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
targetPlayer.gameMode = newGamemode
|
targetPlayer.gameMode = newGamemode
|
||||||
player.sendMessage("${ChatColor.GREEN}Set ${targetPlayer.name}'s gamemode to $newGamemode.")
|
player.sendMessage("${ChatColor.GREEN}Set ${targetPlayer.name}'s gamemode to $newGamemode.")
|
||||||
targetPlayer.sendMessage("${ChatColor.GREEN}Your gamemode was set to $newGamemode by ${player.name}.")
|
targetPlayer.sendMessage("${ChatColor.GREEN}Your gamemode was set to $newGamemode by ${player.name}.")
|
||||||
|
|
||||||
// Refresh the player options menu
|
|
||||||
openPlayerOptionsMenu(player, targetPlayer)
|
openPlayerOptionsMenu(player, targetPlayer)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -382,20 +462,22 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
|
|
||||||
player.sendMessage("${ChatColor.GREEN}Healed ${targetPlayer.name}.")
|
player.sendMessage("${ChatColor.GREEN}Healed ${targetPlayer.name}.")
|
||||||
targetPlayer.sendMessage("${ChatColor.GREEN}You were healed by ${player.name}.")
|
targetPlayer.sendMessage("${ChatColor.GREEN}You were healed by ${player.name}.")
|
||||||
|
|
||||||
// Refresh the player options menu
|
|
||||||
openPlayerOptionsMenu(player, targetPlayer)
|
openPlayerOptionsMenu(player, targetPlayer)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun kickPlayer(player: Player, targetPlayer: Player) {
|
private fun kickPlayer(admin: Player, targetPlayer: Player) {
|
||||||
if (targetPlayer.hasPermission("easyadmin.exempt")) {
|
if (targetPlayer.hasPermission("easyadmin.exempt")) {
|
||||||
player.sendMessage("${ChatColor.RED}You cannot kick ${targetPlayer.name} as they are exempt!")
|
admin.sendMessage("${ChatColor.RED}You cannot kick ${targetPlayer.name} as they are exempt!")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
val kickMessage = getRandomKickMessage(targetPlayer.name)
|
||||||
|
Bukkit.broadcastMessage(kickMessage)
|
||||||
|
|
||||||
|
spawnFireworks(targetPlayer)
|
||||||
targetPlayer.kickPlayer("${ChatColor.RED}You have been kicked by an administrator.")
|
targetPlayer.kickPlayer("${ChatColor.RED}You have been kicked by an administrator.")
|
||||||
player.sendMessage("${ChatColor.GREEN}Kicked ${targetPlayer.name} from the server.")
|
admin.sendMessage("${ChatColor.GREEN}Kicked ${targetPlayer.name} from the server.")
|
||||||
player.closeInventory()
|
admin.closeInventory()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openWorldManagement(player: Player) {
|
private fun openWorldManagement(player: Player) {
|
||||||
@@ -403,100 +485,91 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
|
|
||||||
var slot = 0
|
var slot = 0
|
||||||
for (world in Bukkit.getWorlds()) {
|
for (world in Bukkit.getWorlds()) {
|
||||||
if (slot >= 27) break
|
if (slot >= 26) break
|
||||||
|
|
||||||
val worldIcon = ItemStack(Material.GRASS_BLOCK, 1)
|
val worldIcon = ItemStack(when (world.environment) {
|
||||||
if (world.environment == org.bukkit.World.Environment.NETHER) {
|
org.bukkit.World.Environment.NETHER -> Material.NETHERRACK
|
||||||
worldIcon.type = Material.NETHERRACK
|
org.bukkit.World.Environment.THE_END -> Material.END_STONE
|
||||||
} else if (world.environment == org.bukkit.World.Environment.THE_END) {
|
else -> Material.GRASS_BLOCK
|
||||||
worldIcon.type = Material.END_STONE
|
}, 1)
|
||||||
}
|
|
||||||
|
|
||||||
val meta = worldIcon.itemMeta!!
|
val meta = worldIcon.itemMeta!!
|
||||||
meta.setDisplayName("${ChatColor.YELLOW}${world.name}")
|
meta.setDisplayName("${ChatColor.YELLOW}${world.name}")
|
||||||
|
|
||||||
val lore = mutableListOf<String>()
|
meta.lore = listOf(
|
||||||
lore.add("${ChatColor.GRAY}Players: ${ChatColor.WHITE}${world.players.size}")
|
"${ChatColor.GRAY}Players: ${ChatColor.WHITE}${world.players.size}",
|
||||||
lore.add("${ChatColor.GRAY}Time: ${ChatColor.WHITE}${world.time}")
|
"${ChatColor.GRAY}Time: ${ChatColor.WHITE}${world.time}",
|
||||||
lore.add("${ChatColor.GRAY}Weather: ${ChatColor.WHITE}${if (world.hasStorm()) "Raining" else "Clear"}")
|
"${ChatColor.GRAY}Weather: ${ChatColor.WHITE}${if (world.hasStorm()) "Raining" else "Clear"}",
|
||||||
lore.add("")
|
"",
|
||||||
lore.add("${ChatColor.GREEN}Click: ${ChatColor.WHITE}Teleport to world spawn")
|
"${ChatColor.GREEN}Click: ${ChatColor.WHITE}Teleport to world spawn"
|
||||||
|
)
|
||||||
|
|
||||||
meta.lore = lore
|
|
||||||
worldIcon.itemMeta = meta
|
worldIcon.itemMeta = meta
|
||||||
|
|
||||||
inventory.setItem(slot, worldIcon)
|
inventory.setItem(slot, worldIcon)
|
||||||
slot++
|
slot++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inventory.setItem(26, createGuiItem(Material.ARROW, "${ChatColor.YELLOW}Back",
|
||||||
|
"${ChatColor.GRAY}Return to main menu"))
|
||||||
|
|
||||||
player.openInventory(inventory)
|
player.openInventory(inventory)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun openServerSettings(player: Player) {
|
private fun openServerSettings(player: Player) {
|
||||||
val inventory = Bukkit.createInventory(null, 27, "${ChatColor.LIGHT_PURPLE}${ChatColor.BOLD}Server Settings")
|
val inventory = Bukkit.createInventory(null, 27, "${ChatColor.LIGHT_PURPLE}${ChatColor.BOLD}Server Settings")
|
||||||
|
|
||||||
// Difficulty setting
|
|
||||||
inventory.setItem(10, createGuiItem(Material.ZOMBIE_HEAD, "${ChatColor.RED}Difficulty",
|
inventory.setItem(10, createGuiItem(Material.ZOMBIE_HEAD, "${ChatColor.RED}Difficulty",
|
||||||
"${ChatColor.GRAY}Current: ${ChatColor.WHITE}${player.world.difficulty}",
|
"${ChatColor.GRAY}Current: ${ChatColor.WHITE}${player.world.difficulty}",
|
||||||
"${ChatColor.GRAY}Click to cycle"))
|
"${ChatColor.GRAY}Click to cycle"))
|
||||||
|
|
||||||
// Gamemode setting
|
|
||||||
inventory.setItem(11, createGuiItem(Material.DIAMOND_SWORD, "${ChatColor.BLUE}Default Gamemode",
|
inventory.setItem(11, createGuiItem(Material.DIAMOND_SWORD, "${ChatColor.BLUE}Default Gamemode",
|
||||||
"${ChatColor.GRAY}Current: ${ChatColor.WHITE}${Bukkit.getDefaultGameMode()}",
|
"${ChatColor.GRAY}Current: ${ChatColor.WHITE}${Bukkit.getDefaultGameMode()}",
|
||||||
"${ChatColor.GRAY}Click to cycle"))
|
"${ChatColor.GRAY}Click to cycle"))
|
||||||
|
|
||||||
// Toggle mob spawning
|
|
||||||
val spawnMobs = player.world.getGameRuleValue(org.bukkit.GameRule.DO_MOB_SPAWNING) ?: true
|
val spawnMobs = player.world.getGameRuleValue(org.bukkit.GameRule.DO_MOB_SPAWNING) ?: true
|
||||||
inventory.setItem(12, createGuiItem(Material.SPAWNER, "${ChatColor.GREEN}Mob Spawning",
|
inventory.setItem(12, createGuiItem(Material.SPAWNER, "${ChatColor.GREEN}Mob Spawning",
|
||||||
"${ChatColor.GRAY}Current: ${if (spawnMobs) "${ChatColor.GREEN}Enabled" else "${ChatColor.RED}Disabled"}",
|
"${ChatColor.GRAY}Current: ${if (spawnMobs) "${ChatColor.GREEN}Enabled" else "${ChatColor.RED}Disabled"}",
|
||||||
"${ChatColor.GRAY}Click to toggle mob spawning"))
|
"${ChatColor.GRAY}Click to toggle mob spawning"))
|
||||||
|
|
||||||
// PVP toggle
|
|
||||||
inventory.setItem(13, createGuiItem(Material.GOLDEN_SWORD, "${ChatColor.GOLD}PVP",
|
inventory.setItem(13, createGuiItem(Material.GOLDEN_SWORD, "${ChatColor.GOLD}PVP",
|
||||||
"${ChatColor.GRAY}Current: ${if (player.world.pvp) "${ChatColor.GREEN}Enabled" else "${ChatColor.RED}Disabled"}",
|
"${ChatColor.GRAY}Current: ${if (player.world.pvp) "${ChatColor.GREEN}Enabled" else "${ChatColor.RED}Disabled"}",
|
||||||
"${ChatColor.GRAY}Click to toggle PVP"))
|
"${ChatColor.GRAY}Click to toggle PVP"))
|
||||||
|
|
||||||
// Whitelist
|
|
||||||
inventory.setItem(14, createGuiItem(Material.PAPER, "${ChatColor.WHITE}Whitelist",
|
inventory.setItem(14, createGuiItem(Material.PAPER, "${ChatColor.WHITE}Whitelist",
|
||||||
"${ChatColor.GRAY}Current: ${if (Bukkit.hasWhitelist()) "${ChatColor.GREEN}Enabled" else "${ChatColor.RED}Disabled"}",
|
"${ChatColor.GRAY}Current: ${if (Bukkit.hasWhitelist()) "${ChatColor.GREEN}Enabled" else "${ChatColor.RED}Disabled"}",
|
||||||
"${ChatColor.GRAY}Click to toggle whitelist"))
|
"${ChatColor.GRAY}Click to toggle whitelist"))
|
||||||
|
|
||||||
// Save all worlds
|
|
||||||
inventory.setItem(15, createGuiItem(Material.FLOWER_POT, "${ChatColor.AQUA}Save All",
|
inventory.setItem(15, createGuiItem(Material.FLOWER_POT, "${ChatColor.AQUA}Save All",
|
||||||
"${ChatColor.GRAY}Click to save all worlds"))
|
"${ChatColor.GRAY}Click to save all worlds"))
|
||||||
|
|
||||||
// Restart server (placeholder)
|
|
||||||
inventory.setItem(16, createGuiItem(Material.REDSTONE_BLOCK, "${ChatColor.DARK_RED}Restart Server",
|
inventory.setItem(16, createGuiItem(Material.REDSTONE_BLOCK, "${ChatColor.DARK_RED}Restart Server",
|
||||||
"${ChatColor.GRAY}Click to restart server",
|
"${ChatColor.GRAY}Click to restart server",
|
||||||
"${ChatColor.RED}This requires additional setup"))
|
"${ChatColor.RED}This requires additional setup"))
|
||||||
|
|
||||||
|
inventory.setItem(26, createGuiItem(Material.ARROW, "${ChatColor.YELLOW}Back",
|
||||||
|
"${ChatColor.GRAY}Return to main menu"))
|
||||||
|
|
||||||
player.openInventory(inventory)
|
player.openInventory(inventory)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun cycleDifficulty(player: Player) {
|
private fun cycleDifficulty(player: Player) {
|
||||||
val world = player.world
|
val world = player.world
|
||||||
val difficulty = world.difficulty
|
world.difficulty = when (world.difficulty) {
|
||||||
|
|
||||||
world.difficulty = when (difficulty) {
|
|
||||||
org.bukkit.Difficulty.PEACEFUL -> org.bukkit.Difficulty.EASY
|
org.bukkit.Difficulty.PEACEFUL -> org.bukkit.Difficulty.EASY
|
||||||
org.bukkit.Difficulty.EASY -> org.bukkit.Difficulty.NORMAL
|
org.bukkit.Difficulty.EASY -> org.bukkit.Difficulty.NORMAL
|
||||||
org.bukkit.Difficulty.NORMAL -> org.bukkit.Difficulty.HARD
|
org.bukkit.Difficulty.NORMAL -> org.bukkit.Difficulty.HARD
|
||||||
org.bukkit.Difficulty.HARD -> org.bukkit.Difficulty.PEACEFUL
|
org.bukkit.Difficulty.HARD -> org.bukkit.Difficulty.PEACEFUL
|
||||||
}
|
}
|
||||||
|
|
||||||
player.sendMessage("${ChatColor.GREEN}Difficulty set to ${world.difficulty} in ${world.name}.")
|
player.sendMessage("${ChatColor.GREEN}Difficulty set to ${world.difficulty} in ${world.name}.")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun cycleDefaultGamemode(player: Player) {
|
private fun cycleDefaultGamemode(player: Player) {
|
||||||
val currentGamemode = Bukkit.getDefaultGameMode()
|
val newGamemode = when (Bukkit.getDefaultGameMode()) {
|
||||||
|
|
||||||
val newGamemode = when (currentGamemode) {
|
|
||||||
org.bukkit.GameMode.SURVIVAL -> org.bukkit.GameMode.CREATIVE
|
org.bukkit.GameMode.SURVIVAL -> org.bukkit.GameMode.CREATIVE
|
||||||
org.bukkit.GameMode.CREATIVE -> org.bukkit.GameMode.ADVENTURE
|
org.bukkit.GameMode.CREATIVE -> org.bukkit.GameMode.ADVENTURE
|
||||||
org.bukkit.GameMode.ADVENTURE -> org.bukkit.GameMode.SPECTATOR
|
org.bukkit.GameMode.ADVENTURE -> org.bukkit.GameMode.SPECTATOR
|
||||||
org.bukkit.GameMode.SPECTATOR -> org.bukkit.GameMode.SURVIVAL
|
org.bukkit.GameMode.SPECTATOR -> org.bukkit.GameMode.SURVIVAL
|
||||||
}
|
}
|
||||||
|
|
||||||
Bukkit.setDefaultGameMode(newGamemode)
|
Bukkit.setDefaultGameMode(newGamemode)
|
||||||
player.sendMessage("${ChatColor.GREEN}Default gamemode set to $newGamemode.")
|
player.sendMessage("${ChatColor.GREEN}Default gamemode set to $newGamemode.")
|
||||||
}
|
}
|
||||||
@@ -504,7 +577,6 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
private fun toggleMobSpawning(player: Player) {
|
private fun toggleMobSpawning(player: Player) {
|
||||||
val world = player.world
|
val world = player.world
|
||||||
val currentValue = world.getGameRuleValue(org.bukkit.GameRule.DO_MOB_SPAWNING) ?: true
|
val currentValue = world.getGameRuleValue(org.bukkit.GameRule.DO_MOB_SPAWNING) ?: true
|
||||||
|
|
||||||
world.setGameRule(org.bukkit.GameRule.DO_MOB_SPAWNING, !currentValue)
|
world.setGameRule(org.bukkit.GameRule.DO_MOB_SPAWNING, !currentValue)
|
||||||
player.sendMessage("${ChatColor.GREEN}Mob spawning ${if (!currentValue) "enabled" else "disabled"} in ${world.name}.")
|
player.sendMessage("${ChatColor.GREEN}Mob spawning ${if (!currentValue) "enabled" else "disabled"} in ${world.name}.")
|
||||||
}
|
}
|
||||||
@@ -512,22 +584,17 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
private fun togglePvP(player: Player) {
|
private fun togglePvP(player: Player) {
|
||||||
val world = player.world
|
val world = player.world
|
||||||
world.pvp = !world.pvp
|
world.pvp = !world.pvp
|
||||||
|
|
||||||
player.sendMessage("${ChatColor.GREEN}PvP ${if (world.pvp) "enabled" else "disabled"} in ${world.name}.")
|
player.sendMessage("${ChatColor.GREEN}PvP ${if (world.pvp) "enabled" else "disabled"} in ${world.name}.")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun toggleWhitelist(player: Player) {
|
private fun toggleWhitelist(player: Player) {
|
||||||
val currentValue = Bukkit.hasWhitelist()
|
val currentValue = Bukkit.hasWhitelist()
|
||||||
Bukkit.setWhitelist(!currentValue)
|
Bukkit.setWhitelist(!currentValue)
|
||||||
|
|
||||||
player.sendMessage("${ChatColor.GREEN}Whitelist ${if (!currentValue) "enabled" else "disabled"}.")
|
player.sendMessage("${ChatColor.GREEN}Whitelist ${if (!currentValue) "enabled" else "disabled"}.")
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun saveAllWorlds(player: Player) {
|
private fun saveAllWorlds(player: Player) {
|
||||||
for (world in Bukkit.getWorlds()) {
|
Bukkit.getWorlds().forEach { it.save() }
|
||||||
world.save()
|
|
||||||
}
|
|
||||||
|
|
||||||
player.sendMessage("${ChatColor.GREEN}All worlds have been saved.")
|
player.sendMessage("${ChatColor.GREEN}All worlds have been saved.")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -536,22 +603,25 @@ class Easyadmin : JavaPlugin(), Listener {
|
|||||||
|
|
||||||
var slot = 0
|
var slot = 0
|
||||||
for (plugin in Bukkit.getPluginManager().plugins) {
|
for (plugin in Bukkit.getPluginManager().plugins) {
|
||||||
if (slot >= 54) break
|
if (slot >= 53) break
|
||||||
|
|
||||||
val enabled = plugin.isEnabled
|
val enabled = plugin.isEnabled
|
||||||
val material = if (enabled) Material.LIME_DYE else Material.GRAY_DYE
|
val pluginItem = createGuiItem(
|
||||||
|
if (enabled) Material.LIME_DYE else Material.GRAY_DYE,
|
||||||
val pluginItem = createGuiItem(material,
|
|
||||||
"${if (enabled) ChatColor.GREEN else ChatColor.RED}${plugin.name}",
|
"${if (enabled) ChatColor.GREEN else ChatColor.RED}${plugin.name}",
|
||||||
"${ChatColor.GRAY}Version: ${ChatColor.WHITE}${plugin.description.version}",
|
"${ChatColor.GRAY}Version: ${ChatColor.WHITE}${plugin.description.version}",
|
||||||
"${ChatColor.GRAY}Status: ${if (enabled) "${ChatColor.GREEN}Enabled" else "${ChatColor.RED}Disabled"}",
|
"${ChatColor.GRAY}Status: ${if (enabled) "${ChatColor.GREEN}Enabled" else "${ChatColor.RED}Disabled"}",
|
||||||
"",
|
"",
|
||||||
"${ChatColor.YELLOW}Click to ${if (enabled) "disable" else "enable"}")
|
"${ChatColor.YELLOW}Click to ${if (enabled) "disable" else "enable"}"
|
||||||
|
)
|
||||||
|
|
||||||
inventory.setItem(slot, pluginItem)
|
inventory.setItem(slot, pluginItem)
|
||||||
slot++
|
slot++
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inventory.setItem(53, createGuiItem(Material.ARROW, "${ChatColor.YELLOW}Back",
|
||||||
|
"${ChatColor.GRAY}Return to main menu"))
|
||||||
|
|
||||||
player.openInventory(inventory)
|
player.openInventory(inventory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user