From 22700aa88be47d49617815a94c5efc4f2b194d5f Mon Sep 17 00:00:00 2001 From: boy0001 Date: Mon, 23 Feb 2015 10:12:33 +1100 Subject: [PATCH] fixes --- .../intellectualcrafters/plot/BukkitMain.java | 41 ++++++++++++++++++- .../intellectualcrafters/plot/IPlotMain.java | 3 ++ .../plot/PlotSquared.java | 16 ++++---- .../plot/commands/Claim.java | 2 +- .../plot/commands/MainCommand.java | 3 +- .../intellectualcrafters/plot/config/C.java | 2 +- PlotSquared/src/main/resources/plugin.yml | 2 +- 7 files changed, 57 insertions(+), 12 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index 1d5b63dea..e8de76e7b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -29,6 +29,7 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.PlotMeConverter; import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.generator.BukkitHybridUtils; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.HybridUtils; @@ -39,6 +40,8 @@ import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; import com.intellectualcrafters.plot.listeners.PlotPlusListener; import com.intellectualcrafters.plot.listeners.WorldEditListener; import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.titles.AbstractTitle; +import com.intellectualcrafters.plot.titles.DefaultTitle; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.MainUtil; @@ -54,6 +57,9 @@ import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.intellectualcrafters.plot.uuid.DefaultUUIDWrapper; +import com.intellectualcrafters.plot.uuid.OfflineUUIDWrapper; +import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @@ -102,8 +108,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void onEnable() { - MAIN = new PlotSquared(this); THIS = this; + MAIN = new PlotSquared(this); if (Settings.METRICS) { try { final Metrics metrics = new Metrics(this); @@ -127,6 +133,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void log(String message) { + message = message.replaceAll("\u00B2", "2"); if ((THIS == null) || (Bukkit.getServer().getConsoleSender() == null)) { System.out.println(ChatColor.stripColor(ConsoleColors.fromString(message))); } else { @@ -337,4 +344,36 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public SetupUtils initSetupUtils() { return new BukkitSetupUtils(); } + + @Override + public UUIDWrapper initUUIDHandler() { + boolean checkVersion = checkVersion(1, 7, 6); + if (!checkVersion) { + log(C.PREFIX.s()+" &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature."); + Settings.TITLES = false; + FlagManager.removeFlag(FlagManager.getFlag("titles")); + } + else { + AbstractTitle.TITLE_CLASS = new DefaultTitle(); + } + if (Settings.OFFLINE_MODE) { + UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + Settings.OFFLINE_MODE = true; + } + else if (checkVersion) { + UUIDHandler.uuidWrapper = new DefaultUUIDWrapper(); + Settings.OFFLINE_MODE = false; + } + else { + UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); + Settings.OFFLINE_MODE = true; + } + if (Settings.OFFLINE_MODE) { + log(C.PREFIX.s()+" &6PlotSquared is using Offline Mode UUIDs either because of user preference, or because you are using an old version of Bukkit"); + } + else { + log(C.PREFIX.s()+" &6PlotSquared is using online UUIDs"); + } + return UUIDHandler.uuidWrapper; + } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 76c59e5ac..c109c4149 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -9,6 +9,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.uuid.UUIDWrapper; public interface IPlotMain { public void log(String message); @@ -43,6 +44,8 @@ public interface IPlotMain { public HybridUtils initHybridUtils(); + public UUIDWrapper initUUIDHandler(); + public boolean initPlotMeConverter(); public void getGenerator(String world, String name); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java index ed5d96fd1..ef965f8a3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotSquared.java @@ -437,6 +437,8 @@ public class PlotSquared { IMP.registerPlotPlusEvents(); IMP.registerForceFieldEvents(); IMP.registerWorldEditEvents(); + // create UUIDWrapper + UUIDHandler.uuidWrapper = IMP.initUUIDHandler(); // create Hybrid utility class HybridUtils.manager = IMP.initHybridUtils(); // create setup util class @@ -771,9 +773,6 @@ public class PlotSquared { storage.set(node.getKey(), node.getValue()); } } - } - - public static void showDebug() { Settings.DB.USE_MYSQL = storage.getBoolean("mysql.use"); Settings.DB.USER = storage.getString("mysql.user"); Settings.DB.PASSWORD = storage.getString("mysql.password"); @@ -790,10 +789,13 @@ public class PlotSquared { Settings.API_URL = config.getString("uuid.api.location"); Settings.CUSTOM_API = config.getBoolean("uuid.api.custom"); Settings.UUID_FECTHING = config.getBoolean("uuid.fetching"); - C.COLOR_1 = "\u00A7" + (style.getString("color.1")); - C.COLOR_2 = "\u00A7" + (style.getString("color.2")); - C.COLOR_3 = "\u00A7" + (style.getString("color.3")); - C.COLOR_4 = "\u00A7" + (style.getString("color.4")); + } + + public static void showDebug() { + C.COLOR_1 = "&" + (style.getString("color.1")); + C.COLOR_2 = "&" + (style.getString("color.2")); + C.COLOR_3 = "&" + (style.getString("color.3")); + C.COLOR_4 = "&" + (style.getString("color.4")); if (Settings.DEBUG) { final Map settings = new HashMap<>(); settings.put("Kill Road Mobs", "" + Settings.KILL_ROAD_MOBS); 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 b22686649..c0b590cc3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -53,7 +53,7 @@ public class Claim extends SubCommand { // final PlayerClaimPlotEvent event = new PlayerClaimPlotEvent(player, plot, auto); // Bukkit.getPluginManager().callEvent(event); // boolean result = event.isCancelled(); - boolean result = true; + boolean result = false; if (!result) { MainUtil.createPlot(player.getUUID(), plot); 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 a0d12fe46..c7dc2dc37 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -84,6 +84,7 @@ public class MainCommand { } final List help = new ArrayList<>(); help.add(C.HELP_HEADER.s()); + System.out.print(C.HELP_HEADER.s()); // HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"), help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages + 1)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size())); SubCommand cmd; @@ -158,7 +159,7 @@ public class MainCommand { for (final String string : helpMenu(player, cato, page)) { help.append(string).append("\n"); } - player.sendMessage(MainUtil.colorise('&', help.toString())); + MainUtil.sendMessage(player, help.toString()); // return PlayerFunctions.sendMessage(player, help.toString()); } else { for (final SubCommand command : subCommands) { 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 479355b21..b68e8e4db 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -444,7 +444,7 @@ public enum C { * @see com.intellectualsites.translation.TranslationLanguage */ protected final static TranslationLanguage lang = new TranslationLanguage("PlotSquared", "this", "use"); - public static String COLOR_1 = "\u00A76", COLOR_2 = "\u00A77", COLOR_3 = "\u00A78", COLOR_4 = "\u00A73"; + public static String COLOR_1 = "&6", COLOR_2 = "&7", COLOR_3 = "&8", COLOR_4 = "&3"; /** * The TranslationManager * diff --git a/PlotSquared/src/main/resources/plugin.yml b/PlotSquared/src/main/resources/plugin.yml index e0ba9b747..3720eac38 100644 --- a/PlotSquared/src/main/resources/plugin.yml +++ b/PlotSquared/src/main/resources/plugin.yml @@ -1,5 +1,5 @@ name: ${project.name} -main: com.intellectualcrafters.plot.PlotSquared +main: com.intellectualcrafters.plot.BukkitMain version: ${project.version} load: STARTUP description: >