diff --git a/bootstrap/bukkit/src/main/resources/plugin.yml b/bootstrap/bukkit/src/main/resources/plugin.yml index 6286893..da549d9 100644 --- a/bootstrap/bukkit/src/main/resources/plugin.yml +++ b/bootstrap/bukkit/src/main/resources/plugin.yml @@ -26,42 +26,44 @@ softdepend: - Nexo - Oraxen permissions: - hud.help: + betterhud.help: description: Access to help command. default: op - hud.reload: + betterhud.reload: description: Access to reload command. default: op - hud.hud: + betterhud.hud: description: Access to hud command. default: op children: - hud.hud.add: true - hud.hud.remove: true - hud.compass: + betterhud.hud.add: true + betterhud.hud.remove: true + betterhud.compass: description: Access to compass command. default: op children: - hud.compass.add: true - hud.compass.remove: true - hud.turn: + betterhud.compass.add: true + betterhud.compass.remove: true + betterhud.turn: description: Access to turn command. default: op children: - hud.turn.on: true - hud.turn.off: true - hud.pointer: + betterhud.turn.on: true + betterhud.turn.off: true + betterhud.turn.on.admin: true + betterhud.turn.off.admin: true + betterhud.pointer: description: Access to pointer command. default: op children: - hud.pointer.set: true - hud.pointer.clear: true - hud.pointer.remove: true - hud.popup: + betterhud.pointer.set: true + betterhud.pointer.clear: true + betterhud.pointer.remove: true + betterhud.popup: description: Access to popup command. default: op children: - hud.popup.add: true - hud.popup.remove: true - hud.popup.show: true - hud.popup.hide: true \ No newline at end of file + betterhud.popup.add: true + betterhud.popup.remove: true + betterhud.popup.show: true + betterhud.popup.hide: true \ No newline at end of file diff --git a/dist/src/main/kotlin/kr/toxicity/hud/manager/CommandManager.kt b/dist/src/main/kotlin/kr/toxicity/hud/manager/CommandManager.kt index 7a7c33a..565bd6e 100644 --- a/dist/src/main/kotlin/kr/toxicity/hud/manager/CommandManager.kt +++ b/dist/src/main/kotlin/kr/toxicity/hud/manager/CommandManager.kt @@ -5,13 +5,11 @@ import kr.toxicity.command.BetterCommandSource import kr.toxicity.command.impl.ClassSerializer import kr.toxicity.command.CommandListener import kr.toxicity.command.impl.CommandMessage -import kr.toxicity.command.SenderType import kr.toxicity.command.impl.annotation.Aliases import kr.toxicity.command.impl.annotation.Command import kr.toxicity.command.impl.annotation.Description import kr.toxicity.command.impl.annotation.Option import kr.toxicity.command.impl.annotation.Permission -import kr.toxicity.command.impl.annotation.Sender import kr.toxicity.command.impl.annotation.Source import kr.toxicity.hud.api.adapter.LocationWrapper import kr.toxicity.hud.api.adapter.WorldWrapper @@ -420,25 +418,37 @@ object CommandManager : BetterHudManager { .permission("hud.turn") .executes(object : CommandListener { //Turn on + private val on_no_target = library.registerKey(CommandMessage("betterhud.turn.on.message.no_target", Component.text("No target player provided."))) private val on_success = library.registerKey(CommandMessage("betterhud.turn.on.message.success", Component.text("Successfully turned the HUD on."))) @Command @Description(key = "betterhud.turn.on.description", defaultValue = "Turns on your HUD.") @Permission("hud.turn.on") - @Sender(type = [SenderType.PLAYER]) - fun on(@Source me: HudPlayer) { - me.isHudEnabled = true + fun on(@Source me: BetterCommandSource, @Option target: HudPlayerStack?) { + when { + target != null && me.hasPermission("betterhud.turn.on.admin") -> target.forEach { p -> + p.isHudEnabled = true + } + me is HudPlayer -> me.isHudEnabled = true + else -> return on_no_target.send(me) + } on_success.send(me) } //Turn on //Turn off + private val off_no_target = library.registerKey(CommandMessage("betterhud.turn.off.message.no_target", Component.text("No target player provided."))) private val off_success = library.registerKey(CommandMessage("betterhud.turn.off.message.success", Component.text("Successfully turned the HUD off."))) @Command @Description(key = "betterhud.turn.off.description", defaultValue = "Turns off your HUD.") @Permission("hud.turn.off") - @Sender(type = [SenderType.PLAYER]) - fun off(@Source me: HudPlayer) { - me.isHudEnabled = false + fun off(@Source me: BetterCommandSource, @Option target: HudPlayerStack?) { + when { + target != null && me.hasPermission("betterhud.turn.off.admin") -> target.forEach { p -> + p.isHudEnabled = false + } + me is HudPlayer -> me.isHudEnabled = false + else -> return off_no_target.send(me) + } off_success.send(me) } //Turn off