diff --git a/PlotSquared/pom.xml b/PlotSquared/pom.xml index 12619df47..ba8ecd512 100644 --- a/PlotSquared/pom.xml +++ b/PlotSquared/pom.xml @@ -6,7 +6,7 @@ com.intellectualcrafters PlotSquared - 2.5.1 + 2.5.3 PlotSquared jar diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java index c02f6dd63..556b0939a 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/PlotMain.java @@ -1533,7 +1533,7 @@ import java.util.concurrent.TimeUnit; UUIDHandler.uuidWrapper = new OfflineUUIDWrapper(); Settings.OFFLINE_MODE = true; } - else if (checkVersion && Bukkit.getOnlineMode()) { + else if (checkVersion) { UUIDHandler.uuidWrapper = new DefaultUUIDWrapper(); Settings.OFFLINE_MODE = false; } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 0848c3fc4..fc6f3d0ca 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -83,10 +83,11 @@ public class Merge extends SubCommand { } final Plot plot = PlayerFunctions.getCurrentPlot(plr); if ((plot == null) || !plot.hasOwner()) { - PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); + PlayerFunctions.sendMessage(plr, C.PLOT_UNOWNED); return false; } - if (!plot.getOwner().equals(UUIDHandler.getUUID(plr))) { + boolean admin = PlotMain.hasPermission(plr, "plots.admin"); + if (!plot.getOwner().equals(UUIDHandler.getUUID( plr)) && !admin) { PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return false; } @@ -129,7 +130,7 @@ public class Merge extends SubCommand { } for (final PlotId myid : plots) { final Plot myplot = PlotMain.getPlots(world).get(myid); - if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)))) { + if ((myplot == null) || !myplot.hasOwner() || !(myplot.getOwner().equals(UUIDHandler.getUUID(plr)) || admin)) { PlayerFunctions.sendMessage(plr, C.NO_PERM_MERGE.s().replaceAll("%plot%", myid.toString())); return false; } @@ -161,7 +162,7 @@ public class Merge extends SubCommand { PlayerFunctions.sendMessage(plr, "&cPlots have been merged"); PlotHelper.mergePlots(world, plots); - PlotHelper.setSign(world, plr.getName(), plot); + PlotHelper.setSign(world, UUIDHandler.getName(plot.owner), plot); if (PlotHelper.canSetFast) { SetBlockFast.update(plr); 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 45b7bf4c8..bd2684e70 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -244,7 +244,7 @@ public enum C { /* * Info */ - PLOT_INFO_UNCLAIMED("&cPlot &6%s&c is not yet claimed"), + PLOT_UNOWNED("&cThe current plot must have an owner to perform this action"), /* * PLOT_INFO("" + * "&6ID&7: &a%id%&7\n" + 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 32f2bd35c..a05bc5deb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -21,6 +21,8 @@ package com.intellectualcrafters.plot.config; +import org.bukkit.Bukkit; + /** * Updater and DB settings * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java index 2c6977729..89ff1bed7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/UUIDHandler.java @@ -100,14 +100,16 @@ public class UUIDHandler { return s.endsWith(".dat"); } }); - for (String current : dat) { - String s = current.replaceAll(".dat$", ""); - try { - UUID uuid = UUID.fromString(s); - uuids.add(uuid); - } - catch (Exception e) { - PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "Invalid playerdata: "+current); + if (dat != null) { + for (String current : dat) { + String s = current.replaceAll(".dat$", ""); + try { + UUID uuid = UUID.fromString(s); + uuids.add(uuid); + } + catch (Exception e) { + PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "Invalid playerdata: "+current); + } } } @@ -118,13 +120,15 @@ public class UUIDHandler { return s.endsWith(".dat"); } }); - for (String current : dat) { - names.add(current.replaceAll(".dat$", "")); + if (dat != null) { + for (String current : dat) { + names.add(current.replaceAll(".dat$", "")); + } } } - UUIDWrapper wrapper = null; + UUIDWrapper wrapper = new DefaultUUIDWrapper(); for (UUID uuid : uuids) { try { OfflinePlayer player = wrapper.getOfflinePlayer(uuid); @@ -155,6 +159,10 @@ public class UUIDHandler { } public static String getName(UUID uuid) { + if (uuid == null) { + return null; + } + // check online for (Player player : Bukkit.getOnlinePlayers()) { UUID u2 = UUIDHandler.uuidWrapper.getUUID(player); @@ -182,6 +190,10 @@ public class UUIDHandler { } public static UUID getUUID(final String name) { + if (name == null) { + return null; + } + // check online Player player = Bukkit.getPlayer(name); if (player != null) {