diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index a855e2ce..a73b6c76 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -492,7 +492,7 @@ SCRIPT_COMMAND_VARS_SET_VALUE = {0} auf {1} gesetzt SCRIPT_COMMAND_VARS_REMOVE_VALUE = Variable {0} gelöscht # Unsign Book -UNSIGN_HELP_1=§8/§eunsign §8- §7Mache ein Buch beschreibbar +UNSIGN_HELP=§8/§eunsign §8- §7Mache ein Buch beschreibbar # Simulator SIMULATOR_GUI_ITEM_NAME = §eTNT Simulator 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 3f8f33a7..fca3e7bf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java @@ -25,9 +25,7 @@ import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.region.Region; import de.steamwar.bausystem.region.tags.Tag; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; +import de.steamwar.command.*; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import net.md_5.bungee.api.chat.ClickEvent; @@ -73,8 +71,7 @@ public class BackupCommand extends SWCommand { } @Register("create") - public void backupCreate(Player p) { - if (!permissionCheck(p, Permission.WORLDEDIT)) return; + public void backupCreate(@Guard Player p) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { return; @@ -91,8 +88,7 @@ public class BackupCommand extends SWCommand { } @Register("load") - public void backupLoad(Player p, @Mapper("backupName") String backupName) { - if (!permissionCheck(p, Permission.WORLDEDIT)) return; + public void backupLoad(@Guard Player p, @Mapper("backupName") String backupName) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { return; @@ -147,6 +143,20 @@ public class BackupCommand extends SWCommand { return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender)); } + @ClassGuard(value = Player.class, local = true) + public GuardChecker backupGuard() { + return (commandSender, guardCheckType, strings, s) -> { + Player player = (Player) commandSender; + if (Permission.hasPermission(player, Permission.WORLDEDIT)) { + return GuardResult.ALLOWED; + } + if (guardCheckType != GuardCheckType.TAB_COMPLETE) { + BauSystem.MESSAGE.send("BACKUP_NO_PERMS", player); + } + return GuardResult.DENIED; + }; + } + private List listBackup(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 94ce4021..733125eb 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java @@ -25,9 +25,7 @@ import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.LinkedInstance; -import de.steamwar.command.SWCommand; -import de.steamwar.command.SWCommandUtils; -import de.steamwar.command.TypeMapper; +import de.steamwar.command.*; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; import org.bukkit.entity.Player; @@ -59,18 +57,12 @@ public class BauCommand extends SWCommand { } @Register("togglewe") - public void toggleWECommand(Player p, SteamwarUser user) { - if (!permissionCheck(p)) { - return; - } + public void toggleWECommand(@Guard Player p, SteamwarUser user) { onToggleWE(p, user); } @Register("toggleworld") - public void toggleWorldCommand(Player p, SteamwarUser user) { - if (!permissionCheck(p)) { - return; - } + public void toggleWorldCommand(@Guard Player p, SteamwarUser user) { onToggleWorld(p, user); } @@ -116,17 +108,6 @@ public class BauCommand extends SWCommand { return false; } - - private boolean permissionCheck(Player p) { - if (!bauServer.getOwner().equals(p.getUniqueId())) { - BauSystem.MESSAGE.send("BAU_NO-WORLD", p); - return false; - } else { - return true; - } - } - - @ClassMapper(value = SteamwarUser.class, local = true) private TypeMapper steamwarUserTypeMapper() { return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(bauServer.getOwnerID()) @@ -146,4 +127,18 @@ public class BauCommand extends SWCommand { .collect(Collectors.toList()); }); } + + @ClassGuard(value = Player.class, local = true) + public GuardChecker bauGuard() { + return (commandSender, guardCheckType, strings, s) -> { + Player p = (Player) commandSender; + if (!bauServer.getOwner().equals(p.getUniqueId())) { + if (guardCheckType != GuardCheckType.TAB_COMPLETE) { + BauSystem.MESSAGE.send("BAU_NO-WORLD", p); + } + return GuardResult.DENIED; + } + return GuardResult.ALLOWED; + }; + } } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java index a700c1b1..0007bdcf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderBauGuiItem.java @@ -21,7 +21,6 @@ package de.steamwar.bausystem.features.loader; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; -import de.steamwar.bausystem.config.ColorConfig; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.bausystem.linkage.specific.BauGuiItem; @@ -44,7 +43,7 @@ public class LoaderBauGuiItem extends BauGuiItem { @Override public ItemStack getItem(Player player) { - return new SWItem(Material.FLINT_AND_STEEL, ColorConfig.HIGHLIGHT + BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)).getItemStack(); + return new SWItem(Material.FLINT_AND_STEEL, BauSystem.MESSAGE.parse("LOADER_GUI_NAME", player)).getItemStack(); } @Override diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/script/UnsignCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/script/UnsignCommand.java index a8ad53ee..92e70064 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/script/UnsignCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/script/UnsignCommand.java @@ -38,7 +38,7 @@ public class UnsignCommand extends SWCommand { @Register(help = true) public void genericHelp(Player p, String... args) { BauSystem.MESSAGE.sendPrefixless("COMMAND_HELP_HEAD", p, "Unsign"); - BauSystem.MESSAGE.sendPrefixless("UNSIGN_HELP_1", p); + BauSystem.MESSAGE.sendPrefixless("UNSIGN_HELP", p); } @Register