diff --git a/pom.xml b/pom.xml
index 39b450efd..34d18a309 100644
--- a/pom.xml
+++ b/pom.xml
@@ -40,7 +40,33 @@
maven-jar-plugin
-
+
+ bukkit
+
+ jar
+
+ package
+
+ PlotSquared-Bukkit
+
+ **/com/plotsquared/sponge/**
+
+
+
+
+ sponge
+
+ jar
+
+ package
+
+ PlotSquared-Sponge
+
+ **/com/plotsquared/bukkit/**
+ **/com/intellectualcrafters/plot/api/*
+
+
+
diff --git a/src/main/java/com/intellectualcrafters/plot/PS.java b/src/main/java/com/intellectualcrafters/plot/PS.java
index 53d638dc0..0ea5e1842 100644
--- a/src/main/java/com/intellectualcrafters/plot/PS.java
+++ b/src/main/java/com/intellectualcrafters/plot/PS.java
@@ -7,6 +7,7 @@ import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.lang.reflect.Array;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
@@ -265,6 +266,7 @@ public class PS {
}
// Copy files
+ copyFile("automerge.js", "scripts");
copyFile("town.template", "templates");
copyFile("skyblock.template", "templates");
copyFile("german.yml", "translations");
@@ -317,8 +319,8 @@ public class PS {
* @param message Message to log
* @see IPlotMain#log(String)
*/
- public static void log(final String message) {
- get().IMP.log(message);
+ public static void log(Object message) {
+ get().IMP.log(StringMan.getString(message));
}
/**
diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
index ad4610b99..c0b9452ec 100644
--- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
+++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java
@@ -40,6 +40,8 @@ import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
+import org.bukkit.ChatColor;
+
import com.google.common.io.Files;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
@@ -120,7 +122,6 @@ public class DebugExec extends SubCommand {
scope.put("UUIDHandler", UUIDHandler.implementation);
scope.put("DBFunc", DBFunc.dbManager);
scope.put("HybridUtils", HybridUtils.manager);
- scope.put("HybridUtils", HybridUtils.manager);
scope.put("IMP", PS.get().IMP);
scope.put("MainCommand", MainCommand.getInstance());
@@ -366,7 +367,7 @@ public class DebugExec extends SubCommand {
}
case "run": {
try {
- script = StringMan.join(Files.readLines(new File(PS.get().IMP.getDirectory(), args[1]), StandardCharsets.UTF_8), "");
+ script = StringMan.join(Files.readLines(new File(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8), System.getProperty("line.separator"));
if (args.length > 2) {
HashMap replacements = new HashMap<>();
for (int i = 2; i < args.length; i++) {
@@ -384,9 +385,13 @@ public class DebugExec extends SubCommand {
script = StringMan.join(args, " ");
}
}
+ if (!ConsolePlayer.isConsole(player)) {
+ MainUtil.sendMessage(player, C.NOT_CONSOLE);
+ return false;
+ }
init();
scope.put("PlotPlayer", player);
- PS.log("> " + script);
+ System.out.print("> " + script);
try {
if (async) {
final String toExec = script;
diff --git a/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/src/main/java/com/intellectualcrafters/plot/object/Plot.java
index 58c42bd53..f26952922 100644
--- a/src/main/java/com/intellectualcrafters/plot/object/Plot.java
+++ b/src/main/java/com/intellectualcrafters/plot/object/Plot.java
@@ -476,9 +476,10 @@ public class Plot {
/**
* Auto merge the plot with any adjacent plots of the same owner
* @see MainUtil#autoMerge(Plot, UUID) to specify the owner
+ * @param removeRoads If to remove roads when merging
*/
- public void autoMerge() {
- MainUtil.autoMerge(this, owner);
+ public void autoMerge(boolean removeRoads) {
+ MainUtil.autoMerge(this, owner, removeRoads);
}
/**
diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
index 694717e77..fc8a5b0b9 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java
@@ -821,7 +821,7 @@ public class MainUtil {
return string;
}
- public static void autoMerge(final Plot plot, final UUID uuid) {
+ public static void autoMerge(final Plot plot, final UUID uuid, boolean removeRoads) {
if (plot == null) {
return;
}
@@ -843,7 +843,7 @@ public class MainUtil {
final PlotId top = getTopPlot(plot).id;
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y - 1), new PlotId(top.x, top.y));
if (ownsPlots(plot.world, plots, uuid, 0)) {
- final boolean result = mergePlots(plot.world, plots, true);
+ final boolean result = mergePlots(plot.world, plots, removeRoads);
if (result) {
merge = true;
continue;
@@ -851,7 +851,7 @@ public class MainUtil {
}
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x + 1, top.y));
if (ownsPlots(plot.world, plots, uuid, 1)) {
- final boolean result = mergePlots(plot.world, plots, true);
+ final boolean result = mergePlots(plot.world, plots, removeRoads);
if (result) {
merge = true;
continue;
@@ -859,7 +859,7 @@ public class MainUtil {
}
plots = getPlotSelectionIds(new PlotId(bot.x, bot.y), new PlotId(top.x, top.y + 1));
if (ownsPlots(plot.world, plots, uuid, 2)) {
- final boolean result = mergePlots(plot.world, plots, true);
+ final boolean result = mergePlots(plot.world, plots, removeRoads);
if (result) {
merge = true;
continue;
@@ -867,7 +867,7 @@ public class MainUtil {
}
plots = getPlotSelectionIds(new PlotId(bot.x - 1, bot.y), new PlotId(top.x, top.y));
if (ownsPlots(plot.world, plots, uuid, 3)) {
- final boolean result = mergePlots(plot.world, plots, true);
+ final boolean result = mergePlots(plot.world, plots, removeRoads);
if (result) {
merge = true;
continue;
@@ -928,7 +928,7 @@ public class MainUtil {
}
final PlotWorld plotworld = PS.get().getPlotWorld(plot.world);
if (plotworld.AUTO_MERGE) {
- autoMerge(p, uuid);
+ autoMerge(p, uuid, true);
}
return true;
}
diff --git a/src/main/java/com/intellectualcrafters/plot/util/StringMan.java b/src/main/java/com/intellectualcrafters/plot/util/StringMan.java
index d5c04159f..799df7657 100644
--- a/src/main/java/com/intellectualcrafters/plot/util/StringMan.java
+++ b/src/main/java/com/intellectualcrafters/plot/util/StringMan.java
@@ -1,6 +1,8 @@
package com.intellectualcrafters.plot.util;
+import java.lang.reflect.Array;
import java.util.Collection;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -26,6 +28,37 @@ public class StringMan {
return sb.toString();
}
+ public static String getString(Object obj) {
+ if (obj == null) {
+ return "null";
+ }
+ if (obj.getClass() == String.class) {
+ return (String) obj;
+ }
+ if (obj.getClass().isArray()) {
+ String result = "";
+ String prefix = "";
+
+ for(int i=0; i) {
+ String result = "";
+ String prefix = "";
+ for (Object element : (List>) obj) {
+ result += prefix + getString(element);
+ prefix = ",";
+ }
+ return "[ " + result + " ]";
+ }
+ else {
+ return obj.toString();
+ }
+ }
+
public static String replaceFirst(char c, String s) {
if (s == null) {
return "";
diff --git a/src/main/resources/automerge.js b/src/main/resources/automerge.js
new file mode 100644
index 000000000..7eb4818a3
--- /dev/null
+++ b/src/main/resources/automerge.js
@@ -0,0 +1,24 @@
+/*
+Need to script something quick with PlotSquared?
+/plot debugexec runasync automerge.js
+
+This is an example script that will auto merge all plots
+*/
+var plots = PS.sortPlots(PS.getPlots());
+PS.log("Attempting to auto merge " + plots.size() + " plots");
+if ("%s0" === "true") {
+ for (var i = 0; i < plots.size(); i++) {
+ var plot = plots.get(i);
+ plot.autoMerge(false);
+ }
+}
+else if ("%s0" === "false") {
+ for (var i = 0; i < plots.size(); i++) {
+ var plot = plots.get(i);
+ plot.autoMerge(false);
+ }
+}
+else {
+ C_COMMAND_SYNTAX.send(PlotPlayer, "/plot debugexec automerge.js ");
+ MainUtil.sendMessage(PlotPlayer, "$1 is true or false if you want to remove roads when auto merging");
+}
\ No newline at end of file