This commit is contained in:
boy0001 2015-02-21 15:32:01 +11:00
parent 4cf92c4a0a
commit 6c2bce824c
14 changed files with 84 additions and 75 deletions

View File

@ -57,7 +57,7 @@ public class Claim extends SubCommand {
if (!event.isCancelled()) { if (!event.isCancelled()) {
MainUtil.createPlot(player, plot); MainUtil.createPlot(player, plot);
MainUtil.setSign(player, plot); MainUtil.setSign(player, plot);
BukkitPlayerFunctions.sendMessage(player, C.CLAIMED); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED);
if (teleport) { if (teleport) {
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
} }

View File

@ -320,7 +320,7 @@ public class Cluster extends SubCommand {
DBFunc.setInvited(world, cluster, uuid); DBFunc.setInvited(world, cluster, uuid);
final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
if (player != null) { 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); BukkitPlayerFunctions.sendMessage(plr, C.CLUSTER_ADDED_USER);
@ -367,7 +367,7 @@ public class Cluster extends SubCommand {
DBFunc.removeInvited(cluster, uuid); DBFunc.removeInvited(cluster, uuid);
final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid); final Player player = UUIDHandler.uuidWrapper.getPlayer(uuid);
if (player != null) { 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)) { for (final Plot plot : PlotSquared.getPlots(plr.getWorld(), uuid)) {
final PlotCluster current = ClusterManager.getCluster(plot); final PlotCluster current = ClusterManager.getCluster(plot);

View File

@ -38,7 +38,7 @@ public class CreateRoadSchematic extends SubCommand {
@Override @Override
public boolean execute(final Player player, final String... args) { public boolean execute(final Player player, final String... args) {
if (!BukkitPlayerFunctions.isInPlot(player)) { if (!BukkitPlayerFunctions.isInPlot(player)) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT);
return false; return false;
} }
if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) { if (!(PlotSquared.getPlotWorld(player.getWorld()) instanceof HybridPlotWorld)) {
@ -48,7 +48,7 @@ public class CreateRoadSchematic extends SubCommand {
final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld()); final HybridPlotManager manager = (HybridPlotManager) PlotSquared.getPlotManager(player.getWorld());
manager.setupRoadSchematic(plot); manager.setupRoadSchematic(plot);
MainUtil.update(BukkitUtil.getLocation(entity)); MainUtil.update(BukkitUtil.getLocation(entity));
BukkitPlayerFunctions.sendMessage(player, "&6Saved new road schematic"); MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Saved new road schematic");
return true; return true;
} }
} }

View File

@ -141,7 +141,7 @@ public class Database extends SubCommand {
if (player == null) { if (player == null) {
PlotSquared.log(msg); PlotSquared.log(msg);
} else { } else {
BukkitPlayerFunctions.sendMessage(player, msg); MainUtil.sendMessage(BukkitUtil.getPlayer(player), msg);
} }
return true; return true;
} }

View File

@ -64,7 +64,7 @@ public class DebugClaimTest extends SubCommand {
if (!event.isCancelled()) { if (!event.isCancelled()) {
MainUtil.createPlot(player, plot); MainUtil.createPlot(player, plot);
MainUtil.setSign(player, plot); MainUtil.setSign(player, plot);
BukkitPlayerFunctions.sendMessage(player, C.CLAIMED); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLAIMED);
if (teleport) { if (teleport) {
PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot); PlotSquared.teleportPlayer(player, BukkitUtil.getLocation(entity), plot);
} }

View File

@ -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; return true;
} }
} }

View File

@ -48,7 +48,7 @@ public class DebugRoadRegen extends SubCommand {
if (result) { if (result) {
SetBlockManager.setBlockManager.update(Arrays.asList(new Chunk[] { chunk })); 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; return true;
} }
} }

View File

@ -94,7 +94,7 @@ public class Denied extends SubCommand {
if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) { if (!uuid.equals(DBFunc.everyone) && (player != null) && player.isOnline()) {
final Plot pl = BukkitPlayerFunctions.getCurrentPlot(player); final Plot pl = BukkitPlayerFunctions.getCurrentPlot(player);
if ((pl != null) && pl.id.equals(plot.id)) { 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()); player.teleport(player.getWorld().getSpawnLocation());
} }
} }

View File

@ -53,12 +53,12 @@ public class FlagCmd extends SubCommand {
* plot flag list * plot flag list
*/ */
if (args.length == 0) { if (args.length == 0) {
BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>"); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
return false; return false;
} }
final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player); final Plot plot = BukkitPlayerFunctions.getCurrentPlot(player);
if (plot == null) { if (plot == null) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT);
return false; return false;
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
@ -66,88 +66,88 @@ public class FlagCmd extends SubCommand {
return false; return false;
} }
if (!plot.hasRights(player) && !BukkitMain.hasPermission(player, "plots.set.flag.other")) { 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; return false;
} }
switch (args[0].toLowerCase()) { switch (args[0].toLowerCase()) {
case "info": { case "info": {
if (!BukkitMain.hasPermission(player, "plots.set.flag")) { 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; return false;
} }
if (args.length != 2) { if (args.length != 2) {
BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>"); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag info <flag>");
return false; return false;
} }
final AbstractFlag af = FlagManager.getFlag(args[1]); final AbstractFlag af = FlagManager.getFlag(args[1]);
if (af == null) { if (af == null) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG);
BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info <flag>"); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag info <flag>");
return false; return false;
} }
// flag key // flag key
BukkitPlayerFunctions.sendMessage(player, C.FLAG_KEY, af.getKey()); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_KEY, af.getKey());
// flag type // 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 // Flag type description
BukkitPlayerFunctions.sendMessage(player, C.FLAG_DESC, af.getValueDesc()); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_DESC, af.getValueDesc());
BukkitPlayerFunctions.sendMessage(player, "&cNot implemented."); MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&cNot implemented.");
} }
case "set": { case "set": {
if (!BukkitMain.hasPermission(player, "plots.set.flag")) { 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; return false;
} }
if (args.length < 3) { if (args.length < 3) {
BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag set <flag> <value>"); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag set <flag> <value>");
return false; return false;
} }
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
if (af == null) { if (af == null) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG);
return false; return false;
} }
if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { 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; return false;
} }
final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
final Object parsed = af.parseValueRaw(value); final Object parsed = af.parseValueRaw(value);
if (parsed == null) { if (parsed == null) {
BukkitPlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&c" + af.getValueDesc());
return false; return false;
} }
final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed); final Flag flag = new Flag(FlagManager.getFlag(args[1].toLowerCase(), true), parsed);
final boolean result = FlagManager.addPlotFlag(plot, flag); final boolean result = FlagManager.addPlotFlag(plot, flag);
if (!result) { if (!result) {
BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_ADDED);
return false; return false;
} }
BukkitPlayerFunctions.sendMessage(player, C.FLAG_ADDED); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_ADDED);
PlotListener.plotEntry(player, plot); PlotListener.plotEntry(player, plot);
return true; return true;
} }
case "remove": { case "remove": {
if (!BukkitMain.hasPermission(player, "plots.flag.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; return false;
} }
if ((args.length != 2) && (args.length != 3)) { if ((args.length != 2) && (args.length != 3)) {
BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]"); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
return false; return false;
} }
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
if (af == null) { if (af == null) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG);
return false; return false;
} }
if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { 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; return false;
} }
final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase()); final Flag flag = FlagManager.getPlotFlagAbs(plot, args[1].toLowerCase());
if (flag == null) { if (flag == null) {
BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_IN_PLOT); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_IN_PLOT);
return false; return false;
} }
if ((args.length == 3) && flag.getAbstractFlag().isList()) { if ((args.length == 3) && flag.getAbstractFlag().isList()) {
@ -157,36 +157,36 @@ public class FlagCmd extends SubCommand {
} else { } else {
final boolean result = FlagManager.removePlotFlag(plot, flag.getKey()); final boolean result = FlagManager.removePlotFlag(plot, flag.getKey());
if (!result) { if (!result) {
BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_REMOVED); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_REMOVED);
return false; return false;
} }
} }
BukkitPlayerFunctions.sendMessage(player, C.FLAG_REMOVED); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_REMOVED);
PlotListener.plotEntry(player, plot); PlotListener.plotEntry(player, plot);
return true; return true;
} }
case "add": { case "add": {
if (!BukkitMain.hasPermission(player, "plots.flag.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; return false;
} }
if (args.length < 3) { if (args.length < 3) {
BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag add <flag> <values>"); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag add <flag> <values>");
return false; return false;
} }
final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase()); final AbstractFlag af = FlagManager.getFlag(args[1].toLowerCase());
if (af == null) { if (af == null) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_FLAG); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_FLAG);
return false; return false;
} }
if (!BukkitMain.hasPermission(player, "plots.set.flag." + args[1].toLowerCase())) { 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; return false;
} }
final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " "); final String value = StringUtils.join(Arrays.copyOfRange(args, 2, args.length), " ");
final Object parsed = af.parseValueRaw(value); final Object parsed = af.parseValueRaw(value);
if (parsed == null) { if (parsed == null) {
BukkitPlayerFunctions.sendMessage(player, "&c" + af.getValueDesc()); MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&c" + af.getValueDesc());
return false; return false;
} }
Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase()); Flag flag = FlagManager.getPlotFlag(plot, args[1].toLowerCase());
@ -197,21 +197,21 @@ public class FlagCmd extends SubCommand {
} }
final boolean result = FlagManager.addPlotFlag(plot, flag); final boolean result = FlagManager.addPlotFlag(plot, flag);
if (!result) { if (!result) {
BukkitPlayerFunctions.sendMessage(player, C.FLAG_NOT_ADDED); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.FLAG_NOT_ADDED);
return false; return false;
} }
DBFunc.setFlags(plot.world, plot, plot.settings.flags); 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); PlotListener.plotEntry(player, plot);
return true; return true;
} }
case "list": { case "list": {
if (!BukkitMain.hasPermission(player, "plots.flag.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; return false;
} }
if (args.length != 1) { 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; return false;
} }
final HashMap<String, ArrayList<String>> flags = new HashMap<>(); final HashMap<String, ArrayList<String>> flags = new HashMap<>();
@ -228,11 +228,11 @@ public class FlagCmd extends SubCommand {
message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", "); message += prefix + "&6" + flag + ": &7" + StringUtils.join(flags.get(flag), ", ");
prefix = "\n"; prefix = "\n";
} }
BukkitPlayerFunctions.sendMessage(player, message); MainUtil.sendMessage(BukkitUtil.getPlayer(player), message);
return true; return true;
} }
} }
BukkitPlayerFunctions.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>"); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.COMMAND_SYNTAX, "/plot flag <set|remove|add|list|info>");
return false; return false;
} }
} }

View File

@ -58,11 +58,11 @@ public class Info extends SubCommand {
if (player != null) { if (player != null) {
world = player.getWorld(); world = player.getWorld();
if (!PlotSquared.isPlotWorld(world)) { if (!PlotSquared.isPlotWorld(world)) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT_WORLD); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT_WORLD);
return false; return false;
} }
if (!BukkitPlayerFunctions.isInPlot(player)) { if (!BukkitPlayerFunctions.isInPlot(player)) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT);
return false; return false;
} }
plot = BukkitPlayerFunctions.getCurrentPlot(player); plot = BukkitPlayerFunctions.getCurrentPlot(player);
@ -73,7 +73,7 @@ public class Info extends SubCommand {
} }
final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]); final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]);
if (plotworld == null) { if (plotworld == null) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_WORLD); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_WORLD);
return false; return false;
} }
try { try {
@ -81,7 +81,7 @@ public class Info extends SubCommand {
final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id); plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id);
if (plot == null) { if (plot == null) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_VALID_PLOT_ID); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_PLOT_ID);
return false; return false;
} }
world = Bukkit.getWorld(args[0]); world = Bukkit.getWorld(args[0]);
@ -91,7 +91,7 @@ public class Info extends SubCommand {
args = new String[0]; args = new String[0];
} }
} catch (final Exception e) { } catch (final Exception e) {
BukkitPlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.INFO_SYNTAX_CONSOLE);
return false; return false;
} }
} }
@ -109,7 +109,7 @@ public class Info extends SubCommand {
} }
// Unclaimed? // Unclaimed?
if (!hasOwner && !containsEveryone && !trustedEveryone) { 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; return true;
} }
String owner = "none"; String owner = "none";
@ -123,13 +123,13 @@ public class Info extends SubCommand {
if (args.length == 1) { if (args.length == 1) {
info = getCaption(args[0].toLowerCase()); info = getCaption(args[0].toLowerCase());
if (info == null) { 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; return false;
} }
} }
info = format(info, world, plot, player); info = format(info, world, plot, player);
BukkitPlayerFunctions.sendMessage(player, C.PLOT_INFO_HEADER); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_HEADER);
BukkitPlayerFunctions.sendMessage(player, info, false); MainUtil.sendMessage(BukkitUtil.getPlayer(player), info, false);
return true; return true;
} }

View File

@ -53,7 +53,7 @@ public class MainCommand {
}; };
public static boolean no_permission(final PlotPlayer player, final String permission) { 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; 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%", 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")); 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]; final String cat = args[1];
SubCommand.CommandCategory cato = null; SubCommand.CommandCategory cato = null;
@ -137,7 +137,7 @@ public class MainCommand {
for (final SubCommand.CommandCategory category : SubCommand.CommandCategory.values()) { 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())); 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(); final StringBuilder help = new StringBuilder();
int page = 0; 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()]; final String[] commands = new String[subCommands.size()];
for (int x = 0; x < subCommands.size(); x++) { for (int x = 0; x < subCommands.size(); x++) {
commands[x] = subCommands.get(x).cmd; commands[x] = subCommands.get(x).cmd;
} }
/* Let's try to get a proper usage string */ /* Let's try to get a proper usage string */
final String command = new StringComparison(args[0], commands).getBestMatch(); 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 // PlayerFunctions.sendMessage(player, C.DID_YOU_MEAN, new
// StringComparsion(args[0], commands).getBestMatch()); // StringComparsion(args[0], commands).getBestMatch());
} }

View File

@ -189,7 +189,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
passed = false; passed = false;
} }
if (passed) { if (passed) {
BukkitPlayerFunctions.sendMessage(player, C.BORDER); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.BORDER);
return; return;
} }
} }
@ -199,7 +199,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
final UUID uuid = UUIDHandler.getUUID(player); final UUID uuid = UUIDHandler.getUUID(player);
if (plot.isDenied(uuid)) { if (plot.isDenied(uuid)) {
if (!BukkitMain.hasPermission(player, "plots.admin.entry.denied")) { 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); event.setCancelled(true);
return; return;
} }
@ -265,7 +265,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (BukkitMain.hasPermission(player, "plots.admin.destroy.unowned")) { if (BukkitMain.hasPermission(player, "plots.admin.destroy.unowned")) {
return; 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); event.setCancelled(true);
return; return;
} }
@ -279,7 +279,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) { if (BukkitMain.hasPermission(event.getPlayer(), "plots.admin.destroy.other")) {
return; 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); event.setCancelled(true);
return; return;
} }
@ -289,7 +289,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
if (isPlotArea(loc)) { 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); event.setCancelled(true);
return; return;
} }
@ -529,7 +529,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (BukkitMain.hasPermission(player, "plots.admin.interact.unowned")) { if (BukkitMain.hasPermission(player, "plots.admin.interact.unowned")) {
return; 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); event.setCancelled(true);
return; return;
} }
@ -542,7 +542,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) { if (BukkitMain.hasPermission(player, "plots.admin.interact.other")) {
return; 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); event.setCancelled(true);
return; return;
} }
@ -552,7 +552,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
if (isPlotArea(loc)) { 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); event.setCancelled(true);
return; return;
} }
@ -746,6 +746,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
if (Setup.setupMap.containsKey(event.getPlayer().getName())) { if (Setup.setupMap.containsKey(event.getPlayer().getName())) {
Setup.setupMap.remove(event.getPlayer().getName()); Setup.setupMap.remove(event.getPlayer().getName());
} }
BukkitUtil.removePlayer(event.getPlayer().getName());
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) { if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
final Collection<Plot> plots = PlotSquared.getPlots(event.getPlayer().getName()).values(); final Collection<Plot> plots = PlotSquared.getPlots(event.getPlayer().getName()).values();
for (final Plot plot : plots) { 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")) { if (BukkitMain.hasPermission(player, "plots.admin.build.unowned")) {
return; 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); event.setCancelled(true);
return; return;
} }
@ -1090,7 +1091,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
return; return;
} }
if (!BukkitMain.hasPermission(player, "plots.admin.build.other")) { 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); event.setCancelled(true);
return; return;
} }
@ -1099,7 +1100,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
if (!BukkitMain.hasPermission(player, "plots.admin.build.road")) { if (!BukkitMain.hasPermission(player, "plots.admin.build.road")) {
if (isPlotArea(loc)) { 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); event.setCancelled(true);
return; return;
} }

View File

@ -108,12 +108,12 @@ public class PlotPlusListener extends PlotListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player)); final Plot plot = MainUtil.getPlot(BukkitUtil.getLocation(player));
if (plot == null) { if (plot == null) {
BukkitPlayerFunctions.sendMessage(player, C.NOT_IN_PLOT); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT);
return; return;
} }
UUID uuid = UUIDHandler.getUUID(player); UUID uuid = UUIDHandler.getUUID(player);
if (!plot.isAdded(uuid)) { if (!plot.isAdded(uuid)) {
BukkitPlayerFunctions.sendMessage(player, C.NO_PLOT_PERMS); MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NO_PLOT_PERMS);
return; return;
} }
final Set<Player> plotPlayers = new HashSet<>(); final Set<Player> plotPlayers = new HashSet<>();
@ -215,7 +215,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
return; return;
} }
if (player.isOnline()) { 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; return;
} }
if (player.isOnline()) { 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()));
} }
} }
} }

View File

@ -31,6 +31,14 @@ public class BukkitUtil extends BlockManager {
private static Player lastPlayer = null; private static Player lastPlayer = null;
private static PlotPlayer lastPlotPlayer = 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) { public static PlotPlayer getPlayer(Player player) {
if (player == lastPlayer) { if (player == lastPlayer) {
return lastPlotPlayer; return lastPlotPlayer;