Updated Printing the furthest plot (markdown)

NotMyFault 2020-02-16 18:06:20 +01:00
parent 5607785322
commit 4aa853e2cf

@ -1,24 +1,34 @@
## This guide is for PlotSquared versions <= 1.12.2
``` javascript ``` javascript
/* /*
* Script to find the furthest plot from origin in a world: * Script to find the furthest plot from origin in a world:
* - /plot debugexec runasync furthest.js <plotworld> * - /plot debugexec runasync furthest.js <plotworld>
*/ */
if (PS.isPlotWorld("%s0")) { if (PS.hasPlotArea("%s0")) {
plots=PS.getPlotAreaByString("l").getPlots(); var plots = PS.getAllPlotsRaw().get("%s0").values().toArray();
iter=plots.iterator(); var max = 0;
max=0; var maxplot;
while(iter.hasNext()){ for (var i in plots) {
plot=iter.next(); var plot = plots[i];
if(t=Math.max(Math.abs(plot.id.x),Math.abs(plot.id.y))>max){ if (plot.x > max) {
max=t; max = plot.x;
maxPlot=plot maxplot = plot;
} }
}; if (plot.y > max) {
PS.class.static.log(maxPlot); max = plot.y;
} maxplot = plot;
else { }
if (-plot.x > max) {
max = -plot.x;
maxplot = plot;
}
if (-plot.y > max) {
max = -plot.y;
maxplot = plot;
}
}
PS.class.static.log(plot);
} else {
PlotPlayer.sendMessage("Usage: /plot debugexec runasync furthest.js <plotworld>"); PlotPlayer.sendMessage("Usage: /plot debugexec runasync furthest.js <plotworld>");
} }
``` ```