diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index c0b9452ec..1aa762434 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -62,6 +62,7 @@ import com.intellectualcrafters.plot.object.RunnableVal; import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; +import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.MainUtil; @@ -119,6 +120,7 @@ public class DebugExec extends SubCommand { scope.put("BlockManager", BlockManager.manager); scope.put("SetupUtils", SetupUtils.manager); scope.put("EventUtil", EventUtil.manager); + scope.put("EconHandler", EconHandler.manager); scope.put("UUIDHandler", UUIDHandler.implementation); scope.put("DBFunc", DBFunc.dbManager); scope.put("HybridUtils", HybridUtils.manager); diff --git a/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java b/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java index a340508c4..a15c2f115 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java +++ b/src/main/java/com/intellectualcrafters/plot/util/EconHandler.java @@ -16,7 +16,6 @@ public abstract class EconHandler { public abstract void withdrawMoney(PlotPlayer player, double amount); public abstract void depositMoney(PlotPlayer player, double amount); public abstract void depositMoney(OfflinePlotPlayer player, double amount); - public abstract void setPermission(PlotPlayer player, String perm, boolean value); -// public abstract void setPermission(OfflinePlotPlayer player, String perm, boolean value); -// public abstract void getPermission(OfflinePlotPlayer player, String perm); + public abstract void setPermission(String player, String perm, boolean value); + public abstract boolean hasPermission(String player, String perm); } diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index fc8a5b0b9..c035d5cce 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -635,6 +635,15 @@ public class MainUtil { } manager.startPlotMerge(plotworld, plotIds); + for (int x = pos1.x; x <= pos2.x; x++) { + for (int y = pos1.y; y <= pos2.y; y++) { + final PlotId id = new PlotId(x, y); + final Plot plot = PS.get().getPlots(world).get(id); + if (removeRoads) { + removeSign(plot); + } + } + } for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { final boolean lx = x < pos2.x; @@ -642,9 +651,6 @@ public class MainUtil { final PlotId id = new PlotId(x, y); final Plot plot = PS.get().getPlots(world).get(id); Plot plot2 = null; - if (removeRoads) { - removeSign(plot); - } if (lx) { if (ly) { if (!plot.getSettings().getMerged(1) || !plot.getSettings().getMerged(2)) { diff --git a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java index 927630cc4..80cf4ba5f 100644 --- a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java +++ b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java @@ -31,6 +31,7 @@ public class BukkitPlayer extends PlotPlayer { private long last = 0; public HashSet hasPerm = new HashSet<>(); public HashSet noPerm = new HashSet<>(); + public boolean offline; /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. @@ -40,6 +41,11 @@ public class BukkitPlayer extends PlotPlayer { this.player = player; } + public BukkitPlayer(final Player player, boolean offline) { + this.player = player; + this.offline = offline; + } + public long getPreviousLogin() { if (last == 0) { last = player.getLastPlayed(); @@ -78,6 +84,9 @@ public class BukkitPlayer extends PlotPlayer { this.hasPerm.add(perm); return true; } + if (offline && EconHandler.manager != null) { + return EconHandler.manager.hasPermission(getName(), perm); + } return this.player.hasPermission(perm); } @@ -106,7 +115,7 @@ public class BukkitPlayer extends PlotPlayer { @Override public boolean isOnline() { - return this.player.isOnline(); + return !offline && this.player.isOnline(); } @Override @@ -123,7 +132,7 @@ public class BukkitPlayer extends PlotPlayer { @Override public void setAttribute(String key) { key = "plotsquared_user_attributes." + key; - EconHandler.manager.setPermission(this, key, true); + EconHandler.manager.setPermission(getName(), key, true); } @Override @@ -141,7 +150,7 @@ public class BukkitPlayer extends PlotPlayer { @Override public void removeAttribute(String key) { key = "plotsquared_user_attributes." + key; - EconHandler.manager.setPermission(this, key, false); + EconHandler.manager.setPermission(getName(), key, false); } @Override diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java b/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java index e5ef70211..1fee50cb7 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java @@ -4,8 +4,10 @@ import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.permission.Permission; import org.bukkit.Bukkit; +import org.bukkit.World; import org.bukkit.plugin.RegisteredServiceProvider; +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.EconHandler; @@ -68,12 +70,17 @@ public class BukkitEconHandler extends EconHandler { } @Override - public void setPermission(PlotPlayer player, String perm, boolean value) { + public void setPermission(String player, String perm, boolean value) { if (value) { - perms.playerAdd(((BukkitPlayer) player).player, perm); + perms.playerAdd((World) null, player, perm); } else { - perms.playerRemove(((BukkitPlayer) player).player, perm); + perms.playerRemove((World) null, player, perm); } } + + @Override + public boolean hasPermission(String player, String perm) { + return perms.playerHas((String) null, Bukkit.getOfflinePlayer(player), perm); + } } diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index b60024edc..b8d03d81c 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -118,7 +118,7 @@ public class BukkitUtil extends BlockManager { } Player player = OfflinePlayerUtil.loadPlayer(op); player.loadData(); - return new BukkitPlayer(player); + return new BukkitPlayer(player, true); } public static PlotPlayer getPlayer(final Player player) { diff --git a/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java b/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java index ed63bf750..f951aa001 100644 --- a/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java +++ b/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java @@ -141,7 +141,7 @@ public class SpongePlayer extends PlotPlayer { @Override public void setAttribute(String key) { key = "plotsquared_user_attributes." + key; - EconHandler.manager.setPermission(this, key, true); + EconHandler.manager.setPermission(getName(), key, true); } @Override @@ -156,7 +156,7 @@ public class SpongePlayer extends PlotPlayer { @Override public void removeAttribute(String key) { key = "plotsquared_user_attributes." + key; - EconHandler.manager.setPermission(this, key, false); + EconHandler.manager.setPermission(getName(), key, false); } @Override diff --git a/src/main/resources/automerge.js b/src/main/resources/automerge.js index 7eb4818a3..5c21b68bd 100644 --- a/src/main/resources/automerge.js +++ b/src/main/resources/automerge.js @@ -3,6 +3,30 @@ Need to script something quick with PlotSquared? /plot debugexec runasync automerge.js This is an example script that will auto merge all plots + +The following utility classes are usable: + - PS + - TaskManager + - TitleManager + - ConsolePlayer + - SchematicHandler + - ChunkManager + - BlockManager + - SetupUtils + - EventUtil + - UUIDHandler + - DBFunc + - HybridUtils + - IMP ( BukkitMain or SpongeMain) + - MainCommand + - MainUtil + - Settings + - StringMan + - MathMan + - C ( use C_ ) + - Permissions ( use Permissions_ ) + + For more information see: https://github.com/IntellectualSites/PlotSquared/wiki/Scripting */ var plots = PS.sortPlots(PS.getPlots()); PS.log("Attempting to auto merge " + plots.size() + " plots");