From df800682c0e2992ea0061b48e5f580ac398e5a27 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sun, 21 Nov 2021 16:17:53 +0100 Subject: [PATCH] Add new Message system from CMD Framework Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 31 ++++++++++--------- .../features/autostart/AutoStartCommand.java | 9 +----- .../features/backup/BackupCommand.java | 24 +++----------- .../bausystem/features/bau/BauCommand.java | 12 ++----- .../countingwand/CountingwandCommand.java | 2 +- .../features/detonator/DetonatorCommand.java | 17 +++------- .../features/hotbar/HotbarCommand.java | 16 +++------- .../features/util/StructureVoidCommand.java | 5 ++- .../bausystem/features/warp/Moon.java | 2 +- .../bausystem/linkage/LinkageType.java | 2 +- 10 files changed, 40 insertions(+), 80 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index eacb7838..afb70800 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -100,9 +100,10 @@ AUTOSTART_MESSAGE_RESULT2 = §eZeitdifferenz in ticks §7bis {0} Sekunden§8:§e AUTOSTART_MESSAGE_RESULT3 = §7Positiv, wenn zu wenig, negativ wenn zu viel # Backup -BACKUP_HELP_1=§8/§ebackup create §8- §7Erstelle ein Backup der Region -BACKUP_HELP_2=§8/§ebackup load §8[§7BackupName§8] §8- §7 Lade ein Backup -BACKUP_HELP_3=§8/§ebackup list §8- §7Liste alle Backups der Region auf +BACKUP_HELP_CREATE=§8/§ebackup create §8- §7Erstelle ein Backup der Region +BACKUP_HELP_LOAD=§8/§ebackup load §8[§7BackupName§8] §8- §7 Lade ein Backup +BACKUP_HELP_LIST=§8/§ebackup list §8- §7Liste alle Backups der Region auf +BACKUP_HELP_GUI=§8/§ebackup gui §8- §7Öffne die Backups in einer GUI BACKUP_REGION_NO_REGION=§cDu bist in keiner Region BACKUP_NO_PERMS=§cDu darfst hier nicht das Backup System verwenden BACKUP_CREATE_SUCCESS=§7Das Backup wurde erstellt @@ -117,8 +118,9 @@ BACKUP_ITEM_NAME=§eBackup §7von §e{0} BACKUP_LORE=§eKlicken zum Laden # Bau -BAU_COMMAND_HELP1 = §8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers -BAU_COMMAND_HELP2 = §8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Welt Rechte eines Spielers +BAU_COMMAND_HELP_INFO = §8/§ebau info §8- §7Alias für §8/§ebauinfo +BAU_COMMAND_HELP_TOGGLEWE = §8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers +BAU_COMMAND_HELP_TOGGLEWORLD = §8/§ebau toggleworld §8[§7Player§8] §8- §7Editiere die Welt Rechte eines Spielers BAU_UNKNOWN-PLAYER = §cUnbekannter Spieler BAU_NO-PLAYER = §cDer Spieler ist kein Mitglied deiner Welt! BAU_NO-WORLD = §cDies ist nicht deine Welt! @@ -144,6 +146,7 @@ BAU-INFO_COMMAND_FLAG = §e{0} §8: §7{1} BAU-INFO_COMMAND_TPS = TPS:§e # Countingwand +COUNTINGWAND_COMMAND_HELP = §8/§ecountingwand §8- §7Gibt dir en CountingWand COUNTINGWAND_ITEM_NAME = §eZollstock COUNTINGWAND_ITEM_LORE1 = §eLinksklick §8- §7Setzt die 1. Position COUNTINGWAND_ITEM_LORE2 = §eRechtsklick §8- §7Setzt die 2. Position @@ -168,10 +171,10 @@ DETONATOR_WAND_NAME=§eFernzünder DETONATOR_WAND_LORE_1=§eLinks Klick §8- §7Setzte einen Punkt zum Aktivieren DETONATOR_WAND_LORE_2=§eLinks Klick + Shift §8- §eFüge einen Punkt hinzu DETONATOR_WAND_LORE_3=§eRechts Klick §8- §eLöse alle Punkte aus -DETONATOR_HELP_1=§8/§edetonator wand §8-§7 Gibt den Fernzünder -DETONATOR_HELP_2=§8/§edetonator click §8-§7 Aktiviere einen Fernzünder (Haupthand -> Hotbar -> Inventar) -DETONATOR_HELP_3=§8/§edetonator clear §8-§7 Cleare einen Fernzünder -DETONATOR_HELP_4=§8/§edetonator autostart §8-§7 Automatisch den Autostarttester Aktivieren +DETONATOR_HELP_WAND=§8/§edetonator wand §8-§7 Gibt den Fernzünder +DETONATOR_HELP_CLICK=§8/§edetonator click §8-§7 Aktiviere einen Fernzünder (Haupthand -> Hotbar -> Inventar) +DETONATOR_HELP_CLEAR=§8/§edetonator clear §8-§7 Cleare einen Fernzünder +DETONATOR_HELP_AUTOSTART=§8/§edetonator autostart §8-§7 Automatisch den Autostarttester Aktivieren DETONATOR_AUTOSTART_ENABLE=§7Autostart beim detonate §aangeschaltet DETONATOR_AUTOSTART_DISABLE=§7Autostart beim detonate §causgeschaltet DETONATOR_POINT_ACT=§eEinen Punkt ausgelöst @@ -180,10 +183,10 @@ DETONATOR_INVALID_POINT=§cEin Punkt konnte nicht ausgeführt werden DETONATOR_INVALID_POINTS=§c{0} Punkte konnten nicht ausgeführt werden DETONATOR_INVALID_BLOCK=§eDer Block konnte nicht hinzugefügt werden # Hotbar -HOTBAR_HELP_1=§7Speichert eine Hotbar. Diese wird beim Joinen eines Bauserver, wo du ein Leeres Inventar hast geladen. -HOTBAR_HELP_2=§8/§ehotbar save §8-§7 Speicher deine Aktuelle Hotbar -HOTBAR_HELP_3=§8/§ehotbar load §8-§7 Lade deine Standard Hotbar -HOTBAR_HELP_4=§8/§ehotbar show §8-§7 Zeigt dir deine Standard Hotbar +HOTBAR_HELP_GENERIC=§7Speichert eine Hotbar. Diese wird beim Joinen eines Bauserver, wo du ein Leeres Inventar hast geladen. +HOTBAR_HELP_SAVE=§8/§ehotbar save §8-§7 Speicher deine Aktuelle Hotbar +HOTBAR_HELP_LOAD=§8/§ehotbar load §8-§7 Lade deine Standard Hotbar +HOTBAR_HELP_SHOW=§8/§ehotbar show §8-§7 Zeigt dir deine Standard Hotbar HOTBAR_SAVED=§7Deine Hotbar wurde als Standard gespeichert HOTBAR_LOADED=§7Deine Standard Hotbar wurde geladen HOTBAR_INVENTORY=Standard Hotbar @@ -873,4 +876,4 @@ WARP_HELP_4=§8/§ewarp delete §8[§7Name§8] - §7Lösche einen Warp WARP_HELP_5=§8/§ewarp gui - §7Öffne die Warp-GUI WARP_HELP_6=§8/§ewarp list - §7Liste alle Warp-Punkt auf WARP_MOON_ITEM_NAME=§3Atemkugel -WARP_MOON_COUNTDOOWN=§7Noch §e§l{0} §77Sekunden! +WARP_MOON_COUNTDOOWN=§7Noch §e§l{0} §7Sekunden! diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java index d2da652f..552dd816 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autostart/AutoStartCommand.java @@ -19,7 +19,6 @@ package de.steamwar.bausystem.features.autostart; -import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; @@ -33,14 +32,8 @@ public class AutoStartCommand extends SWCommand { super("timer", "autostarttimer", "at", "autostart"); } - @Register(help = true) - public void genericHelp(Player p, String... args) { - BauSystem.MESSAGE.send("AUTOSTART_COMMAND_HELP", p); - } - - @Register + @Register(description = "AUTOSTART_COMMAND_HELP") public void genericCommand(Player p) { SWUtils.giveItemToPlayer(p, AutostartListener.getWandItem(p)); } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java index fca3e7bf..6edc2db5 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java @@ -46,14 +46,6 @@ public class BackupCommand extends SWCommand { super("backup", "bu"); } - @Register(help = true) - public void genericHelp(Player p, String... args) { - BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", p, "Backup"); - BauSystem.MESSAGE.sendPrefixless("BACKUP_HELP_1", p); - BauSystem.MESSAGE.sendPrefixless("BACKUP_HELP_2", p); - BauSystem.MESSAGE.sendPrefixless("BACKUP_HELP_3", p); - } - static boolean checkGlobalRegion(Region region, Player p) { if (region.isGlobal()) { BauSystem.MESSAGE.send("BACKUP_REGION_NO_REGION", p); @@ -62,15 +54,7 @@ public class BackupCommand extends SWCommand { return false; } - private boolean permissionCheck(Player player, Permission permission) { - if (Permission.hasPermission(player, permission)) { - return true; - } - BauSystem.MESSAGE.send("BACKUP_NO_PERMS", player); - return false; - } - - @Register("create") + @Register(value = "create", description = "BACKUP_HELP_CREATE") public void backupCreate(@Guard Player p) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { @@ -87,7 +71,7 @@ public class BackupCommand extends SWCommand { } } - @Register("load") + @Register(value = "load", description = "BACKUP_HELP_LOAD") public void backupLoad(@Guard Player p, @Mapper("backupName") String backupName) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { @@ -103,7 +87,7 @@ public class BackupCommand extends SWCommand { BauSystem.MESSAGE.send("BACKUP_LOAD", p); } - @Register("list") + @Register(value = "list", description = "BACKUP_HELP_LIST") public void backupList(Player p) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { @@ -116,7 +100,7 @@ public class BackupCommand extends SWCommand { }); } - @Register("gui") + @Register(value = "gui", description = "BACKUP_HELP_GUI") public void backupGui(Player p) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java index 733125eb..6b3f49de 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java @@ -45,23 +45,17 @@ public class BauCommand extends SWCommand { super("bau", "b", "gs"); } - @Register(help = true) - public void genericHelp(Player p, String... args) { - BauSystem.MESSAGE.send("BAU_COMMAND_HELP1", p); - BauSystem.MESSAGE.send("BAU_COMMAND_HELP2", p); - } - - @Register("info") + @Register(value = "info", description = "BAU_COMMAND_HELP_INFO") public void infoCommand(Player p) { infoCommand.sendBauInfo(p); } - @Register("togglewe") + @Register(value = "togglewe", description = "BAU_COMMAND_HELP_TOGGLEWE") public void toggleWECommand(@Guard Player p, SteamwarUser user) { onToggleWE(p, user); } - @Register("toggleworld") + @Register(value = "toggleworld", description = "BAU_COMMAND_HELP_TOGGLEWORLD") public void toggleWorldCommand(@Guard Player p, SteamwarUser user) { onToggleWorld(p, user); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java index 4a2bde6f..2ffab2ff 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/countingwand/CountingwandCommand.java @@ -33,7 +33,7 @@ public class CountingwandCommand extends SWCommand { super("countingwand", "/countingwand", "cwand", "/cwand", "zollstock", "/zollstock"); } - @Register + @Register(description = "COUNTINGWAND_COMMAND_HELP") public void genericCommand(final Player p) { SWUtils.giveItemToPlayer(p, Countingwand.getWandItem(p)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java index 3a79a37a..73435fde 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/detonator/DetonatorCommand.java @@ -57,33 +57,24 @@ public class DetonatorCommand extends SWCommand { super("detonator", "dt"); } - @Register(help = true) - public void genericHelp(Player p, String... args) { - BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", p, "Detonator"); - BauSystem.MESSAGE.sendPrefixless("DETONATOR_HELP_1", p); - BauSystem.MESSAGE.sendPrefixless("DETONATOR_HELP_2", p); - BauSystem.MESSAGE.sendPrefixless("DETONATOR_HELP_3", p); - BauSystem.MESSAGE.sendPrefixless("DETONATOR_HELP_4", p); - } - - @Register("wand") + @Register(value = "wand", description = "DETONATOR_HELP_WAND") public void giveWand(Player p) { SWUtils.giveItemToPlayer(p, getWAND(p)); } - @Register("click") + @Register(value = "click", description = "DETONATOR_HELP_CLICK") public void clickDetonator(Player p) { Detonator.activateDetonator(new ItemStorage(p)); } - @Register("clear") + @Register(value = "clear", description = "DETONATOR_HELP_CLEAR") public void clearDetonator(Player p) { DetonatorStorage storage = new ItemStorage(p); storage.clear(); storage.write(); } - @Register("autostart") + @Register(value = "autostart", description = "DETONATOR_HELP_AUTOSTART") public void toggleAutostartTimer(Player p) { boolean current = Config.getInstance().get(p).getPlainValueOrDefault("detonator-autostart", false); Config.getInstance().get(p).put("detonator-autostart", !current); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java index 20586581..aaee9818 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/hotbar/HotbarCommand.java @@ -32,30 +32,22 @@ public class HotbarCommand extends SWCommand { protected HotbarCommand() { super("hotbar", "hb"); + addDefaultHelpMessage("HOTBAR_HELP_GENERIC"); } - @Register(help = true) - public void genericHelp(Player p, String... args) { - BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", p, "Hotbar"); - BauSystem.MESSAGE.sendPrefixless("HOTBAR_HELP_1", p); - BauSystem.MESSAGE.sendPrefixless("HOTBAR_HELP_2", p); - BauSystem.MESSAGE.sendPrefixless("HOTBAR_HELP_3", p); - BauSystem.MESSAGE.sendPrefixless("HOTBAR_HELP_4", p); - } - - @Register("load") + @Register(value = "load", description = "HOTBAR_HELP_LOAD") public void loadHotbar(Player p) { DefaultHotbar.setHotbar(p); BauSystem.MESSAGE.send("HOTBAR_LOADED", p); } - @Register("save") + @Register(value = "save", description = "HOTBAR_HELP_SAVE") public void saveHotbar(Player p) { DefaultHotbar.updateHotbar(p); BauSystem.MESSAGE.send("HOTBAR_SAVED", p); } - @Register("show") + @Register(value = "show", description = "HOTBAR_HELP_SHOW") public void showHotbar(Player p) { SWInventory inv = new SWInventory(p, 9, BauSystem.MESSAGE.parse("HOTBAR_INVENTORY", p)); ItemStack[] hotbar = DefaultHotbar.getItems(p); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java index a2f435c2..ac642a55 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/StructureVoidCommand.java @@ -33,15 +33,18 @@ public class StructureVoidCommand extends SWCommand { public StructureVoidCommand() { super("structureVoid", "structure", "void", "structurevoid"); + setMessage(BauSystem.MESSAGE); } + /* @Register(help = true) public void genericHelp(Player p, String... args) { BauSystem.MESSAGE.send("COMMAND_HELP_HEAD", p, "structureVoid"); BauSystem.MESSAGE.send("STRUCTURE-VOID_COMMAND_HELP", p); } + */ - @Register + @Register(description = "STRUCTURE-VOID_COMMAND_HELP") public void genericCommand(Player p) { SWUtils.giveItemToPlayer(p, new ItemStack(Material.STRUCTURE_VOID, 1)); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Moon.java b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Moon.java index 065bc21e..a70909c9 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Moon.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/warp/Moon.java @@ -52,7 +52,7 @@ public class Moon { }, 0, 1); bukkitTask.cancel(); } else { - BauSystem.MESSAGE.sendPrefixless("WARP_MOON_COUNTDOOWN", player, countDown.getAndIncrement()); + BauSystem.MESSAGE.sendPrefixless("WARP_MOON_COUNTDOOWN", player, countDown.getAndDecrement()); } }, 0, 20); } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java index 7d033602..9b501472 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/linkage/LinkageType.java @@ -46,7 +46,7 @@ import java.util.function.Predicate; public enum LinkageType { // NORMAL - COMMAND(-1, false, SWCommand.class::isAssignableFrom), + COMMAND(-1, false, SWCommand.class::isAssignableFrom, o -> ((SWCommand) o).setMessage(BauSystem.MESSAGE)), ENABLE_LINK(0, false, Enable.class::isAssignableFrom, o -> ((Enable) o).enable()), DISABLE_LINK(0, true, Disable.class::isAssignableFrom, o -> ((Disable) o).disable()), PLAIN(1, false, clazz -> true),