From a39ec22c8c9eae2d6f21f6e47c5b4e13a4a4c9a8 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 27 Jul 2015 23:10:14 +1000 Subject: [PATCH] commit --- .../plot/commands/Add.java | 7 +- .../plot/commands/Auto.java | 8 +- .../plot/commands/Buy.java | 8 +- .../plot/commands/Chat.java | 8 +- .../plot/commands/Claim.java | 8 +- .../plot/commands/Clear.java | 38 +-- .../plot/commands/Cluster.java | 16 +- .../plot/commands/Comment.java | 7 +- .../plot/commands/Condense.java | 7 +- .../plot/commands/Confirm.java | 7 +- .../plot/commands/Copy.java | 7 +- .../plot/commands/CreateRoadSchematic.java | 7 +- .../plot/commands/Database.java | 9 +- .../plot/commands/Debug.java | 7 +- .../plot/commands/DebugAllowUnsafe.java | 8 +- .../plot/commands/DebugClaimTest.java | 6 +- .../plot/commands/DebugClear.java | 47 +-- .../plot/commands/DebugExec.java | 11 +- .../plot/commands/DebugFill.java | 7 +- .../plot/commands/DebugFixFlags.java | 7 +- .../plot/commands/DebugLoadTest.java | 6 +- .../plot/commands/DebugPaste.java | 8 +- .../plot/commands/DebugRoadRegen.java | 7 +- .../plot/commands/DebugSaveTest.java | 6 +- .../plot/commands/DebugUUID.java | 6 +- .../plot/commands/Delete.java | 8 +- .../plot/commands/Deny.java | 8 +- .../plot/commands/Download.java | 8 +- .../plot/commands/FlagCmd.java | 8 +- .../plot/commands/Help.java | 4 +- .../plot/commands/Home.java | 8 +- .../plot/commands/Inbox.java | 8 +- .../plot/commands/Info.java | 8 +- .../plot/commands/Kick.java | 8 +- .../plot/commands/Load.java | 8 +- .../plot/commands/MainCommand.java | 268 ++++++++++-------- .../plot/commands/Merge.java | 8 +- .../plot/commands/Move.java | 8 +- .../plot/commands/MusicSubcommand.java | 8 +- .../plot/commands/Purge.java | 26 +- .../plot/commands/Rate.java | 8 +- .../plot/commands/RegenAllRoads.java | 13 +- .../plot/commands/Reload.java | 10 +- .../plot/commands/Remove.java | 6 +- .../plot/commands/RequiredType.java | 23 ++ .../plot/commands/Save.java | 8 +- .../plot/commands/SchematicCmd.java | 11 +- .../plot/commands/Set.java | 8 +- .../plot/commands/SetOwner.java | 7 +- .../plot/commands/Setup.java | 10 +- .../plot/commands/Swap.java | 8 +- .../plot/commands/TP.java | 7 +- .../plot/commands/Target.java | 7 +- .../plot/commands/Template.java | 14 +- .../plot/commands/Toggle.java | 15 +- .../plot/commands/Trim.java | 7 +- .../plot/commands/Trust.java | 8 +- .../plot/commands/Unclaim.java | 8 +- .../plot/commands/Undeny.java | 8 +- .../plot/commands/Unlink.java | 8 +- .../plot/commands/Untrust.java | 7 +- .../plot/commands/Update.java | 12 +- .../plot/commands/Visit.java | 7 +- .../plot/commands/WE_Anywhere.java | 9 +- .../plot/commands/callers/ConsoleCaller.java | 36 --- .../commands/callers/PlotPlayerCaller.java | 44 --- .../plot/commands/list.java | 8 +- .../plot/commands/plugin.java | 8 +- .../intellectualcrafters/plot/config/C.java | 11 + .../plot/object/ConsolePlayer.java | 126 ++++++++ .../plot/object/Plot.java | 3 + .../plot/util/MainUtil.java | 20 +- .../plot/util/StringMan.java | 30 +- .../plot/util/UUIDHandler.java | 4 +- .../plot/util/UUIDHandlerImplementation.java | 25 +- .../intellectualsites/commands/Argument.java | 32 +-- .../intellectualsites/commands/Command.java | 49 +++- .../commands/CommandCaller.java | 19 -- .../commands/CommandDeclaration.java | 3 +- .../commands/CommandManager.java | 20 +- .../commands/util/StringUtil.java | 26 -- .../com/plotsquared/bukkit/BukkitMain.java | 6 +- .../bukkit/commands/BukkitCommand.java | 3 +- .../bukkit/listeners/WorldEvents.java | 2 +- .../util/bukkit/uuid/FileUUIDHandler.java | 11 +- .../util/bukkit/uuid/SQLUUIDHandler.java | 163 ++++++----- .../com/plotsquared/sponge/SpongeMain.java | 2 +- 87 files changed, 785 insertions(+), 752 deletions(-) create mode 100644 src/main/java/com/intellectualcrafters/plot/commands/RequiredType.java delete mode 100644 src/main/java/com/intellectualcrafters/plot/commands/callers/ConsoleCaller.java delete mode 100644 src/main/java/com/intellectualcrafters/plot/commands/callers/PlotPlayerCaller.java create mode 100644 src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java delete mode 100644 src/main/java/com/intellectualsites/commands/CommandCaller.java delete mode 100644 src/main/java/com/intellectualsites/commands/util/StringUtil.java diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Add.java b/src/main/java/com/intellectualcrafters/plot/commands/Add.java index 9eb98a6d7..be4bd1caa 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Add.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Add.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; @CommandDeclaration( @@ -44,7 +44,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; usage = "/plot add ", category = CommandCategory.ACTIONS, permission = "plots.add", - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Add extends SubCommand { @@ -55,8 +55,7 @@ public class Add extends SubCommand { } @Override - public boolean onCommand(CommandCaller caller, String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(PlotPlayer plr, String[] args) { final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 29fbdd69c..5be21ef0f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -34,13 +34,13 @@ import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "auto", permission = "plots.auto", category = CommandCategory.CLAIMING, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, description = "Claim the nearest plot", aliases = {"a"}, usage = "/plot auto" @@ -77,8 +77,8 @@ public class Auto extends SubCommand { } @Override - public boolean onCommand(CommandCaller caller, String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(PlotPlayer plr, String[] args) { + String world; int size_x = 1; int size_z = 1; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Buy.java b/src/main/java/com/intellectualcrafters/plot/commands/Buy.java index 0ba318ee3..acb73954b 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Buy.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Buy.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "buy", @@ -45,13 +45,13 @@ import com.intellectualsites.commands.CommandCaller; usage = "/plot buy", permission = "plots.buy", category = CommandCategory.CLAIMING, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Buy extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String ... args) { + if (EconHandler.manager == null) { return sendMessage(plr, C.ECON_DISABLED); } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Chat.java b/src/main/java/com/intellectualcrafters/plot/commands/Chat.java index efe9e89d1..b30d90a41 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Chat.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Chat.java @@ -5,7 +5,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "chat", @@ -13,13 +13,13 @@ import com.intellectualsites.commands.CommandCaller; usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Chat extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String ... args) { + final String world = plr.getLocation().getWorld(); if (!PS.get().isPlotWorld(world)) { return !sendMessage(plr, C.NOT_IN_PLOT_WORLD); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index 3b81ffd6f..f56592f69 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -35,14 +35,14 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "claim", aliases = {"c"}, description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, permission = "plots.claim", usage = "/plot claim" ) @@ -96,8 +96,8 @@ public class Claim extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String ... args) { + String schematic = ""; if (args.length >= 1) { schematic = args[0]; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index 68079ff44..b64158bd5 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import java.util.Set; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "clear", @@ -48,39 +48,7 @@ import com.intellectualsites.commands.CommandCaller; public class Clear extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null; - if (plr == null) { - // Is console - if (args.length < 2) { - PS.log("You need to specify two arguments: ID (0;0) & World (world)"); - } else { - final PlotId id = PlotId.fromString(args[0]); - final String world = args[1]; - if (id == null) { - PS.log("Invalid Plot ID: " + args[0]); - } else { - if (!PS.get().isPlotWorld(world)) { - PS.log("Invalid plot world: " + world); - } else { - final Plot plot = MainUtil.getPlot(world, id); - if (plot == null) { - PS.log("Could not find plot " + args[0] + " in world " + world); - } else { - Runnable runnable = new Runnable() { - @Override - public void run() { - MainUtil.clear(plot, plot.owner == null, null); - PS.log("Plot " + plot.getId().toString() + " cleared."); - } - }; - TaskManager.runTask(runnable); - } - } - } - } - return true; - } + public boolean onCommand(final PlotPlayer plr, final String ... args) { final Location loc = plr.getLocation(); final Plot plot; if (args.length == 2) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index ed9ecdc20..87a6cef77 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -29,12 +29,6 @@ import org.bukkit.generator.ChunkGenerator; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.generator.PlotGenerator; -import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; -import com.plotsquared.bukkit.generator.AugmentedPopulator; -import com.plotsquared.bukkit.generator.BukkitPlotGenerator; -import com.plotsquared.bukkit.generator.HybridGen; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -48,21 +42,25 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.intellectualsites.commands.CommandDeclaration; +import com.plotsquared.bukkit.generator.AugmentedPopulator; +import com.plotsquared.bukkit.generator.BukkitPlotGenerator; +import com.plotsquared.bukkit.generator.HybridGen; import com.plotsquared.bukkit.util.SetupUtils; @CommandDeclaration( command = "cluser", aliases = {"clusters"}, category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, permission = "plots.cluster", description = "Manage a plot cluster" ) public class Cluster extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String ... args) { + // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome if (args.length == 0) { // return arguments diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index 6471542fe..75aa91f00 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -23,7 +23,7 @@ package com.intellectualcrafters.plot.commands; import java.util.Arrays; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.config.C; @@ -41,14 +41,13 @@ import com.intellectualcrafters.plot.util.MainUtil; aliases = {"msg"}, description = "Comment on a plot", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, permission = "plot.comment" ) public class Comment extends SubCommand { @Override - public boolean onCommand(CommandCaller caller, String[] args) { - final PlotPlayer player = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(PlotPlayer player, String[] args) { if (args.length < 2) { sendMessage(player, C.COMMENT_SYNTAX, StringUtils.join(CommentManager.inboxes.keySet(),"|")); return false; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index a3218e509..9f1bdc356 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -27,7 +27,7 @@ import java.util.List; import java.util.Set; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.PS; @@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.util.MainUtil; permission = "plots.admin", description = "Condense a plotworld", category = CommandCategory.DEBUG, - requiredType = PS.class + requiredType = RequiredType.CONSOLE ) public class Condense extends SubCommand { @@ -54,8 +54,7 @@ public class Condense extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, String ... args) { - final PlotPlayer plr = null; + public boolean onCommand(final PlotPlayer plr, String ... args) { if ((args.length != 2) && (args.length != 3)) { MainUtil.sendMessage(plr, "/plot condense [radius]"); return false; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java b/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java index 8270fe9f8..ec06a7b4c 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java @@ -20,7 +20,7 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.CmdInstance; import com.intellectualcrafters.plot.object.PlotPlayer; @@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.util.CmdConfirm; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "confirm", @@ -39,8 +39,7 @@ import com.intellectualsites.commands.CommandCaller; public class Confirm extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null; + public boolean onCommand(final PlotPlayer plr, final String ... args) { CmdInstance command = CmdConfirm.getPending(plr); if (command == null) { MainUtil.sendMessage(plr, C.FAILED_CONFIRM); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Copy.java b/src/main/java/com/intellectualcrafters/plot/commands/Copy.java index 1010f10d1..9432a8a71 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Copy.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Copy.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "copy", @@ -38,7 +38,7 @@ import com.intellectualsites.commands.CommandCaller; category = CommandCategory.ACTIONS, description = "Copy a plot", usage = "/plot copy ", - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Copy extends SubCommand { @@ -49,8 +49,7 @@ public class Copy extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String ... args) { final Location loc = plr.getLocation(); final Plot plot1 = MainUtil.getPlot(loc); if (plot1 == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java b/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java index 415350ddd..066d61f24 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -29,13 +29,13 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "createroadschematic", aliases = {"crs"}, category = CommandCategory.DEBUG, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, permission = "plots.createroadschematic", description = "Add a road schematic to your world using the roads around your current plot", usage = "/plot createroadschematic" @@ -43,8 +43,7 @@ import com.intellectualsites.commands.CommandCaller; public class CreateRoadSchematic extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer player = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer player, final String ... args) { final Location loc = player.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 1840a2cfd..91437258e 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -6,7 +6,7 @@ import java.util.ArrayList; import java.util.UUID; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualcrafters.plot.database.MySQL; import com.intellectualcrafters.plot.database.SQLManager; import com.intellectualcrafters.plot.object.Plot; @@ -16,7 +16,7 @@ import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "database", @@ -24,7 +24,9 @@ import com.intellectualsites.commands.CommandCaller; category = CommandCategory.DEBUG, permission = "plots.database", description = "Convert/Backup Storage", + requiredType = RequiredType.CONSOLE, usage = "/plots database [details...]" + ) public class Database extends SubCommand { @@ -73,8 +75,7 @@ public class Database extends SubCommand { } @Override - public boolean onCommand(CommandCaller caller, String[] args) { - final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null; + public boolean onCommand(PlotPlayer plr, String[] args) { if (args.length < 1) { return sendMessage(plr, "/plot database [sqlite/mysql]"); } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/src/main/java/com/intellectualcrafters/plot/commands/Debug.java index eeec759e7..d97595a94 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -21,13 +21,13 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.Lag; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "debug", @@ -39,8 +39,7 @@ import com.intellectualsites.commands.CommandCaller; public class Debug extends SubCommand { @Override - public boolean onCommand(CommandCaller caller, String[] args) { - final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null; + public boolean onCommand(PlotPlayer plr, String[] args) { if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { final StringBuilder msg = new StringBuilder(); for (final C c : C.values()) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugAllowUnsafe.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugAllowUnsafe.java index fdc6d9d00..72e2594cb 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugAllowUnsafe.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugAllowUnsafe.java @@ -9,14 +9,14 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "debugallowunsafe", description = "Allow unsafe actions until toggled off", usage = "/plot debugallowunsafe", category = CommandCategory.DEBUG, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, permission = "plots.debugallowunsafe" ) public class DebugAllowUnsafe extends SubCommand { @@ -24,8 +24,8 @@ public class DebugAllowUnsafe extends SubCommand { public static final List unsafeAllowed = new ArrayList<>(); @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String ... args) { + if (unsafeAllowed.contains(plr.getUUID())) { unsafeAllowed.remove(plr.getUUID()); sendMessage(plr, C.DEBUGALLOWUNSAFE_OFF); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index 43dc7f3a0..a155c6b1b 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -41,13 +41,13 @@ import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "debugclaimtest", description = "If you accidentally delete your database, this command will attempt to restore all plots based on the data from plot sighs. Execution time may vary", category = CommandCategory.DEBUG, - requiredType = PS.class, + requiredType = RequiredType.CONSOLE, permission = "plots.debugclaimtest" ) public class DebugClaimTest extends SubCommand { @@ -70,7 +70,7 @@ public class DebugClaimTest extends SubCommand { } @Override - public boolean onCommand(CommandCaller caller, String[] args) { + public boolean onCommand(PlotPlayer plr, String[] args) { if (args.length < 3) { return !MainUtil.sendMessage(null, "If you accidentally delete your database, this command will attempt to restore all plots based on the data from the plot signs. \n\n&cMissing world arg /plot debugclaimtest {world} {PlotId min} {PlotId max}"); } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index fc13bb66c..f242c92c0 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -21,7 +21,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Location; @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "debugclear", @@ -44,46 +44,7 @@ import com.intellectualsites.commands.CommandCaller; public class DebugClear extends SubCommand { @Override - public boolean onCommand(CommandCaller caller, String[] args) { - final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null; - if (plr == null) { - // Is console - if (args.length < 2) { - PS.log("You need to specify two arguments: ID (0;0) & World (world)"); - } else { - final PlotId id = PlotId.fromString(args[0]); - final String world = args[1]; - if (id == null) { - PS.log("Invalid Plot ID: " + args[0]); - } else { - if (!PS.get().isPlotWorld(world) || !(PS.get().getPlotWorld(world) instanceof SquarePlotWorld)) { - PS.log("Invalid plot world: " + world); - } else { - final Plot plot = MainUtil.getPlot(world, id); - if (plot == null) { - PS.log("Could not find plot " + args[0] + " in world " + world); - } else { - final Location pos1 = MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1); - final Location pos2 = MainUtil.getPlotTopLoc(world, plot.id); - if (MainUtil.runners.containsKey(plot)) { - MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); - return false; - } - MainUtil.runners.put(plot, 1); - ChunkManager.manager.regenerateRegion(pos1, pos2, new Runnable() { - @Override - public void run() { - MainUtil.runners.remove(plot); - PS.log("Plot " + plot.getId().toString() + " cleared."); - PS.log("&aDone!"); - } - }); - } - } - } - } - return true; - } + public boolean onCommand(final PlotPlayer plr, String[] args) { final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || !(PS.get().getPlotWorld(loc.getWorld()) instanceof SquarePlotWorld)) { @@ -109,8 +70,6 @@ public class DebugClear extends SubCommand { MainUtil.sendMessage(plr, "&aDone!"); } }); - // sign - // wall return true; } } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index a49c6cc6c..cfd0a7058 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -30,9 +30,9 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; @@ -64,17 +64,12 @@ import com.intellectualcrafters.plot.util.UUIDHandler; public class DebugExec extends SubCommand { @Override - public boolean onCommand(CommandCaller caller, String[] args) { - final PlotPlayer player = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null; + public boolean onCommand(final PlotPlayer player, String[] args) { final List allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "trim-check"); if (args.length > 0) { final String arg = args[0].toLowerCase(); switch (arg) { case "analyze": { - if (player == null) { - MainUtil.sendMessage(player, C.IS_CONSOLE); - return false; - } Plot plot = MainUtil.getPlot(player.getLocation()); if (plot == null) { MainUtil.sendMessage(player, C.NOT_IN_PLOT); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java index 2aefaed87..4d8b932fc 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugFill.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SetBlockQueue; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "fill", @@ -39,13 +39,12 @@ import com.intellectualsites.commands.CommandCaller; usage = "/plot fill", aliases = {"debugfill"}, category = CommandCategory.DEBUG, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class DebugFill extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer player = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer player, final String ... args) { if (args.length != 1 || (!args[0].equalsIgnoreCase("outline") && !args[0].equalsIgnoreCase("all"))) { MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot fill "); return true; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java index 5280f7bd3..33359a528 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugFixFlags.java @@ -35,14 +35,14 @@ import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "debugfixflags", usage = "/plot debugfixflags ", permission = "plots.debugfixflags", description = "Attempt to fix all flags for a world", - requiredType = PS.class, + requiredType = RequiredType.CONSOLE, category = CommandCategory.DEBUG ) public class DebugFixFlags extends SubCommand { @@ -54,8 +54,7 @@ public class DebugFixFlags extends SubCommand { } @Override - public boolean onCommand(CommandCaller caller, String[] args) { - final PlotPlayer plr = null; + public boolean onCommand(PlotPlayer plr, String[] args) { final String world = args[0]; if (!BlockManager.manager.isWorld(world) || !PS.get().isPlotWorld(world)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD, args[0]); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java index abb9c6dc5..2e9a46d03 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugLoadTest.java @@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "debugloadtest", @@ -35,12 +35,12 @@ import com.intellectualsites.commands.CommandCaller; description = "This debug command will force the reload of all plots in the DB", usage = "/plot debugloadtest", category = CommandCategory.DEBUG, - requiredType = PS.class + requiredType = RequiredType.CONSOLE ) public class DebugLoadTest extends SubCommand { @Override - public boolean onCommand(CommandCaller caller, String[] args) { + public boolean onCommand(PlotPlayer plr, String[] args) { try { final Field fPlots = PS.class.getDeclaredField("plots"); fPlots.setAccessible(true); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java index f67d80ca9..e8caf2358 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java @@ -1,7 +1,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.bukkit.BukkitMain; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; @@ -26,7 +26,7 @@ import java.io.IOException; public class DebugPaste extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, String[] args) { + public boolean onCommand(final PlotPlayer plr, String[] args) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { @@ -36,7 +36,7 @@ public class DebugPaste extends SubCommand { try { latestLOG = HastebinUtility.upload(new File(BukkitMain.THIS.getDirectory(), "../../logs/latest.log")); } catch(final Exception e) { - caller.message("&clatest.log is too big to be pasted, will ignore"); + plr.sendMessage("&clatest.log is too big to be pasted, will ignore"); latestLOG = "too big :("; } StringBuilder b = new StringBuilder(); @@ -65,7 +65,7 @@ public class DebugPaste extends SubCommand { b.append("\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues"); String link = HastebinUtility.upload(b.toString()); - caller.message(C.DEBUG_REPORT_CREATED.s().replace("%url%", link)); + plr.sendMessage(C.DEBUG_REPORT_CREATED.s().replace("%url%", link)); } catch (IOException e) { e.printStackTrace(); } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index 82312472e..fdcd3e575 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -29,12 +29,12 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "debugroadregen", usage = "/plot debugroadregen", - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, description = "Regenerate all roads based on the road schematic", category = CommandCategory.DEBUG, permission = "plots.debugroadregen" @@ -42,8 +42,7 @@ import com.intellectualsites.commands.CommandCaller; public class DebugRoadRegen extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer player = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer player, final String ... args) { final Location loc = player.getLocation(); final String world = loc.getWorld(); if (!(PS.get().getPlotWorld(world) instanceof HybridPlotWorld)) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java index 7317a6ec4..fc20cd360 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugSaveTest.java @@ -28,20 +28,20 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "debugsavetest", permission = "plots.debugsavetest", category = CommandCategory.DEBUG, - requiredType = PS.class, + requiredType = RequiredType.CONSOLE, usage = "/plot debugsavetest", description = "This command will force the recreation of all plots in the DB" ) public class DebugSaveTest extends SubCommand { @Override - public boolean onCommand(CommandCaller caller, String[] args) { + public boolean onCommand(PlotPlayer plr, String[] args) { final ArrayList plots = new ArrayList(); plots.addAll(PS.get().getPlots()); MainUtil.sendMessage(null, "&6Starting `DEBUGSAVETEST`"); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java index 01a7ff053..73659aa92 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugUUID.java @@ -30,7 +30,7 @@ import java.util.UUID; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.bukkit.Bukkit; @@ -57,7 +57,7 @@ import com.intellectualcrafters.plot.uuid.UUIDWrapper; permission = "plots.admin", description = "Debug UUID conversion", usage = "/plot uuidconvert ", - requiredType = PS.class, + requiredType = RequiredType.CONSOLE, category = CommandCategory.DEBUG ) public class DebugUUID extends SubCommand { @@ -69,7 +69,7 @@ public class DebugUUID extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { + public boolean onCommand(final PlotPlayer plr, final String[] args) { PlotPlayer player = null; UUIDWrapper currentUUIDWrapper = UUIDHandler.getUUIDWrapper(); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index 17c200d52..e7173d9ee 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "delete", @@ -42,13 +42,13 @@ import com.intellectualsites.commands.CommandCaller; description = "Delete a plot", usage = "/plot delete", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Delete extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Deny.java b/src/main/java/com/intellectualcrafters/plot/commands/Deny.java index 3448a180c..a31a98f92 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Deny.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -34,7 +34,7 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; @CommandDeclaration( @@ -43,7 +43,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; description = "Deny a user from a plot", usage = "/plot deny ", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Deny extends SubCommand { @@ -54,8 +54,8 @@ public class Deny extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Download.java b/src/main/java/com/intellectualcrafters/plot/commands/Download.java index 2374665a0..a0bb4491d 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Download.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Download.java @@ -14,21 +14,21 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "download", aliases = {"dl"}, category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, description = "Download your plot", permission = "plots.download" ) public class Download extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + if (!Settings.METRICS) { MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service"); return false; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index f5ac0a8d5..ee79da51f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -25,7 +25,7 @@ import java.util.Arrays; import java.util.HashMap; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.config.C; @@ -45,14 +45,14 @@ import com.intellectualcrafters.plot.util.Permissions; aliases = {"f"}, description = "Manage plot flags", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, permission = "plots.flag" ) public class FlagCmd extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer player = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer player, final String ... args) { + /* * plot flag set fly true * plot flag remove fly diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Help.java b/src/main/java/com/intellectualcrafters/plot/commands/Help.java index 81ff2375c..7b4bc950f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Help.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Help.java @@ -8,7 +8,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "help", @@ -20,7 +20,7 @@ import com.intellectualsites.commands.CommandCaller; public class Help extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { + public boolean onCommand(final PlotPlayer plr, final String[] args) { return true; } } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/src/main/java/com/intellectualcrafters/plot/commands/Home.java index 2ab2a7fbb..5ff9f3564 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -28,7 +28,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "home", @@ -36,7 +36,7 @@ import com.intellectualsites.commands.CommandCaller; description = "Go to your plot", usage = "/plot home [id|alias]", category = CommandCategory.TELEPORT, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Home extends SubCommand { @@ -50,8 +50,8 @@ public class Home extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, String[] args) { + final ArrayList plots = PS.get().sortPlotsByWorld(PS.get().getPlots(plr)); if (plots.size() == 1) { MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0)); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 8a78c2928..6a5b27acf 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -24,7 +24,7 @@ import java.util.ArrayList; import java.util.List; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; import com.intellectualcrafters.plot.config.C; @@ -43,7 +43,7 @@ import com.intellectualcrafters.plot.util.StringMan; usage = "/plot inbox [inbox] [delete |clear|page]", permission = "plots.inbox", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Inbox extends SubCommand { @@ -86,8 +86,8 @@ public class Inbox extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer player = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer player, final String[] args) { + final Plot plot = MainUtil.getPlot(player.getLocation()); if (args.length == 0) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 347c65b9f..37967934e 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -25,10 +25,10 @@ import java.util.Collection; import java.util.UUID; import java.util.regex.Matcher; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualcrafters.plot.flag.Flag; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; @@ -88,9 +88,7 @@ public class Info extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, String[] args) { - final PlotPlayer player = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null; - + public boolean onCommand(final PlotPlayer player, String[] args) { String arg = null; Plot plot; if (args.length > 0) arg = args[0] + ""; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 01243156c..739c664c8 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -29,7 +29,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "kick", @@ -37,13 +37,13 @@ import com.intellectualsites.commands.CommandCaller; description = "Kick a player from your plot", permission = "plots.kick", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Kick extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Load.java b/src/main/java/com/intellectualcrafters/plot/commands/Load.java index e4f14e961..39313c8f3 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Load.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Load.java @@ -17,13 +17,13 @@ import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "load", aliases = {"restore"}, category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, description = "Load your plot", permission = "plots.load", usage = "/plot restore" @@ -31,8 +31,8 @@ import com.intellectualsites.commands.CommandCaller; public class Load extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + if (!Settings.METRICS) { MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service"); return false; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 633f54712..f0d19f30b 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -24,22 +24,23 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Iterator; import java.util.List; +import java.util.UUID; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.commands.callers.ConsoleCaller; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.object.ConsolePlayer; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.Command; import com.intellectualsites.commands.CommandHandlingOutput; import com.intellectualsites.commands.CommandManager; -import com.intellectualsites.commands.CommandCaller; -import com.intellectualsites.commands.util.StringUtil; +import com.intellectualcrafters.plot.object.PlotPlayer; /** * PlotSquared command class @@ -92,13 +93,12 @@ public class MainCommand extends CommandManager { return false; } - public static List getCommands(final CommandCategory category, final PlotPlayer player) { - final List cmds = new ArrayList<>(); - for (final Command c : instance.commands.values()) { - if (c.getRequiredType().isInstance(PlotPlayer.class)) { - if ((category == null || (c.getCategory().equals(category))) && player.hasPermission(c.getPermission())) { - cmds.add(c); - } + public static ArrayList getCommands(final CommandCategory category, final PlotPlayer player) { + ArrayList cmds = instance.getCommands(); + for (Iterator iter = cmds.iterator(); iter.hasNext();){ + Command cmd = iter.next(); + if ((category != null && (cmd.getCategory().equals(category))) || !player.hasPermission(cmd.getPermission())) { + iter.remove(); } } return cmds; @@ -142,106 +142,134 @@ public class MainCommand extends CommandManager { return help; } - public static boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { - if ((args.length < 1) || ((args.length >= 1) && (args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("he")))) { - if (args.length < 2) { - final StringBuilder builder = new StringBuilder(); - builder.append(C.HELP_INFO.s()); - for (final CommandCategory category : CommandCategory.values()) { - builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); - } - builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands")); - return MainUtil.sendMessage(player, builder.toString()); - } - final String cat = args[1]; - CommandCategory cato = null; - for (final CommandCategory category : CommandCategory.values()) { - if (cat.equalsIgnoreCase(category.toString())) { - cato = category; - break; - } - } - if ((cato == null) && !cat.equalsIgnoreCase("all")) { - final StringBuilder builder = new StringBuilder(); - builder.append(C.HELP_INFO.s()); - for (final CommandCategory category : CommandCategory.values()) { - builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); - } - return MainUtil.sendMessage(player, builder.toString(), false); - } - final StringBuilder help = new StringBuilder(); - int page = 0; - boolean digit = true; - String arg2; - if (args.length > 2) { - arg2 = args[2]; - } else { - arg2 = "1"; - } - for (final char c : arg2.toCharArray()) { - if (!Character.isDigit(c)) { - digit = false; - break; - } - } - if (digit) { - page = Integer.parseInt(arg2); - if (--page < 0) { - page = 0; - } - } - for (final String string : helpMenu(player, cato, page)) { - help.append(string).append("\n"); - } - MainUtil.sendMessage(player, help.toString()); - // return PlayerFunctions.sendMessage(player, help.toString()); - } else { - CommandCaller caller; - if (player != null) { - caller = new PlotPlayerCaller(player); - } else { - caller = new ConsoleCaller(); - } - StringBuilder builder = new StringBuilder(cmd).append(" "); - Iterator iterator = Arrays.asList(args).iterator(); - while (iterator.hasNext()) { - builder.append(iterator.next()); - if (iterator.hasNext()) { - builder.append(" "); - } - } - instance.handle(caller, builder.toString()); - // for (final SubCommand command : subCommands) { - // if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.contains(args[0].toLowerCase())) { - // final String[] arguments = new String[args.length - 1]; - // System.arraycopy(args, 1, arguments, 0, args.length - 1); - // if (command.permission.hasPermissipon(player)) { - // if ((player != null) || !command.isPlayer) { - // return command.execute(player, arguments); - // } else { - // return !MainUtil.sendMessage(null, C.IS_CONSOLE); - // } - // } else { - // return no_permission(player, command.permission.permission.toLowerCase()); - // } - // } - // } - // MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND); - // final String[] commands = new String[subCommands.size()]; - // for (int x = 0; x < subCommands.size(); x++) { - // commands[x] = subCommands.get(x).cmd; - // } - // /* Let's try to get a proper usage string */ - // final String command = new StringComparison(args[0], commands).getBestMatch(); - // return MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); - // PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new - // StringComparsion(args[0], commands).getBestMatch()); + public static void displayHelp(PlotPlayer player, String cat, int page) { + if (cat != null && StringMan.isEqualIgnoreCase(cat, "all")) { + cat = null; } + if (cat == null && page == 0) { + final StringBuilder builder = new StringBuilder(); + builder.append(C.HELP_INFO.s()); + for (final CommandCategory category : CommandCategory.values()) { + builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); + } + builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", "all").replaceAll("%category_desc%", "Display all commands")); + MainUtil.sendMessage(player, builder.toString()); + return; + } + CommandCategory cato = null; + for (final CommandCategory category : CommandCategory.values()) { + if (cat.equalsIgnoreCase(category.toString())) { + cato = category; + break; + } + } + if ((cato == null) && !cat.equalsIgnoreCase("all")) { + final StringBuilder builder = new StringBuilder(); + builder.append(C.HELP_INFO.s()); + for (final CommandCategory category : CommandCategory.values()) { + builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); + } + MainUtil.sendMessage(player, builder.toString(), false); + return; + } + final StringBuilder help = new StringBuilder(); + for (final String string : helpMenu(player, cato, page)) { + help.append(string).append("\n"); + } + MainUtil.sendMessage(player, help.toString()); + } + + public static boolean onCommand(final PlotPlayer player, final String cmd, final String... args) { + int help_index = -1; + String category = null; + if (args.length == 0) { + help_index = 0; + } + else if (StringMan.isEqualIgnoreCaseToAny(args[0], "he", "help", "?")) { + help_index = 0; + switch (args.length) { + case 3: { + category = args[1]; + } + case 2: { + if (MathMan.isInteger(args[args.length - 1])) { + category = null; + try { + help_index = Integer.parseInt(args[1]) - 1; + } + catch (NumberFormatException e) {} + } + if (category == null) { + category = args[1]; + } + } + case 1: { + break; + } + } + if (args.length == 3) { + if (MathMan.isInteger(args[args.length - 1])) { + category = null; + try { + help_index = Integer.parseInt(args[1]) - 1; + } + catch (NumberFormatException e) {} + } + else { + category = args[1]; + } + } + } + else if (MathMan.isInteger(args[args.length - 1])) { + try { + help_index = Integer.parseInt(args[args.length - 1]) - 1; + } + catch (NumberFormatException e) {} + } + if (help_index != -1) { + displayHelp(player, category, help_index); + return true; + } + PlotPlayer caller; + StringBuilder builder = new StringBuilder(cmd).append(" "); + Iterator iterator = Arrays.asList(args).iterator(); + while (iterator.hasNext()) { + builder.append(iterator.next()); + if (iterator.hasNext()) { + builder.append(" "); + } + } + instance.handle(player, builder.toString()); + // for (final SubCommand command : subCommands) { + // if (command.cmd.equalsIgnoreCase(args[0]) || command.alias.contains(args[0].toLowerCase())) { + // final String[] arguments = new String[args.length - 1]; + // System.arraycopy(args, 1, arguments, 0, args.length - 1); + // if (command.permission.hasPermissipon(player)) { + // if ((player != null) || !command.isPlayer) { + // return command.execute(player, arguments); + // } else { + // return !MainUtil.sendMessage(null, C.IS_CONSOLE); + // } + // } else { + // return no_permission(player, command.permission.permission.toLowerCase()); + // } + // } + // } + // MainUtil.sendMessage(player, C.NOT_VALID_SUBCOMMAND); + // final String[] commands = new String[subCommands.size()]; + // for (int x = 0; x < subCommands.size(); x++) { + // commands[x] = subCommands.get(x).cmd; + // } + // /* Let's try to get a proper usage string */ + // final String command = new StringComparison(args[0], commands).getBestMatch(); + // return MainUtil.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); + // PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new + // StringComparsion(args[0], commands).getBestMatch()); return true; } @Override - public int handle(CommandCaller caller, String input) { + public int handle(PlotPlayer plr, String input) { String[] parts = input.split(" "); String[] args; String command = parts[0].toLowerCase(); @@ -252,29 +280,31 @@ public class MainCommand extends CommandManager { System.arraycopy(parts, 1, args, 0, args.length); } Command cmd = null; + System.out.print(command); + System.out.print(StringMan.join(commands.entrySet(), ", ")); cmd = this.commands.get(command); if (cmd == null) { - caller.message(C.NOT_VALID_SUBCOMMAND); + MainUtil.sendMessage(plr, C.NOT_VALID_SUBCOMMAND); { final String[] commands = new String[this.commands.size()]; for (int i = 0; i < commands.length; i++) { commands[i] = this.commands.get(i).getCommand(); } final String bestMatch = new StringComparison(args[0], commands).getBestMatch(); - caller.message(C.DID_YOU_MEAN, "/plot " + bestMatch); + MainUtil.sendMessage(plr, C.DID_YOU_MEAN, "/plot " + bestMatch); } return CommandHandlingOutput.NOT_FOUND; } - if (!cmd.getRequiredType().isInstance(caller.getSuperCaller())) { - if (caller instanceof PlotPlayerCaller) { - caller.message(C.NOT_CONSOLE); + if (cmd.getRequiredType().allows(plr)) { + if (ConsolePlayer.isConsole(plr)) { + MainUtil.sendMessage(plr, C.IS_CONSOLE); } else { - caller.message(C.IS_CONSOLE); - return CommandHandlingOutput.CALLER_OF_WRONG_TYPE; + MainUtil.sendMessage(plr, C.NOT_CONSOLE); } + return CommandHandlingOutput.CALLER_OF_WRONG_TYPE; } - if (!caller.hasPermission(cmd.getPermission())) { - caller.message(C.NO_PERMISSION, cmd.getPermission()); + if (!plr.hasPermission(cmd.getPermission())) { + MainUtil.sendMessage(plr, C.NO_PERMISSION, cmd.getPermission()); return CommandHandlingOutput.NOT_PERMITTED; } Argument[] requiredArguments = cmd.getRequiredArguments(); @@ -291,16 +321,16 @@ public class MainCommand extends CommandManager { } } if (!success) { - caller.sendRequiredArgumentsList(this, cmd, requiredArguments); + C.COMMAND_SYNTAX.send(plr, cmd.getUsage()); return CommandHandlingOutput.WRONG_USAGE; } } try { - boolean a = cmd.onCommand(caller, args); - if (!a) { + boolean result = cmd.onCommand(plr, args); + if (!result) { String usage = cmd.getUsage(); if (usage != null && !usage.isEmpty()) { - caller.message(usage); + MainUtil.sendMessage(plr, usage); } return CommandHandlingOutput.WRONG_USAGE; } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 26f5f8ad8..556b665fc 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -26,7 +26,7 @@ import java.util.UUID; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; @@ -51,7 +51,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; permission = "plots.merge", usage = "/plot merge [direction]", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Merge extends SubCommand { public final static String[] values = new String[] { "north", "east", "south", "west" }; @@ -86,8 +86,8 @@ public class Merge extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + final Location loc = plr.getLocationFull(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Move.java b/src/main/java/com/intellectualcrafters/plot/commands/Move.java index 7159f86bd..4204ec1bf 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Move.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Move.java @@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "move", @@ -39,7 +39,7 @@ import com.intellectualsites.commands.CommandCaller; aliases = {"debugmove"}, permission = "plots.move", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Move extends SubCommand { @@ -50,8 +50,8 @@ public class Move extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + final Location loc = plr.getLocation(); final Plot plot1 = MainUtil.getPlot(loc); if (plot1 == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index c5bdacee5..9a68c158d 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "music", @@ -40,13 +40,13 @@ import com.intellectualsites.commands.CommandCaller; description = "Player music in a plot", usage = "/plot music", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class MusicSubcommand extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer player = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer player, final String[] args) { + final Location loc = player.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Purge.java b/src/main/java/com/intellectualcrafters/plot/commands/Purge.java index 736eda58f..68be7e377 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Purge.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Purge.java @@ -33,7 +33,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( @@ -41,7 +41,7 @@ import com.intellectualsites.commands.CommandCaller; permission = "plots.admin", description = "Purge all plots for a world", category = CommandCategory.ACTIONS, - requiredType = PS.class + requiredType = RequiredType.CONSOLE ) public class Purge extends SubCommand { @@ -55,45 +55,45 @@ public class Purge extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { + public boolean onCommand(final PlotPlayer plr, final String[] args) { if (args.length == 1) { final String arg = args[0].toLowerCase(); final PlotId id = getId(arg); if (id != null) { - caller.message("/plot purxe x;z &l"); + MainUtil.sendMessage(plr, "/plot purxe x;z &l"); return false; } final UUID uuid = UUIDHandler.getUUID(args[0], null); if (uuid != null) { - caller.message("/plot purge " + args[0] + " &l"); + MainUtil.sendMessage(plr, "/plot purge " + args[0] + " &l"); return false; } if (arg.equals("player")) { - caller.message("/plot purge &l "); + MainUtil.sendMessage(plr, "/plot purge &l "); return false; } if (arg.equals("unowned")) { - caller.message("/plot purge unowned &l"); + MainUtil.sendMessage(plr, "/plot purge unowned &l"); return false; } if (arg.equals("unknown")) { - caller.message("/plot purge unknown &l"); + MainUtil.sendMessage(plr, "/plot purge unknown &l"); return false; } if (arg.equals("all")) { - caller.message("/plot purge all &l"); + MainUtil.sendMessage(plr, "/plot purge all &l"); return false; } - caller.message(C.PURGE_SYNTAX); + MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } if (args.length != 2) { - caller.message(C.PURGE_SYNTAX); + MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } final String worldname = args[1]; if (!PS.get().getAllPlotsRaw().containsKey(worldname)) { - caller.message("INVALID WORLD"); + MainUtil.sendMessage(plr, "INVALID WORLD"); return false; } final String arg = args[0].toLowerCase(); @@ -160,7 +160,7 @@ public class Purge extends SubCommand { DBFunc.purge(worldname, ids); return finishPurge(length); } - caller.message(C.PURGE_SYNTAX); + MainUtil.sendMessage(plr, C.PURGE_SYNTAX); return false; } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index bb1629f00..a3bea463c 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -27,7 +27,7 @@ import java.util.Map.Entry; import java.util.UUID; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.mutable.MutableInt; import org.bukkit.Bukkit; @@ -53,14 +53,12 @@ import com.intellectualcrafters.plot.util.TaskManager; usage = "/plot rate [#|next]", aliases = {"rt"}, category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Rate extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer player = (PlotPlayer) caller.getSuperCaller(); - + public boolean onCommand(final PlotPlayer player, final String[] args) { if (args.length == 1) { if (args[0].equalsIgnoreCase("next")) { ArrayList plots = new ArrayList<>(PS.get().getPlots()); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java index e2ca3f312..9b7df48f7 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -30,16 +30,17 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "regenallroads", description = "Regenerate all roads in the map using the set road schematic", aliases = {"rgar"}, category = CommandCategory.DEBUG, - requiredType = PS.class, + requiredType = RequiredType.CONSOLE, permission = "plots.regenallroads" ) public class RegenAllRoads extends SubCommand { @@ -51,22 +52,22 @@ public class RegenAllRoads extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { + public boolean onCommand(final PlotPlayer plr, final String[] args) { int height = 0; if (args.length == 2) { try { height = Integer.parseInt(args[1]); } catch (NumberFormatException e) { - caller.message(C.NOT_VALID_NUMBER, "(0, 256)"); - caller.message(C.COMMAND_SYNTAX, "/plot regenallroads [height]"); + MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(0, 256)"); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot regenallroads [height]"); return false; } } final String name = args[0]; final PlotManager manager = PS.get().getPlotManager(name); if ((manager == null) || !(manager instanceof HybridPlotManager)) { - caller.message(C.NOT_VALID_PLOT_WORLD); + MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); return false; } final List chunks = ChunkManager.manager.getChunkChunks(name); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index c1105b0cd..59f34b3b9 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -23,9 +23,9 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; - import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; +import com.intellectualcrafters.plot.util.MainUtil; @CommandDeclaration( command = "reload", @@ -37,7 +37,7 @@ import com.intellectualsites.commands.CommandCaller; public class Reload extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { + public boolean onCommand(final PlotPlayer plr, final String[] args) { try { // The following won't affect world generation, as that has to be // loaded during startup unfortunately. @@ -48,9 +48,9 @@ public class Reload extends SubCommand { final PlotWorld plotworld = PS.get().getPlotWorld(pw); plotworld.loadDefaultConfiguration(PS.get().config.getConfigurationSection("worlds." + pw)); } - caller.message(C.RELOADED_CONFIGS); + MainUtil.sendMessage(plr, C.RELOADED_CONFIGS); } catch (final Exception e) { - caller.message(C.RELOAD_FAILED); + MainUtil.sendMessage(plr, C.RELOAD_FAILED); } return true; } diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Remove.java b/src/main/java/com/intellectualcrafters/plot/commands/Remove.java index e7b175381..0179e78f5 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Remove.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Remove.java @@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; @CommandDeclaration( @@ -42,7 +41,7 @@ import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; description = "Remove a player from a plot", usage = "/plot remove ", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, permission = "plots.remove" ) public class Remove extends SubCommand { @@ -54,8 +53,7 @@ public class Remove extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { if (args.length != 1) { MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot remove "); return true; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/RequiredType.java b/src/main/java/com/intellectualcrafters/plot/commands/RequiredType.java new file mode 100644 index 000000000..3a0987180 --- /dev/null +++ b/src/main/java/com/intellectualcrafters/plot/commands/RequiredType.java @@ -0,0 +1,23 @@ +package com.intellectualcrafters.plot.commands; + +import com.intellectualcrafters.plot.object.ConsolePlayer; +import com.intellectualcrafters.plot.object.PlotPlayer; + +public enum RequiredType { + CONSOLE, + PLAYER, + NONE; + + public boolean allows(PlotPlayer player) { + switch (this) { + case NONE: + return true; + case PLAYER: + return !ConsolePlayer.isConsole(player); + case CONSOLE: + return ConsolePlayer.isConsole(player); + default: + return false; + } + } +} diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Save.java b/src/main/java/com/intellectualcrafters/plot/commands/Save.java index d88a1b94d..dd1200b23 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Save.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Save.java @@ -17,21 +17,21 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "save", aliases = {"backup"}, description = "Save your plot", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, permission = "plots.save" ) public class Save extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + if (!Settings.METRICS) { MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service"); return false; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index 52eb89a9a..37ec55906 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -27,7 +27,7 @@ import java.util.HashMap; import java.util.UUID; import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; @@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler.Schematic; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; // TODO Add sub-subcommands @@ -61,8 +61,7 @@ public class SchematicCmd extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = caller instanceof PlotPlayerCaller ? (PlotPlayer) caller.getSuperCaller() : null; + public boolean onCommand(final PlotPlayer plr, final String ... args) { if (args.length < 1) { sendMessage(plr, C.SCHEMATIC_MISSING_ARG); return true; @@ -72,10 +71,6 @@ public class SchematicCmd extends SubCommand { final Schematic schematic; switch (arg) { case "paste": { - if (plr == null) { - PS.log(C.IS_CONSOLE.s()); - return false; - } if (!Permissions.hasPermission(plr, "plots.schematic.paste")) { MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.schematic.paste"); return false; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 055a4ce4b..c75589637 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -25,7 +25,7 @@ import java.util.Arrays; import java.util.List; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; @@ -61,15 +61,15 @@ import com.intellectualcrafters.plot.util.UUIDHandler; usage = "/plot set ", permission = "plots.set", category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Set extends SubCommand { public final static String[] values = new String[] { "biome", "alias", "home", "flag" }; public final static String[] aliases = new String[] { "b", "w", "wf", "f", "a", "h", "fl" }; @Override - public boolean onCommand(final CommandCaller caller, final String ... args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String ... args) { + final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if (plot == null) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java b/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java index 5d3959798..d428c5858 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/SetOwner.java @@ -36,7 +36,7 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "setowner", @@ -45,7 +45,7 @@ import com.intellectualsites.commands.CommandCaller; usage = "/plot setowner ", aliases = {"so"}, category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class SetOwner extends SubCommand { @@ -60,8 +60,7 @@ public class SetOwner extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller; + public boolean onCommand(final PlotPlayer plr, final String[] args) { final Location loc = plr.getLocation(); final Plot plot = MainUtil.getPlot(loc); if ((plot == null) || (plot.owner == null)) { diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index e6422bf76..f1618ed70 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -25,9 +25,9 @@ import java.util.Arrays; import java.util.List; import java.util.Map.Entry; -import com.intellectualcrafters.plot.commands.callers.PlotPlayerCaller; + import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; import org.bukkit.generator.ChunkGenerator; @@ -74,9 +74,7 @@ public class Setup extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - PlotPlayer plr = (caller instanceof PlotPlayerCaller) ? (PlotPlayer) caller.getSuperCaller() : null; - + public boolean onCommand(final PlotPlayer plr, final String[] args) { // going through setup String name; if (plr == null) { @@ -219,7 +217,7 @@ public class Setup extends SubCommand { step.setValue(args[0]); object.setup_index++; if (object.setup_index == object.step.length) { - onCommand(caller, args); + onCommand(plr, args); return false; } step = object.step[object.setup_index]; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index 608deb937..8e4a634ff 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -34,20 +34,20 @@ import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "swap", description = "Swap two plots", aliases = {"switch"}, category = CommandCategory.ACTIONS, - requiredType = PlotPlayer.class + requiredType = RequiredType.PLAYER ) public class Swap extends SubCommand { @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - final PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { + MainUtil.sendMessage(plr, "&cThis command has not been optimized for large selections yet. Please bug me if this becomes an issue."); if (args.length < 1) { MainUtil.sendMessage(plr, C.NEED_PLOT_ID); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/TP.java b/src/main/java/com/intellectualcrafters/plot/commands/TP.java index 33bd9fe5f..7a9434e06 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -22,7 +22,7 @@ package com.intellectualcrafters.plot.commands; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import org.apache.commons.lang.StringUtils; @@ -41,7 +41,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; description = "Teleport to a plot", permission = "plots.tp", usage = "/plot tp ", - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, category = CommandCategory.TELEPORT ) public class TP extends SubCommand { @@ -53,8 +53,7 @@ public class TP extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { final String id = args[0]; PlotId plotid; final Location loc = plr.getLocation(); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/src/main/java/com/intellectualcrafters/plot/commands/Target.java index 9cd641382..0b7a8b7ca 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -28,14 +28,14 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.Argument; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; @CommandDeclaration( command = "target", usage = "/plot target ", description = "Target a plot with your compass", permission = "plots.target", - requiredType = PlotPlayer.class, + requiredType = RequiredType.PLAYER, category = CommandCategory.ACTIONS ) public class Target extends SubCommand { @@ -47,8 +47,7 @@ public class Target extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { - PlotPlayer plr = (PlotPlayer) caller.getSuperCaller(); + public boolean onCommand(final PlotPlayer plr, final String[] args) { final Location ploc = plr.getLocation(); if (!PS.get().isPlotWorld(ploc.getWorld())) { MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Template.java b/src/main/java/com/intellectualcrafters/plot/commands/Template.java index 93682bc3b..8840c909b 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Template.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Template.java @@ -42,7 +42,7 @@ import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualsites.commands.CommandDeclaration; -import com.intellectualsites.commands.CommandCaller; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.bukkit.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; @@ -119,25 +119,21 @@ public class Template extends SubCommand { } @Override - public boolean onCommand(final CommandCaller caller, final String[] args) { + public boolean onCommand(final PlotPlayer plr, final String[] args) { if (args.length != 2 && args.length != 3) { if (args.length == 1) { if (args[0].equalsIgnoreCase("export")) { - caller.message(C.COMMAND_SYNTAX, "/plot template export "); + MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot template export "); return true; } else if (args[0].equalsIgnoreCase("import")) { - caller.message(C.COMMAND_SYNTAX, "/plot template import