Update scripts and code to work nicely with each other.

Fixes #2208
This commit is contained in:
dordsor21
2019-01-12 19:56:11 +00:00
parent f62777bc1a
commit d81d3c72e4
10 changed files with 113 additions and 20 deletions

View File

@ -0,0 +1,18 @@
/*
This will increase a player's allowed plots by the provided value
/plot debugexec runasync addperm <player> <amount>
*/
var uuid = UUIDHandler.getUUID('%s0', null);
if (uuid === null) {
C_INVALID_PLAYER.send(PlotPlayer, '%s0');
}
else if (!MathMan.class.static.isInteger('%s1')) {
C_NOT_VALID_NUMBER.send(PlotPlayer, '(0, ' + Settings.MAX_PLOTS + ')');
}
else {
var amount = parseInt('%s1');
var pp = IMP.wrapPlayer(UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid).player);
var allowed = pp.getAllowedPlots();
MainUtil.class.static.sendMessage(PlotPlayer, '$4Setting permission: plots.plot.' + (allowed + amount) + ' for %s0');
IMP.getEconomyHandler().setPermission("", pp.getName(), 'plots.plot.' + (allowed + amount), true);
}

View File

@ -0,0 +1,12 @@
/*
This script will fix all signs in the world.
*/
var plots = PS.sortPlots(PS.getPlots());
for (var i = 0; i < plots.size(); i++) {
var plot = plots.get(i);
if (!plot.isMerged() || !plot.getMerged(0)) {
plot.setSign();
PS.class.static.log('&cSetting sign for: ' + plot);
}
java.lang.Thread.sleep(10);
}

View File

@ -5,7 +5,7 @@ Need to script something quick with PlotSquared?
This is an example script that will auto merge all plots
The following utility classes are usable:
- PS
- PlotSquared
- TaskManager
- TitleManager
- ConsolePlayer
@ -33,16 +33,16 @@ PS.class.static.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);
plot.autoMerge(-1, 250000, plot.owner, true);
}
}
else if ("%s0" === "false") {
for (var i = 0; i < plots.size(); i++) {
var plot = plots.get(i);
plot.autoMerge(false);
plot.autoMerge(-1, 250000, plot.owner, false);
}
}
else {
C_COMMAND_SYNTAX.send(PlotPlayer, "/plot debugexec automerge.js <removeroads>");
MainUtil.sendMessage(PlotPlayer, "$1<removeroads> is true or false if you want to remove roads when auto merging");
MainUtil.class.static.sendMessage(PlotPlayer, "$1<removeroads> is true or false if you want to remove roads when auto merging");
}

View File

@ -0,0 +1,33 @@
/*
* Script to find the furthest plot from origin in a world:
* - /plot debugexec runasync furthest.js <plotworld>
*/
if (PS.hasPlotArea("%s0")) {
var plots = PS.getAllPlotsRaw().get("%s0").values().toArray();
var max = 0;
var maxplot;
for (var i in plots) {
var plot = plots[i];
if (plot.x > max) {
max = plot.x;
maxplot = plot;
}
if (plot.y > max) {
max = plot.y;
maxplot = plot;
}
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>");
}

View File

@ -0,0 +1,2 @@
// This command is registered from the start.js file which is run during startup
PlotPlayer.sendMessage("Hello World!");

View File

@ -0,0 +1,12 @@
/*
This script will reset all biomes in claimed plots
*/
var plots = PS.sortPlots(PS.getPlots());
for (var i = 0; i < plots.size(); i++) {
var plot = plots.get(i);
if (!plot.isMerged() || !plot.getMerged(0)) {
plot.setBiome("%s0", null);
PS.class.static.log('&cSetting biome for: ' + plot);
}
java.lang.Thread.sleep(1000);
}

View File

@ -0,0 +1,7 @@
// Add your commands to this list
var commands = ["mycommand"];
// Command registration:
for (var i in commands) {
MainCommand.class.static.onCommand(PlotPlayer, "plot", "debugexec", "addcmd", commands[i] + ".js");
}