From 699906476cb523ef9064561a5287782917f2ba85 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Wed, 24 Jun 2015 13:31:13 +1000 Subject: [PATCH] Added nicer plot listing, info and visit --- .../intellectualcrafters/plot/BukkitMain.java | 29 +-- .../intellectualcrafters/plot/IPlotMain.java | 2 + .../plot/PlotSquared.java | 9 + .../plot/commands/Home.java | 4 +- .../plot/commands/Info.java | 72 +++---- .../plot/commands/RegenAllRoads.java | 2 +- .../plot/commands/Visit.java | 114 +++++++++-- .../plot/commands/list.java | 193 ++++++++++++++++-- .../intellectualcrafters/plot/config/C.java | 7 +- .../plot/config/Settings.java | 4 + .../plot/object/Plot.java | 2 +- .../plot/util/ExpireManager.java | 2 +- .../plot/util/MainUtil.java | 57 ++++++ .../plot/util/bukkit/UUIDHandler.java | 5 + 14 files changed, 407 insertions(+), 95 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index bfb93649f..14db2da11 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -142,22 +142,25 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static BukkitMain THIS = null; public static PlotSquared MAIN = null; - public static boolean checkVersion(final int major, final int minor, final int minor2) { - try { - final String[] version = Bukkit.getBukkitVersion().split("-")[0].split("\\."); - final int a = Integer.parseInt(version[0]); - final int b = Integer.parseInt(version[1]); - int c = 0; - if (version.length == 3) { - c = Integer.parseInt(version[2]); + private int[] version; + + @Override + public boolean checkVersion(final int major, final int minor, final int minor2) { + if (version == null) { + try { + version = new int[3]; + final String[] split = Bukkit.getBukkitVersion().split("-")[0].split("\\."); + version[0] = Integer.parseInt(split[0]); + version[1] = Integer.parseInt(split[1]); + if (version.length == 3) { + version[2] = Integer.parseInt(split[2]); + } } - if ((a > major) || ((a == major) && (b > minor)) || ((a == major) && (b == minor) && (c >= minor2))) { - return true; + catch (Exception e) { + return false; } - return false; - } catch (final Exception e) { - return false; } + return (version[0] > major) || ((version[0] == major) && (version[1] > minor)) || ((version[0] == major) && (version[1] == minor) && (version[2] >= minor2)); } @Override diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index b6b828197..5938f0041 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -74,4 +74,6 @@ public interface IPlotMain { public void registerWorldEvents(); public PlayerManager initPlayerManager(); + + public boolean checkVersion(int major, int minor, int minor2); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index a97d92ea0..f72ccacb1 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -870,6 +870,7 @@ public class PlotSquared { // Misc options.put("console.color", Settings.CONSOLE_COLOR); + options.put("chat.fancy", Settings.FANCY_CHAT); options.put("metrics", true); options.put("debug", true); options.put("auto_update", false); @@ -961,6 +962,14 @@ public class PlotSquared { log(C.PREFIX.s() + "&6Debug Mode Enabled (Default). Edit the config to turn this off."); } Settings.CONSOLE_COLOR = config.getBoolean("console.color"); + if (!config.getBoolean("chat.fancy") || !IMP.checkVersion(1, 7, 0)) { + System.out.print("FANCY CHAT ======================================="); + System.out.print("FANCY CHAT ======================================="); + System.out.print("FANCY CHAT ======================================="); + System.out.print(!config.getBoolean("chat.fancy")); + System.out.print(!IMP.checkVersion(1, 7, 0)); + Settings.FANCY_CHAT = false; + } Settings.METRICS = config.getBoolean("metrics"); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java index b1e1953b9..24da0bc8b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -70,11 +70,11 @@ public class Home extends SubCommand { MainUtil.sendMessage(plr, C.NOT_YOUR_PLOT); return false; } - MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER); + MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + plots.size() + ")"); return true; } if ((id > (plots.size())) || (id < 1)) { - MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER); + MainUtil.sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + plots.size() + ")"); return false; } MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(id - 1)); 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 68ff20247..6f57bd1ef 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -21,6 +21,7 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.UUID; import java.util.regex.Matcher; @@ -53,46 +54,35 @@ public class Info extends SubCommand { @Override public boolean execute(final PlotPlayer player, String... args) { - Plot plot; - String world; - if (player != null) { - final Location loc = player.getLocation(); - world = loc.getWorld(); - if (!PlotSquared.isPlotWorld(world)) { - MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD); + String arg = null; + if (args.length > 0) arg = args[0] + ""; + switch (arg) { + case "trusted": + case "alias": + case "biome": + case "denied": + case "flags": + case "id": + case "size": + case "members": + case "owner": + case "rating": + arg = null; + } + Plot plot = MainUtil.getPlotFromString(player, arg, true); + if (plot == null) { + if (player == null) { return false; } - plot = MainUtil.getPlot(loc); - if (plot == null) { - return !sendMessage(player, C.NOT_IN_PLOT); + MainUtil.sendMessage(player, C.NOT_IN_PLOT); + return false; + } + if (arg != null) { + if (args.length == 1) { + args = new String[0]; } - } else { - if (args.length < 2) { - MainUtil.sendMessage(null, C.INFO_SYNTAX_CONSOLE); - return false; - } - final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]); - if (plotworld == null) { - MainUtil.sendMessage(player, C.NOT_VALID_WORLD); - return false; - } - try { - final String[] split = args[1].split(";"); - final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - plot = MainUtil.getPlot(plotworld.worldname, id); - if (plot == null) { - MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID); - return false; - } - world = args[0]; - if (args.length == 3) { - args = new String[] { args[2] }; - } else { - args = new String[0]; - } - } catch (final Exception e) { - MainUtil.sendMessage(player, C.INFO_SYNTAX_CONSOLE); - return false; + else { + args = new String[] { args[1] }; } } if ((args.length == 1) && args[0].equalsIgnoreCase("inv")) { @@ -127,7 +117,7 @@ public class Info extends SubCommand { return false; } } - formatAndSend(info, world, plot, player); + formatAndSend(info, plot.world, plot, player); return true; } @@ -209,10 +199,10 @@ public class Info extends SubCommand { MainUtil.sendMessage(player, info, false); } - private String getPlayerList(final Collection uuids) { + public static String getPlayerList(final Collection uuids) { ArrayList l = new ArrayList<>(uuids); if ((l == null) || (l.size() < 1)) { - return " none"; + return C.NONE.s(); } final String c = C.PLOT_USER_LIST.s(); final StringBuilder list = new StringBuilder(); @@ -226,7 +216,7 @@ public class Info extends SubCommand { return list.toString(); } - private String getPlayerName(final UUID uuid) { + public static String getPlayerName(final UUID uuid) { if (uuid == null) { return "unknown"; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java index 7847a2223..a34696752 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/RegenAllRoads.java @@ -52,7 +52,7 @@ public class RegenAllRoads extends SubCommand { height = Integer.parseInt(args[1]); } catch (NumberFormatException e) { - sendMessage(player, C.NOT_VALID_NUMBER); + sendMessage(player, C.NOT_VALID_NUMBER, "(0, 256)"); sendMessage(player, C.COMMAND_SYNTAX, "/plot regenallroads [height]"); return false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java index ffc9dbd22..0fb82c130 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Visit.java @@ -27,8 +27,10 @@ import java.util.UUID; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Visit extends SubCommand { @@ -49,31 +51,105 @@ public class Visit extends SubCommand { @Override public boolean execute(final PlotPlayer plr, final String... args) { if (args.length < 1) { - return sendMessage(plr, C.NEED_USER); + return sendMessage(plr, C.COMMAND_SYNTAX, "/plot visit [#]"); } - final String username = args[0]; - final UUID uuid = UUIDHandler.getUUID(username); - List plots = null; - if (uuid != null) { - plots = PlotSquared.sortPlotsByWorld(getPlots(uuid)); + ArrayList plots = new ArrayList<>(); + UUID user = UUIDHandler.getUUID(args[0]); + if (user != null ) { + // do plots by username + plots.addAll(PlotSquared.getPlots(user)); } - if ((uuid == null) || plots.isEmpty()) { - return sendMessage(plr, C.FOUND_NO_PLOTS); + else if (PlotSquared.isPlotWorld(args[0])) { + // do plots by world + plots.addAll(PlotSquared.getPlots(args[0]).values()); } - if (args.length < 2) { - MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0)); - return true; + else { + Plot plot = MainUtil.getPlotFromString(plr, args[0], false); + if (plot == null) { + return false; + } + plots.add(plot); } - int i; - try { - i = Integer.parseInt(args[1]); - } catch (final Exception e) { - return sendMessage(plr, C.NOT_VALID_NUMBER); + if (plots.size() == 0) { + sendMessage(plr, C.FOUND_NO_PLOTS); + return false; } - if ((i < 1) || (i > plots.size())) { - return sendMessage(plr, C.NOT_VALID_NUMBER); + int index = 0; + if (args.length == 2) { + try { + index = Integer.parseInt(args[1]) - 1; + if (index < 0 || index >= plots.size()) { + sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + plots.size() + ")"); + sendMessage(plr, C.COMMAND_SYNTAX, "/plot visit " + args[0] + " [#]"); + return false; + } + } + catch (Exception e) { + sendMessage(plr, C.NOT_VALID_NUMBER, "(1, " + plots.size() + ")"); + sendMessage(plr, C.COMMAND_SYNTAX, "/plot visit " + args[0] + " [#]"); + return false; + } } - MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(i - 1)); + + Plot plot = plots.get(index); + if (!plot.hasOwner()) { + if (!Permissions.hasPermission(plr, "plots.visit.unowned")) { + sendMessage(plr, C.NO_PERMISSION, "plots.visit.unowned"); + return false; + } + } + else if (plot.isOwner(plr.getUUID())) { + if (!Permissions.hasPermission(plr, "plots.visit.owned") && !Permissions.hasPermission(plr, "plots.home")) { + sendMessage(plr, C.NO_PERMISSION, "plots.visit.unowned, plots.home"); + return false; + } + } + else if (plot.isAdded(plr.getUUID())) { + if (!Permissions.hasPermission(plr, "plots.visit.shared")) { + sendMessage(plr, C.NO_PERMISSION, "plots.visit.shared"); + return false; + } + } + else { + if (!Permissions.hasPermission(plr, "plots.visit.other")) { + sendMessage(plr, C.NO_PERMISSION, "plots.visit.other"); + return false; + } + } + MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(index)); return true; + +// +// // from alias +// +// +// id = PlotId.fromString(args[0]); +// +// +// +// final String username = args[0]; +// final UUID uuid = UUIDHandler.getUUID(username); +// List plots = null; +// if (uuid != null) { +// plots = PlotSquared.sortPlotsByWorld(getPlots(uuid)); +// } +// if ((uuid == null) || plots.isEmpty()) { +// return sendMessage(plr, C.FOUND_NO_PLOTS); +// } +// if (args.length < 2) { +// MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(0)); +// return true; +// } +// int i; +// try { +// i = Integer.parseInt(args[1]); +// } catch (final Exception e) { +// return sendMessage(plr, C.NOT_VALID_NUMBER); +// } +// if ((i < 1) || (i > plots.size())) { +// return sendMessage(plr, C.NOT_VALID_NUMBER); +// } +// MainUtil.teleportPlayer(plr, plr.getLocation(), plots.get(i - 1)); +// return true; } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java index d27e78f3d..e0e1e3b56 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -27,10 +27,15 @@ import java.util.List; import java.util.Set; import java.util.UUID; +import org.apache.commons.lang.StringUtils; +import org.bukkit.ChatColor; + import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.EconHandler; @@ -38,6 +43,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.intellectualcrafters.plot.util.bukkit.chat.FancyMessage; /** * @author Citymonstret @@ -239,11 +245,11 @@ public class list extends SubCommand { return false; } - displayPlots(plr, plots, 12, page, world); + displayPlots(plr, plots, 12, page, world, args); return true; } - public void displayPlots(PlotPlayer player, Collection oldPlots, int pageSize, int page, String world) { + public void displayPlots(PlotPlayer player, Collection oldPlots, int pageSize, int page, String world, String[] args) { List plots; if (world != null) { plots = PlotSquared.sortPlots(oldPlots, world); @@ -264,20 +270,179 @@ public class list extends SubCommand { max = plots.size(); } - plots = plots.subList(page * pageSize, max); + List subList = plots.subList(page * pageSize, max); - - - final StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n"); - Plot p; - // This might work xD - for (int x = (page * 12); x < max; x++) { - p = (Plot) plots.toArray()[x]; - string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", x + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n"); + // Header + String header = C.PLOT_LIST_HEADER_PAGED.s() + .replaceAll("%cur", page + 1 + "") + .replaceAll("%max", totalPages + 1 + "") + .replaceAll("%amount%", plots.size() + "") + .replaceAll("%word%", "all"); + MainUtil.sendMessage(player, header); + + int i = page * pageSize; + for (Plot plot : subList) { + if (plot.settings.isMerged()) { + if (!MainUtil.getBottomPlot(plot).equals(plot)) { + continue; + } + } + i++; + if (Settings.FANCY_CHAT) { + ChatColor color; + if (player == null) { + color = ChatColor.GOLD; + } + else if (plot.isOwner(player.getUUID())) { + color = ChatColor.BLUE; + } + else if (plot.isAdded(player.getUUID())) { + color = ChatColor.DARK_GREEN; + } + else if (plot.isDenied(player.getUUID())) { + color = ChatColor.RED; + } + else { + color = ChatColor.GOLD; + } + FancyMessage trusted = + new FancyMessage( + ChatColor.stripColor( + ChatColor.translateAlternateColorCodes('&', + C.PLOT_INFO_TRUSTED.s().replaceAll("%trusted%", Info.getPlayerList(plot.trusted))))) + .color(ChatColor.GOLD); + + FancyMessage members = + new FancyMessage( + ChatColor.stripColor( + ChatColor.translateAlternateColorCodes('&', + C.PLOT_INFO_MEMBERS.s().replaceAll("%members%", Info.getPlayerList(plot.members))))) + .color(ChatColor.GOLD); + String strFlags = StringUtils.join(plot.settings.flags.values(), ","); + if (strFlags.length() == 0) { + strFlags = C.NONE.s(); + } + FancyMessage flags = + new FancyMessage( + ChatColor.stripColor( + ChatColor.translateAlternateColorCodes('&', + C.PLOT_INFO_FLAGS.s().replaceAll("%flags%", strFlags)))) + .color(ChatColor.GOLD); + + FancyMessage message = new FancyMessage("") + .then("[") + .color(ChatColor.DARK_GRAY) + .then(i + "") + .command("/plot visit " + plot.toString()) + .tooltip("/plot visit " + plot.toString()) + .color(ChatColor.GOLD) + .then("]") + + // teleport tooltip + + .color(ChatColor.DARK_GRAY) + .then(" " + plot.toString()) + + .formattedTooltip(trusted, members, flags) + .command("/plot info " + plot.toString()) + + .color(color) + .then(" - ") + .color(ChatColor.GRAY); + String prefix = ""; + for (UUID uuid : plot.getOwners()) { + String name = UUIDHandler.getName(uuid); + if (name == null) { + message = message + .then(prefix) + .color(ChatColor.DARK_GRAY) + .then("unknown") + .color(ChatColor.GRAY) + .tooltip(uuid.toString()) + .suggest(uuid.toString()); + } + else { + PlotPlayer pp = UUIDHandler.getPlayer(uuid); + if (pp != null) { + message = message + .then(prefix) + .color(ChatColor.DARK_GRAY) + .then(name).color(ChatColor.GOLD) + .formattedTooltip(new FancyMessage("Online").color(ChatColor.DARK_GREEN)); + } + else { + message = message + .then(prefix) + .color(ChatColor.DARK_GRAY) + .then(name).color(ChatColor.GOLD) + .formattedTooltip(new FancyMessage("Offline").color(ChatColor.RED)); + } + } + prefix = ", "; + } + message.send(((BukkitPlayer) player).player); + } + else { + String message = C.PLOT_LIST_ITEM.s() + .replaceAll("%in", i + 1 + "") + .replaceAll("%id", plot.id.toString()) + .replaceAll("%world", plot.world) + .replaceAll("%owner", getName(plot.owner)) + + // Unused + + .replaceAll("%trusted%", "") + .replaceAll("%members%", "") + .replaceAll("%tp%", ""); + MainUtil.sendMessage(player, message); + } + } + if (Settings.FANCY_CHAT) { + if (page < totalPages && page > 0) { + // back | next + new FancyMessage("") + .then("<-") + .color(ChatColor.GOLD) + .command("/plot list " + args[0] + " " + (page)) + .then(" | ") + .color(ChatColor.DARK_GRAY) + .then("->") + .color(ChatColor.GOLD) + .command("/plot list " + args[0] + " " + (page + 2)) + .send(((BukkitPlayer) player).player); + return; + } + if (page == 0) { + // next + new FancyMessage("") + .then("<-") + .color(ChatColor.DARK_GRAY) + .then(" | ") + .color(ChatColor.DARK_GRAY) + .then("->") + .color(ChatColor.GOLD) + .command("/plot list " + args[0] + " " + (page + 2)) + .send(((BukkitPlayer) player).player); + return; + } + if (page == totalPages) { + // back + new FancyMessage("") + .then("<-") + .color(ChatColor.GOLD) + .command("/plot list " + args[0] + " " + (page)) + .then(" | ") + .color(ChatColor.DARK_GRAY) + .then("->") + .color(ChatColor.DARK_GRAY) + .send(((BukkitPlayer) player).player); + return; + } + } + else { + String footer = C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", plots.size() + "").replaceAll("%plot%", plots.size() == 1 ? "plot" : "plots"); + MainUtil.sendMessage(player, footer); } - string.append(C.PLOT_LIST_FOOTER.s().replaceAll("%word%", "There is").replaceAll("%num%", plots.size() + "").replaceAll("%plot%", plots.size() == 1 ? "plot" : "plots")); - MainUtil.sendMessage(player, string.toString()); } private String getArgumentList(final String[] strings) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index fd32a9479..ecd523426 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -322,7 +322,7 @@ public enum C { */ NOT_VALID_DATA("$2That's not a valid data id.", "Invalid"), NOT_VALID_BLOCK("$2That's not a valid block.", "Invalid"), - NOT_VALID_NUMBER("$2That's not a valid number", "Invalid"), + NOT_VALID_NUMBER("$2That's not a valid number within the range: %s", "Invalid"), NOT_VALID_PLOT_ID("$2That's not a valid plot id.", "Invalid"), PLOT_ID_FORM("$2The plot id must be in the form: $1X;Y $2e.g. $1-5;7", "Invalid"), NOT_YOUR_PLOT("$2That is not your plot.", "Invalid"), @@ -345,6 +345,7 @@ public enum C { /* * Info */ + NONE("None", "Info"), PLOT_UNOWNED("$2The current plot must have an owner to perform this action", "Info"), PLOT_INFO_UNCLAIMED("$2Plot $1%s$2 is not yet claimed", "Info"), PLOT_INFO_HEADER("$3====== $1INFO $3======", false, "Info"), @@ -360,7 +361,7 @@ public enum C { PLOT_INFO_ALIAS("$1Alias:$2 %alias%", "Info"), PLOT_INFO_SIZE("$1Size:$2 %size%", "Info"), PLOT_USER_LIST(" $1%user%$2,", "Info"), - INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"), + INFO_SYNTAX_CONSOLE("$2/plot info X;Y", "Info"), /* * Generating */ @@ -379,7 +380,7 @@ public enum C { /* * List */ - PLOT_LIST_HEADER_PAGED("$2(Page $1%cur$2/$1%max$2) $1List of %word% plots", "List"), + PLOT_LIST_HEADER_PAGED("$2(Page $1%cur$2/$1%max$2) $1List of %amount% plots", "List"), PLOT_LIST_HEADER("$1List of %word% plots", "List"), PLOT_LIST_ITEM("$2>> $1%id$2:$1%world $2- $1%owner", "List"), PLOT_LIST_ITEM_ORDERED("$2[$1%in$2] >> $1%id$2:$1%world $2- $1%owner", "List"), diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java index 78d3a0d8b..c694cc37f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -137,6 +137,10 @@ public class Settings { * Have colored console messages? */ public static boolean CONSOLE_COLOR = true; + /** + * Fancy chat e.g. for /plot list + */ + public static boolean FANCY_CHAT = true; /** * The delay (in seconds) before teleportation commences */ diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java index f419d3b91..93bee189f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -262,7 +262,7 @@ public class Plot implements Cloneable { public void removeTrusted(final UUID uuid) { this.members.remove(uuid); } - + @Override public boolean equals(final Object obj) { if (this == obj) { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index fd7c85b16..97aba1b1c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -232,7 +232,7 @@ public class ExpireManager { final String worldname = Bukkit.getWorlds().get(0).getName(); String foldername; String filename = null; - if (BukkitMain.checkVersion(1, 7, 5)) { + if (PlotSquared.IMP.checkVersion(1, 7, 5)) { foldername = "playerdata"; try { final OfflinePlotPlayer op = UUIDHandler.uuidWrapper.getOfflinePlayer(uuid); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 7c1e92e3b..376e2b9e8 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -73,6 +73,63 @@ public class MainUtil { return new Location(plot.world, bot.getX() + (top.getX() - bot.getX()) / 2, 0, bot.getZ() + (top.getZ() - bot.getZ()) / 2); } + public static Plot getPlotFromString(PlotPlayer player, String arg, boolean message) { + if (arg == null) { + if (player == null) { + if (message) MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD); + return null; + } + return getPlot(player.getLocation()); + } + String worldname = null; + PlotId id = null; + if (player != null) { + worldname = player.getLocation().getWorld(); + } + String[] split = arg.split(";|,"); + if (split.length == 3) { + worldname = split[0]; + id = PlotId.fromString(split[1] + ";" + split[2]); + } + else if (split.length == 2) { + id = PlotId.fromString(arg); + } + else { + if (worldname == null) { + if (PlotSquared.getPlotWorlds().size() == 0) { + if (message) MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD); + return null; + } + worldname = PlotSquared.getPlotWorlds().iterator().next(); + } + for (Plot p : PlotSquared.getPlots(worldname).values()) { + String name = p.settings.getAlias(); + if (name.length() != 0 && name.equalsIgnoreCase(arg)) { + return p; + } + } + for (String world : PlotSquared.getPlotWorlds()) { + if (!world.endsWith(worldname)) { + for (Plot p : PlotSquared.getPlots(world).values()) { + String name = p.settings.getAlias(); + if (name.length() != 0 && name.equalsIgnoreCase(arg)) { + return p; + } + } + } + } + } + if (worldname == null || !PlotSquared.isPlotWorld(worldname)) { + if (message) MainUtil.sendMessage(player, C.NOT_VALID_PLOT_WORLD); + return null; + } + if (id == null) { + if (message) MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID); + return null; + } + return getPlot(worldname, id); + } + /** * Merges all plots in the arraylist (with cost) * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java index 963950952..01a4ce8f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/UUIDHandler.java @@ -222,19 +222,24 @@ public class UUIDHandler { } public static String getName(final UUID uuid) { + System.out.print(uuid); if (uuid == null) { + System.out.print(1); return null; } // check online final PlotPlayer player = UUIDHandler.getPlayer(uuid); if (player != null) { + System.out.print(2); return player.getName(); } // check cache final StringWrapper name = UUIDHandler.uuidMap.inverse().get(uuid); if (name != null) { + System.out.print(3); return name.value; } + System.out.print(4); return null; }