mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 11:55:38 +01:00
Move confirmation to commands.yml
This commit is contained in:
parent
ed62ed2487
commit
7ab8d22325
@ -1951,11 +1951,6 @@ public class PS {
|
||||
this.config.set("platform", this.platform);
|
||||
|
||||
Map<String, Object> options = new HashMap<>();
|
||||
// Command confirmation
|
||||
options.put("confirmation.setowner", Settings.CONFIRM_SETOWNER);
|
||||
options.put("confirmation.clear", Settings.CONFIRM_CLEAR);
|
||||
options.put("confirmation.delete", Settings.CONFIRM_DELETE);
|
||||
options.put("confirmation.unlink", Settings.CONFIRM_UNLINK);
|
||||
|
||||
// Protection
|
||||
options.put("protection.redstone.disable-offline", Settings.REDSTONE_DISABLER);
|
||||
@ -2081,12 +2076,6 @@ public class PS {
|
||||
}
|
||||
}
|
||||
|
||||
// Command confirmation
|
||||
Settings.CONFIRM_SETOWNER = this.config.getBoolean("confirmation.setowner");
|
||||
Settings.CONFIRM_CLEAR = this.config.getBoolean("confirmation.clear");
|
||||
Settings.CONFIRM_DELETE = this.config.getBoolean("confirmation.delete");
|
||||
Settings.CONFIRM_UNLINK = this.config.getBoolean("confirmation.unlink");
|
||||
|
||||
// Protection
|
||||
Settings.REDSTONE_DISABLER = this.config.getBoolean("protection.redstone.disable-offline");
|
||||
Settings.REDSTONE_DISABLER_UNOCCUPIED = this.config.getBoolean("protection.redstone.disable-unoccupied");
|
||||
|
@ -38,7 +38,8 @@ import java.util.Set;
|
||||
requiredType = RequiredType.NONE,
|
||||
description = "Create a new PlotArea",
|
||||
aliases = "world",
|
||||
usage = "/plot area <create|info|list|tp|regen>")
|
||||
usage = "/plot area <create|info|list|tp|regen>",
|
||||
confirmation=true)
|
||||
public class Area extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -113,7 +114,7 @@ public class Area extends SubCommand {
|
||||
object.setupGenerator = "PlotSquared";
|
||||
object.step = area.getSettingNodes();
|
||||
final String path = "worlds." + area.worldname + ".areas." + area.id + "-" + object.min + "-" + object.max;
|
||||
CmdConfirm.addPending(plr, "/plot area create pos2 (Creates world)", new Runnable() {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (offsetx != 0) {
|
||||
@ -139,7 +140,12 @@ public class Area extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "An error occured while creating the world: " + area.worldname);
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot area create pos2 (Creates world)", run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -234,7 +240,7 @@ public class Area extends SubCommand {
|
||||
C.SETUP_WORLD_TAKEN.send(plr, pa.worldname);
|
||||
return false;
|
||||
}
|
||||
CmdConfirm.addPending(plr, "/plot area " + StringMan.join(args, " "), new Runnable() {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String path = "worlds." + pa.worldname;
|
||||
@ -259,7 +265,12 @@ public class Area extends SubCommand {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot area " + StringMan.join(args, " "), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (pa.id == null) {
|
||||
|
@ -40,7 +40,8 @@ import java.util.Set;
|
||||
permission = "plots.clear",
|
||||
category = CommandCategory.APPEARANCE,
|
||||
usage = "/plot clear [id]",
|
||||
aliases = "reset")
|
||||
aliases = "reset",
|
||||
confirmation=true)
|
||||
public class Clear extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -118,7 +119,7 @@ public class Clear extends SubCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_CLEAR && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot clear " + plot.getId(), runnable);
|
||||
} else {
|
||||
TaskManager.runTask(runnable);
|
||||
|
@ -21,7 +21,6 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
@ -32,7 +31,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -42,7 +40,8 @@ import java.util.HashSet;
|
||||
usage = "/plot delete",
|
||||
aliases = {"dispose", "del"},
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
requiredType = RequiredType.NONE,
|
||||
confirmation=true)
|
||||
public class Delete extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -90,7 +89,7 @@ public class Delete extends SubCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_DELETE && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run);
|
||||
} else {
|
||||
TaskManager.runTask(run);
|
||||
|
@ -42,7 +42,8 @@ import java.util.UUID;
|
||||
description = "Merge the plot you are standing on, with another plot",
|
||||
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
|
||||
category = CommandCategory.SETTINGS,
|
||||
requiredType = RequiredType.NONE)
|
||||
requiredType = RequiredType.NONE,
|
||||
confirmation=true)
|
||||
public class Merge extends SubCommand {
|
||||
|
||||
public final static String[] values = new String[]{"north", "east", "south", "west", "auto"};
|
||||
@ -180,7 +181,7 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
isOnline = true;
|
||||
final int dir = direction;
|
||||
CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), new Runnable() {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(accepter, C.MERGE_ACCEPTED);
|
||||
@ -200,7 +201,12 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
}
|
||||
});
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(accepter, C.MERGE_REQUEST_CONFIRM.s().replaceAll("%s", plr.getName()), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
}
|
||||
if (!isOnline) {
|
||||
MainUtil.sendMessage(plr, C.NO_AVAILABLE_AUTOMERGE);
|
||||
|
@ -41,7 +41,8 @@ import java.util.UUID;
|
||||
usage = "/plot setowner <player>",
|
||||
aliases = {"owner", "so", "seto"},
|
||||
category = CommandCategory.CLAIMING,
|
||||
requiredType = RequiredType.NONE)
|
||||
requiredType = RequiredType.NONE,
|
||||
confirmation=true)
|
||||
public class Owner extends SetCommand {
|
||||
|
||||
@Override
|
||||
@ -104,7 +105,7 @@ public class Owner extends SetCommand {
|
||||
}
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_SETOWNER && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot set owner " + value, run);
|
||||
} else {
|
||||
TaskManager.runTask(run);
|
||||
|
@ -43,7 +43,8 @@ import java.util.UUID;
|
||||
permission = "plots.admin",
|
||||
description = "Purge all plots for a world",
|
||||
category = CommandCategory.ADMINISTRATION,
|
||||
requiredType = RequiredType.CONSOLE)
|
||||
requiredType = RequiredType.CONSOLE,
|
||||
confirmation=true)
|
||||
public class Purge extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -167,7 +168,7 @@ public class Purge extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
String cmd = "/plot purge " + StringMan.join(args, " ") + " (" + toDelete.size() + " plots)";
|
||||
CmdConfirm.addPending(plr, cmd, new Runnable() {
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
HashSet<Integer> ids = new HashSet<Integer>();
|
||||
@ -181,7 +182,12 @@ public class Purge extends SubCommand {
|
||||
DBFunc.purgeIds(ids);
|
||||
C.PURGE_SUCCESS.send(plr, ids.size() + "/" + toDelete.size());
|
||||
}
|
||||
});
|
||||
};
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, cmd, run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,6 @@
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
@ -37,7 +36,8 @@ import com.plotsquared.general.commands.CommandDeclaration;
|
||||
description = "Unlink a mega-plot",
|
||||
usage = "/plot unlink",
|
||||
requiredType = RequiredType.NONE,
|
||||
category = CommandCategory.SETTINGS)
|
||||
category = CommandCategory.SETTINGS,
|
||||
confirmation=true)
|
||||
public class Unlink extends SubCommand {
|
||||
|
||||
@Override
|
||||
@ -77,7 +77,7 @@ public class Unlink extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.UNLINK_SUCCESS);
|
||||
}
|
||||
};
|
||||
if (Settings.CONFIRM_UNLINK && !Permissions.hasPermission(plr, "plots.confirm.bypass")) {
|
||||
if (hasConfirmation(plr)) {
|
||||
CmdConfirm.addPending(plr, "/plot unlink " + plot.getId(), runnable);
|
||||
} else {
|
||||
TaskManager.runTask(runnable);
|
||||
|
@ -172,13 +172,6 @@ public class Settings {
|
||||
public static boolean TWIN_MODE_UUID = false;
|
||||
public static boolean OFFLINE_MODE = false;
|
||||
public static boolean UUID_LOWERCASE = false;
|
||||
/**
|
||||
* Command confirmation
|
||||
*/
|
||||
public static boolean CONFIRM_SETOWNER = true;
|
||||
public static boolean CONFIRM_CLEAR = true;
|
||||
public static boolean CONFIRM_DELETE = true;
|
||||
public static boolean CONFIRM_UNLINK = true;
|
||||
/**
|
||||
* Use global plot limit?
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user