From 6c2bce824c7a481c85c388070ea2b96c392917eb Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 15:32:01 +1100 Subject: [PATCH] messages --- .../plot/commands/Claim.java | 2 +- .../plot/commands/Cluster.java | 4 +- .../plot/commands/CreateRoadSchematic.java | 4 +- .../plot/commands/Database.java | 2 +- .../plot/commands/DebugClaimTest.java | 2 +- .../plot/commands/DebugExec.java | 2 +- .../plot/commands/DebugRoadRegen.java | 2 +- .../plot/commands/Denied.java | 2 +- .../plot/commands/FlagCmd.java | 72 +++++++++---------- .../plot/commands/Info.java | 18 ++--- .../plot/commands/MainCommand.java | 10 +-- .../plot/listeners/PlayerEvents.java | 23 +++--- .../plot/listeners/PlotPlusListener.java | 8 +-- .../plot/util/bukkit/BukkitUtil.java | 8 +++ 14 files changed, 84 insertions(+), 75 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index 32a7f2435..1e2604998 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -57,7 +57,7 @@ public class Claim extends SubCommand { if (!event.isCancelled()) { MainUtil.createPlot(player, plot); MainUtil.setSign(player, plot); - BukkitPlayerFunctions.sendMessage(player, C.CLAIMED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED); if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 4fbedab0c..e2377d85a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -320,7 +320,7 @@ public class Cluster extends SubCommand { DBFunc.setInvited(world, cluster, uuid); final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { - BukkitPlayerFunctions.sendMessage(player, C.CLUSTER_INVITED, cluster.getName()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLUSTER_INVITED, cluster.getName()); } } BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_USER); @@ -367,7 +367,7 @@ public class Cluster extends SubCommand { DBFunc.removeInvited(cluster, uuid); final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); if (player != null) { - BukkitPlayerFunctions.sendMessage(player, C.CLUSTER_REMOVED, cluster.getName()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLUSTER_REMOVED, cluster.getName()); } for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) { final PlotCluster current = ClusterManager.getCluster(plot); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java index 7542b0f11..8c30f8dfc 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/CreateRoadSchematic.java @@ -38,7 +38,7 @@ public class CreateRoadSchematic extends SubCommand { @Override public boolean execute(final Player player, final String... args) { if (!BukkitPlayerFunctions.isInPlot(player)) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return false; } if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { @@ -48,7 +48,7 @@ public class CreateRoadSchematic extends SubCommand { final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); manager.setupRoadSchematic(plot); MainUtil.update(BukkitUtil.getLocation(entity)); - BukkitPlayerFunctions.sendMessage(player, "&6Saved new road schematic"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Saved new road schematic"); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java index b29d9e030..b57efa460 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -141,7 +141,7 @@ public class Database extends SubCommand { if (player == null) { PlotSquared.log(msg); } else { - BukkitPlayerFunctions.sendMessage(player, msg); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), msg); } return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java index 92d8db244..b8552ff9d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClaimTest.java @@ -64,7 +64,7 @@ public class DebugClaimTest extends SubCommand { if (!event.isCancelled()) { MainUtil.createPlot(player, plot); MainUtil.setSign(player, plot); - BukkitPlayerFunctions.sendMessage(player, C.CLAIMED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED); if (teleport) { PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 0b2d77319..3dc5767e7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -166,7 +166,7 @@ public class DebugExec extends SubCommand { } } } - BukkitPlayerFunctions.sendMessage(player, "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "Possible sub commands: /plot debugexec <" + StringUtils.join(allowed_params, "|") + ">"); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java index 8561f4610..f5f47d33a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugRoadRegen.java @@ -48,7 +48,7 @@ public class DebugRoadRegen extends SubCommand { if (result) { SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); } - BukkitPlayerFunctions.sendMessage(player, "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Regenerating chunk: " + chunk.getX() + "," + chunk.getZ() + "\n&6 - Result: " + (result == true ? "&aSuccess" : "&cFailed")); return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index 397ffecb7..12c2730a5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -94,7 +94,7 @@ public class Denied extends SubCommand { if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) { final Plot pl = BukkitPlayerFunctions.getCurrentPlot(player); if ((pl != null) && pl.id.equals(plot.id)) { - BukkitPlayerFunctions.sendMessage(player, C.YOU_BE_DENIED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.YOU_BE_DENIED); player.teleport(player.getWorld().getSpawnLocation()); } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 7baf99bdb..6c7ccc50c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -53,12 +53,12 @@ public class FlagCmd extends SubCommand { * plot flag list */ if (args.length == 0) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag "); return false; } final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); if (plot == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return false; } if (!plot.hasOwner()) { @@ -66,88 +66,88 @@ public class FlagCmd extends SubCommand { return false; } if (!plot.hasRights(player) && !BukkitMain.hasPermission(player, "plots.set.flag.other")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag.other"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag.other"); return false; } switch (args[0].toLowerCase()) { case "info": { if (!BukkitMain.hasPermission(player, "plots.set.flag")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.info"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.info"); return false; } if (args.length != 2) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag info "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1]); if (af == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag info "); return false; } // flag key - BukkitPlayerFunctions.sendMessage(player, C.FLAG_KEY, af.getKey()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_KEY, af.getKey()); // flag type - BukkitPlayerFunctions.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_TYPE, af.value.getClass().getSimpleName()); // Flag type description - BukkitPlayerFunctions.sendMessage(player, C.FLAG_DESC, af.getValueDesc()); - BukkitPlayerFunctions.sendMessage(player, "&cNot implemented."); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_DESC, af.getValueDesc()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&cNot implemented."); } case "set": { if (!BukkitMain.hasPermission(player, "plots.set.flag")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag"); return false; } if (args.length < 3) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag set "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed = af.parseValueRaw(value); if (parsed == null) { - BukkitPlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&c" + af.getValueDesc()); return false; } final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed); final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_ADDED); return false; } - BukkitPlayerFunctions.sendMessage(player, C.FLAG_ADDED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_ADDED); PlotListener.plotEntry(player, plot); return true; } case "remove": { if (!BukkitMain.hasPermission(player, "plots.flag.remove")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.remove"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.remove"); return false; } if ((args.length != 2) && (args.length != 3)) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove [values]"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag remove [values]"); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()); if (flag == null) { - BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_IN_PLOT); return false; } if ((args.length == 3) && flag.getAbstractFlag().isList()) { @@ -157,36 +157,36 @@ public class FlagCmd extends SubCommand { } else { final boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); if (!result) { - BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_REMOVED); return false; } } - BukkitPlayerFunctions.sendMessage(player, C.FLAG_REMOVED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_REMOVED); PlotListener.plotEntry(player, plot); return true; } case "add": { if (!BukkitMain.hasPermission(player, "plots.flag.add")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.add"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.add"); return false; } if (args.length < 3) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag add "); return false; } final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); if (af == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG); return false; } if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.set.flag." + args[1].toLowerCase()); return false; } final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final Object parsed = af.parseValueRaw(value); if (parsed == null) { - BukkitPlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&c" + af.getValueDesc()); return false; } Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase()); @@ -197,21 +197,21 @@ public class FlagCmd extends SubCommand { } final boolean result = FlagManager.addPlotFlag(plot, flag); if (!result) { - BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_ADDED); return false; } DBFunc.setFlags(plot.world, plot, plot.settings.flags); - BukkitPlayerFunctions.sendMessage(player, C.FLAG_ADDED); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_ADDED); PlotListener.plotEntry(player, plot); return true; } case "list": { if (!BukkitMain.hasPermission(player, "plots.flag.list")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.flag.list"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.flag.list"); return false; } if (args.length != 1) { - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag list"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag list"); return false; } final HashMap> flags = new HashMap<>(); @@ -228,11 +228,11 @@ public class FlagCmd extends SubCommand { message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", "); prefix = "\n"; } - BukkitPlayerFunctions.sendMessage(player, message); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), message); return true; } } - BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag "); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag "); return false; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 15078754a..459e70ea2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -58,11 +58,11 @@ public class Info extends SubCommand { if (player != null) { world = player.getWorld(); if (!PlotSquared.isPlotWorld(world)) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT_WORLD); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT_WORLD); return false; } if (!BukkitPlayerFunctions.isInPlot(player)) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return false; } plot = BukkitPlayerFunctions.getCurrentPlot(player); @@ -73,7 +73,7 @@ public class Info extends SubCommand { } final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]); if (plotworld == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_WORLD); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_WORLD); return false; } try { @@ -81,7 +81,7 @@ public class Info extends SubCommand { final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id); if (plot == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_PLOT_ID); return false; } world = Bukkit.getWorld(args[0]); @@ -91,7 +91,7 @@ public class Info extends SubCommand { args = new String[0]; } } catch (final Exception e) { - BukkitPlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.INFO_SYNTAX_CONSOLE); return false; } } @@ -109,7 +109,7 @@ public class Info extends SubCommand { } // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { - BukkitPlayerFunctions.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); return true; } String owner = "none"; @@ -123,13 +123,13 @@ public class Info extends SubCommand { if (args.length == 1) { info = getCaption(args[0].toLowerCase()); if (info == null) { - BukkitPlayerFunctions.sendMessage(player, "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); return false; } } info = format(info, world, plot, player); - BukkitPlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER); - BukkitPlayerFunctions.sendMessage(player, info, false); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_HEADER); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), info, false); return true; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 0d72e1e8d..947a8fbd8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -53,7 +53,7 @@ public class MainCommand { }; public static boolean no_permission(final PlotPlayer player, final String permission) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, permission); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, permission); return false; } @@ -121,7 +121,7 @@ public class MainCommand { 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 BukkitPlayerFunctions.sendMessage(player, builder.toString()); + return MainUtil.sendMessage(BukkitUtil.getPlayer(player), builder.toString()); } final String cat = args[1]; SubCommand.CommandCategory cato = null; @@ -137,7 +137,7 @@ public class MainCommand { for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { builder.append("\n").append(C.HELP_INFO_ITEM.s().replaceAll("%category%", category.toString().toLowerCase()).replaceAll("%category_desc%", category.toString())); } - return BukkitPlayerFunctions.sendMessage(player, builder.toString(), false); + return MainUtil.sendMessage(BukkitUtil.getPlayer(player), builder.toString(), false); } final StringBuilder help = new StringBuilder(); int page = 0; @@ -181,14 +181,14 @@ public class MainCommand { } } } - BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_SUBCOMMAND); + MainUtil.sendMessage(BukkitUtil.getPlayer(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 BukkitPlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, "/plot " + command); + return MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.DID_YOU_MEAN, "/plot " + command); // PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new // StringComparsion(args[0], commands).getBestMatch()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 0d4d50273..1cb3e9cf2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -189,7 +189,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi passed = false; } if (passed) { - BukkitPlayerFunctions.sendMessage(player, C.BORDER); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.BORDER); return; } } @@ -199,7 +199,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi final UUID uuid = UUIDHandler.getUUID(player); if (plot.isDenied(uuid)) { if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.entry.denied"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.entry.denied"); event.setCancelled(true); return; } @@ -265,7 +265,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.destroy.unowned")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.unowned"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.unowned"); event.setCancelled(true); return; } @@ -279,7 +279,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.other"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.other"); event.setCancelled(true); return; } @@ -289,7 +289,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.destroy.road"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.destroy.road"); event.setCancelled(true); return; } @@ -529,7 +529,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.interact.unowned")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.unowned"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.unowned"); event.setCancelled(true); return; } @@ -542,7 +542,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.other"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.other"); event.setCancelled(true); return; } @@ -552,7 +552,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.interact.road"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.interact.road"); event.setCancelled(true); return; } @@ -746,6 +746,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (Setup.setupMap.containsKey(event.getPlayer().getName())) { Setup.setupMap.remove(event.getPlayer().getName()); } + BukkitUtil.removePlayer(event.getPlayer().getName()); if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { final Collection plots = PlotSquared.getPlots(event.getPlayer().getName()).values(); for (final Plot plot : plots) { @@ -1079,7 +1080,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (BukkitMain.hasPermission(player, "plots.admin.build.unowned")) { return; } - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.unowned"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.unowned"); event.setCancelled(true); return; } @@ -1090,7 +1091,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi return; } if (!BukkitMain.hasPermission(player, "plots.admin.build.other")) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.other"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.other"); event.setCancelled(true); return; } @@ -1099,7 +1100,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (!BukkitMain.hasPermission(player, "plots.admin.build.road")) { if (isPlotArea(loc)) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PERMISSION, "plots.admin.build.road"); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PERMISSION, "plots.admin.build.road"); event.setCancelled(true); return; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index b695bf5dd..d91fe2134 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -108,12 +108,12 @@ public class PlotPlusListener extends PlotListener implements Listener { event.setCancelled(true); final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); if (plot == null) { - BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT); return; } UUID uuid = UUIDHandler.getUUID(player); if (!plot.isAdded(uuid)) { - BukkitPlayerFunctions.sendMessage(player, C.NO_PLOT_PERMS); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PLOT_PERMS); return; } final Set plotPlayers = new HashSet<>(); @@ -215,7 +215,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } if (player.isOnline()) { - BukkitPlayerFunctions.sendMessage(player, C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOTIFY_ENTER.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); } } } @@ -258,7 +258,7 @@ public class PlotPlusListener extends PlotListener implements Listener { return; } if (player.isOnline()) { - BukkitPlayerFunctions.sendMessage(player, C.NOTIFY_LEAVE.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOTIFY_LEAVE.s().replace("%player", trespasser.getName()).replace("%plot", plot.getId().toString())); } } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index ce762e986..b8d708fb7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -31,6 +31,14 @@ public class BukkitUtil extends BlockManager { private static Player lastPlayer = null; private static PlotPlayer lastPlotPlayer = null; + public static void removePlayer(String plr) { + if (lastPlayer != null && lastPlayer.getName().equals(plr)) { + lastPlayer = null; + lastPlotPlayer = null; + } + players.remove(plr); + } + public static PlotPlayer getPlayer(Player player) { if (player == lastPlayer) { return lastPlotPlayer;