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 6edc2db5..7214bd40 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/backup/BackupCommand.java @@ -25,7 +25,10 @@ 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.*; +import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; +import de.steamwar.command.TypeValidator; import de.steamwar.inventory.SWItem; import de.steamwar.inventory.SWListInv; import net.md_5.bungee.api.chat.ClickEvent; @@ -55,7 +58,7 @@ public class BackupCommand extends SWCommand { } @Register(value = "create", description = "BACKUP_HELP_CREATE") - public void backupCreate(@Guard Player p) { + public void backupCreate(@Validator Player p) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { return; @@ -72,7 +75,7 @@ public class BackupCommand extends SWCommand { } @Register(value = "load", description = "BACKUP_HELP_LOAD") - public void backupLoad(@Guard Player p, @Mapper("backupName") String backupName) { + public void backupLoad(@Validator Player p, @Mapper("backupName") String backupName) { Region region = Region.getRegion(p.getLocation()); if (checkGlobalRegion(region, p)) { return; @@ -127,17 +130,10 @@ 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; + @ClassValidator(value = Player.class, local = true) + public TypeValidator backupValidator() { + return (commandSender, player, messageSender) -> { + return !messageSender.send(!Permission.hasPermission(player, Permission.WORLDEDIT), "BACKUP_NO_PERMS"); }; } 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 16c4c8e3..8680f7bf 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/BauCommand.java @@ -19,23 +19,15 @@ package de.steamwar.bausystem.features.bau; -import de.steamwar.bausystem.BauSystem; -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.GuardCheckType; -import de.steamwar.command.GuardChecker; -import de.steamwar.command.GuardResult; import de.steamwar.command.SWCommand; import org.bukkit.entity.Player; @Linked(LinkageType.COMMAND) public class BauCommand extends SWCommand { - @LinkedInstance - private BauServer bauServer; - @LinkedInstance private InfoCommand infoCommand; @@ -47,18 +39,4 @@ public class BauCommand extends SWCommand { public void infoCommand(Player p) { infoCommand.sendBauInfo(p); } - - @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/bau/InfoCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java index de23a4fb..327e4903 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/bau/InfoCommand.java @@ -75,5 +75,4 @@ public class InfoCommand extends SWCommand { } p.sendMessage(tpsMessage.toString()); } - } diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java index 30fa127d..2a86545a 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/loader/LoaderCommand.java @@ -23,10 +23,7 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; -import de.steamwar.command.GuardCheckType; -import de.steamwar.command.GuardChecker; -import de.steamwar.command.GuardResult; -import de.steamwar.command.SWCommand; +import de.steamwar.command.*; import org.bukkit.entity.Player; @Linked(LinkageType.COMMAND) @@ -47,7 +44,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "setup", description = "LOADER_HELP_SETUP") - public void setupLoader(@Guard Player p) { + public void setupLoader(@Validator Player p) { if (Loader.getLoader(p) != null) { Loader.getLoader(p).setup(); BauSystem.MESSAGE.send("LOADER_BACK_SETUP", p); @@ -59,7 +56,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "start", description = "LOADER_HELP_START") - public void startLoader(@Guard Player p) { + public void startLoader(@Validator Player p) { Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) { return; @@ -69,7 +66,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "stop", description = "LOADER_HELP_STOP") - public void stopLoader(@Guard Player p) { + public void stopLoader(@Validator Player p) { Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) { return; @@ -79,7 +76,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "pause", description = "LOADER_HELP_PAUSE") - public void pauseLoader(@Guard Player p) { + public void pauseLoader(@Validator Player p) { Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) { return; @@ -89,7 +86,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "resume", description = "LOADER_HELP_RESUME") - public void resumeLoader(@Guard Player p) { + public void resumeLoader(@Validator Player p) { Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) { return; @@ -99,7 +96,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "wait", description = "LOADER_HELP_WAIT") - public void shotDelayLoader(@Guard Player p, int delay) { + public void shotDelayLoader(@Validator Player p, int delay) { if (delay < 1) { BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); return; @@ -113,7 +110,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "speed", description = "LOADER_HELP_SPEED") - public void speedLoader(@Guard Player p, int delay) { + public void speedLoader(@Validator Player p, int delay) { if (delay < 0) { BauSystem.MESSAGE.send("LOADER_SMALL_TIME", p); return; @@ -127,7 +124,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "undo", description = "LOADER_HELP_UNDO") - public void undoLast(@Guard Player p) { + public void undoLast(@Validator Player p) { Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) { return; @@ -137,7 +134,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "clear", description = "LOADER_HELP_CLEAR") - public void clearLoader(@Guard Player p) { + public void clearLoader(@Validator Player p) { Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) { return; @@ -146,7 +143,7 @@ public class LoaderCommand extends SWCommand { } @Register(value = "single", description = "LOADER_HELP_SINGLE") - public void singleLoader(@Guard Player p) { + public void singleLoader(@Validator Player p) { Loader loader = Loader.getLoader(p); if (loaderNullCheck(loader, p)) { return; @@ -155,17 +152,10 @@ public class LoaderCommand extends SWCommand { BauSystem.MESSAGE.send("LOADER_SINGLE", p); } - @ClassGuard(value = Player.class, local = true) - public GuardChecker loaderGuard() { - return (commandSender, guardCheckType, strings, s) -> { - Player player = (Player) commandSender; - if (!Permission.hasPermission(player, Permission.WORLD)) { - if (guardCheckType != GuardCheckType.TAB_COMPLETE) { - BauSystem.MESSAGE.send("LOADER_PERMS", player); - } - return GuardResult.DENIED; - } - return GuardResult.ALLOWED; + @ClassValidator(value = Player.class, local = true) + public TypeValidator loaderValidator() { + return (commandSender, player, messageSender) -> { + return !messageSender.send(!Permission.hasPermission(player, Permission.WORLD), "LOADER_PERMS"); }; } }