Reformat code

This commit is contained in:
Alexander Söderberg 2020-02-18 13:41:08 +01:00
parent 800dcecfe6
commit 00c435e29b
146 changed files with 1002 additions and 968 deletions

View File

@ -81,7 +81,8 @@ public abstract class Command {
&& types[2] == String[].class && types[3] == RunnableVal3.class && types[2] == String[].class && types[3] == RunnableVal3.class
&& types[4] == RunnableVal2.class) { && types[4] == RunnableVal2.class) {
Command tmp = new Command(this, true) { Command tmp = new Command(this, true) {
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override
public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
try { try {
@ -264,8 +265,7 @@ public abstract class Command {
if (totalPages != 0) { // Back if (totalPages != 0) { // Back
new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ") new PlotMessage().text("<-").color("$1").command(baseCommand + " " + page).text(" | ")
.color("$3").text("->").color("$3").text(Captions.CLICKABLE.getTranslated()) .color("$3").text("->").color("$3").text(Captions.CLICKABLE.getTranslated())
.color("$2") .color("$2").send(player);
.send(player);
} }
} }

View File

@ -83,7 +83,7 @@ public class YamlConfiguration extends FileConfiguration {
Map<?, ?> input; Map<?, ?> input;
try { try {
input = (Map<?, ?>) yaml.load(contents); input = yaml.load(contents);
} catch (YAMLException e) { } catch (YAMLException e) {
throw new InvalidConfigurationException(e); throw new InvalidConfigurationException(e);
} catch (ClassCastException ignored) { } catch (ClassCastException ignored) {

View File

@ -186,7 +186,7 @@ public class JSONObject {
* @param object An object that has fields that should be used to make a JSONObject. * @param object An object that has fields that should be used to make a JSONObject.
* @param names An array of strings, the names of the fields to be obtained from the object. * @param names An array of strings, the names of the fields to be obtained from the object.
*/ */
public JSONObject(Object object, String names[]) { public JSONObject(Object object, String[] names) {
this(); this();
Class c = object.getClass(); Class c = object.getClass();
for (String name : names) { for (String name : names) {

View File

@ -155,7 +155,7 @@ import java.util.zip.ZipInputStream;
// //
// Register configuration serializable classes // Register configuration serializable classes
// //
// ConfigurationSerialization.registerClass(BlockState.class, "BlockState"); // ConfigurationSerialization.registerClass(BlockState.class, "BlockState");
ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket"); ConfigurationSerialization.registerClass(BlockBucket.class, "BlockBucket");
try { try {
@ -247,7 +247,8 @@ import java.util.zip.ZipInputStream;
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) { if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
try { try {
if (this.IMP.initWorldEdit()) { if (this.IMP.initWorldEdit()) {
PlotSquared.log(Captions.PREFIX + "&6" + IMP.getPluginName() + " hooked into WorldEdit."); PlotSquared.log(Captions.PREFIX + "&6" + IMP.getPluginName()
+ " hooked into WorldEdit.");
this.worldedit = WorldEdit.getInstance(); this.worldedit = WorldEdit.getInstance();
WorldEdit.getInstance().getEventBus().register(new WESubscriber()); WorldEdit.getInstance().getEventBus().register(new WESubscriber());
if (Settings.Enabled_Components.COMMANDS) { if (Settings.Enabled_Components.COMMANDS) {
@ -347,7 +348,8 @@ import java.util.zip.ZipInputStream;
* @see IPlotMain#log(String) * @see IPlotMain#log(String)
*/ */
public static void log(Object message) { public static void log(Object message) {
if (message == null || (message instanceof Caption ? ((Caption) message).getTranslated().isEmpty() : if (message == null || (message instanceof Caption ?
((Caption) message).getTranslated().isEmpty() :
message.toString().isEmpty())) { message.toString().isEmpty())) {
return; return;
} }
@ -1832,7 +1834,8 @@ import java.util.zip.ZipInputStream;
if (this.version != null) { if (this.version != null) {
this.style.set("Version", this.version.toString()); this.style.set("Version", this.version.toString());
} }
this.style.set("Information", "Left Row: PlotSquared color codes ($), right row: Minecraft color codes (&)"); this.style.set("Information",
"Left Row: PlotSquared color codes ($), right row: Minecraft color codes (&)");
Map<String, Object> object = new HashMap<>(16); Map<String, Object> object = new HashMap<>(16);
object.put("color.1", "6"); object.put("color.1", "6");
object.put("color.2", "7"); object.put("color.2", "7");

View File

@ -37,6 +37,7 @@ public class PlotVersion {
return "4." + build; return "4." + build;
} }
} }
@Override public String toString() { @Override public String toString() {
if (hash == 0 && build == 0) { if (hash == 0 && build == 0) {
return "PlotSquared-NoVer-SNAPSHOT"; return "PlotSquared-NoVer-SNAPSHOT";

View File

@ -17,10 +17,8 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "add", @CommandDeclaration(command = "add", description = "Allow a user to build in a plot while the plot owner is online.", usage = "/plot add <player|*>", category = CommandCategory.SETTINGS, permission = "plots.add", requiredType = RequiredType.PLAYER)
description = "Allow a user to build in a plot while the plot owner is online.", public class Add extends Command {
usage = "/plot add <player|*>", category = CommandCategory.SETTINGS, permission = "plots.add",
requiredType = RequiredType.PLAYER) public class Add extends Command {
public Add() { public Add() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);

View File

@ -12,11 +12,10 @@ import com.github.intellectualsites.plotsquared.plot.util.MathMan;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
@CommandDeclaration(command = "setalias", permission = "plots.alias", @CommandDeclaration(command = "setalias", permission = "plots.alias", description = "Set the plot name", usage = "/plot alias <set|remove> <alias>", aliases = {
description = "Set the plot name", usage = "/plot alias <set|remove> <alias>", "alias", "sa", "name", "rename", "setname", "seta",
aliases = {"alias", "sa", "name", "rename", "setname", "seta", "nameplot"}, "nameplot"}, category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER)
category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Alias public class Alias extends SubCommand {
extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {

View File

@ -33,11 +33,8 @@ import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@CommandDeclaration(command = "area", permission = "plots.area", @CommandDeclaration(command = "area", permission = "plots.area", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, description = "Create a new PlotArea", aliases = "world", usage = "/plot area <create|info|list|tp|regen>", confirmation = true)
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, public class Area extends SubCommand {
description = "Create a new PlotArea", aliases = "world",
usage = "/plot area <create|info|list|tp|regen>", confirmation = true) public class Area
extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) { if (args.length == 0) {
@ -135,14 +132,14 @@ import java.util.Set;
if (WorldUtil.IMP.isWorld(world)) { if (WorldUtil.IMP.isWorld(world)) {
PlotSquared.get().loadWorld(world, null); PlotSquared.get().loadWorld(world, null);
Captions.SETUP_FINISHED.send(player); Captions.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND); player.teleport(WorldUtil.IMP.getSpawn(world),
TeleportCause.COMMAND);
if (area.TERRAIN != 3) { if (area.TERRAIN != 3) {
ChunkManager.largeRegionTask(world, region, ChunkManager.largeRegionTask(world, region,
new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
AugmentedUtils AugmentedUtils.generate(world, value.getX(),
.generate(world, value.getX(), value.getZ(), value.getZ(), null);
null);
} }
}, null); }, null);
} }
@ -258,7 +255,8 @@ import java.util.Set;
String world = SetupUtils.manager.setupWorld(object); String world = SetupUtils.manager.setupWorld(object);
if (WorldUtil.IMP.isWorld(world)) { if (WorldUtil.IMP.isWorld(world)) {
Captions.SETUP_FINISHED.send(player); Captions.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND); player.teleport(WorldUtil.IMP.getSpawn(world),
TeleportCause.COMMAND);
} else { } else {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"An error occurred while creating the world: " "An error occurred while creating the world: "
@ -285,13 +283,15 @@ import java.util.Set;
} }
if (WorldUtil.IMP.isWorld(pa.worldname)) { if (WorldUtil.IMP.isWorld(pa.worldname)) {
if (!player.getLocation().getWorld().equals(pa.worldname)) { if (!player.getLocation().getWorld().equals(pa.worldname)) {
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname), TeleportCause.COMMAND); player.teleport(WorldUtil.IMP.getSpawn(pa.worldname),
TeleportCause.COMMAND);
} }
} else { } else {
object.terrain = 0; object.terrain = 0;
object.type = 0; object.type = 0;
SetupUtils.manager.setupWorld(object); SetupUtils.manager.setupWorld(object);
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname), TeleportCause.COMMAND); player.teleport(WorldUtil.IMP.getSpawn(pa.worldname),
TeleportCause.COMMAND);
} }
player.setMeta("area_create_area", pa); player.setMeta("area_create_area", pa);
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
@ -432,10 +432,11 @@ import java.util.Set;
"$4Stop the server and delete: " + area.worldname + "/region"); "$4Stop the server and delete: " + area.worldname + "/region");
return false; return false;
} }
ChunkManager ChunkManager.largeRegionTask(area.worldname, area.getRegion(),
.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<BlockVector2>() { new RunnableVal<BlockVector2>() {
@Override public void run(BlockVector2 value) { @Override public void run(BlockVector2 value) {
AugmentedUtils.generate(area.worldname, value.getX(), value.getZ(), null); AugmentedUtils
.generate(area.worldname, value.getX(), value.getZ(), null);
} }
}, () -> player.sendMessage("Regen complete")); }, () -> player.sendMessage("Regen complete"));
return true; return true;
@ -463,9 +464,10 @@ import java.util.Set;
center = WorldUtil.IMP.getSpawn(area.worldname); center = WorldUtil.IMP.getSpawn(area.worldname);
} else { } else {
CuboidRegion region = area.getRegion(); CuboidRegion region = area.getRegion();
center = center = new Location(area.worldname, region.getMinimumPoint().getX()
new Location(area.worldname, region.getMinimumPoint().getX() + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2, + (region.getMaximumPoint().getX() - region.getMinimumPoint().getX()) / 2,
0, region.getMinimumPoint().getZ() + (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2); 0, region.getMinimumPoint().getZ()
+ (region.getMaximumPoint().getZ() - region.getMinimumPoint().getZ()) / 2);
center.setY(1 + WorldUtil.IMP center.setY(1 + WorldUtil.IMP
.getHighestBlock(area.worldname, center.getX(), center.getZ())); .getHighestBlock(area.worldname, center.getX(), center.getZ()));
} }

View File

@ -23,9 +23,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.Set; import java.util.Set;
@CommandDeclaration(command = "auto", permission = "plots.auto", @CommandDeclaration(command = "auto", permission = "plots.auto", category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE, description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]")
category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE,
description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]")
public class Auto extends SubCommand { public class Auto extends SubCommand {
@Deprecated public static PlotId getNextPlotId(PlotId id, int step) { @Deprecated public static PlotId getNextPlotId(PlotId id, int step) {
@ -177,7 +175,7 @@ public class Auto extends SubCommand {
try { try {
String[] split = args[0].split(",|;"); String[] split = args[0].split(",|;");
if (split[1] == null) { if (split[1] == null) {
MainUtil.sendMessage(player,"Correct use /plot auto [length,width]"); MainUtil.sendMessage(player, "Correct use /plot auto [length,width]");
size_x = 1; size_x = 1;
size_z = 1; size_z = 1;
} else { } else {
@ -220,12 +218,12 @@ public class Auto extends SubCommand {
sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic); sendMessage(player, Captions.SCHEMATIC_INVALID, "non-existent: " + schematic);
return true; return true;
} }
if (!Permissions.hasPermission(player, if (!Permissions.hasPermission(player, CaptionUtility
CaptionUtility.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) .format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
CaptionUtility.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)); .format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic));
return true; return true;
} }
} }

View File

@ -9,16 +9,17 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
@CommandDeclaration(command = "setbiome", permission = "plots.set.biome", @CommandDeclaration(command = "setbiome", permission = "plots.set.biome", description = "Set the plot biome", usage = "/plot biome [biome]", aliases = {
description = "Set the plot biome", usage = "/plot biome [biome]", "biome", "sb", "setb",
aliases = {"biome", "sb", "setb", "b"}, category = CommandCategory.APPEARANCE, "b"}, category = CommandCategory.APPEARANCE, requiredType = RequiredType.NONE)
requiredType = RequiredType.NONE) public class Biome extends SetCommand { public class Biome extends SetCommand {
@Override public boolean set(final PlotPlayer player, final Plot plot, final String value) { @Override public boolean set(final PlotPlayer player, final Plot plot, final String value) {
BiomeType biome = null; BiomeType biome = null;
try { try {
biome = BiomeTypes.get(value.toLowerCase()); biome = BiomeTypes.get(value.toLowerCase());
} catch (final Exception ignore) {} } catch (final Exception ignore) {
}
if (biome == null) { if (biome == null) {
String biomes = StringMan String biomes = StringMan
.join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated()); .join(BiomeType.REGISTRY.values(), Captions.BLOCK_LIST_SEPARATOR.getTranslated());

View File

@ -15,9 +15,8 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "buy", description = "Buy the plot you are standing on", @CommandDeclaration(command = "buy", description = "Buy the plot you are standing on", usage = "/plot buy", permission = "plots.buy", category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE)
usage = "/plot buy", permission = "plots.buy", category = CommandCategory.CLAIMING, public class Buy extends Command {
requiredType = RequiredType.NONE) public class Buy extends Command {
public Buy() { public Buy() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);

View File

@ -3,9 +3,8 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "chat", description = "Toggle plot chat on or off", @CommandDeclaration(command = "chat", description = "Toggle plot chat on or off", usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER)
usage = "/plot chat [on|off]", permission = "plots.chat", category = CommandCategory.CHAT, public class Chat extends SubCommand {
requiredType = RequiredType.PLAYER) public class Chat extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null); MainCommand.getInstance().toggle.chat(this, player, new String[0], null, null);

View File

@ -17,9 +17,7 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
import com.google.common.primitives.Ints; import com.google.common.primitives.Ints;
@CommandDeclaration(command = "claim", aliases = "c", @CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER, permission = "plots.claim", usage = "/plot claim")
description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER, permission = "plots.claim", usage = "/plot claim")
public class Claim extends SubCommand { public class Claim extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
@ -38,8 +36,7 @@ public class Claim extends SubCommand {
int grants = 0; int grants = 0;
if (currentPlots >= player.getAllowedPlots()) { if (currentPlots >= player.getAllowedPlots()) {
if (player.hasPersistentMeta("grantedPlots")) { if (player.hasPersistentMeta("grantedPlots")) {
grants = grants = Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
Ints.fromByteArray(player.getPersistentMeta("grantedPlots"));
if (grants <= 0) { if (grants <= 0) {
player.removePersistentMeta("grantedPlots"); player.removePersistentMeta("grantedPlots");
return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS); return sendMessage(player, Captions.CANT_CLAIM_MORE_PLOTS);
@ -58,8 +55,7 @@ public class Claim extends SubCommand {
return sendMessage(player, Captions.SCHEMATIC_INVALID, return sendMessage(player, Captions.SCHEMATIC_INVALID,
"non-existent: " + schematic); "non-existent: " + schematic);
} }
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, CaptionUtility
.format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic)) .format(Captions.PERMISSION_CLAIM_SCHEMATIC.getTranslated(), schematic))
&& !Permissions && !Permissions
.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_SCHEMATIC)) {
@ -86,8 +82,7 @@ public class Claim extends SubCommand {
if (grants == 1) { if (grants == 1) {
player.removePersistentMeta("grantedPlots"); player.removePersistentMeta("grantedPlots");
} else { } else {
player.setPersistentMeta("grantedPlots", player.setPersistentMeta("grantedPlots", Ints.toByteArray(grants - 1));
Ints.toByteArray(grants - 1));
} }
sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1)); sendMessage(player, Captions.REMOVED_GRANTED_PLOT, "1", "" + (grants - 1));
} }

View File

@ -16,9 +16,8 @@ import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "clear", description = "Clear the plot you stand on", requiredType = RequiredType.NONE, @CommandDeclaration(command = "clear", description = "Clear the plot you stand on", requiredType = RequiredType.NONE, permission = "plots.clear", category = CommandCategory.APPEARANCE, usage = "/plot clear", aliases = "reset", confirmation = true)
permission = "plots.clear", category = CommandCategory.APPEARANCE, usage = "/plot clear", public class Clear extends Command {
aliases = "reset", confirmation = true) public class Clear extends Command {
// Note: To clear a specific plot use /plot <plot> clear // Note: To clear a specific plot use /plot <plot> clear
// The syntax also works with any command: /plot <plot> <command> // The syntax also works with any command: /plot <plot> <command>

View File

@ -22,10 +22,8 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "cluster", aliases = "clusters", @CommandDeclaration(command = "cluster", aliases = "clusters", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, permission = "plots.cluster", description = "Manage a plot cluster")
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, public class Cluster extends SubCommand {
permission = "plots.cluster", description = "Manage a plot cluster") public class Cluster
extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {

View File

@ -16,8 +16,8 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.Arrays; import java.util.Arrays;
import java.util.Map.Entry; import java.util.Map.Entry;
@CommandDeclaration(command = "comment", aliases = {"msg"}, description = "Comment on a plot", @CommandDeclaration(command = "comment", aliases = {
category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER, permission = "plots.comment") "msg"}, description = "Comment on a plot", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER, permission = "plots.comment")
public class Comment extends SubCommand { public class Comment extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {

View File

@ -19,10 +19,8 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@CommandDeclaration(command = "condense", permission = "plots.admin", @CommandDeclaration(command = "condense", permission = "plots.admin", usage = "/plot condense <area> <start|stop|info> [radius]", description = "Condense a plotworld", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE)
usage = "/plot condense <area> <start|stop|info> [radius]", public class Condense extends SubCommand {
description = "Condense a plotworld", category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.CONSOLE) public class Condense extends SubCommand {
public static boolean TASK = false; public static boolean TASK = false;

View File

@ -9,9 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.util.CmdConfirm;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@CommandDeclaration(command = "confirm", permission = "plots.use", @CommandDeclaration(command = "confirm", permission = "plots.use", description = "Confirm an action", category = CommandCategory.INFO)
description = "Confirm an action", category = CommandCategory.INFO) public class Confirm public class Confirm extends SubCommand {
extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
CmdInstance command = CmdConfirm.getPending(player); CmdInstance command = CmdConfirm.getPending(player);

View File

@ -9,10 +9,8 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(command = "continue", @CommandDeclaration(command = "continue", description = "Continue a plot that was previously marked as done", permission = "plots.continue", category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER)
description = "Continue a plot that was previously marked as done", public class Continue extends SubCommand {
permission = "plots.continue", category = CommandCategory.SETTINGS,
requiredType = RequiredType.PLAYER) public class Continue extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();

View File

@ -8,9 +8,9 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(command = "copy", permission = "plots.copy", aliases = {"copypaste"}, @CommandDeclaration(command = "copy", permission = "plots.copy", aliases = {
category = CommandCategory.CLAIMING, description = "Copy a plot", usage = "/plot copy <X;Z>", "copypaste"}, category = CommandCategory.CLAIMING, description = "Copy a plot", usage = "/plot copy <X;Z>", requiredType = RequiredType.NONE)
requiredType = RequiredType.NONE) public class Copy extends SubCommand { public class Copy extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -9,11 +9,9 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "createroadschematic", aliases = {"crs"}, @CommandDeclaration(command = "createroadschematic", aliases = {
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.PLAYER, "crs"}, category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.PLAYER, permission = "plots.createroadschematic", description = "Add a road schematic to your world using the roads around your current plot", usage = "/plot createroadschematic")
permission = "plots.createroadschematic", public class CreateRoadSchematic extends SubCommand {
description = "Add a road schematic to your world using the roads around your current plot",
usage = "/plot createroadschematic") public class CreateRoadSchematic extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -22,11 +22,9 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
@CommandDeclaration(command = "database", aliases = {"convert"}, @CommandDeclaration(command = "database", aliases = {
category = CommandCategory.ADMINISTRATION, permission = "plots.database", "convert"}, category = CommandCategory.ADMINISTRATION, permission = "plots.database", description = "Convert/Backup Storage", requiredType = RequiredType.CONSOLE, usage = "/plot database [area] <sqlite|mysql|import>")
description = "Convert/Backup Storage", requiredType = RequiredType.CONSOLE, public class Database extends SubCommand {
usage = "/plot database [area] <sqlite|mysql|import>") public class Database
extends SubCommand {
public static void insertPlots(final SQLManager manager, final List<Plot> plots, public static void insertPlots(final SQLManager manager, final List<Plot> plots,
final PlotPlayer player) { final PlotPlayer player) {

View File

@ -9,8 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.Map; import java.util.Map;
@CommandDeclaration(command = "debug", category = CommandCategory.DEBUG, @CommandDeclaration(command = "debug", category = CommandCategory.DEBUG, description = "Show debug information", usage = "/plot debug [msg]", permission = "plots.admin")
description = "Show debug information", usage = "/plot debug [msg]", permission = "plots.admin")
public class Debug extends SubCommand { public class Debug extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
@ -19,7 +18,6 @@ public class Debug extends SubCommand {
MainUtil.sendMessage(player, MainUtil.sendMessage(player,
"Key: " + meta.getKey() + " Value: " + meta.getValue().toString() + " , "); "Key: " + meta.getKey() + " Value: " + meta.getValue().toString() + " , ");
} }
;
} }
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
StringBuilder msg = new StringBuilder(); StringBuilder msg = new StringBuilder();

View File

@ -8,10 +8,8 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "debugallowunsafe", @CommandDeclaration(command = "debugallowunsafe", description = "Allow unsafe actions until toggled off", usage = "/plot debugallowunsafe", category = CommandCategory.DEBUG, requiredType = RequiredType.NONE, permission = "plots.debugallowunsafe")
description = "Allow unsafe actions until toggled off", usage = "/plot debugallowunsafe", public class DebugAllowUnsafe extends SubCommand {
category = CommandCategory.DEBUG, requiredType = RequiredType.NONE,
permission = "plots.debugallowunsafe") public class DebugAllowUnsafe extends SubCommand {
public static final List<UUID> unsafeAllowed = new ArrayList<>(); public static final List<UUID> unsafeAllowed = new ArrayList<>();

View File

@ -56,7 +56,8 @@ public class DebugClaimTest extends SubCommand {
PlotManager manager = area.getPlotManager(); PlotManager manager = area.getPlotManager();
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(min, max); ArrayList<PlotId> ids = MainUtil.getPlotSelectionIds(min, max);
MainUtil.sendMessage(player, "&3Sign Block&8->&3Plot&8: " + ids.size() + " plot ids to check!"); MainUtil.sendMessage(player,
"&3Sign Block&8->&3Plot&8: " + ids.size() + " plot ids to check!");
for (PlotId id : ids) { for (PlotId id : ids) {
Plot plot = area.getPlotAbs(id); Plot plot = area.getPlotAbs(id);
if (plot.hasOwner()) { if (plot.hasOwner()) {
@ -74,7 +75,8 @@ public class DebugClaimTest extends SubCommand {
BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap(); BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
UUID uuid = map.get(new StringWrapper(line)); UUID uuid = map.get(new StringWrapper(line));
if (uuid == null) { if (uuid == null) {
for (Map.Entry<StringWrapper, UUID> stringWrapperUUIDEntry : map.entrySet()) { for (Map.Entry<StringWrapper, UUID> stringWrapperUUIDEntry : map
.entrySet()) {
if (stringWrapperUUIDEntry.getKey().value.toLowerCase() if (stringWrapperUUIDEntry.getKey().value.toLowerCase()
.startsWith(line.toLowerCase())) { .startsWith(line.toLowerCase())) {
uuid = stringWrapperUUIDEntry.getValue(); uuid = stringWrapperUUIDEntry.getValue();
@ -86,11 +88,13 @@ public class DebugClaimTest extends SubCommand {
uuid = UUIDHandler.getUUID(line, null); uuid = UUIDHandler.getUUID(line, null);
} }
if (uuid != null) { if (uuid != null) {
MainUtil.sendMessage(player, " - &aFound plot: " + plot.getId() + " : " + line); MainUtil.sendMessage(player,
" - &aFound plot: " + plot.getId() + " : " + line);
plot.setOwner(uuid); plot.setOwner(uuid);
MainUtil.sendMessage(player, " - &8Updated plot: " + plot.getId()); MainUtil.sendMessage(player, " - &8Updated plot: " + plot.getId());
} else { } else {
MainUtil.sendMessage(player, " - &cInvalid PlayerName: " + plot.getId() + " : " + line); MainUtil.sendMessage(player,
" - &cInvalid PlayerName: " + plot.getId() + " : " + line);
} }
} }
} }

View File

@ -55,9 +55,8 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugexec", permission = "plots.admin", @CommandDeclaration(command = "debugexec", permission = "plots.admin", description = "Mutli-purpose debug command", aliases = {
description = "Mutli-purpose debug command", aliases = {"exec", "$"}, "exec", "$"}, category = CommandCategory.DEBUG) public class DebugExec extends SubCommand {
category = CommandCategory.DEBUG) public class DebugExec extends SubCommand {
private ScriptEngine engine; private ScriptEngine engine;
private Bindings scope; private Bindings scope;
@ -306,8 +305,8 @@ import java.util.concurrent.CompletableFuture;
System.getProperty("line.separator")); System.getProperty("line.separator"));
new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null, new Command(MainCommand.getInstance(), true, args[1].split("\\.")[0], null,
RequiredType.NONE, CommandCategory.DEBUG) { RequiredType.NONE, CommandCategory.DEBUG) {
@Override public CompletableFuture<Boolean> execute(PlotPlayer player, String[] args, @Override public CompletableFuture<Boolean> execute(PlotPlayer player,
RunnableVal3<Command, Runnable, Runnable> confirm, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
try { try {
DebugExec.this.scope.put("PlotPlayer", player); DebugExec.this.scope.put("PlotPlayer", player);

View File

@ -16,9 +16,7 @@ import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.Map.Entry; import java.util.Map.Entry;
@CommandDeclaration(command = "debugfixflags", usage = "/plot debugfixflags <world>", @CommandDeclaration(command = "debugfixflags", usage = "/plot debugfixflags <world>", permission = "plots.debugfixflags", description = "Attempt to fix all flags for a world", requiredType = RequiredType.CONSOLE, category = CommandCategory.DEBUG)
permission = "plots.debugfixflags", description = "Attempt to fix all flags for a world",
requiredType = RequiredType.CONSOLE, category = CommandCategory.DEBUG)
public class DebugFixFlags extends SubCommand { public class DebugFixFlags extends SubCommand {
public DebugFixFlags() { public DebugFixFlags() {

View File

@ -18,9 +18,8 @@ import java.io.File;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "debugimportworlds", permission = "plots.admin", @CommandDeclaration(command = "debugimportworlds", permission = "plots.admin", description = "Import worlds by player name", requiredType = RequiredType.CONSOLE, category = CommandCategory.TELEPORT)
description = "Import worlds by player name", requiredType = RequiredType.CONSOLE, public class DebugImportWorlds extends Command {
category = CommandCategory.TELEPORT) public class DebugImportWorlds extends Command {
public DebugImportWorlds() { public DebugImportWorlds() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }

View File

@ -5,10 +5,8 @@ import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.database.DBFunc; import com.github.intellectualsites.plotsquared.plot.database.DBFunc;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "debugloadtest", permission = "plots.debugloadtest", @CommandDeclaration(command = "debugloadtest", permission = "plots.debugloadtest", description = "This debug command will force the reload of all plots in the DB", usage = "/plot debugloadtest", category = CommandCategory.DEBUG, requiredType = RequiredType.CONSOLE)
description = "This debug command will force the reload of all plots in the DB", public class DebugLoadTest extends SubCommand {
usage = "/plot debugloadtest", category = CommandCategory.DEBUG,
requiredType = RequiredType.CONSOLE) public class DebugLoadTest extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
PlotSquared.get().plots_tmp = DBFunc.getPlots(); PlotSquared.get().plots_tmp = DBFunc.getPlots();

View File

@ -25,9 +25,7 @@ import java.util.Map;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste", @CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste", description = "Upload settings.yml, worlds.yml, PlotSquared.use_THIS.yml your latest.log and Multiverse's worlds.yml (if being used) to https://athion.net/ISPaster/paste", permission = "plots.debugpaste", category = CommandCategory.DEBUG, confirmation = true, requiredType = RequiredType.NONE)
description = "Upload settings.yml, worlds.yml, PlotSquared.use_THIS.yml your latest.log and Multiverse's worlds.yml (if being used) to https://athion.net/ISPaster/paste",
permission = "plots.debugpaste", category = CommandCategory.DEBUG, confirmation = true, requiredType = RequiredType.NONE)
public class DebugPaste extends SubCommand { public class DebugPaste extends SubCommand {
private static String readFile(@NonNull final File file) throws IOException { private static String readFile(@NonNull final File file) throws IOException {
@ -56,7 +54,8 @@ public class DebugPaste extends SubCommand {
b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(';') b.append("online_mode: ").append(UUIDHandler.getUUIDWrapper()).append(';')
.append(!Settings.UUID.OFFLINE).append('\n'); .append(!Settings.UUID.OFFLINE).append('\n');
b.append("Plugins:"); b.append("Plugins:");
for (Map.Entry<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared.get().IMP.getPluginIds()) { for (Map.Entry<Map.Entry<String, String>, Boolean> pluginInfo : PlotSquared
.get().IMP.getPluginIds()) {
Map.Entry<String, String> nameVersion = pluginInfo.getKey(); Map.Entry<String, String> nameVersion = pluginInfo.getKey();
String name = nameVersion.getKey(); String name = nameVersion.getKey();
String version = nameVersion.getValue(); String version = nameVersion.getValue();
@ -67,12 +66,17 @@ public class DebugPaste extends SubCommand {
b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n"); b.append("\n\n# YAY! Now, let's see what we can find in your JVM\n");
Runtime runtime = Runtime.getRuntime(); Runtime runtime = Runtime.getRuntime();
RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean(); RuntimeMXBean rb = ManagementFactory.getRuntimeMXBean();
b.append("Uptime: ").append(TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS) + " minutes").append('\n'); b.append("Uptime: ").append(
TimeUnit.MINUTES.convert(rb.getUptime(), TimeUnit.MILLISECONDS) + " minutes")
.append('\n');
b.append("JVM Flags: ").append(rb.getInputArguments()).append('\n'); b.append("JVM Flags: ").append(rb.getInputArguments()).append('\n');
b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024 + " MB").append('\n'); b.append("Free Memory: ").append(runtime.freeMemory() / 1024 / 1024 + " MB")
b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024 + " MB").append('\n'); .append('\n');
b.append("Max Memory: ").append(runtime.maxMemory() / 1024 / 1024 + " MB")
.append('\n');
b.append("Java Name: ").append(rb.getVmName()).append('\n'); b.append("Java Name: ").append(rb.getVmName()).append('\n');
b.append("Java Version: '").append(System.getProperty("java.version")).append("'\n"); b.append("Java Version: '").append(System.getProperty("java.version"))
.append("'\n");
b.append("Java Vendor: '").append(System.getProperty("java.vendor")).append("'\n"); b.append("Java Vendor: '").append(System.getProperty("java.vendor")).append("'\n");
b.append("Operating System: '").append(System.getProperty("os.name")).append("'\n"); b.append("Operating System: '").append(System.getProperty("os.name")).append("'\n");
b.append("OS Version: ").append(System.getProperty("os.version")).append('\n'); b.append("OS Version: ").append(System.getProperty("os.version")).append('\n');
@ -119,12 +123,13 @@ public class DebugPaste extends SubCommand {
} }
try { try {
final File MultiverseWorlds = final File MultiverseWorlds = new File(PlotSquared.get().IMP.getDirectory(),
new File(PlotSquared.get().IMP.getDirectory(), "../Multiverse-Core/worlds.yml"); "../Multiverse-Core/worlds.yml");
incendoPaster incendoPaster.addFile(new IncendoPaster.PasteFile("MultiverseCore/worlds.yml",
.addFile(new IncendoPaster.PasteFile("MultiverseCore/worlds.yml", readFile(MultiverseWorlds))); readFile(MultiverseWorlds)));
} catch (final IOException ignored) { } catch (final IOException ignored) {
MainUtil.sendMessage(player, "&cSkipping Multiverse worlds.yml because the plugin is not in use"); MainUtil.sendMessage(player,
"&cSkipping Multiverse worlds.yml because the plugin is not in use");
} }
try { try {

View File

@ -13,10 +13,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.util.Arrays; import java.util.Arrays;
@CommandDeclaration(command = "debugroadregen", usage = DebugRoadRegen.USAGE, @CommandDeclaration(command = "debugroadregen", usage = DebugRoadRegen.USAGE, requiredType = RequiredType.NONE, description = "Regenerate roads in the plot or region the user is, based on the road schematic", category = CommandCategory.DEBUG, permission = "plots.debugroadregen")
requiredType = RequiredType.NONE,
description = "Regenerate roads in the plot or region the user is, based on the road schematic",
category = CommandCategory.DEBUG, permission = "plots.debugroadregen")
public class DebugRoadRegen extends SubCommand { public class DebugRoadRegen extends SubCommand {
public static final String USAGE = "/plot debugroadregen <plot|region [height]>"; public static final String USAGE = "/plot debugroadregen <plot|region [height]>";
@ -67,13 +64,11 @@ public class DebugRoadRegen extends SubCommand {
height = Integer.parseInt(args[0]); height = Integer.parseInt(args[0]);
} catch (NumberFormatException ignored) { } catch (NumberFormatException ignored) {
MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0, 256)"); MainUtil.sendMessage(player, Captions.NOT_VALID_NUMBER, "(0, 256)");
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE);
DebugRoadRegen.USAGE);
return false; return false;
} }
} else if (args.length != 0) { } else if (args.length != 0) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, DebugRoadRegen.USAGE);
DebugRoadRegen.USAGE);
return false; return false;
} }

View File

@ -9,10 +9,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.util.ArrayList; import java.util.ArrayList;
@CommandDeclaration(command = "debugsavetest", permission = "plots.debugsavetest", @CommandDeclaration(command = "debugsavetest", permission = "plots.debugsavetest", category = CommandCategory.DEBUG, requiredType = RequiredType.CONSOLE, usage = "/plot debugsavetest", description = "This command will force the recreation of all plots in the DB")
category = CommandCategory.DEBUG, requiredType = RequiredType.CONSOLE,
usage = "/plot debugsavetest",
description = "This command will force the recreation of all plots in the DB")
public class DebugSaveTest extends SubCommand { public class DebugSaveTest extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -15,10 +15,10 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@CommandDeclaration(command = "delete", permission = "plots.delete", @CommandDeclaration(command = "delete", permission = "plots.delete", description = "Delete the plot you stand on", usage = "/plot delete", aliases = {
description = "Delete the plot you stand on", usage = "/plot delete", "dispose", "del",
aliases = {"dispose", "del", "unclaim"}, category = CommandCategory.CLAIMING, "unclaim"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE, confirmation = true)
requiredType = RequiredType.NONE, confirmation = true) public class Delete extends SubCommand { public class Delete extends SubCommand {
// Note: To delete a specific plot use /plot <plot> delete // Note: To delete a specific plot use /plot <plot> delete
// The syntax also works with any command: /plot <plot> <command> // The syntax also works with any command: /plot <plot> <command>

View File

@ -18,10 +18,9 @@ import com.sk89q.worldedit.world.gamemode.GameModes;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "deny", aliases = {"d", "ban"}, @CommandDeclaration(command = "deny", aliases = {"d",
description = "Deny a user from entering a plot", usage = "/plot deny <player|*>", "ban"}, description = "Deny a user from entering a plot", usage = "/plot deny <player|*>", category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER)
category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER) public class Deny public class Deny extends SubCommand {
extends SubCommand {
public Deny() { public Deny() {
super(Argument.PlayerName); super(Argument.PlayerName);

View File

@ -7,10 +7,10 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "setdescription", permission = "plots.set.desc", @CommandDeclaration(command = "setdescription", permission = "plots.set.desc", description = "Set the plot description", usage = "/plot desc <description>", aliases = {
description = "Set the plot description", usage = "/plot desc <description>", "desc", "setdesc", "setd",
aliases = {"desc", "setdesc", "setd", "description"}, category = CommandCategory.SETTINGS, "description"}, category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER)
requiredType = RequiredType.PLAYER) public class Desc extends SetCommand { public class Desc extends SetCommand {
@Override public boolean set(PlotPlayer player, Plot plot, String desc) { @Override public boolean set(PlotPlayer player, Plot plot, String desc) {
if (desc.isEmpty()) { if (desc.isEmpty()) {

View File

@ -3,10 +3,8 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "dislike", permission = "plots.dislike", @CommandDeclaration(command = "dislike", permission = "plots.dislike", description = "Dislike the plot", usage = "/plot dislike [next|purge]", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
description = "Dislike the plot", usage = "/plot dislike [next|purge]", public class Dislike extends SubCommand {
category = CommandCategory.INFO, requiredType = RequiredType.PLAYER) public class Dislike
extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
return Like.handleLike(player, args, false); return Like.handleLike(player, args, false);

View File

@ -14,9 +14,9 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager; import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis; import com.github.intellectualsites.plotsquared.plot.util.expiry.PlotAnalysis;
@CommandDeclaration(command = "done", aliases = {"submit"}, description = "Mark a plot as done", @CommandDeclaration(command = "done", aliases = {
permission = "plots.done", category = CommandCategory.SETTINGS, "submit"}, description = "Mark a plot as done", permission = "plots.done", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE)
requiredType = RequiredType.NONE) public class Done extends SubCommand { public class Done extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -17,10 +17,9 @@ import com.sk89q.jnbt.CompoundTag;
import java.net.URL; import java.net.URL;
@CommandDeclaration(usage = "/plot download [schematic|world]", command = "download", @CommandDeclaration(usage = "/plot download [schematic|world]", command = "download", aliases = {
aliases = {"dl"}, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, "dl"}, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download")
description = "Download your plot", permission = "plots.download") public class Download public class Download extends SubCommand {
extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorld();
@ -35,8 +34,8 @@ import java.net.URL;
MainUtil.sendMessage(player, Captions.PLOT_UNOWNED); MainUtil.sendMessage(player, Captions.PLOT_UNOWNED);
return false; return false;
} }
if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!DoneFlag.isDone(plot))) if ((Settings.Done.REQUIRED_FOR_DOWNLOAD && (!DoneFlag.isDone(plot))) && !Permissions
&& !Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) { .hasPermission(player, Captions.PERMISSION_ADMIN_COMMAND_DOWNLOAD)) {
MainUtil.sendMessage(player, Captions.DONE_NOT_DONE); MainUtil.sendMessage(player, Captions.DONE_NOT_DONE);
return false; return false;
} }

View File

@ -30,30 +30,29 @@ import java.util.Map;
import java.util.StringJoiner; import java.util.StringJoiner;
@CommandDeclaration(command = "flag", aliases = {"f", @CommandDeclaration(command = "flag", aliases = {"f",
"flag"}, usage = "/plot flag <set|remove|add|list|info> <flag> <value>", "flag"}, usage = "/plot flag <set|remove|add|list|info> <flag> <value>", description = "Set plot flags", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.flag")
description = "Set plot flags",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
permission = "plots.flag")
public class FlagCmd extends SubCommand { public class FlagCmd extends SubCommand {
private boolean checkPermValue(PlotPlayer player, PlotFlag<?, ?> flag, String key, String value) { private boolean checkPermValue(PlotPlayer player, PlotFlag<?, ?> flag, String key,
String value) {
key = key.toLowerCase(); key = key.toLowerCase();
value = value.toLowerCase(); value = value.toLowerCase();
String perm = CaptionUtility String perm = CaptionUtility
.format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(), value.toLowerCase()); .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(),
value.toLowerCase());
if (flag instanceof IntegerFlag && MathMan.isInteger(value)) { if (flag instanceof IntegerFlag && MathMan.isInteger(value)) {
try { try {
int numeric = Integer.parseInt(value); int numeric = Integer.parseInt(value);
perm = perm.substring(0, perm.length() - value.length() - 1); perm = perm.substring(0, perm.length() - value.length() - 1);
if (numeric > 0) { if (numeric > 0) {
int checkRange = int checkRange = PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ?
PlotSquared.get().getPlatform().equalsIgnoreCase("bukkit") ? numeric : Settings.Limit.MAX_PLOTS; numeric :
Settings.Limit.MAX_PLOTS;
final boolean result = player.hasPermissionRange(perm, checkRange) >= numeric; final boolean result = player.hasPermissionRange(perm, checkRange) >= numeric;
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(), .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
value.toLowerCase())); key.toLowerCase(), value.toLowerCase()));
} }
return result; return result;
} }
@ -87,13 +86,13 @@ public class FlagCmd extends SubCommand {
PlotFlag<? extends List<?>, ?> parsedFlag = listFlag.parse(value); PlotFlag<? extends List<?>, ?> parsedFlag = listFlag.parse(value);
for (final Object entry : parsedFlag.getValue()) { for (final Object entry : parsedFlag.getValue()) {
final String permission = CaptionUtility final String permission = CaptionUtility
.format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(), .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
entry.toString().toLowerCase()); key.toLowerCase(), entry.toString().toLowerCase());
final boolean result = Permissions.hasPermission(player, permission); final boolean result = Permissions.hasPermission(player, permission);
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(), key.toLowerCase(), .format(Captions.PERMISSION_SET_FLAG_KEY_VALUE.getTranslated(),
value.toLowerCase())); key.toLowerCase(), value.toLowerCase()));
return false; return false;
} }
} }
@ -134,8 +133,10 @@ public class FlagCmd extends SubCommand {
sendMessage(player, Captions.PLOT_NOT_CLAIMED); sendMessage(player, Captions.PLOT_NOT_CLAIMED);
return false; return false;
} }
if (!plot.isOwner(player.getUUID()) && !Permissions.hasPermission(player, Captions.PERMISSION_SET_FLAG_OTHER)) { if (!plot.isOwner(player.getUUID()) && !Permissions
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG_OTHER); .hasPermission(player, Captions.PERMISSION_SET_FLAG_OTHER)) {
MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG_OTHER);
return false; return false;
} }
PlotFlag flag = null; PlotFlag flag = null;
@ -145,7 +146,8 @@ public class FlagCmd extends SubCommand {
boolean suggested = false; boolean suggested = false;
try { try {
StringComparison<PlotFlag<?, ?>> stringComparison = StringComparison<PlotFlag<?, ?>> stringComparison =
new StringComparison<>(args[1], GlobalFlagContainer.getInstance().getFlagMap().values()); new StringComparison<>(args[1],
GlobalFlagContainer.getInstance().getFlagMap().values());
String best = stringComparison.getBestMatch(); String best = stringComparison.getBestMatch();
if (best != null) { if (best != null) {
MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG_SUGGESTED, best); MainUtil.sendMessage(player, Captions.NOT_VALID_FLAG_SUGGESTED, best);
@ -164,11 +166,13 @@ public class FlagCmd extends SubCommand {
} }
case "set": { case "set": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_SET_FLAG)) { if (!Permissions.hasPermission(player, Captions.PERMISSION_SET_FLAG)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG); MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_SET_FLAG);
return false; return false;
} }
if (args.length < 3) { if (args.length < 3) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag set <flag> <value>"); MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot flag set <flag> <value>");
return false; return false;
} }
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " "); String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
@ -188,25 +192,30 @@ public class FlagCmd extends SubCommand {
} }
case "remove": { case "remove": {
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_REMOVE)) { if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_REMOVE)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_REMOVE); MainUtil.sendMessage(player, Captions.NO_PERMISSION,
Captions.PERMISSION_FLAG_REMOVE);
return false; return false;
} }
if (args.length != 2 && args.length != 3) { if (args.length != 2 && args.length != 3) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag remove <flag> [values]"); MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot flag remove <flag> [values]");
return false; return false;
} }
if (!Permissions.hasPermission(player, if (!Permissions.hasPermission(player, CaptionUtility
CaptionUtility.format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(), args[1].toLowerCase()))) { .format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[1].toLowerCase()))) {
if (args.length != 3) { if (args.length != 3) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(), args[1].toLowerCase())); .format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[1].toLowerCase()));
return false; return false;
} }
} }
if (args.length == 3 && flag instanceof ListFlag) { if (args.length == 3 && flag instanceof ListFlag) {
String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " "); String value = StringMan.join(Arrays.copyOfRange(args, 2, args.length), " ");
final ListFlag<?, ?> listFlag = (ListFlag<?, ?>) flag; final ListFlag<?, ?> listFlag = (ListFlag<?, ?>) flag;
final List<?> list = plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass()); final List<?> list =
plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass());
final PlotFlag<? extends List<?>, ?> parsedFlag; final PlotFlag<? extends List<?>, ?> parsedFlag;
try { try {
parsedFlag = listFlag.parse(value); parsedFlag = listFlag.parse(value);
@ -250,11 +259,13 @@ public class FlagCmd extends SubCommand {
} }
case "add": case "add":
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_ADD)) { if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_ADD)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_ADD); MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_ADD);
return false; return false;
} }
if (args.length < 3) { if (args.length < 3) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag add <flag> <values>"); MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX,
"/plot flag add <flag> <values>");
return false; return false;
} }
for (String entry : args[2].split(",")) { for (String entry : args[2].split(",")) {
@ -279,7 +290,8 @@ public class FlagCmd extends SubCommand {
return true; return true;
case "list": case "list":
if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_LIST)) { if (!Permissions.hasPermission(player, Captions.PERMISSION_FLAG_LIST)) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_LIST); MainUtil
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_FLAG_LIST);
return false; return false;
} }
if (args.length > 1) { if (args.length > 1) {
@ -287,19 +299,23 @@ public class FlagCmd extends SubCommand {
return false; return false;
} }
final Map<String, ArrayList<String>> flags = new HashMap<>(); final Map<String, ArrayList<String>> flags = new HashMap<>();
for (PlotFlag<?, ?> plotFlag : GlobalFlagContainer.getInstance().getRecognizedPlotFlags()) { for (PlotFlag<?, ?> plotFlag : GlobalFlagContainer.getInstance()
.getRecognizedPlotFlags()) {
final String category = plotFlag.getFlagCategory().getTranslated(); final String category = plotFlag.getFlagCategory().getTranslated();
final Collection<String> flagList = flags.computeIfAbsent(category, k -> new ArrayList<>()); final Collection<String> flagList =
flags.computeIfAbsent(category, k -> new ArrayList<>());
flagList.add(plotFlag.getName()); flagList.add(plotFlag.getName());
} }
final Iterator<Map.Entry<String, ArrayList<String>>> iterator = flags.entrySet().iterator(); final Iterator<Map.Entry<String, ArrayList<String>>> iterator =
flags.entrySet().iterator();
final StringJoiner message = new StringJoiner("\n"); final StringJoiner message = new StringJoiner("\n");
while (iterator.hasNext()) { while (iterator.hasNext()) {
final Map.Entry<String, ArrayList<String>> flagsEntry = iterator.next(); final Map.Entry<String, ArrayList<String>> flagsEntry = iterator.next();
final List<String> flagNames = flagsEntry.getValue(); final List<String> flagNames = flagsEntry.getValue();
Collections.sort(flagNames); Collections.sort(flagNames);
message.add(String.format(Captions.FLAG_LIST_ENTRY.formatted(), flagsEntry.getKey(), message.add(String
.format(Captions.FLAG_LIST_ENTRY.formatted(), flagsEntry.getKey(),
StringMan.join(flagNames, ", "))); StringMan.join(flagNames, ", ")));
} }
MainUtil.sendMessage(player, message.toString()); MainUtil.sendMessage(player, message.toString());

View File

@ -157,8 +157,7 @@ import java.util.Map;
@Override public boolean onCommand(final PlotPlayer player, final String[] args) { @Override public boolean onCommand(final PlotPlayer player, final String[] args) {
new HelpMenu(player).setCategory(CommandCategory.SETTINGS).setCommands(this.getCommands()) new HelpMenu(player).setCategory(CommandCategory.SETTINGS).setCommands(this.getCommands())
.generateMaxPages() .generateMaxPages().generatePage(0, getParent().toString()).render();
.generatePage(0, getParent().toString()).render();
return true; return true;
} }
@ -229,8 +228,7 @@ import java.util.Map;
.send(player, e.getFlag().getName(), e.getValue(), e.getErrorMessage()); .send(player, e.getFlag().getName(), e.getValue(), e.getErrorMessage());
return; return;
} }
boolean result = player.getLocation().getPlotAbs() boolean result = player.getLocation().getPlotAbs().setFlag(flag.merge(parsed.getValue()));
.setFlag(flag.merge(parsed.getValue()));
if (!result) { if (!result) {
MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED); MainUtil.sendMessage(player, Captions.FLAG_NOT_ADDED);
return; return;
@ -247,18 +245,20 @@ import java.util.Map;
return; return;
} }
if (args.length != 1 && args.length != 2) { if (args.length != 1 && args.length != 2) {
MainUtil.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag remove <flag> [values]"); MainUtil
.sendMessage(player, Captions.COMMAND_SYNTAX, "/plot flag remove <flag> [values]");
return; return;
} }
final PlotFlag<?, ?> flag = getFlag(player, args[0]); final PlotFlag<?, ?> flag = getFlag(player, args[0]);
if (flag == null) { if (flag == null) {
return; return;
} }
if (!Permissions.hasPermission(player, if (!Permissions.hasPermission(player, CaptionUtility
CaptionUtility.format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(), args[0].toLowerCase()))) { .format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(), args[0].toLowerCase()))) {
if (args.length != 2) { if (args.length != 2) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(), args[0].toLowerCase())); .format(Captions.PERMISSION_SET_FLAG_KEY.getTranslated(),
args[0].toLowerCase()));
return; return;
} }
} }
@ -266,7 +266,8 @@ import java.util.Map;
if (args.length == 2 && flag instanceof ListFlag) { if (args.length == 2 && flag instanceof ListFlag) {
String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " "); String value = StringMan.join(Arrays.copyOfRange(args, 1, args.length), " ");
final ListFlag<?, ?> listFlag = (ListFlag<?, ?>) flag; final ListFlag<?, ?> listFlag = (ListFlag<?, ?>) flag;
final List<?> list = plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass()); final List<?> list =
plot.getFlag((Class<? extends ListFlag<?, ?>>) listFlag.getClass());
final PlotFlag<? extends List<?>, ?> parsedFlag; final PlotFlag<? extends List<?>, ?> parsedFlag;
try { try {
parsedFlag = listFlag.parse(value); parsedFlag = listFlag.parse(value);
@ -325,19 +326,21 @@ import java.util.Map;
final Map<String, ArrayList<String>> flags = new HashMap<>(); final Map<String, ArrayList<String>> flags = new HashMap<>();
for (PlotFlag<?, ?> plotFlag : GlobalFlagContainer.getInstance().getRecognizedPlotFlags()) { for (PlotFlag<?, ?> plotFlag : GlobalFlagContainer.getInstance().getRecognizedPlotFlags()) {
final String category = plotFlag.getFlagCategory().getTranslated(); final String category = plotFlag.getFlagCategory().getTranslated();
final Collection<String> flagList = flags.computeIfAbsent(category, k -> new ArrayList<>()); final Collection<String> flagList =
flags.computeIfAbsent(category, k -> new ArrayList<>());
flagList.add(plotFlag.getName()); flagList.add(plotFlag.getName());
} }
for (final Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) { for (final Map.Entry<String, ArrayList<String>> entry : flags.entrySet()) {
Collections.sort(entry.getValue()); Collections.sort(entry.getValue());
PlotMessage plotMessage = new PlotMessage(entry.getKey() + ": ").color(Captions.FLAG_INFO_COLOR_KEY.getTranslated()); PlotMessage plotMessage = new PlotMessage(entry.getKey() + ": ")
.color(Captions.FLAG_INFO_COLOR_KEY.getTranslated());
final Iterator<String> flagIterator = entry.getValue().iterator(); final Iterator<String> flagIterator = entry.getValue().iterator();
while (flagIterator.hasNext()) { while (flagIterator.hasNext()) {
final String flag = flagIterator.next(); final String flag = flagIterator.next();
plotMessage = plotMessage.text(flag).command("/plot flag info " + flag) plotMessage = plotMessage.text(flag).command("/plot flag info " + flag)
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()) .color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()).tooltip(
.tooltip(new PlotMessage(Captions.FLAG_LIST_SEE_INFO.getTranslated()) new PlotMessage(Captions.FLAG_LIST_SEE_INFO.getTranslated())
.color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated())); .color(Captions.FLAG_INFO_COLOR_VALUE.getTranslated()));
if (flagIterator.hasNext()) { if (flagIterator.hasNext()) {
plotMessage = plotMessage.text(", ") plotMessage = plotMessage.text(", ")

View File

@ -17,9 +17,8 @@ import com.google.common.primitives.Ints;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "grant", category = CommandCategory.CLAIMING, @CommandDeclaration(command = "grant", category = CommandCategory.CLAIMING, usage = "/plot grant <check|add> [player]", permission = "plots.grant", requiredType = RequiredType.NONE)
usage = "/plot grant <check|add> [player]", permission = "plots.grant", public class Grant extends Command {
requiredType = RequiredType.NONE) public class Grant extends Command {
public Grant() { public Grant() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);

View File

@ -14,8 +14,7 @@ import com.github.intellectualsites.plotsquared.plot.util.helpmenu.HelpMenu;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "help", description = "Get this help menu", aliases = "?", @CommandDeclaration(command = "help", description = "Get this help menu", aliases = "?", category = CommandCategory.INFO, usage = "help [category|#]", permission = "plots.use")
category = CommandCategory.INFO, usage = "help [category|#]", permission = "plots.use")
public class Help extends Command { public class Help extends Command {
public Help(Command parent) { public Help(Command parent) {
super(parent, true); super(parent, true);
@ -56,7 +55,8 @@ public class Help extends Command {
return CompletableFuture.completedFuture(true); return CompletableFuture.completedFuture(true);
} }
public CompletableFuture<Boolean> displayHelp(final CommandCaller player, final String catRaw, final int page) { public CompletableFuture<Boolean> displayHelp(final CommandCaller player, final String catRaw,
final int page) {
return CompletableFuture.supplyAsync(() -> { return CompletableFuture.supplyAsync(() -> {
String cat = catRaw; String cat = catRaw;
@ -81,11 +81,10 @@ public class Help extends Command {
for (CommandCategory c : CommandCategory.values()) { for (CommandCategory c : CommandCategory.values()) {
builder.append("\n").append(StringMan builder.append("\n").append(StringMan
.replaceAll(Captions.HELP_INFO_ITEM.getTranslated(), "%category%", .replaceAll(Captions.HELP_INFO_ITEM.getTranslated(), "%category%",
c.toString().toLowerCase(), c.toString().toLowerCase(), "%category_desc%", c.toString()));
"%category_desc%", c.toString()));
} }
builder.append("\n") builder.append("\n").append(
.append(Captions.HELP_INFO_ITEM.getTranslated().replaceAll("%category%", "all") Captions.HELP_INFO_ITEM.getTranslated().replaceAll("%category%", "all")
.replaceAll("%category_desc%", "Display all commands")); .replaceAll("%category_desc%", "Display all commands"));
builder.append("\n").append(Captions.HELP_FOOTER.getTranslated()); builder.append("\n").append(Captions.HELP_FOOTER.getTranslated());
MainUtil.sendMessage(player, builder.toString(), false); MainUtil.sendMessage(player, builder.toString(), false);

View File

@ -13,8 +13,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.List; import java.util.List;
@CommandDeclaration(command = "inbox", description = "Review the comments for a plot", @CommandDeclaration(command = "inbox", description = "Review the comments for a plot", usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER)
usage = "/plot inbox [inbox] [delete <index>|clear|page]", permission = "plots.inbox", category = CommandCategory.CHAT, requiredType = RequiredType.PLAYER)
public class Inbox extends SubCommand { public class Inbox extends SubCommand {
public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) { public void displayComments(PlotPlayer player, List<PlotComment> oldComments, int page) {
@ -40,8 +39,7 @@ public class Inbox extends SubCommand {
StringBuilder string = new StringBuilder(); StringBuilder string = new StringBuilder();
string.append(StringMan string.append(StringMan
.replaceAll(Captions.COMMENT_LIST_HEADER_PAGED.getTranslated(), "%amount%", .replaceAll(Captions.COMMENT_LIST_HEADER_PAGED.getTranslated(), "%amount%",
comments.length, "%cur", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") + '\n');
page + 1, "%max", totalPages + 1, "%word", "all") + '\n');
// This might work xD // This might work xD
for (int x = page * 12; x < max; x++) { for (int x = page * 12; x < max; x++) {

View File

@ -15,8 +15,7 @@ import com.github.intellectualsites.plotsquared.plot.util.expiry.ExpireManager;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info", @CommandDeclaration(command = "info", aliases = "i", description = "Display plot info", usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO)
usage = "/plot info <id> [-f, to force info]", category = CommandCategory.INFO)
public class Info extends SubCommand { public class Info extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -17,9 +17,8 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "kick", aliases = "k", description = "Kick a player from your plot", @CommandDeclaration(command = "kick", aliases = "k", description = "Kick a player from your plot", permission = "plots.kick", usage = "/plot kick <player|*>", category = CommandCategory.TELEPORT, requiredType = RequiredType.PLAYER)
permission = "plots.kick", usage = "/plot kick <player|*>", category = CommandCategory.TELEPORT, public class Kick extends SubCommand {
requiredType = RequiredType.PLAYER) public class Kick extends SubCommand {
public Kick() { public Kick() {
super(Argument.PlayerName); super(Argument.PlayerName);

View File

@ -13,10 +13,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "leave", @CommandDeclaration(command = "leave", description = "Removes self from being trusted or a member of the plot", permission = "plots.leave", usage = "/plot leave", category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER)
description = "Removes self from being trusted or a member of the plot", public class Leave extends Command {
permission = "plots.leave", usage = "/plot leave", category = CommandCategory.CLAIMING,
requiredType = RequiredType.PLAYER) public class Leave extends Command {
public Leave() { public Leave() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }

View File

@ -21,9 +21,8 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "like", permission = "plots.like", description = "Like the plot", @CommandDeclaration(command = "like", permission = "plots.like", description = "Like the plot", usage = "/plot like [next|purge]", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
usage = "/plot like [next|purge]", category = CommandCategory.INFO, public class Like extends SubCommand {
requiredType = RequiredType.PLAYER) public class Like extends SubCommand {
protected static boolean handleLike(final PlotPlayer player, String[] args, protected static boolean handleLike(final PlotPlayer player, String[] args,
final boolean like) { final boolean like) {
@ -41,8 +40,8 @@ import java.util.UUID;
return v2 > v1 ? 1 : -1; return v2 > v1 ? 1 : -1;
}); });
for (final Plot plot : plots) { for (final Plot plot : plots) {
if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) if ((!Settings.Done.REQUIRED_FOR_RATINGS || DoneFlag.isDone(plot)) && plot
&& plot.isBasePlot() && (!plot.getLikes().containsKey(uuid))) { .isBasePlot() && (!plot.getLikes().containsKey(uuid))) {
plot.teleportPlayer(player, TeleportCause.COMMAND); plot.teleportPlayer(player, TeleportCause.COMMAND);
MainUtil.sendMessage(player, Captions.RATE_THIS); MainUtil.sendMessage(player, Captions.RATE_THIS);
return true; return true;

View File

@ -28,9 +28,8 @@ import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "list", aliases = {"l", "find", "search"}, description = "List plots", @CommandDeclaration(command = "list", aliases = {"l", "find",
permission = "plots.list", category = CommandCategory.INFO, "search"}, description = "List plots", permission = "plots.list", category = CommandCategory.INFO, usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]")
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]")
public class ListCmd extends SubCommand { public class ListCmd extends SubCommand {
private String[] getArgumentList(PlotPlayer player) { private String[] getArgumentList(PlotPlayer player) {
@ -137,11 +136,10 @@ public class ListCmd extends SubCommand {
Captions.PERMISSION_LIST_WORLD); Captions.PERMISSION_LIST_WORLD);
return false; return false;
} }
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) {
CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world));
CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world));
return false; return false;
} }
plots = new ArrayList<>(PlotSquared.get().getPlots(world)); plots = new ArrayList<>(PlotSquared.get().getPlots(world));
@ -162,11 +160,10 @@ public class ListCmd extends SubCommand {
.sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_AREA); .sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_LIST_AREA);
return false; return false;
} }
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) {
CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world))) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world));
CaptionUtility.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), world));
return false; return false;
} }
plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots()); plots = area == null ? new ArrayList<Plot>() : new ArrayList<>(area.getPlots());
@ -308,8 +305,7 @@ public class ListCmd extends SubCommand {
Captions.PERMISSION_LIST_WORLD); Captions.PERMISSION_LIST_WORLD);
return false; return false;
} }
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, CaptionUtility
.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]))) { .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0])); .format(Captions.PERMISSION_LIST_WORLD_NAME.getTranslated(), args[0]));

View File

@ -19,9 +19,8 @@ import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
@CommandDeclaration(command = "load", aliases = "restore", category = CommandCategory.SCHEMATIC, @CommandDeclaration(command = "load", aliases = "restore", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Load your plot", permission = "plots.load", usage = "/plot load")
requiredType = RequiredType.NONE, description = "Load your plot", permission = "plots.load", public class Load extends SubCommand {
usage = "/plot load") public class Load extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorld();

View File

@ -23,9 +23,8 @@ import java.util.concurrent.CompletableFuture;
/** /**
* PlotSquared command class. * PlotSquared command class.
*/ */
@CommandDeclaration(command = "plot", @CommandDeclaration(command = "plot", aliases = {"plots", "p", "plotsquared", "plot2", "p2", "ps",
aliases = {"plots", "p", "plotsquared", "plot2", "p2", "ps", "2", "plotme", "plotz", "ap"}) "2", "plotme", "plotz", "ap"}) public class MainCommand extends Command {
public class MainCommand extends Command {
private static MainCommand instance; private static MainCommand instance;
public Help help; public Help help;
@ -208,7 +207,8 @@ public class MainCommand extends Command {
PlotArea area = player.getApplicablePlotArea(); PlotArea area = player.getApplicablePlotArea();
Plot newPlot = Plot.fromString(area, args[0]); Plot newPlot = Plot.fromString(area, args[0]);
if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea() if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea()
.equals(area) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_SUDO_AREA)) .equals(area) || Permissions.hasPermission(player, Captions.PERMISSION_ADMIN)
|| Permissions.hasPermission(player, Captions.PERMISSION_ADMIN_SUDO_AREA))
&& !newPlot.isDenied(player.getUUID())) { && !newPlot.isDenied(player.getUUID())) {
Location newLoc = newPlot.getCenter(); Location newLoc = newPlot.getCenter();
if (player.canTeleport(newLoc)) { if (player.canTeleport(newLoc)) {

View File

@ -20,10 +20,7 @@ import java.util.UUID;
import static com.github.intellectualsites.plotsquared.plot.object.Direction.getFromIndex; import static com.github.intellectualsites.plotsquared.plot.object.Direction.getFromIndex;
@CommandDeclaration(command = "merge", aliases = "m", @CommandDeclaration(command = "merge", aliases = "m", 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, confirmation = true)
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, confirmation = true)
public class Merge extends SubCommand { public class Merge extends SubCommand {
public static final String[] values = new String[] {"north", "east", "south", "west", "auto"}; public static final String[] values = new String[] {"north", "east", "south", "west", "auto"};
@ -160,8 +157,7 @@ public class Merge extends SubCommand {
} }
Plot adjacent = plot.getRelative(direction); Plot adjacent = plot.getRelative(direction);
if (adjacent == null || !adjacent.hasOwner() || adjacent if (adjacent == null || !adjacent.hasOwner() || adjacent
.getMerged((direction.getIndex() + 2) % 4) .getMerged((direction.getIndex() + 2) % 4) || adjacent.isOwner(uuid)) {
|| adjacent.isOwner(uuid)) {
MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE); MainUtil.sendMessage(player, Captions.NO_AVAILABLE_AUTOMERGE);
return false; return false;
} }

View File

@ -10,10 +10,9 @@ import com.github.intellectualsites.plotsquared.plot.object.TeleportCause;
/** /**
* @author manuelgu, altered by Citymonstret * @author manuelgu, altered by Citymonstret
*/ */
@CommandDeclaration(command = "middle", aliases = {"center", "centre"}, @CommandDeclaration(command = "middle", aliases = {"center",
description = "Teleports you to the center of the plot", usage = "/plot middle", "centre"}, description = "Teleports you to the center of the plot", usage = "/plot middle", category = CommandCategory.TELEPORT, requiredType = RequiredType.PLAYER)
category = CommandCategory.TELEPORT, requiredType = RequiredType.PLAYER) public class Middle public class Middle extends SubCommand {
extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] arguments) { @Override public boolean onCommand(PlotPlayer player, String[] arguments) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -10,9 +10,8 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(usage = "/plot move <X;Z>", command = "move", description = "Move a plot", @CommandDeclaration(usage = "/plot move <X;Z>", command = "move", description = "Move a plot", permission = "plots.move", category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER)
permission = "plots.move", category = CommandCategory.CLAIMING, public class Move extends SubCommand {
requiredType = RequiredType.PLAYER) public class Move extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
Location location = player.getLocation(); Location location = player.getLocation();

View File

@ -13,10 +13,8 @@ import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.Locale; import java.util.Locale;
@CommandDeclaration(command = "music", permission = "plots.music", @CommandDeclaration(command = "music", permission = "plots.music", description = "Play music in your plot", usage = "/plot music", category = CommandCategory.APPEARANCE, requiredType = RequiredType.PLAYER)
description = "Play music in your plot", usage = "/plot music", public class Music extends SubCommand {
category = CommandCategory.APPEARANCE, requiredType = RequiredType.PLAYER) public class Music
extends SubCommand {
private static final Collection<String> DISCS = Arrays private static final Collection<String> DISCS = Arrays
.asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp", .asList("music_disc_13", "music_disc_cat", "music_disc_blocks", "music_disc_chirp",

View File

@ -11,8 +11,7 @@ import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players", @CommandDeclaration(command = "near", aliases = "n", description = "Display nearby players", usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
usage = "/plot near", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
public class Near extends Command { public class Near extends Command {
public Near() { public Near() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);

View File

@ -14,10 +14,10 @@ import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "setowner", permission = "plots.set.owner", @CommandDeclaration(command = "setowner", permission = "plots.set.owner", description = "Set the plot owner", usage = "/plot setowner <player>", aliases = {
description = "Set the plot owner", usage = "/plot setowner <player>", "owner", "so",
aliases = {"owner", "so", "seto"}, category = CommandCategory.CLAIMING, "seto"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE, confirmation = true)
requiredType = RequiredType.NONE, confirmation = true) public class Owner extends SetCommand { public class Owner extends SetCommand {
@Override public boolean set(final PlotPlayer player, final Plot plot, String value) { @Override public boolean set(final PlotPlayer player, final Plot plot, String value) {
if (value == null || value.isEmpty()) { if (value == null || value.isEmpty()) {

View File

@ -8,9 +8,8 @@ import com.github.intellectualsites.plotsquared.plot.util.HttpUtil;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@CommandDeclaration(command = "plugin", permission = "plots.use", @CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", usage = "/plot plugin", aliases = "version", category = CommandCategory.INFO)
description = "Show plugin information", usage = "/plot plugin", aliases = "version", public class PluginCmd extends SubCommand {
category = CommandCategory.INFO) public class PluginCmd extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
TaskManager.IMP.taskAsync(new Runnable() { TaskManager.IMP.taskAsync(new Runnable() {

View File

@ -18,11 +18,8 @@ import java.util.HashSet;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration( @CommandDeclaration(usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]", command = "purge", permission = "plots.admin", description = "Purge all plots for a world", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE, confirmation = true)
usage = "/plot purge world:<world> area:<area> id:<id> owner:<owner> shared:<shared> unknown:[true|false]", public class Purge extends SubCommand {
command = "purge", permission = "plots.admin", description = "Purge all plots for a world",
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE,
confirmation = true) public class Purge extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) { if (args.length == 0) {

View File

@ -24,9 +24,8 @@ import java.util.HashMap;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot", @CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot", usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO, requiredType = RequiredType.PLAYER)
usage = "/plot rate [#|next|purge]", aliases = "rt", category = CommandCategory.INFO, public class Rate extends SubCommand {
requiredType = RequiredType.PLAYER) public class Rate extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 1) { if (args.length == 1) {

View File

@ -10,11 +10,9 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotManager;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "regenallroads", @CommandDeclaration(command = "regenallroads", description = "Regenerate all roads in the map using the set road schematic", aliases = {
description = "Regenerate all roads in the map using the set road schematic", "rgar"}, usage = "/plot regenallroads <world> [height]", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE, permission = "plots.regenallroads")
aliases = {"rgar"}, usage = "/plot regenallroads <world> [height]", public class RegenAllRoads extends SubCommand {
category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE,
permission = "plots.regenallroads") public class RegenAllRoads extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
int height = 0; int height = 0;

View File

@ -13,8 +13,8 @@ import com.github.intellectualsites.plotsquared.plot.util.block.LocalBlockQueue;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "relight", description = "Relight your plot", usage = "/plot relight", @CommandDeclaration(command = "relight", description = "Relight your plot", usage = "/plot relight", category = CommandCategory.DEBUG, requiredType = RequiredType.PLAYER)
category = CommandCategory.DEBUG, requiredType = RequiredType.PLAYER) public class Relight extends Command { public class Relight extends Command {
public Relight() { public Relight() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }

View File

@ -12,9 +12,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import java.io.IOException; import java.io.IOException;
import java.util.Objects; import java.util.Objects;
@CommandDeclaration(command = "reload", aliases = "rl", permission = "plots.admin.command.reload", @CommandDeclaration(command = "reload", aliases = "rl", permission = "plots.admin.command.reload", description = "Reload translations and world settings", usage = "/plot reload", category = CommandCategory.ADMINISTRATION)
description = "Reload translations and world settings", usage = "/plot reload", public class Reload extends SubCommand {
category = CommandCategory.ADMINISTRATION) public class Reload extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] args) { @Override public boolean onCommand(PlotPlayer player, String[] args) {
try { try {

View File

@ -17,10 +17,9 @@ import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "remove", aliases = {"r", "untrust", "ut", "undeny", "unban", "ud"}, @CommandDeclaration(command = "remove", aliases = {"r", "untrust", "ut", "undeny", "unban",
description = "Remove a player from a plot", usage = "/plot remove <player|*>", "ud"}, description = "Remove a player from a plot", usage = "/plot remove <player|*>", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, permission = "plots.remove")
category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE, public class Remove extends SubCommand {
permission = "plots.remove") public class Remove extends SubCommand {
public Remove() { public Remove() {
super(Argument.PlayerName); super(Argument.PlayerName);

View File

@ -18,9 +18,9 @@ import java.net.URL;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "save", aliases = {"backup"}, description = "Save your plot", @CommandDeclaration(command = "save", aliases = {
category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, "backup"}, description = "Save your plot", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, permission = "plots.save")
permission = "plots.save") public class Save extends SubCommand { public class Save extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {
String world = player.getLocation().getWorld(); String world = player.getLocation().getWorld();

View File

@ -23,9 +23,9 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "schematic", permission = "plots.schematic", @CommandDeclaration(command = "schematic", permission = "plots.schematic", description = "Schematic command", aliases = {
description = "Schematic command", aliases = {"sch", "schem"}, "sch",
category = CommandCategory.SCHEMATIC, usage = "/plot schematic <save|saveall|paste>") "schem"}, category = CommandCategory.SCHEMATIC, usage = "/plot schematic <save|saveall|paste>")
public class SchematicCmd extends SubCommand { public class SchematicCmd extends SubCommand {
private boolean running = false; private boolean running = false;
@ -136,7 +136,8 @@ public class SchematicCmd extends SubCommand {
return false; return false;
} else { } else {
MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_STARTED); MainUtil.sendMessage(player, Captions.SCHEMATIC_EXPORTALL_STARTED);
MainUtil.sendMessage(player, "&3Plot&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots..."); MainUtil.sendMessage(player,
"&3Plot&8->&3Schematic&8: &7Found &c" + plots.size() + "&7 plots...");
} }
break; break;
} }

View File

@ -22,10 +22,9 @@ import java.util.HashSet;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
@CommandDeclaration(command = "set", description = "Set a plot value", aliases = {"s"}, @CommandDeclaration(command = "set", description = "Set a plot value", aliases = {
usage = "/plot set <biome|alias|home|flag> <value...>", permission = "plots.set", "s"}, usage = "/plot set <biome|alias|home|flag> <value...>", permission = "plots.set", category = CommandCategory.APPEARANCE, requiredType = RequiredType.NONE)
category = CommandCategory.APPEARANCE, requiredType = RequiredType.NONE) public class Set public class Set extends SubCommand {
extends SubCommand {
public static final String[] values = new String[] {"biome", "alias", "home", "flag"}; public static final String[] values = new String[] {"biome", "alias", "home", "flag"};
public static final String[] aliases = new String[] {"b", "w", "wf", "f", "a", "h", "fl"}; public static final String[] aliases = new String[] {"b", "w", "wf", "f", "a", "h", "fl"};
@ -51,7 +50,8 @@ import java.util.stream.IntStream;
for (String component : components) { for (String component : components) {
if (component.equalsIgnoreCase(args[0])) { if (component.equalsIgnoreCase(args[0])) {
if (!Permissions.hasPermission(player, CaptionUtility if (!Permissions.hasPermission(player, CaptionUtility
.format(Captions.PERMISSION_SET_COMPONENT.getTranslated(), component))) { .format(Captions.PERMISSION_SET_COMPONENT.getTranslated(),
component))) {
MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
.format(Captions.PERMISSION_SET_COMPONENT.getTranslated(), .format(Captions.PERMISSION_SET_COMPONENT.getTranslated(),
component)); component));
@ -86,11 +86,10 @@ import java.util.stream.IntStream;
new ArrayList<>(Arrays.asList("biome", "alias", "home", "flag")); new ArrayList<>(Arrays.asList("biome", "alias", "home", "flag"));
Plot plot = player.getCurrentPlot(); Plot plot = player.getCurrentPlot();
if (plot != null) { if (plot != null) {
newValues.addAll( newValues.addAll(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
} }
MainUtil MainUtil.sendMessage(player,
.sendMessage(player, Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + StringMan Captions.SUBCOMMAND_SET_OPTIONS_HEADER.getTranslated() + StringMan
.join(newValues, Captions.BLOCK_LIST_SEPARATOR.formatted())); .join(newValues, Captions.BLOCK_LIST_SEPARATOR.formatted()));
return false; return false;
} }
@ -114,8 +113,8 @@ import java.util.stream.IntStream;
return false; return false;
} }
// components // components
HashSet<String> components = new HashSet<>( HashSet<String> components =
Arrays.asList(plot.getManager().getPlotComponents(plot.getId()))); new HashSet<>(Arrays.asList(plot.getManager().getPlotComponents(plot.getId())));
if (components.contains(args[0].toLowerCase())) { if (components.contains(args[0].toLowerCase())) {
return this.component.onCommand(player, Arrays.copyOfRange(args, 0, args.length)); return this.component.onCommand(player, Arrays.copyOfRange(args, 0, args.length));
} }

View File

@ -18,21 +18,19 @@ public abstract class SetCommand extends SubCommand {
return !sendMessage(player, Captions.NOT_IN_PLOT); return !sendMessage(player, Captions.NOT_IN_PLOT);
} }
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, .format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) {
CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()));
CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()));
MainUtil.sendMessage(player, Captions.PLOT_NOT_CLAIMED); MainUtil.sendMessage(player, Captions.PLOT_NOT_CLAIMED);
return false; return false;
} }
} }
if (!plot.isOwner(player.getUUID())) { if (!plot.isOwner(player.getUUID())) {
if (!Permissions if (!Permissions.hasPermission(player, CaptionUtility
.hasPermission(player, .format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) {
CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()))) { MainUtil.sendMessage(player, Captions.NO_PERMISSION, CaptionUtility
MainUtil.sendMessage(player, Captions.NO_PERMISSION, .format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()));
CaptionUtility.format(Captions.PERMISSION_ADMIN_COMMAND.getTranslated(), getFullId()));
MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS); MainUtil.sendMessage(player, Captions.NO_PLOT_PERMS);
return false; return false;
} }

View File

@ -8,9 +8,8 @@ import com.github.intellectualsites.plotsquared.plot.object.Plot;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "sethome", permission = "plots.set.home", @CommandDeclaration(command = "sethome", permission = "plots.set.home", description = "Set the plot home to your current position", usage = "/plot sethome [none]", aliases = {
description = "Set the plot home to your current position", usage = "/plot sethome [none]", "sh", "seth"}, category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER)
aliases = {"sh", "seth"}, category = CommandCategory.SETTINGS, requiredType = RequiredType.PLAYER)
public class SetHome extends SetCommand { public class SetHome extends SetCommand {
@Override public boolean set(PlotPlayer player, Plot plot, String value) { @Override public boolean set(PlotPlayer player, Plot plot, String value) {

View File

@ -34,9 +34,14 @@ import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "setup", permission = "plots.admin.command.setup", @CommandDeclaration(command = "setup", permission = "plots.admin.command.setup", description = "Setup wizard for plot worlds", usage = "/plot setup", aliases = {
description = "Setup wizard for plot worlds", usage = "/plot setup", aliases = {"create"}, "create"}, category = CommandCategory.ADMINISTRATION) public class Setup extends SubCommand {
category = CommandCategory.ADMINISTRATION) public class Setup extends SubCommand {
private static boolean d(String s) {
return s.chars().allMatch((i) -> {
return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46;
});
}
public void displayGenerators(PlotPlayer player) { public void displayGenerators(PlotPlayer player) {
StringBuilder message = new StringBuilder(); StringBuilder message = new StringBuilder();
@ -336,11 +341,7 @@ import java.util.UUID;
return false; return false;
} }
private static boolean d(String s) {
return s.chars().allMatch((i) -> {
return i == 95 || i == 45 || i >= 97 && i <= 122 || i >= 48 && i <= 57 || i == 46;
});
}
private static final class StepPickGenerator extends SetupStep { private static final class StepPickGenerator extends SetupStep {
@Getter private String generator; @Getter private String generator;
@ -414,7 +415,7 @@ import java.util.UUID;
} }
@Override public boolean parseInput(String input) { @Override public boolean parseInput(String input) {
if (!WORLD_TYPES.keySet().contains(input.toLowerCase())) { if (!WORLD_TYPES.containsKey(input.toLowerCase())) {
return false; return false;
} }
this.worldType = input.toLowerCase(); this.worldType = input.toLowerCase();

View File

@ -8,8 +8,8 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.Permissions; import com.github.intellectualsites.plotsquared.plot.util.Permissions;
@CommandDeclaration(usage = "/plot swap <X;Z>", command = "swap", description = "Swap two plots", @CommandDeclaration(usage = "/plot swap <X;Z>", command = "swap", description = "Swap two plots", aliases = {
aliases = {"switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER) "switch"}, category = CommandCategory.CLAIMING, requiredType = RequiredType.PLAYER)
public class Swap extends SubCommand { public class Swap extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -10,10 +10,8 @@ import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
@CommandDeclaration(command = "target", usage = "/plot target <<plot>|nearest>", @CommandDeclaration(command = "target", usage = "/plot target <<plot>|nearest>", description = "Target a plot with your compass", permission = "plots.target", requiredType = RequiredType.PLAYER, category = CommandCategory.INFO)
description = "Target a plot with your compass", permission = "plots.target", public class Target extends SubCommand {
requiredType = RequiredType.PLAYER, category = CommandCategory.INFO) public class Target
extends SubCommand {
public Target() { public Target() {
super(Argument.PlotID); super(Argument.PlotID);

View File

@ -29,10 +29,8 @@ import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream; import java.util.zip.ZipInputStream;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@CommandDeclaration(command = "template", permission = "plots.admin", @CommandDeclaration(command = "template", permission = "plots.admin", description = "Create or use a world template", usage = "/plot template [import|export] <world> <template>", category = CommandCategory.ADMINISTRATION)
description = "Create or use a world template", public class Template extends SubCommand {
usage = "/plot template [import|export] <world> <template>",
category = CommandCategory.ADMINISTRATION) public class Template extends SubCommand {
public static boolean extractAllFiles(String world, String template) { public static boolean extractAllFiles(String world, String template) {
try { try {

View File

@ -8,16 +8,15 @@ import com.github.intellectualsites.plotsquared.plot.object.RunnableVal2;
import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3; import com.github.intellectualsites.plotsquared.plot.object.RunnableVal3;
import com.github.intellectualsites.plotsquared.plot.util.MainUtil; import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
@CommandDeclaration(command = "toggle", aliases = {"attribute"}, permission = "plots.use", @CommandDeclaration(command = "toggle", aliases = {
usage = "/plot toggle <chat|chatspy|clear-confirmation|time|titles|worldedit>", "attribute"}, permission = "plots.use", usage = "/plot toggle <chat|chatspy|clear-confirmation|time|titles|worldedit>", description = "Toggle per user settings", requiredType = RequiredType.NONE, category = CommandCategory.SETTINGS)
description = "Toggle per user settings", requiredType = RequiredType.NONE, public class Toggle extends Command {
category = CommandCategory.SETTINGS) public class Toggle extends Command {
public Toggle() { public Toggle() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
} }
@CommandDeclaration(command = "chatspy", aliases = {"spy"}, @CommandDeclaration(command = "chatspy", aliases = {
permission = "plots.admin.command.chat", description = "Toggle plot chat spy") "spy"}, permission = "plots.admin.command.chat", description = "Toggle plot chat spy")
public void chatspy(Command command, PlotPlayer player, String[] args, public void chatspy(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
@ -28,8 +27,8 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "worldedit", aliases = {"we", "wea"}, @CommandDeclaration(command = "worldedit", aliases = {"we",
permission = "plots.worldedit.bypass", description = "Toggle worldedit area restrictions") "wea"}, permission = "plots.worldedit.bypass", description = "Toggle worldedit area restrictions")
public void worldedit(Command command, PlotPlayer player, String[] args, public void worldedit(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
@ -40,8 +39,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "chat", permission = "plots.toggle.chat", @CommandDeclaration(command = "chat", permission = "plots.toggle.chat", description = "Toggle plot chat")
description = "Toggle plot chat")
public void chat(Command command, PlotPlayer player, String[] args, public void chat(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
@ -52,8 +50,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "clear-confirmation", @CommandDeclaration(command = "clear-confirmation", permission = "plots.admin.command.autoclear", description = "Toggle autoclear confirmation")
permission = "plots.admin.command.autoclear", description = "Toggle autoclear confirmation")
public void clearConfirmation(Command command, PlotPlayer player, String[] args, public void clearConfirmation(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
@ -64,8 +61,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "titles", permission = "plots.toggle.titles", @CommandDeclaration(command = "titles", permission = "plots.toggle.titles", description = "Toggle plot title messages")
description = "Toggle plot title messages")
public void titles(Command command, PlotPlayer player, String[] args, public void titles(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {
@ -76,8 +72,7 @@ import com.github.intellectualsites.plotsquared.plot.util.MainUtil;
} }
} }
@CommandDeclaration(command = "time", permission = "plots.toggle.time", @CommandDeclaration(command = "time", permission = "plots.toggle.time", description = "Toggle plot time settings")
description = "Toggle plot time settings")
public void time(Command command, PlotPlayer player, String[] args, public void time(Command command, PlotPlayer player, String[] args,
RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal3<Command, Runnable, Runnable> confirm,
RunnableVal2<Command, CommandResult> whenDone) { RunnableVal2<Command, CommandResult> whenDone) {

View File

@ -30,10 +30,8 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
@CommandDeclaration(command = "trim", permission = "plots.admin", @CommandDeclaration(command = "trim", permission = "plots.admin", description = "Delete unmodified portions of your plotworld", usage = "/plot trim <world> [regenerate]", requiredType = RequiredType.CONSOLE, category = CommandCategory.ADMINISTRATION)
description = "Delete unmodified portions of your plotworld", public class Trim extends SubCommand {
usage = "/plot trim <world> [regenerate]", requiredType = RequiredType.CONSOLE,
category = CommandCategory.ADMINISTRATION) public class Trim extends SubCommand {
public static ArrayList<Plot> expired = null; public static ArrayList<Plot> expired = null;
private static volatile boolean TASK = false; private static volatile boolean TASK = false;
@ -177,18 +175,20 @@ import java.util.Set;
} }
int bx = cbx << 4; int bx = cbx << 4;
int bz = cbz << 4; int bz = cbz << 4;
CuboidRegion region = RegionUtil.createRegion(bx, bx + 511, bz, bz + 511); CuboidRegion region =
RegionUtil.createRegion(bx, bx + 511, bz, bz + 511);
for (Plot plot : PlotSquared.get().getPlots(world)) { for (Plot plot : PlotSquared.get().getPlots(world)) {
Location bot = plot.getBottomAbs(); Location bot = plot.getBottomAbs();
Location top = plot.getExtendedTopAbs(); Location top = plot.getExtendedTopAbs();
CuboidRegion plotReg = CuboidRegion plotReg = RegionUtil
RegionUtil.createRegion(bot.getX(), top.getX(), bot.getZ(), .createRegion(bot.getX(), top.getX(), bot.getZ(), top.getZ());
top.getZ());
if (!RegionUtil.intersects(region, plotReg)) { if (!RegionUtil.intersects(region, plotReg)) {
continue; continue;
} }
for (int x = plotReg.getMinimumPoint().getX() >> 4; x <= plotReg.getMaximumPoint().getX() >> 4; x++) { for (int x = plotReg.getMinimumPoint().getX() >> 4;
for (int z = plotReg.getMinimumPoint().getZ() >> 4; z <= plotReg.getMaximumPoint().getZ() >> 4; z++) { x <= plotReg.getMaximumPoint().getX() >> 4; x++) {
for (int z = plotReg.getMinimumPoint().getZ() >> 4;
z <= plotReg.getMaximumPoint().getZ() >> 4; z++) {
BlockVector2 loc = BlockVector2.at(x, z); BlockVector2 loc = BlockVector2.at(x, z);
chunks.remove(loc); chunks.remove(loc);
} }

View File

@ -17,10 +17,9 @@ import java.util.Set;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "trust", aliases = {"t"}, requiredType = RequiredType.PLAYER, @CommandDeclaration(command = "trust", aliases = {
usage = "/plot trust <player|*>", "t"}, requiredType = RequiredType.PLAYER, usage = "/plot trust <player|*>", description = "Allow a user to build in a plot and use WorldEdit while the plot owner is offline.", category = CommandCategory.SETTINGS)
description = "Allow a user to build in a plot and use WorldEdit while the plot owner is offline.", public class Trust extends Command {
category = CommandCategory.SETTINGS) public class Trust extends Command {
public Trust() { public Trust() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);

View File

@ -11,9 +11,8 @@ import com.github.intellectualsites.plotsquared.plot.util.Permissions;
import com.github.intellectualsites.plotsquared.plot.util.StringMan; import com.github.intellectualsites.plotsquared.plot.util.StringMan;
import com.github.intellectualsites.plotsquared.plot.util.TaskManager; import com.github.intellectualsites.plotsquared.plot.util.TaskManager;
@CommandDeclaration(command = "unlink", aliases = {"u", "unmerge"}, @CommandDeclaration(command = "unlink", aliases = {"u",
description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", "unmerge"}, description = "Unlink a mega-plot", usage = "/plot unlink [createroads]", requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
requiredType = RequiredType.PLAYER, category = CommandCategory.SETTINGS, confirmation = true)
public class Unlink extends SubCommand { public class Unlink extends SubCommand {
@Override public boolean onCommand(final PlotPlayer player, String[] args) { @Override public boolean onCommand(final PlotPlayer player, String[] args) {

View File

@ -24,10 +24,10 @@ import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
@CommandDeclaration(command = "visit", permission = "plots.visit", @CommandDeclaration(command = "visit", permission = "plots.visit", description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]", aliases = {
description = "Visit someones plot", usage = "/plot visit [<player>|<alias>|<world>|<id>] [#]", "v", "tp", "teleport", "goto", "home", "h",
aliases = {"v", "tp", "teleport", "goto", "home", "h", "warp"}, requiredType = RequiredType.PLAYER, "warp"}, requiredType = RequiredType.PLAYER, category = CommandCategory.TELEPORT)
category = CommandCategory.TELEPORT) public class Visit extends Command { public class Visit extends Command {
public Visit() { public Visit() {
super(MainCommand.getInstance(), true); super(MainCommand.getInstance(), true);
@ -139,8 +139,8 @@ import java.util.concurrent.CompletableFuture;
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }
} else { } else {
if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER) && if (!Permissions.hasPermission(player, Captions.PERMISSION_VISIT_OTHER) && !plot
!plot.getFlag(UntrustedVisitFlag.class)) { .getFlag(UntrustedVisitFlag.class)) {
Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OTHER); Captions.NO_PERMISSION.send(player, Captions.PERMISSION_VISIT_OTHER);
return CompletableFuture.completedFuture(false); return CompletableFuture.completedFuture(false);
} }

View File

@ -3,11 +3,9 @@ package com.github.intellectualsites.plotsquared.plot.commands;
import com.github.intellectualsites.plotsquared.commands.CommandDeclaration; import com.github.intellectualsites.plotsquared.commands.CommandDeclaration;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@CommandDeclaration(command = "weanywhere", permission = "plots.worldedit.bypass", @CommandDeclaration(command = "weanywhere", permission = "plots.worldedit.bypass", description = "Force bypass of WorldEdit restrictions", aliases = {
description = "Force bypass of WorldEdit restrictions", aliases = {"wea"}, usage = "/plot weanywhere", "wea"}, usage = "/plot weanywhere", requiredType = RequiredType.NONE, category = CommandCategory.ADMINISTRATION)
requiredType = RequiredType.NONE, category = CommandCategory.ADMINISTRATION) @Deprecated public class WE_Anywhere extends SubCommand {
@Deprecated
public class WE_Anywhere extends SubCommand {
@Override public boolean onCommand(PlotPlayer player, String[] arguments) { @Override public boolean onCommand(PlotPlayer player, String[] arguments) {
MainCommand.getInstance().toggle.worldedit(this, player, new String[0], null, null); MainCommand.getInstance().toggle.worldedit(this, player, new String[0], null, null);

View File

@ -19,8 +19,7 @@ public class Settings extends Config {
public static String ISSUES = "https://github.com/IntellectualSites/PlotSquared/issues"; public static String ISSUES = "https://github.com/IntellectualSites/PlotSquared/issues";
@Final public static String SUGGESTION = @Final public static String SUGGESTION =
"https://github.com/IntellectualSites/PlotSquaredSuggestions"; "https://github.com/IntellectualSites/PlotSquaredSuggestions";
@Final public static String WIKI = @Final public static String WIKI = "https://github.com/IntellectualSites/PlotSquared/wiki";
"https://github.com/IntellectualSites/PlotSquared/wiki";
@Final public static String DATE; // These values are set from P2 before loading @Final public static String DATE; // These values are set from P2 before loading
@Final public static String BUILD; // These values are set from P2 before loading @Final public static String BUILD; // These values are set from P2 before loading
@Final public static String COMMIT; // These values are set from P2 before loading @Final public static String COMMIT; // These values are set from P2 before loading
@ -28,8 +27,9 @@ public class Settings extends Config {
@Comment("Show additional information in console") public static boolean DEBUG = false; @Comment("Show additional information in console") public static boolean DEBUG = false;
@Comment({"The big annoying text that appears when you enter a plot", @Comment({"The big annoying text that appears when you enter a plot",
"For a single plot: `/plot flag set titles false`", "For just you: `/plot toggle titles`", "For all plots: Add `titles: false` in the worlds.yml flags block"}) "For a single plot: `/plot flag set titles false`", "For just you: `/plot toggle titles`",
public static boolean TITLES = true; "For all plots: Add `titles: false` in the worlds.yml flags block"}) public static boolean
TITLES = true;
@Create // This value will be generated automatically @Create // This value will be generated automatically
public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null; public static ConfigBlock<Auto_Clear> AUTO_CLEAR = null;
@ -229,8 +229,7 @@ public class Settings extends Config {
@Comment("Schematic Settings") public static final class Schematics { @Comment("Schematic Settings") public static final class Schematics {
@Comment( @Comment("Whether schematic based generation should paste schematic on top of plots, or from Y=1")
"Whether schematic based generation should paste schematic on top of plots, or from Y=1")
public static boolean PASTE_ON_TOP = true; public static boolean PASTE_ON_TOP = true;
} }
@ -256,11 +255,12 @@ public class Settings extends Config {
public static final class Done { public static final class Done {
@Comment("Require a plot marked as done to download") public static boolean REQUIRED_FOR_DOWNLOAD = @Comment("Require a plot marked as done to download") public static boolean
false; REQUIRED_FOR_DOWNLOAD = false;
@Comment("Only plots marked as done can be rated") public static boolean REQUIRED_FOR_RATINGS = false; @Comment("Only plots marked as done can be rated") public static boolean
@Comment("Restrict building when a plot is marked as done") public static boolean RESTRICT_BUILDING = REQUIRED_FOR_RATINGS = false;
false; @Comment("Restrict building when a plot is marked as done") public static boolean
RESTRICT_BUILDING = false;
@Comment("The limit being how many plots a player can claim") public static boolean @Comment("The limit being how many plots a player can claim") public static boolean
COUNTS_TOWARDS_LIMIT = true; COUNTS_TOWARDS_LIMIT = true;
} }
@ -276,9 +276,10 @@ public class Settings extends Config {
@Comment("Relating to how many plots someone can claim ") public static final class Limit { @Comment("Relating to how many plots someone can claim ") public static final class Limit {
@Comment("Should the limit be global (over multiple worlds)") public static boolean GLOBAL = @Comment("Should the limit be global (over multiple worlds)") public static boolean GLOBAL =
false; false;
@Comment({"The max. range of permissions to check e.g. plots.plot.127", "The value covers the range to check only, you need to assign the permission to players/groups still", @Comment({"The max. range of permissions to check e.g. plots.plot.127",
"Modifying the value does NOT change the amount of plots players can claim"}) public static int "The value covers the range to check only, you need to assign the permission to players/groups still",
MAX_PLOTS = 127; "Modifying the value does NOT change the amount of plots players can claim"})
public static int MAX_PLOTS = 127;
} }
@ -292,7 +293,9 @@ public class Settings extends Config {
@Comment("Teleport to your plot on death") public static boolean ON_DEATH = false; @Comment("Teleport to your plot on death") public static boolean ON_DEATH = false;
@Comment("Teleport to your plot on login") public static boolean ON_LOGIN = false; @Comment("Teleport to your plot on login") public static boolean ON_LOGIN = false;
@Comment("Teleport to your plot on claim") public static boolean ON_CLAIM = true; @Comment("Teleport to your plot on claim") public static boolean ON_CLAIM = true;
@Comment({"Add a delay to all teleport commands", "Assign `plots.teleport.delay.bypass` to bypass the cooldown."}) public static int DELAY = 0; @Comment({"Add a delay to all teleport commands",
"Assign `plots.teleport.delay.bypass` to bypass the cooldown."}) public static int
DELAY = 0;
@Comment("The visit command is ordered by world instead of globally") public static boolean @Comment("The visit command is ordered by world instead of globally") public static boolean
PER_WORLD_VISIT = false; PER_WORLD_VISIT = false;
} }
@ -303,8 +306,7 @@ public class Settings extends Config {
false; false;
@Comment("Disable redstone when all owners/trusted/members are offline") @Comment("Disable redstone when all owners/trusted/members are offline")
public static boolean DISABLE_OFFLINE = false; public static boolean DISABLE_OFFLINE = false;
@Comment( @Comment("Detect and cancel invalid pistons on the edge of plots (e.g. placed with WorldEdit)")
"Detect and cancel invalid pistons on the edge of plots (e.g. placed with WorldEdit)")
public static boolean DETECT_INVALID_EDGE_PISTONS = false; public static boolean DETECT_INVALID_EDGE_PISTONS = false;
} }
@ -322,8 +324,8 @@ public class Settings extends Config {
} }
@Comment( @Comment({"Enable or disable parts of the plugin",
{"Enable or disable parts of the plugin", "Note: A cache will use some memory if enabled"}) "Note: A cache will use some memory if enabled"})
public static final class Enabled_Components { // Group the following values into a new config section public static final class Enabled_Components { // Group the following values into a new config section
@Comment("The database stores all the plots") public static boolean DATABASE = true; @Comment("The database stores all the plots") public static boolean DATABASE = true;
@Comment("Events are needed to track a lot of things") public static boolean EVENTS = true; @Comment("Events are needed to track a lot of things") public static boolean EVENTS = true;
@ -331,7 +333,8 @@ public class Settings extends Config {
true; true;
@Comment("The UUID cacher is used to resolve player names") public static boolean @Comment("The UUID cacher is used to resolve player names") public static boolean
UUID_CACHE = true; UUID_CACHE = true;
@Comment("The plugin auto updater will notify you if updates are available.") public static boolean UPDATER = true; @Comment("The plugin auto updater will notify you if updates are available.")
public static boolean UPDATER = true;
@Comment("Stores user metadata in a database") public static boolean PERSISTENT_META = true; @Comment("Stores user metadata in a database") public static boolean PERSISTENT_META = true;
@Comment("Optimizes permission checks") public static boolean PERMISSION_CACHE = true; @Comment("Optimizes permission checks") public static boolean PERMISSION_CACHE = true;
@Comment("Optimizes block changing code") public static boolean BLOCK_CACHE = true; @Comment("Optimizes block changing code") public static boolean BLOCK_CACHE = true;
@ -340,8 +343,7 @@ public class Settings extends Config {
@Comment("Allow WorldEdit to be restricted to plots") public static boolean @Comment("Allow WorldEdit to be restricted to plots") public static boolean
WORLDEDIT_RESTRICTIONS = true; WORLDEDIT_RESTRICTIONS = true;
@Comment("Allow economy to be used") public static boolean ECONOMY = true; @Comment("Allow economy to be used") public static boolean ECONOMY = true;
@Comment("@deprecated - use bstats config.yml") public static boolean @Comment("@deprecated - use bstats config.yml") public static boolean METRICS = true;
METRICS = true;
@Comment("Expiry will clear old or simplistic plots") public static boolean PLOT_EXPIRY = @Comment("Expiry will clear old or simplistic plots") public static boolean PLOT_EXPIRY =
false; false;
@Comment("Processes chunks (trimming, or entity/tile limits) ") public static boolean @Comment("Processes chunks (trimming, or entity/tile limits) ") public static boolean
@ -356,7 +358,8 @@ public class Settings extends Config {
@Comment("Actively purge invalid database entries") public static boolean DATABASE_PURGER = @Comment("Actively purge invalid database entries") public static boolean DATABASE_PURGER =
false; false;
@Comment("Delete plots when a player is banned") public static boolean BAN_DELETER = false; @Comment("Delete plots when a player is banned") public static boolean BAN_DELETER = false;
@Comment({"Prevent possibly unsafe blocks from being used in plot components", "Can be bypassed with `/plot debugallowunsafe`"}) @Comment({"Prevent possibly unsafe blocks from being used in plot components",
public static boolean PREVENT_UNSAFE = true; "Can be bypassed with `/plot debugallowunsafe`"}) public static boolean PREVENT_UNSAFE =
true;
} }
} }

View File

@ -84,6 +84,7 @@ public class DBFunc {
//TODO Consider Removal //TODO Consider Removal
/** /**
* Check if a {@link ResultSet} contains a column. * Check if a {@link ResultSet} contains a column.
* *

View File

@ -23,7 +23,8 @@ public class BlockStateListFlag extends ListFlag<Set<BlockType>> {
} }
@Override public Set<BlockType> parseValue(final String value) { @Override public Set<BlockType> parseValue(final String value) {
return Arrays.stream(BlockUtil.parse(value)).filter(Objects::nonNull).map(BlockState::getBlockType).collect(Collectors.toSet()); return Arrays.stream(BlockUtil.parse(value)).filter(Objects::nonNull)
.map(BlockState::getBlockType).collect(Collectors.toSet());
} }
@Override public String getValueDescription() { @Override public String getValueDescription() {

View File

@ -27,6 +27,11 @@ import java.util.Map;
this(parentContainer, null); this(parentContainer, null);
} }
@SuppressWarnings("ALL")
public static <V, T extends PlotFlag<V, ?>> T castUnsafe(final PlotFlag<?, ?> flag) {
return (T) flag;
}
/** /**
* Return the parent container (if the container has a parent) * Return the parent container (if the container has a parent)
* *
@ -155,7 +160,8 @@ import java.util.Map;
* @param <T> Flag type * @param <T> Flag type
* @return The flag instance, if it exists in this container, else null. * @return The flag instance, if it exists in this container, else null.
*/ */
@Nullable public <V, T extends PlotFlag<V, ?>> T queryLocal(final Class<? extends T> flagClass) { @Nullable public <V, T extends PlotFlag<V, ?>> T queryLocal(
final Class<? extends T> flagClass) {
final PlotFlag<?, ?> localFlag = this.flagMap.get(flagClass); final PlotFlag<?, ?> localFlag = this.flagMap.get(flagClass);
if (localFlag == null) { if (localFlag == null) {
return null; return null;
@ -164,26 +170,6 @@ import java.util.Map;
} }
} }
@SuppressWarnings("ALL")
public static <V, T extends PlotFlag<V, ?>> T castUnsafe(final PlotFlag<?, ?> flag) {
return (T) flag;
}
/**
* Handler for update events in {@link FlagContainer flag containers}.
*/
@FunctionalInterface public interface PlotFlagUpdateHandler {
/**
* Act on the flag update event
* @param plotFlag Plot flag
* @param type Update type
*/
void handle(PlotFlag<?, ?> plotFlag, PlotFlagUpdateType type);
}
/** /**
* Update event types used in {@link PlotFlagUpdateHandler}. * Update event types used in {@link PlotFlagUpdateHandler}.
*/ */
@ -198,4 +184,20 @@ import java.util.Map;
FLAG_REMOVED FLAG_REMOVED
} }
/**
* Handler for update events in {@link FlagContainer flag containers}.
*/
@FunctionalInterface public interface PlotFlagUpdateHandler {
/**
* Act on the flag update event
*
* @param plotFlag Plot flag
* @param type Update type
*/
void handle(PlotFlag<?, ?> plotFlag, PlotFlagUpdateType type);
}
} }

View File

@ -9,8 +9,8 @@ public class FlagParseException extends Exception {
private final String value; private final String value;
private final String errorMessage; private final String errorMessage;
public FlagParseException(final PlotFlag<?, ?> flag, final String value, final Caption errorMessage, public FlagParseException(final PlotFlag<?, ?> flag, final String value,
final Object ... args) { final Caption errorMessage, final Object... args) {
super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.", super(String.format("Failed to parse flag of type '%s'. Value '%s' was not accepted.",
flag.getName(), value)); flag.getName(), value));
this.flag = flag; this.flag = flag;

View File

@ -27,15 +27,17 @@ import org.jetbrains.annotations.NotNull;
protected PlotFlag(@NotNull final T value, @NotNull final Caption flagCategory, protected PlotFlag(@NotNull final T value, @NotNull final Caption flagCategory,
@NotNull final Caption flagDescription) { @NotNull final Caption flagDescription) {
this.value = Preconditions.checkNotNull(value, "flag value may not be null"); this.value = Preconditions.checkNotNull(value, "flag value may not be null");
this.flagCategory = Preconditions.checkNotNull(flagCategory, "flag category may not be null"); this.flagCategory =
this.flagDescription = Preconditions.checkNotNull(flagDescription, "flag description may not be null"); Preconditions.checkNotNull(flagCategory, "flag category may not be null");
this.flagDescription =
Preconditions.checkNotNull(flagDescription, "flag description may not be null");
// Parse flag name // Parse flag name
final StringBuilder flagName = new StringBuilder(); final StringBuilder flagName = new StringBuilder();
final char[] chars = this.getClass().getSimpleName().replace("Flag", "").toCharArray(); final char[] chars = this.getClass().getSimpleName().replace("Flag", "").toCharArray();
for (int i = 0; i < chars.length; i++) { for (int i = 0; i < chars.length; i++) {
if (i == 0) { if (i == 0) {
flagName.append(Character.toLowerCase(chars[i])); flagName.append(Character.toLowerCase(chars[i]));
} else if(Character.isUpperCase(chars[i])) { } else if (Character.isUpperCase(chars[i])) {
flagName.append('-').append(Character.toLowerCase(chars[i])); flagName.append('-').append(Character.toLowerCase(chars[i]));
} else { } else {
flagName.append(chars[i]); flagName.append(chars[i]);

View File

@ -11,10 +11,12 @@ import java.util.List;
public class BlockedCmdsFlag extends ListFlag<String, BlockedCmdsFlag> { public class BlockedCmdsFlag extends ListFlag<String, BlockedCmdsFlag> {
public static final BlockedCmdsFlag BLOCKED_CMDS_FLAG_NONE = new BlockedCmdsFlag(Collections.emptyList()); public static final BlockedCmdsFlag BLOCKED_CMDS_FLAG_NONE =
new BlockedCmdsFlag(Collections.emptyList());
protected BlockedCmdsFlag(List<String> valueList) { protected BlockedCmdsFlag(List<String> valueList) {
super(valueList, Captions.FLAG_CATEGORY_STRING_LIST, Captions.FLAG_DESCRIPTION_BLOCKED_CMDS); super(valueList, Captions.FLAG_CATEGORY_STRING_LIST,
Captions.FLAG_DESCRIPTION_BLOCKED_CMDS);
} }
@Override public BlockedCmdsFlag parse(@NotNull String input) throws FlagParseException { @Override public BlockedCmdsFlag parse(@NotNull String input) throws FlagParseException {

View File

@ -10,7 +10,8 @@ import org.jetbrains.annotations.Nullable;
public class DenyTeleportFlag extends PlotFlag<DenyTeleportFlag.DeniedGroup, DenyTeleportFlag> { public class DenyTeleportFlag extends PlotFlag<DenyTeleportFlag.DeniedGroup, DenyTeleportFlag> {
public static final DenyTeleportFlag DENY_TELEPORT_FLAG_NONE = new DenyTeleportFlag(DeniedGroup.NONE); public static final DenyTeleportFlag DENY_TELEPORT_FLAG_NONE =
new DenyTeleportFlag(DeniedGroup.NONE);
/** /**
* Construct a new flag instance. * Construct a new flag instance.
@ -21,11 +22,40 @@ public class DenyTeleportFlag extends PlotFlag<DenyTeleportFlag.DeniedGroup, Den
super(value, Captions.FLAG_CATEGORY_ENUM, Captions.FLAG_DESCRIPTION_DENY_TELEPORT); super(value, Captions.FLAG_CATEGORY_ENUM, Captions.FLAG_DESCRIPTION_DENY_TELEPORT);
} }
public static boolean allowsTeleport(PlotPlayer player, Plot plot) {
final DeniedGroup value = plot.getFlag(DenyTeleportFlag.class);
if (value == DeniedGroup.NONE) {
return true;
}
final boolean result;
switch (value) {
case TRUSTED:
result = !plot.getTrusted().contains(player.getUUID());
break;
case MEMBERS:
result = !plot.getMembers().contains(player.getUUID());
break;
case NONMEMBERS:
result = plot.isAdded(player.getUUID());
break;
case NONTRUSTED:
result =
plot.getTrusted().contains(player.getUUID()) || plot.isOwner(player.getUUID());
break;
case NONOWNERS:
result = plot.isOwner(player.getUUID());
break;
default:
return true;
}
return result || player.hasPermission("plots.admin.entry.denied");
}
@Override public DenyTeleportFlag parse(@NotNull String input) throws FlagParseException { @Override public DenyTeleportFlag parse(@NotNull String input) throws FlagParseException {
final DeniedGroup group = DeniedGroup.fromString(input); final DeniedGroup group = DeniedGroup.fromString(input);
if (group == null) { if (group == null) {
throw new FlagParseException(this, input, Captions.FLAG_ERROR_ENUM, "members, nonmembers," throw new FlagParseException(this, input, Captions.FLAG_ERROR_ENUM,
+ " trusted, nontrusted, nonowners"); "members, nonmembers," + " trusted, nontrusted, nonowners");
} }
return flagOf(group); return flagOf(group);
} }
@ -49,42 +79,8 @@ public class DenyTeleportFlag extends PlotFlag<DenyTeleportFlag.DeniedGroup, Den
return new DenyTeleportFlag(value); return new DenyTeleportFlag(value);
} }
public static boolean allowsTeleport(PlotPlayer player, Plot plot) {
final DeniedGroup value = plot.getFlag(DenyTeleportFlag.class);
if (value == DeniedGroup.NONE) {
return true;
}
final boolean result;
switch (value) {
case TRUSTED:
result = !plot.getTrusted().contains(player.getUUID());
break;
case MEMBERS:
result = !plot.getMembers().contains(player.getUUID());
break;
case NONMEMBERS:
result = plot.isAdded(player.getUUID());
break;
case NONTRUSTED:
result = plot.getTrusted().contains(player.getUUID()) || plot
.isOwner(player.getUUID());
break;
case NONOWNERS:
result = plot.isOwner(player.getUUID());
break;
default:
return true;
}
return result || player.hasPermission("plots.admin.entry.denied");
}
public enum DeniedGroup { public enum DeniedGroup {
NONE, NONE, MEMBERS, TRUSTED, NONMEMBERS, NONTRUSTED, NONOWNERS;
MEMBERS,
TRUSTED,
NONMEMBERS,
NONTRUSTED,
NONOWNERS;
@Nullable public static DeniedGroup fromString(@NotNull final String string) { @Nullable public static DeniedGroup fromString(@NotNull final String string) {
for (final DeniedGroup group : values()) { for (final DeniedGroup group : values()) {

View File

@ -17,6 +17,10 @@ public class DoneFlag extends PlotFlag<String, DoneFlag> implements InternalFlag
super(value, Captions.NONE, Captions.NONE); super(value, Captions.NONE, Captions.NONE);
} }
public static boolean isDone(final Plot plot) {
return !plot.getFlag(DoneFlag.class).isEmpty();
}
@Override public DoneFlag parse(@NotNull String input) { @Override public DoneFlag parse(@NotNull String input) {
return flagOf(input); return flagOf(input);
} }
@ -37,8 +41,4 @@ public class DoneFlag extends PlotFlag<String, DoneFlag> implements InternalFlag
return new DoneFlag(value); return new DoneFlag(value);
} }
public static boolean isDone(final Plot plot) {
return !plot.getFlag(DoneFlag.class).isEmpty();
}
} }

View File

@ -10,16 +10,18 @@ import org.jetbrains.annotations.NotNull;
public class GamemodeFlag extends PlotFlag<GameMode, GamemodeFlag> { public class GamemodeFlag extends PlotFlag<GameMode, GamemodeFlag> {
public static final GameMode DEFAULT = new GameMode("default"); public static final GameMode DEFAULT = new GameMode("default");
public static final GamemodeFlag GAMEMODE_FLAG_CREATIVE = new GamemodeFlag(GameModes.CREATIVE);
public static final GamemodeFlag GAMEMODE_FLAG_ADVENTURE =
new GamemodeFlag(GameModes.ADVENTURE);
public static final GamemodeFlag GAMEMODE_FLAG_SPECTATOR =
new GamemodeFlag(GameModes.SPECTATOR);
public static final GamemodeFlag GAMEMODE_FLAG_SURVIVAL = new GamemodeFlag(GameModes.SURVIVAL);
public static final GamemodeFlag GAMEMODE_FLAG_DEFAULT = new GamemodeFlag(DEFAULT);
static { static {
GameModes.register(DEFAULT); GameModes.register(DEFAULT);
} }
public static final GamemodeFlag GAMEMODE_FLAG_CREATIVE = new GamemodeFlag(GameModes.CREATIVE);
public static final GamemodeFlag GAMEMODE_FLAG_ADVENTURE = new GamemodeFlag(GameModes.ADVENTURE);
public static final GamemodeFlag GAMEMODE_FLAG_SPECTATOR = new GamemodeFlag(GameModes.SPECTATOR);
public static final GamemodeFlag GAMEMODE_FLAG_SURVIVAL = new GamemodeFlag(GameModes.SURVIVAL);
public static final GamemodeFlag GAMEMODE_FLAG_DEFAULT = new GamemodeFlag(DEFAULT);
/** /**
* Construct a new flag instance. * Construct a new flag instance.
* *

View File

@ -9,11 +9,16 @@ import org.jetbrains.annotations.NotNull;
public class GuestGamemodeFlag extends PlotFlag<GameMode, GuestGamemodeFlag> { public class GuestGamemodeFlag extends PlotFlag<GameMode, GuestGamemodeFlag> {
public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_CREATIVE = new GuestGamemodeFlag(GameModes.CREATIVE); public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_CREATIVE =
public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_ADVENTURE = new GuestGamemodeFlag(GameModes.ADVENTURE); new GuestGamemodeFlag(GameModes.CREATIVE);
public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_SPECTATOR = new GuestGamemodeFlag(GameModes.SPECTATOR); public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_ADVENTURE =
public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_SURVIVAL = new GuestGamemodeFlag(GameModes.SURVIVAL); new GuestGamemodeFlag(GameModes.ADVENTURE);
public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_DEFAULT = new GuestGamemodeFlag(GamemodeFlag.DEFAULT); public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_SPECTATOR =
new GuestGamemodeFlag(GameModes.SPECTATOR);
public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_SURVIVAL =
new GuestGamemodeFlag(GameModes.SURVIVAL);
public static final GuestGamemodeFlag GUEST_GAMEMODE_FLAG_DEFAULT =
new GuestGamemodeFlag(GamemodeFlag.DEFAULT);
/** /**
* Construct a new flag instance. * Construct a new flag instance.

View File

@ -7,6 +7,7 @@ import org.jetbrains.annotations.NotNull;
public class HealFlag extends TimedFlag<Integer, HealFlag> { public class HealFlag extends TimedFlag<Integer, HealFlag> {
public static final HealFlag HEAL_NOTHING = new HealFlag(new Timed<>(0, 0)); public static final HealFlag HEAL_NOTHING = new HealFlag(new Timed<>(0, 0));
protected HealFlag(@NotNull Timed<Integer> value) { protected HealFlag(@NotNull Timed<Integer> value) {
super(value, 1, Captions.FLAG_DESCRIPTION_HEAL); super(value, 1, Captions.FLAG_DESCRIPTION_HEAL);
} }

View File

@ -5,7 +5,8 @@ import com.github.intellectualsites.plotsquared.plot.flags.types.NonNegativeInte
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class HostileCapFlag extends NonNegativeIntegerFlag<HostileCapFlag> { public class HostileCapFlag extends NonNegativeIntegerFlag<HostileCapFlag> {
public static final HostileCapFlag HOSTILE_CAP_UNLIMITED = new HostileCapFlag(Integer.MAX_VALUE); public static final HostileCapFlag HOSTILE_CAP_UNLIMITED =
new HostileCapFlag(Integer.MAX_VALUE);
protected HostileCapFlag(int value) { protected HostileCapFlag(int value) {
super(value, Captions.FLAG_DESCRIPTION_HOSTILE_CAP); super(value, Captions.FLAG_DESCRIPTION_HOSTILE_CAP);

View File

@ -7,9 +7,12 @@ import org.jetbrains.annotations.NotNull;
public class PlotWeatherFlag extends PlotFlag<PlotWeather, PlotWeatherFlag> { public class PlotWeatherFlag extends PlotFlag<PlotWeather, PlotWeatherFlag> {
public static final PlotWeatherFlag PLOT_WEATHER_FLAG_RAIN = new PlotWeatherFlag(PlotWeather.RAIN); public static final PlotWeatherFlag PLOT_WEATHER_FLAG_RAIN =
public static final PlotWeatherFlag PLOT_WEATHER_FLAG_CLEAR = new PlotWeatherFlag(PlotWeather.CLEAR); new PlotWeatherFlag(PlotWeather.RAIN);
public static final PlotWeatherFlag PLOT_WEATHER_FLAG_OFF = new PlotWeatherFlag(PlotWeather.RESET); public static final PlotWeatherFlag PLOT_WEATHER_FLAG_CLEAR =
new PlotWeatherFlag(PlotWeather.CLEAR);
public static final PlotWeatherFlag PLOT_WEATHER_FLAG_OFF =
new PlotWeatherFlag(PlotWeather.RESET);
/** /**
* Construct a new flag instance. * Construct a new flag instance.

View File

@ -5,7 +5,8 @@ import com.github.intellectualsites.plotsquared.plot.flags.types.NonNegativeInte
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public class VehicleCapFlag extends NonNegativeIntegerFlag<VehicleCapFlag> { public class VehicleCapFlag extends NonNegativeIntegerFlag<VehicleCapFlag> {
public static final VehicleCapFlag VEHICLE_CAP_UNLIMITED = new VehicleCapFlag(Integer.MAX_VALUE); public static final VehicleCapFlag VEHICLE_CAP_UNLIMITED =
new VehicleCapFlag(Integer.MAX_VALUE);
protected VehicleCapFlag(int value) { protected VehicleCapFlag(int value) {
super(value, Captions.FLAG_DESCRIPTION_VEHICLE_CAP); super(value, Captions.FLAG_DESCRIPTION_VEHICLE_CAP);

View File

@ -6,8 +6,10 @@ import org.jetbrains.annotations.NotNull;
public class VillagerInteractFlag extends BooleanFlag<VillagerInteractFlag> { public class VillagerInteractFlag extends BooleanFlag<VillagerInteractFlag> {
public static final VillagerInteractFlag VILLAGER_INTERACT_TRUE = new VillagerInteractFlag(true); public static final VillagerInteractFlag VILLAGER_INTERACT_TRUE =
public static final VillagerInteractFlag VILLAGER_INTERACT_FALSE = new VillagerInteractFlag(false); new VillagerInteractFlag(true);
public static final VillagerInteractFlag VILLAGER_INTERACT_FALSE =
new VillagerInteractFlag(false);
private VillagerInteractFlag(boolean value) { private VillagerInteractFlag(boolean value) {
super(value, Captions.FLAG_DESCRIPTION_VILLAGER_INTERACT); super(value, Captions.FLAG_DESCRIPTION_VILLAGER_INTERACT);

View File

@ -11,7 +11,8 @@ import org.jetbrains.annotations.NotNull;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
public abstract class BlockTypeListFlag<F extends ListFlag<BlockType, F>> extends ListFlag<BlockType, F> { public abstract class BlockTypeListFlag<F extends ListFlag<BlockType, F>>
extends ListFlag<BlockType, F> {
protected BlockTypeListFlag(List<BlockType> blockTypeList, Caption description) { protected BlockTypeListFlag(List<BlockType> blockTypeList, Caption description) {
super(blockTypeList, Captions.FLAG_CATEGORY_BLOCK_LIST, description); super(blockTypeList, Captions.FLAG_CATEGORY_BLOCK_LIST, description);

View File

@ -12,8 +12,10 @@ import java.util.Locale;
public abstract class BooleanFlag<F extends PlotFlag<Boolean, F>> extends PlotFlag<Boolean, F> { public abstract class BooleanFlag<F extends PlotFlag<Boolean, F>> extends PlotFlag<Boolean, F> {
private static final Collection<String> positiveValues = Arrays.asList("1", "yes", "allow", "true"); private static final Collection<String> positiveValues =
private static final Collection<String> negativeValues = Arrays.asList("0", "no", "deny", "disallow", "false"); Arrays.asList("1", "yes", "allow", "true");
private static final Collection<String> negativeValues =
Arrays.asList("0", "no", "deny", "disallow", "false");
/** /**
* Construct a new flag instance. * Construct a new flag instance.

View File

@ -8,7 +8,8 @@ import org.jetbrains.annotations.NotNull;
public abstract class DoubleFlag<F extends NumberFlag<Double, F>> extends NumberFlag<Double, F> { public abstract class DoubleFlag<F extends NumberFlag<Double, F>> extends NumberFlag<Double, F> {
protected DoubleFlag(@NotNull Double value, Double minimum, Double maximum, @NotNull Caption flagDescription) { protected DoubleFlag(@NotNull Double value, Double minimum, Double maximum,
@NotNull Caption flagDescription) {
super(value, minimum, maximum, Captions.FLAG_CATEGORY_DOUBLES, flagDescription); super(value, minimum, maximum, Captions.FLAG_CATEGORY_DOUBLES, flagDescription);
} }

View File

@ -7,7 +7,8 @@ import org.jetbrains.annotations.NotNull;
public abstract class IntegerFlag<F extends NumberFlag<Integer, F>> extends NumberFlag<Integer, F> { public abstract class IntegerFlag<F extends NumberFlag<Integer, F>> extends NumberFlag<Integer, F> {
protected IntegerFlag(final int value, int minimum, int maximum, @NotNull Caption flagDescription) { protected IntegerFlag(final int value, int minimum, int maximum,
@NotNull Caption flagDescription) {
super(value, minimum, maximum, Captions.FLAG_CATEGORY_INTEGERS, flagDescription); super(value, minimum, maximum, Captions.FLAG_CATEGORY_INTEGERS, flagDescription);
} }

View File

@ -7,11 +7,12 @@ import org.jetbrains.annotations.NotNull;
public abstract class LongFlag<F extends NumberFlag<Long, F>> extends NumberFlag<Long, F> { public abstract class LongFlag<F extends NumberFlag<Long, F>> extends NumberFlag<Long, F> {
protected LongFlag(@NotNull Long value, Long minimum, Long maximum, @NotNull Caption flagDescription) { protected LongFlag(@NotNull Long value, Long minimum, Long maximum,
@NotNull Caption flagDescription) {
super(value, minimum, maximum, Captions.FLAG_CATEGORY_INTEGERS, flagDescription); super(value, minimum, maximum, Captions.FLAG_CATEGORY_INTEGERS, flagDescription);
} }
protected LongFlag(@NotNull Long value,@NotNull Caption flagDescription) { protected LongFlag(@NotNull Long value, @NotNull Caption flagDescription) {
this(value, Long.MIN_VALUE, Long.MAX_VALUE, flagDescription); this(value, Long.MIN_VALUE, Long.MAX_VALUE, flagDescription);
} }

View File

@ -6,7 +6,8 @@ import com.github.intellectualsites.plotsquared.plot.flags.FlagParseException;
import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag; import com.github.intellectualsites.plotsquared.plot.flags.PlotFlag;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
public abstract class NumberFlag<N extends Number & Comparable<N>, F extends PlotFlag<N, F>> extends PlotFlag<N, F> { public abstract class NumberFlag<N extends Number & Comparable<N>, F extends PlotFlag<N, F>>
extends PlotFlag<N, F> {
protected final N minimum; protected final N minimum;
protected final N maximum; protected final N maximum;
@ -14,7 +15,8 @@ public abstract class NumberFlag<N extends Number & Comparable<N>, F extends Plo
@NotNull Caption flagDescription) { @NotNull Caption flagDescription) {
super(value, flagCategory, flagDescription); super(value, flagCategory, flagDescription);
if (maximum.compareTo(minimum) < 0) { if (maximum.compareTo(minimum) < 0) {
throw new IllegalArgumentException("Maximum may not be less than minimum:" + maximum + " < " + minimum); throw new IllegalArgumentException(
"Maximum may not be less than minimum:" + maximum + " < " + minimum);
} }
this.minimum = minimum; this.minimum = minimum;
this.maximum = maximum; this.maximum = maximum;
@ -23,8 +25,8 @@ public abstract class NumberFlag<N extends Number & Comparable<N>, F extends Plo
@Override public F parse(@NotNull String input) throws FlagParseException { @Override public F parse(@NotNull String input) throws FlagParseException {
final N parsed = parseNumber(input); final N parsed = parseNumber(input);
if (parsed.compareTo(minimum) < 0 || parsed.compareTo(maximum) > 0) { if (parsed.compareTo(minimum) < 0 || parsed.compareTo(maximum) > 0) {
throw new FlagParseException(this, input, throw new FlagParseException(this, input, Captions.NUMBER_NOT_IN_RANGE, minimum,
Captions.NUMBER_NOT_IN_RANGE, minimum, maximum); maximum);
} }
return flagOf(parsed); return flagOf(parsed);

Some files were not shown because too many files have changed in this diff Show More