From 047f9a75b99da1767bd8cbb5e79845c87ab91ec6 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 27 Jun 2016 17:45:19 +1000 Subject: [PATCH 1/2] Fix #1222 --- .../main/java/com/intellectualcrafters/plot/object/Plot.java | 2 +- .../intellectualcrafters/plot/util/expiry/ExpireManager.java | 2 +- .../intellectualcrafters/plot/util/expiry/ExpirySettings.java | 4 ---- 3 files changed, 2 insertions(+), 6 deletions(-) delete mode 100644 Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpirySettings.java diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index b2f43b91e..d5cd9b231 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -2681,7 +2681,7 @@ public class Plot { greaterPlot.setMerged(3, true); lesserPlot.mergeData(greaterPlot); if (removeRoads) { - Plot diagonal = greaterPlot.getRelative(1); + Plot diagonal = greaterPlot.getRelative(2); if (diagonal.getMerged(7)) { lesserPlot.removeRoadSouthEast(); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java index a67a95bed..a78ca1b5c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpireManager.java @@ -300,7 +300,7 @@ public class ExpireManager { } }, 86400000); } else { - TaskManager.runTaskLaterAsync(this, 20); + TaskManager.runTaskLaterAsync(this, 20 * 10); } } }); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpirySettings.java b/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpirySettings.java deleted file mode 100644 index 24ba134d3..000000000 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/expiry/ExpirySettings.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.intellectualcrafters.plot.util.expiry; - -public class ExpirySettings { -} From 817a5bc16e9180800ecb22483e0a106adac7ca20 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Mon, 27 Jun 2016 18:38:14 +1000 Subject: [PATCH 2/2] Various Fix compatibility with bukkit 1.5 Recover on failed fancy message initialization Fix /2 remove * --- .../main/java/com/plotsquared/bukkit/BukkitMain.java | 6 +++--- .../java/com/plotsquared/bukkit/chat/Reflection.java | 9 +++------ .../bukkit/titles/DefaultTitleManager_183.java | 1 - .../bukkit/util/block/BukkitLocalQueue.java | 2 +- .../com/intellectualcrafters/plot/commands/Kick.java | 5 ++--- .../com/intellectualcrafters/plot/object/Plot.java | 6 +++--- .../intellectualcrafters/plot/object/PlotMessage.java | 10 +++++++++- .../plot/object/chat/PlainChatManager.java | 8 ++++---- 8 files changed, 25 insertions(+), 22 deletions(-) rename Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java => Core/src/main/java/com/intellectualcrafters/plot/object/chat/PlainChatManager.java (82%) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index e28de55a4..0db1248e6 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -52,7 +52,7 @@ import com.plotsquared.bukkit.util.BukkitEconHandler; import com.plotsquared.bukkit.util.BukkitEventUtil; import com.plotsquared.bukkit.util.BukkitHybridUtils; import com.plotsquared.bukkit.util.BukkitInventoryUtil; -import com.plotsquared.bukkit.util.BukkitPlainChatManager; +import com.intellectualcrafters.plot.object.chat.PlainChatManager; import com.plotsquared.bukkit.util.BukkitSchematicHandler; import com.plotsquared.bukkit.util.BukkitSetupUtils; import com.plotsquared.bukkit.util.BukkitTaskManager; @@ -428,7 +428,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain new SendChunk(); MainUtil.canSendChunk = true; } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) { - e.printStackTrace(); + PS.debug(SendChunk.class + " does not support " + StringMan.getString(getServerVersion())); MainUtil.canSendChunk = false; } if (PS.get().checkVersion(getServerVersion(), 1, 9, 0)) { @@ -653,7 +653,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain if (Settings.Chat.INTERACTIVE) { return new BukkitChatManager(); } else { - return new BukkitPlainChatManager(); + return new PlainChatManager(); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java index 636c20091..9745fdf87 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java @@ -64,9 +64,8 @@ public final class Reflection { try { clazz = Class.forName(fullName); } catch (Exception e) { - e.printStackTrace(); _loadedNMSClasses.put(className, null); - return null; + throw new RuntimeException(e); } _loadedNMSClasses.put(className, clazz); return clazz; @@ -89,9 +88,8 @@ public final class Reflection { try { clazz = Class.forName(fullName); } catch (Exception e) { - e.printStackTrace(); _loadedOBCClasses.put(className, null); - return null; + throw new RuntimeException(e); } _loadedOBCClasses.put(className, clazz); return clazz; @@ -110,8 +108,7 @@ public final class Reflection { try { return getMethod(obj.getClass(), "getHandle").invoke(obj); } catch (Exception e) { - e.printStackTrace(); - return null; + throw new RuntimeException(e); } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java index 37745ba3e..20d050f01 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java @@ -30,7 +30,6 @@ public class DefaultTitleManager_183 extends DefaultTitleManager { this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent"); this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction"); this.nmsChatSerializer = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer"); - } @Override diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/BukkitLocalQueue.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/BukkitLocalQueue.java index c655f40ec..f61d4d6a2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/BukkitLocalQueue.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/BukkitLocalQueue.java @@ -85,7 +85,7 @@ public class BukkitLocalQueue extends BasicLocalBlockQueue { if (block != null) { int x = MainUtil.x_loc[layer][j]; int y = MainUtil.y_loc[layer][j]; - int z = MainUtil.y_loc[layer][j]; + int z = MainUtil.z_loc[layer][j]; Block existing = chunk.getBlock(x, y, z); int existingId = existing.getTypeId(); if (existingId == block.id) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 8e02d029c..283ae0828 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -54,7 +54,7 @@ public class Kick extends SubCommand { } players.add(pp); } - break; + continue; } PlotPlayer pp = UUIDHandler.getPlayer(uuid); if (pp != null) { @@ -67,8 +67,7 @@ public class Kick extends SubCommand { return false; } for (PlotPlayer player2 : players) { - Location location2 = player2.getLocation(); - if (!player2.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) { + if (!plot.equals(player2.getCurrentPlot())) { MainUtil.sendMessage(player, C.INVALID_PLAYER, args[0]); return false; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index d5cd9b231..78e5867ac 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -1650,7 +1650,7 @@ public class Plot { if (uuid == DBFunc.everyone) { boolean result = false; for (UUID other : new HashSet<>(getDenied())) { - result = result || rmvDenied(other); + result = rmvDenied(other) || result; } return result; } @@ -1677,7 +1677,7 @@ public class Plot { if (uuid == DBFunc.everyone) { boolean result = false; for (UUID other : new HashSet<>(getTrusted())) { - result = result || rmvTrusted(other); + result = rmvTrusted(other) || result; } return result; } @@ -1707,7 +1707,7 @@ public class Plot { if (uuid == DBFunc.everyone) { boolean result = false; for (UUID other : new HashSet<>(this.members)) { - result = result || rmvMember(other); + result = rmvMember(other) || result; } return result; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotMessage.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotMessage.java index def432cd3..5dd00edd4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotMessage.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotMessage.java @@ -1,6 +1,8 @@ package com.intellectualcrafters.plot.object; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.chat.PlainChatManager; import com.intellectualcrafters.plot.util.ChatManager; public class PlotMessage { @@ -8,7 +10,13 @@ public class PlotMessage { private Object builder; public PlotMessage() { - reset(ChatManager.manager); + try { + reset(ChatManager.manager); + } catch (Throwable e) { + PS.debug("PlotSquared doesn't support fancy chat for " + PS.get().IMP.getServerVersion()); + ChatManager.manager = new PlainChatManager(); + reset(ChatManager.manager); + } } public PlotMessage(String text) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java b/Core/src/main/java/com/intellectualcrafters/plot/object/chat/PlainChatManager.java similarity index 82% rename from Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java rename to Core/src/main/java/com/intellectualcrafters/plot/object/chat/PlainChatManager.java index 11872a8db..a341f413d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitPlainChatManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/chat/PlainChatManager.java @@ -1,14 +1,14 @@ -package com.plotsquared.bukkit.util; +package com.intellectualcrafters.plot.object.chat; +import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotMessage; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.ChatManager; -import org.bukkit.ChatColor; import java.util.ArrayList; import java.util.List; -public class BukkitPlainChatManager extends ChatManager> { +public class PlainChatManager extends ChatManager> { @Override public List builder() { @@ -29,7 +29,7 @@ public class BukkitPlainChatManager extends ChatManager> { @Override public void text(PlotMessage message, String text) { - message.$(this).add(new StringBuilder(ChatColor.stripColor(text))); + message.$(this).add(new StringBuilder(C.color(text))); } @Override