Merge pull request #995 from manuelgu/master

Cleanup
This commit is contained in:
Matt 2016-03-22 14:36:41 -04:00
commit e18e1d4816
46 changed files with 477 additions and 341 deletions

View File

@ -31,7 +31,6 @@ import org.bukkit.material.Step;
import org.bukkit.material.Tree;
import org.bukkit.material.WoodenStep;
import org.bukkit.material.Wool;
import java.util.Arrays;
import java.util.List;

View File

@ -33,13 +33,13 @@ import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(
command = "setalias",
permission = "plots.set.alias",
description = "Set the plot name",
description = "Set the plot name",
usage = "/plot alias <alias>",
aliases = { "alias", "sa", "name", "rename", "setname", "seta" },
category = CommandCategory.SETTINGS,
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE)
public class Alias extends SetCommand {
@Override
public boolean set(final PlotPlayer plr, final Plot plot, final String alias) {
if (alias.isEmpty()) {

View File

@ -26,16 +26,20 @@ import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Objects;
import java.util.Set;
@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>")
@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>")
public class Area extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, String[] args) {
if (args.length == 0) {
@ -380,7 +384,7 @@ public class Area extends SubCommand {
.text("\nClusters=").color("$1").text("" + clusters).color("$2")
.text("\nRegion=").color("$1").text(region).color("$2")
.text("\nGenerator=").color("$1").text(generator).color("$2");
// type / terrain
String visit = "/plot area tp " + area.toString();
message.text("[").color("$3")
@ -457,5 +461,5 @@ public class Area extends SubCommand {
C.COMMAND_SYNTAX.send(plr, getUsage());
return false;
}
}

View File

@ -32,10 +32,15 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "auto", permission = "plots.auto", category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE,
description = "Claim the nearest plot", aliases = "a", usage = "/plot auto [length,width]")
@CommandDeclaration(command = "auto",
permission = "plots.auto",
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
description = "Claim the nearest plot",
aliases = "a",
usage = "/plot auto [length,width]")
public class Auto extends SubCommand {
public static PlotId getNextPlotId(final PlotId id, final int step) {
final int absX = Math.abs(id.x);
final int absY = Math.abs(id.y);
@ -64,7 +69,7 @@ public class Auto extends SubCommand {
return new PlotId(id.x + 1, id.y);
}
}
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
PlotArea plotarea = plr.getApplicablePlotArea();
@ -199,7 +204,7 @@ public class Auto extends SubCommand {
plotarea.setMeta("lastPlot", new PlotId(0, 0));
return true;
}
public PlotId getLastPlotId(final PlotArea area) {
PlotId value = (PlotId) area.getMeta("lastPlot");
if (value == null) {

View File

@ -29,14 +29,19 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "bo3", aliases = { "bo2" }, description = "Mark a plot as done", permission = "plots.bo3", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE)
@CommandDeclaration(command = "bo3",
aliases = { "bo2" },
description = "Mark a plot as done",
permission = "plots.bo3",
category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE)
public class BO3 extends SubCommand {
public void noArgs(final PlotPlayer plr) {
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 export [category] [alias] [-r]");
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
}
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation();

View File

@ -31,8 +31,12 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot claim")
@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")
public class Claim extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String... args) {

View File

@ -20,8 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.Set;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.FlagManager;
@ -34,11 +32,16 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Set;
@CommandDeclaration(command = "clear", description = "Clear a plot", permission = "plots.clear", category = CommandCategory.APPEARANCE,
usage = "/plot clear [id]", aliases = "reset")
@CommandDeclaration(command = "clear",
description = "Clear a plot",
permission = "plots.clear",
category = CommandCategory.APPEARANCE,
usage = "/plot clear [id]",
aliases = "reset")
public class Clear extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String... args) {
final Location loc = plr.getLocation();

View File

@ -35,19 +35,22 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@CommandDeclaration(command = "cluster", aliases = "clusters", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE,
permission = "plots.cluster", description = "Manage a plot cluster")
@CommandDeclaration(command = "cluster",
aliases = "clusters",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
permission = "plots.cluster",
description = "Manage a plot cluster")
public class Cluster extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String... args) {
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
if (args.length == 0) {
// return arguments

View File

@ -20,9 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
@ -35,10 +32,17 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Arrays;
import java.util.Map.Entry;
@CommandDeclaration(command = "comment", aliases = { "msg" }, description = "Comment on a plot", category = CommandCategory.CHAT, requiredType = RequiredType.NONE, permission = "plots.comment")
@CommandDeclaration(command = "comment",
aliases = { "msg" },
description = "Comment on a plot",
category = CommandCategory.CHAT,
requiredType = RequiredType.NONE,
permission = "plots.comment")
public class Comment extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer player, final String[] args) {
if (args.length < 2) {

View File

@ -30,7 +30,6 @@ import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
@ -39,11 +38,15 @@ import java.util.List;
import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
@CommandDeclaration(command = "condense", permission = "plots.admin", description = "Condense a plotworld", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.CONSOLE)
@CommandDeclaration(command = "condense",
permission = "plots.admin",
description = "Condense a plotworld",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.CONSOLE)
public class Condense extends SubCommand {
public static boolean TASK = false;
@Override
public boolean onCommand(final PlotPlayer plr, final String... args) {
if ((args.length != 2) && (args.length != 3)) {
@ -218,7 +221,7 @@ public class Condense extends SubCommand {
MainUtil.sendMessage(plr, "/plot condense " + area.worldname + " <start|stop|info> [radius]");
return false;
}
public Set<PlotId> getPlots(final Collection<Plot> plots, final int radius) {
final HashSet<PlotId> outside = new HashSet<>();
for (final Plot plot : plots) {

View File

@ -28,9 +28,12 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "confirm", permission = "plots.use", description = "Confirm an action", category = CommandCategory.INFO)
@CommandDeclaration(command = "confirm",
permission = "plots.use",
description = "Confirm an action",
category = CommandCategory.INFO)
public class Confirm extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String... args) {
final CmdInstance command = CmdConfirm.getPending(plr);

View File

@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
@ -27,11 +26,9 @@ category = CommandCategory.ADMINISTRATION,
permission = "plots.database",
description = "Convert/Backup Storage",
requiredType = RequiredType.CONSOLE,
usage = "/plots database [area] <sqlite|mysql|import>"
)
usage = "/plots database [area] <sqlite|mysql|import>")
public class Database extends SubCommand {
public static void insertPlots(final SQLManager manager, final ArrayList<Plot> plots, final PlotPlayer player) {
TaskManager.runTaskAsync(new Runnable() {
@Override
@ -56,7 +53,7 @@ public class Database extends SubCommand {
}
});
}
@Override
public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length < 1) {

View File

@ -28,9 +28,13 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "debug", category = CommandCategory.DEBUG, description = "Show debug information", usage = "/plot debug [msg]", permission = "plots.admin")
@CommandDeclaration(command = "debug",
category = CommandCategory.DEBUG,
description = "Show debug information",
usage = "/plot debug [msg]",
permission = "plots.admin")
public class Debug extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
@ -70,11 +74,11 @@ public class Debug extends SubCommand {
}
return true;
}
private String getSection(final String line, final String val) {
return line.replaceAll("%val%", val) + "\n";
}
private String getLine(final String line, final String var, final Object val) {
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n";
}

View File

@ -27,26 +27,57 @@ import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotAnalysis;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.AbstractTitle;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
import com.plotsquared.listener.WEManager;
import javax.script.*;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.sql.Timestamp;
import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.UUID;
import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
import javax.script.ScriptEngineManager;
import javax.script.ScriptException;
import javax.script.SimpleScriptContext;
@CommandDeclaration(command = "debugexec", permission = "plots.admin", description = "Mutli-purpose debug command", aliases = "exec",
category = CommandCategory.DEBUG)
@CommandDeclaration(command = "debugexec",
permission = "plots.admin",
description = "Mutli-purpose debug command",
aliases = "exec",
category = CommandCategory.DEBUG)
public class DebugExec extends SubCommand {
private ScriptEngine engine;
private Bindings scope;
public DebugExec() {
try {
if (PS.get() != null) {
@ -64,15 +95,15 @@ public class DebugExec extends SubCommand {
}
} catch (IOException | ScriptException e) {}
}
public ScriptEngine getEngine() {
return engine;
}
public Bindings getScope() {
return scope;
}
public void init() {
if (engine != null) {
return;
@ -83,14 +114,14 @@ public class DebugExec extends SubCommand {
}
final ScriptContext context = new SimpleScriptContext();
scope = context.getBindings(ScriptContext.ENGINE_SCOPE);
// stuff
scope.put("MainUtil", new MainUtil());
scope.put("Settings", new Settings());
scope.put("StringMan", new StringMan());
scope.put("MathMan", new MathMan());
scope.put("FlagManager", new FlagManager());
// Classes
scope.put("Location", Location.class);
scope.put("PlotBlock", PlotBlock.class);
@ -98,7 +129,7 @@ public class DebugExec extends SubCommand {
scope.put("PlotId", PlotId.class);
scope.put("Runnable", Runnable.class);
scope.put("RunnableVal", RunnableVal.class);
// Instances
scope.put("PS", PS.get());
scope.put("SetQueue", SetQueue.IMP);
@ -120,16 +151,16 @@ public class DebugExec extends SubCommand {
scope.put("HybridUtils", HybridUtils.manager);
scope.put("IMP", PS.get().IMP);
scope.put("MainCommand", MainCommand.getInstance());
// enums
for (final Enum<?> value : C.values()) {
scope.put("C_" + value.name(), value);
}
}
@Override
public boolean onCommand(final PlotPlayer player, final String... args) {
final List<String> allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen");
final java.util.List<String> allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen");
if (args.length > 0) {
final String arg = args[0].toLowerCase();
String script;
@ -152,7 +183,7 @@ public class DebugExec extends SubCommand {
HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
@Override
public void run(PlotAnalysis value) {
MainUtil.sendMessage(player, "$1Done: $2use $3/plot debugexec analyze$2 for more information");
MainUtil.sendMessage(player, "$1Done: $2Use $3/plot debugexec analyze$2 for more information");
}
});
return true;
@ -219,11 +250,11 @@ public class DebugExec extends SubCommand {
}
case "stop-rgar":
if (!HybridUtils.UPDATE) {
MainUtil.sendMessage(player, "&cTASK NOT RUNNING!");
MainUtil.sendMessage(player, "&cTask not running!");
return false;
}
HybridUtils.UPDATE = false;
MainUtil.sendMessage(player, "&cCancelling task... (please wait)");
MainUtil.sendMessage(player, "&cCancelling task... (Please wait)");
return true;
case "start-expire":
if (ExpireManager.IMP == null) {
@ -246,11 +277,11 @@ public class DebugExec extends SubCommand {
}
final UUID uuid = UUIDHandler.getUUID(args[1], null);
if (uuid == null) {
return MainUtil.sendMessage(player, "player not found: " + args[1]);
return MainUtil.sendMessage(player, "Player not found: " + args[1]);
}
final OfflinePlotPlayer op = UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid);
if (op == null || op.getLastPlayed() == 0) {
return MainUtil.sendMessage(player, "player hasn't connected before: " + args[1]);
return MainUtil.sendMessage(player, "Player hasn't connected before: " + args[1]);
}
final Timestamp stamp = new Timestamp(op.getLastPlayed());
final Date date = new Date(stamp.getTime());
@ -269,8 +300,7 @@ public class DebugExec extends SubCommand {
case "addcmd":
try {
final String cmd = StringMan.join(Files
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]),
StandardCharsets.UTF_8),
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8),
System.getProperty("line.separator"));
final Command<PlotPlayer> subcommand = new Command<PlotPlayer>(args[1].split("\\.")[0]) {
@Override

View File

@ -9,14 +9,16 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.io.File;
import java.io.IOException;
@CommandDeclaration(command = "debugpaste", aliases = "dp", usage = "/plot debugpaste", description = "Upload settings.yml & latest.log to HasteBin",
permission = "plots.debugpaste", category = CommandCategory.DEBUG)
@CommandDeclaration(command = "debugpaste",
aliases = "dp", usage = "/plot debugpaste",
description = "Upload settings.yml & latest.log to HasteBin",
permission = "plots.debugpaste",
category = CommandCategory.DEBUG)
public class DebugPaste extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
TaskManager.runTaskAsync(new Runnable() {
@ -60,7 +62,7 @@ public class DebugPaste extends SubCommand {
b.append("os.version: '").append(System.getProperty("os.version")).append("'\n\n");
b.append("# Okay :D Great. You are now ready to create your bug report!");
b.append("\n# You can do so at https://github.com/IntellectualSites/PlotSquared/issues");
final String link = HastebinUtility.upload(b.toString());
plr.sendMessage(C.DEBUG_REPORT_CREATED.s().replace("%url%", link));
} catch (final IOException e) {

View File

@ -33,19 +33,23 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID;
@CommandDeclaration(command = "deny", aliases = { "d", "ban" }, description = "Deny a user from a plot", usage = "/plot deny <player>", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE)
@CommandDeclaration(command = "deny",
aliases = { "d", "ban" },
description = "Deny a user from a plot",
usage = "/plot deny <player>",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE)
public class Deny extends SubCommand {
public Deny() {
requiredArguments = new Argument[] { Argument.PlayerName };
}
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation();
final Plot plot = loc.getPlotAbs();
if (plot == null) {
@ -73,7 +77,7 @@ public class Deny extends SubCommand {
MainUtil.sendMessage(plr, C.ALREADY_OWNER);
return false;
}
if (plot.getDenied().contains(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_ADDED);
return false;
@ -92,7 +96,7 @@ public class Deny extends SubCommand {
}
return true;
}
private void handleKick(final PlotPlayer pp, final Plot plot) {
if (pp == null) {
return;

View File

@ -34,10 +34,10 @@ permission = "plots.set.desc",
description = "Set the plot description",
usage = "/plot desc <description>",
aliases = { "desc", "setdesc", "setd", "description" },
category = CommandCategory.SETTINGS,
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE)
public class Desc extends SetCommand {
@Override
public boolean set(PlotPlayer plr, Plot plot, String desc) {
if (desc.isEmpty()) {

View File

@ -34,9 +34,14 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "done", aliases = { "submit" }, description = "Mark a plot as done", permission = "plots.done", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE)
@CommandDeclaration(command = "done",
aliases = { "submit" },
description = "Mark a plot as done",
permission = "plots.done",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE)
public class Done extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation();

View File

@ -17,9 +17,15 @@ import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import java.net.URL;
@CommandDeclaration(usage = "/plot download [schematic|bo3|world]", command = "download", aliases = { "dl" }, category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, description = "Download your plot", permission = "plots.download")
@CommandDeclaration(usage = "/plot download [schematic|bo3|world]",
command = "download",
aliases = { "dl" },
category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE,
description = "Download your plot",
permission = "plots.download")
public class Download extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final String world = plr.getLocation().getWorld();

View File

@ -4,7 +4,6 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.Command;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
@ -45,17 +44,17 @@ public class GenerateDocs {
try {
final String clazz = command.getClass().getSimpleName();
final String name = command.getCommand();
// Header
final String source = "https://github.com/IntellectualSites/PlotSquared/tree/master/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java";
final String source = "https://github.com/IntellectualSites/PlotSquared/tree/master/Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java";
log("## [" + name.toUpperCase() + "](" + source + ") ");
final File file = new File("src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
final File file = new File("Core/src/main/java/com/intellectualcrafters/plot/commands/" + clazz + ".java");
final List<String> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
final List<String> perms = getPerms(name, lines);
final List<String> usages = getUsage(name, lines);
final String comment = getComments(lines);
log("#### Description");
log("`" + command.getDescription() + "`");
if (!comment.isEmpty()) {
@ -64,7 +63,7 @@ public class GenerateDocs {
log(comment);
log("```");
}
log("#### Usage ");
{
String mainUsage = command.getUsage().replaceAll("\\{label\\}", "plot");
@ -79,18 +78,18 @@ public class GenerateDocs {
log("`" + mainUsage + "` ");
}
}
if (command.getRequiredType() != RequiredType.NONE) {
log("#### Required callers");
log("`" + command.getRequiredType().name() + "`");
}
final Set<String> aliases = command.getAliases();
if (!aliases.isEmpty()) {
log("#### Aliases");
log("`" + StringMan.getString(command.getAliases()) + "`");
}
log("#### Permissions");
if (!perms.isEmpty()) {
log("##### Primary");
@ -108,7 +107,7 @@ public class GenerateDocs {
e.printStackTrace();
}
}
public static List<String> getUsage(String cmd, List<String> lines) {
final Pattern p = Pattern.compile("\"([^\"]*)\"");
HashSet<String> usages = new HashSet<String>();
@ -136,7 +135,7 @@ public class GenerateDocs {
final Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)");
String last = null;
for (final String line : lines) {
Matcher m2 = p2.matcher(line);
while (m2.find()) {
perms.add(C.valueOf("PERMISSION_" + m2.group(1)).s());
@ -215,7 +214,7 @@ public class GenerateDocs {
}
return result.toString().trim();
}
public static void log(final String s) {
System.out.println(s);
}

View File

@ -1,7 +1,5 @@
package com.intellectualcrafters.plot.commands;
import java.util.UUID;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -11,14 +9,14 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID;
@CommandDeclaration(
command = "grant",
category = CommandCategory.CLAIMING,
usage = "/plot grant <check|add> [player]",
permission = "plots.grant",
requiredType = RequiredType.NONE
)
command = "grant",
category = CommandCategory.CLAIMING,
usage = "/plot grant <check|add> [player]",
permission = "plots.grant",
requiredType = RequiredType.NONE)
public class Grant extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {

View File

@ -3,9 +3,12 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "help", description = "Get this help menu", aliases = { "he" }, category = CommandCategory.INFO)
@CommandDeclaration(command = "help",
description = "Get this help menu",
aliases = { "he" },
category = CommandCategory.INFO)
public class Help extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
return true;

View File

@ -23,10 +23,14 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "home", aliases = { "h" }, description = "Go to your plot", usage = "/plot home [id|alias]",
category = CommandCategory.TELEPORT, requiredType = RequiredType.NONE)
@CommandDeclaration(command = "home",
aliases = { "h" },
description = "Go to your plot",
usage = "/plot home [id|alias]",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.NONE)
public class Home extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, String[] args) {
return MainCommand.getInstance().getCommand("visit").onCommand(plr, args);

View File

@ -29,12 +29,15 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID;
@CommandDeclaration(command = "info", aliases = "i", description = "Display plot info", usage = "/plot info <id>", category = CommandCategory.INFO)
@CommandDeclaration(command = "info",
aliases = "i",
description = "Display plot info",
usage = "/plot info <id>",
category = CommandCategory.INFO)
public class Info extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer player, String[] args) {
Plot plot;
@ -143,7 +146,7 @@ public class Info extends SubCommand {
});
return true;
}
private String getCaption(final String string) {
switch (string) {
case "trusted":

View File

@ -30,9 +30,14 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "kick", aliases = { "k" }, description = "Kick a player from your plot", permission = "plots.kick", category = CommandCategory.TELEPORT, requiredType = RequiredType.NONE)
@CommandDeclaration(command = "kick",
aliases = { "k" },
description = "Kick a player from your plot",
permission = "plots.kick",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.NONE)
public class Kick extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation();

View File

@ -37,7 +37,6 @@ import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandHandlingOutput;
import com.plotsquared.general.commands.CommandManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@ -50,7 +49,6 @@ import java.util.List;
*/
public class MainCommand extends CommandManager<PlotPlayer> {
private static MainCommand instance;
private MainCommand() {
@ -86,11 +84,11 @@ public class MainCommand extends CommandManager<PlotPlayer> {
createCommand(new Remove());
createCommand(new Undeny());
createCommand(new Info());
createCommand(new list());
createCommand(new com.intellectualcrafters.plot.commands.List());
createCommand(new Help());
createCommand(new Debug());
createCommand(new SchematicCmd());
createCommand(new plugin());
createCommand(new Plugin());
createCommand(new Purge());
createCommand(new Reload());
createCommand(new Merge());
@ -103,7 +101,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
createCommand(new Comment());
createCommand(new Database());
createCommand(new Swap());
createCommand(new MusicSubcommand());
createCommand(new Music());
createCommand(new DebugRoadRegen());
createCommand(new Trust());
createCommand(new DebugExec());
@ -143,7 +141,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
MainUtil.sendMessage(player, C.NO_PERMISSION, permission);
return false;
}
public static List<Command<PlotPlayer>> getCommandAndAliases(final CommandCategory category, final PlotPlayer player) {
final List<Command<PlotPlayer>> commands = new ArrayList<>();
for (final Command<PlotPlayer> command : getInstance().getCommands()) {
@ -157,7 +155,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
}
return commands;
}
public static List<Command<PlotPlayer>> getCommands(final CommandCategory category, final PlotPlayer player) {
final List<Command<PlotPlayer>> commands = new ArrayList<>();
for (final Command<PlotPlayer> command : new HashSet<>(getInstance().getCommands())) {
@ -171,7 +169,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
}
return commands;
}
public static void displayHelp(final PlotPlayer player, String cat, int page, final String label) {
CommandCategory catEnum = null;
if (cat != null) {
@ -204,7 +202,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
page--;
new HelpMenu(player).setCategory(catEnum).getCommands().generateMaxPages().generatePage(page, label).render();
}
public static boolean onCommand(final PlotPlayer player, final String cmd, String... args) {
// Clear perm caching //
player.deleteMeta("perm");
@ -314,7 +312,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
}
return true;
}
public int getMatch(String[] args, Command<PlotPlayer> cmd) {
int count = 0;
String perm = cmd.getPermission();
@ -353,7 +351,7 @@ public class MainCommand extends CommandManager<PlotPlayer> {
count += StringMan.intersection(desc, args);
return count;
}
@Override
public int handle(final PlotPlayer plr, final String input) {
final String[] parts = input.split(" ");

View File

@ -36,9 +36,12 @@ import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashSet;
import java.util.UUID;
@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)
@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)
public class Merge extends SubCommand {
public final static String[] values = new String[] { "north", "east", "south", "west", "auto" };
public final static String[] aliases = new String[] { "n", "e", "s", "w", "all" };

View File

@ -12,13 +12,12 @@ import com.plotsquared.general.commands.CommandDeclaration;
* @author manuelgu, altered by Citymonstret
*/
@CommandDeclaration(
command = "middle",
aliases = { "center" },
description = "Teleports you to the center of the current plot",
usage = "/plot middle",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.PLAYER
)
command = "middle",
aliases = { "center" },
description = "Teleports you to the center of the current plot",
usage = "/plot middle",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.PLAYER)
public class Middle extends SubCommand {
@Override

View File

@ -39,7 +39,7 @@ description = "Player music in a plot",
usage = "/plot music",
category = CommandCategory.APPEARANCE,
requiredType = RequiredType.NONE)
public class MusicSubcommand extends SubCommand {
public class Music extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer player, final String[] args) {

View File

@ -36,7 +36,6 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@ -44,8 +43,13 @@ import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
@CommandDeclaration(command = "rate", permission = "plots.rate", description = "Rate the plot", usage = "/plot rate [#|next]", aliases = "rt",
category = CommandCategory.INFO, requiredType = RequiredType.NONE)
@CommandDeclaration(command = "rate",
permission = "plots.rate",
description = "Rate the plot",
usage = "/plot rate [#|next]",
aliases = "rt",
category = CommandCategory.INFO,
requiredType = RequiredType.NONE)
public class Rate extends SubCommand {
@Override

View File

@ -20,8 +20,6 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands;
import java.util.Objects;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.MemorySection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
@ -32,10 +30,15 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Objects;
@CommandDeclaration(command = "reload", permission = "plots.admin.command.reload", description = "Reload configurations", usage = "/plot reload", category = CommandCategory.ADMINISTRATION)
@CommandDeclaration(command = "reload",
permission = "plots.admin.command.reload",
description = "Reload configurations",
usage = "/plot reload",
category = CommandCategory.ADMINISTRATION)
public class Reload extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
try {
@ -72,7 +75,7 @@ public class Reload extends SubCommand {
}
}
area.saveConfiguration(clone);
// netSections is the combination of
// netSections is the combination of
for (String key : clone.getKeys(true)) {
if (clone.get(key) instanceof MemorySection) {
continue;

View File

@ -14,17 +14,21 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.net.URL;
import java.util.List;
import java.util.UUID;
@CommandDeclaration(command = "save", aliases = { "backup" }, description = "Save your plot", category = CommandCategory.SCHEMATIC, requiredType = RequiredType.NONE, permission = "plots.save")
@CommandDeclaration(command = "save",
aliases = { "backup" },
description = "Save your plot",
category = CommandCategory.SCHEMATIC,
requiredType = RequiredType.NONE,
permission = "plots.save")
public class Save extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
if (!Settings.METRICS) {
MainUtil.sendMessage(plr, "&cPlease enable metrics in order to use this command.\n&7 - Or host it yourself if you don't like the free service");
return false;

View File

@ -23,14 +23,18 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
@ -44,9 +48,8 @@ aliases = { "sch" },
category = CommandCategory.SCHEMATIC,
usage = "/plot schematic <arg...>")
public class SchematicCmd extends SubCommand {
private boolean running = false;
@Override
public boolean onCommand(final PlotPlayer plr, final String... args) {
if (args.length < 1) {
@ -54,8 +57,6 @@ public class SchematicCmd extends SubCommand {
return true;
}
final String arg = args[0].toLowerCase();
final String file;
final Schematic schematic;
switch (arg) {
case "paste": {
if (!Permissions.hasPermission(plr, "plots.schematic.paste")) {

View File

@ -28,9 +28,14 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(usage = "/plot swap <X;Z>", command = "swap", description = "Swap two plots", aliases = { "switch" }, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE)
@CommandDeclaration(usage = "/plot swap <X;Z>",
command = "swap",
description = "Swap two plots",
aliases = { "switch" },
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE)
public class Swap extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation();

View File

@ -37,11 +37,11 @@ permission = "plots.target",
requiredType = RequiredType.NONE,
category = CommandCategory.INFO)
public class Target extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location ploc = plr.getLocation();
if (!PS.get().hasPlotArea(ploc.getWorld())) {
if (!ploc.isPlotArea()) {
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
return false;
}
@ -56,7 +56,7 @@ public class Target extends SubCommand {
}
}
if (target == null) {
C.FOUND_NO_PLOTS.send(plr);
MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS);
return false;
}
} else if ((target = MainUtil.getPlotFromString(plr, args[0], true)) == null) {

View File

@ -32,12 +32,17 @@ import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "unlink", aliases = { "u", "unmerge" }, description = "Unlink a mega-plot", usage = "/plot unlink", requiredType = RequiredType.NONE, category = CommandCategory.SETTINGS)
@CommandDeclaration(command = "unlink",
aliases = { "u", "unmerge" },
description = "Unlink a mega-plot",
usage = "/plot unlink",
requiredType = RequiredType.NONE,
category = CommandCategory.SETTINGS)
public class Unlink extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation();
final Plot plot = loc.getPlotAbs();
if (plot == null) {

View File

@ -25,7 +25,6 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration;
import java.net.MalformedURLException;
import java.net.URL;
@ -38,9 +37,7 @@ requiredType = RequiredType.NONE,
aliases = { "updateplugin" },
category = CommandCategory.ADMINISTRATION)
public class Update extends SubCommand {
public static String version;
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
URL url;
@ -50,7 +47,7 @@ public class Update extends SubCommand {
try {
url = new URL(args[0]);
} catch (final MalformedURLException e) {
MainUtil.sendMessage(plr, "&cInvalid url: " + args[0]);
MainUtil.sendMessage(plr, "&cInvalid URL: " + args[0]);
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]");
return false;
}
@ -68,5 +65,5 @@ public class Update extends SubCommand {
}
return true;
}
}

View File

@ -40,13 +40,11 @@ import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.UUID;
@ -57,10 +55,10 @@ 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...>> [#]")
public class list extends SubCommand {
public class List extends SubCommand {
private String[] getArgumentList(final PlotPlayer player) {
final List<String> args = new ArrayList<>();
final java.util.List<String> args = new ArrayList<>();
if ((EconHandler.manager != null) && Permissions.hasPermission(player, "plots.list.forsale")) {
args.add("forsale");
}
@ -102,11 +100,11 @@ public class list extends SubCommand {
}
return args.toArray(new String[args.size()]);
}
public void noArgs(final PlotPlayer plr) {
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(plr)));
}
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
if (args.length < 1) {
@ -125,9 +123,9 @@ public class list extends SubCommand {
page = -1;
}
}
List<Plot> plots = null;
java.util.List<Plot> plots = null;
final String world = plr.getLocation().getWorld();
final PlotArea area = plr.getApplicablePlotArea();
final String arg = args[0].toLowerCase();
@ -353,7 +351,7 @@ public class list extends SubCommand {
}
}
}
if (plots == null) {
sendMessage(plr, C.DID_YOU_MEAN, new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
return false;
@ -366,8 +364,8 @@ public class list extends SubCommand {
displayPlots(plr, plots, 12, page, area, args, sort);
return true;
}
public void displayPlots(final PlotPlayer player, List<Plot> plots, final int pageSize, int page, final PlotArea area, final String[] args, final boolean sort) {
public void displayPlots(final PlotPlayer player, java.util.List<Plot> plots, final int pageSize, int page, final PlotArea area, final String[] args, final boolean sort) {
// Header
Iterator<Plot> iter = plots.iterator();
while (iter.hasNext()) {

View File

@ -25,10 +25,13 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = "version",
category = CommandCategory.INFO)
public class plugin extends SubCommand {
@CommandDeclaration(command = "plugin",
permission = "plots.use",
description = "Show plugin information",
aliases = "version",
category = CommandCategory.INFO)
public class Plugin extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, final String[] args) {
MainUtil.sendMessage(plr, String.format("$2>> $1&lPlotSquared $2($1Version$2: $1%s$2)", PS.get().IMP.getPluginVersion()));

View File

@ -23,11 +23,11 @@ public class Location implements Cloneable, Comparable<Location> {
this.pitch = pitch;
built = false;
}
public Location() {
this("", 0, 0, 0, 0, 0);
}
public Location(final String world, final int x, final int y, final int z) {
this(world, x, y, z, 0f, 0f);
}
@ -40,30 +40,30 @@ public class Location implements Cloneable, Comparable<Location> {
public int getX() {
return x;
}
public void setX(final int x) {
this.x = x;
built = false;
}
public int getY() {
return y;
}
public void setY(final int y) {
this.y = y;
built = false;
}
public int getZ() {
return z;
}
public void setZ(final int z) {
this.z = z;
built = false;
}
public String getWorld() {
return world;
}
@ -76,7 +76,7 @@ public class Location implements Cloneable, Comparable<Location> {
public PlotArea getPlotArea() {
return PS.get().getPlotAreaAbs(this);
}
public Plot getOwnedPlot() {
PlotArea area = PS.get().getPlotAreaAbs(this);
return area != null ? area.getOwnedPlot(this) : null;
@ -90,7 +90,7 @@ public class Location implements Cloneable, Comparable<Location> {
public boolean isPlotArea() {
return PS.get().getPlotAreaAbs(this) != null;
}
public boolean isPlotRoad() {
PlotArea area = PS.get().getPlotAreaAbs(this);
return area != null && area.getPlotAbs(this) == null;
@ -119,25 +119,25 @@ public class Location implements Cloneable, Comparable<Location> {
public ChunkLoc getChunkLoc() {
return new ChunkLoc(x >> 4, z >> 4);
}
public float getYaw() {
return yaw;
}
public void setYaw(final float yaw) {
this.yaw = yaw;
built = false;
}
public float getPitch() {
return pitch;
}
public void setPitch(final float pitch) {
this.pitch = pitch;
built = false;
}
public Location add(final int x, final int y, final int z) {
this.x += x;
this.y += y;
@ -145,31 +145,31 @@ public class Location implements Cloneable, Comparable<Location> {
built = false;
return this;
}
public double getEuclideanDistanceSquared(final Location l2) {
final double x = getX() - l2.getX();
final double y = getY() - l2.getY();
final double z = getZ() - l2.getZ();
return x * x + y * y + z * z;
}
public double getEuclideanDistance(final Location l2) {
return Math.sqrt(getEuclideanDistanceSquared(l2));
}
public boolean isInSphere(final Location origin, final int radius) {
return getEuclideanDistanceSquared(origin) < radius * radius;
}
@Override
public int hashCode() {
return MathMan.pair((short) x, (short) z) * 17 + y;
}
public boolean isInAABB(final Location min, final Location max) {
return x >= min.getX() && x <= max.getX() && y >= min.getY() && y <= max.getY() && z >= min.getX() && z < max.getZ();
}
public void lookTowards(final int x, final int y) {
final double l = this.x - x;
final double c = Math.sqrt(l * l + 0.0);
@ -180,7 +180,7 @@ public class Location implements Cloneable, Comparable<Location> {
}
built = false;
}
public Location subtract(final int x, final int y, final int z) {
this.x -= x;
this.y -= y;
@ -188,7 +188,7 @@ public class Location implements Cloneable, Comparable<Location> {
built = false;
return this;
}
@Override
public boolean equals(final Object o) {
if (o == null) {
@ -200,7 +200,7 @@ public class Location implements Cloneable, Comparable<Location> {
final Location l = (Location) o;
return x == l.getX() && y == l.getY() && z == l.getZ() && world.equals(l.getWorld()) && yaw == l.getY() && pitch == l.getPitch();
}
@Override
public int compareTo(final Location o) {
if (x == o.getX() && y == o.getY() || z == o.getZ()) {
@ -211,7 +211,7 @@ public class Location implements Cloneable, Comparable<Location> {
}
return 1;
}
@Override
public String toString() {
return "\"plotsquaredlocation\":{" + "\"x\":" + x + ",\"y\":" + y + ",\"z\":" + z + ",\"yaw\":" + yaw + ",\"pitch\":" + pitch + ",\"world\":\"" + world + "\"}";

View File

@ -40,7 +40,6 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.listener.PlotListener;
import java.awt.Rectangle;
import java.awt.geom.Area;
import java.awt.geom.PathIterator;
@ -70,7 +69,6 @@ import java.util.concurrent.atomic.AtomicInteger;
*/
@SuppressWarnings("javadoc")
public class Plot {
/**
* @deprecated raw access is deprecated
*/

View File

@ -4,10 +4,18 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.commands.RequiredType;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.EventUtil;
import com.intellectualcrafters.plot.util.ExpireManager;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.PlotGamemode;
import com.intellectualcrafters.plot.util.PlotWeather;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandCaller;
import java.util.*;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger;
@ -16,14 +24,13 @@ import java.util.concurrent.atomic.AtomicInteger;
* - Can cast to: BukkitPlayer / SpongePlayer, which are the current implementations<br>
*/
public abstract class PlotPlayer implements CommandCaller {
private Map<String, byte[]> metaMap = new HashMap<>();
/**
* The metadata map
*/
private ConcurrentHashMap<String, Object> meta;
/**
* Efficiently wrap a Player, or OfflinePlayer object to get a PlotPlayer (or fetch if it's already cached)<br>
* - Accepts sponge/bukkit Player (online)
@ -36,7 +43,7 @@ public abstract class PlotPlayer implements CommandCaller {
public static PlotPlayer wrap(final Object obj) {
return PS.get().IMP.wrapPlayer(obj);
}
/**
* Get the cached PlotPlayer from a username<br>
* - This will return null if the player has not finished logging in or is not online
@ -46,7 +53,7 @@ public abstract class PlotPlayer implements CommandCaller {
public static PlotPlayer get(final String name) {
return UUIDHandler.getPlayer(name);
}
/**
* Set some session only metadata for the player
* @param key
@ -58,7 +65,7 @@ public abstract class PlotPlayer implements CommandCaller {
}
meta.put(key, value);
}
/**
* Get the metadata for a key
* @param <T>
@ -71,7 +78,7 @@ public abstract class PlotPlayer implements CommandCaller {
}
return null;
}
public <T> T getMeta(final String key, T def) {
if (meta != null) {
T value = (T) meta.get(key);
@ -89,7 +96,7 @@ public abstract class PlotPlayer implements CommandCaller {
public Object deleteMeta(final String key) {
return meta == null ? null : meta.remove(key);
}
/**
* Returns the player's name
* @see #getName()
@ -98,7 +105,7 @@ public abstract class PlotPlayer implements CommandCaller {
public String toString() {
return getName();
}
/**
* Get the player's current plot<br>
* - This will return null if the player is standing in the road, or not in a plot world/area
@ -108,7 +115,7 @@ public abstract class PlotPlayer implements CommandCaller {
public Plot getCurrentPlot() {
return (Plot) getMeta("lastplot");
}
/**
* Get the total number of allowed plots
* Possibly relevant: (To increment the player's allowed plots, see the example script on the wiki)
@ -117,7 +124,7 @@ public abstract class PlotPlayer implements CommandCaller {
public int getAllowedPlots() {
return Permissions.hasPermissionRange(this, "plots.plot", Settings.MAX_PLOTS);
}
/**
* Get the number of plots the player owns
*
@ -148,7 +155,7 @@ public abstract class PlotPlayer implements CommandCaller {
});
return count.get();
}
/**
* Get the number of plots the player owns in the world
* @param world
@ -170,7 +177,7 @@ public abstract class PlotPlayer implements CommandCaller {
}
return count;
}
/**
* Get the plots the player owns
* @see PS for more searching functions
@ -180,7 +187,7 @@ public abstract class PlotPlayer implements CommandCaller {
public Set<Plot> getPlots() {
return PS.get().getPlots(this);
}
/**
* Return the PlotArea the player is currently in, or null
* @return
@ -188,18 +195,18 @@ public abstract class PlotPlayer implements CommandCaller {
public PlotArea getPlotAreaAbs() {
return PS.get().getPlotAreaAbs(getLocation());
}
public PlotArea getApplicablePlotArea() {
return PS.get().getApplicablePlotArea(getLocation());
}
@Override
public RequiredType getSuperCaller() {
return RequiredType.PLAYER;
}
/////////////// PLAYER META ///////////////
////////////// PARTIALLY IMPLEMENTED ///////////
/**
* Get the player's last recorded location or null if they don't any plot relevant location
@ -212,21 +219,21 @@ public abstract class PlotPlayer implements CommandCaller {
}
return null;
}
////////////////////////////////////////////////
/**
* Get the previous time the player logged in
* @return
*/
public abstract long getPreviousLogin();
/**
* Get the player's full location (including yaw/pitch)
* @return
*/
public abstract Location getLocationFull();
/**
* Get the player's UUID<br>
* === !IMPORTANT ===<br>
@ -236,58 +243,58 @@ public abstract class PlotPlayer implements CommandCaller {
* @return UUID
*/
public abstract UUID getUUID();
/**
* Check the player's permissions<br>
* - Will be cached if permission caching is enabled
*/
@Override
public abstract boolean hasPermission(final String perm);
/**
* Send the player a message
*/
@Override
public abstract void sendMessage(final String message);
/**
* Teleport the player to a location
* @param loc
*/
public abstract void teleport(final Location loc);
/**
* Is the player online
* @return
*/
public abstract boolean isOnline();
/**
* Get the player's name
* @return
*/
public abstract String getName();
/**
* Set the compass target
* @param loc
*/
public abstract void setCompassTarget(final Location loc);
/**
* Load the player data from disk (if applicable)
* @deprecated hacky
*/
@Deprecated
public abstract void loadData();
/**
* Save the player data from disk (if applicable)
* @deprecated hacky
*/
@Deprecated
public abstract void saveData();
/**
* Set player data that will persist restarts
* - Please note that this is not intended to store large values
@ -309,7 +316,7 @@ public abstract class PlotPlayer implements CommandCaller {
}
return getPersistentMeta("attrib_" + key)[0] == 1;
}
/**
* Remove an attribute from a player
* @param key
@ -323,50 +330,50 @@ public abstract class PlotPlayer implements CommandCaller {
* @param weather
*/
public abstract void setWeather(final PlotWeather weather);
/**
* Get the player's gamemode
* @return
*/
public abstract PlotGamemode getGamemode();
/**
* Set the player's gamemode
* @param gamemode
*/
public abstract void setGamemode(final PlotGamemode gamemode);
/**
* Set the player's local time (ticks)
* @param time
*/
public abstract void setTime(final long time);
/**
* Set the player's fly mode
* @param fly
*/
public abstract void setFlight(final boolean fly);
/**
* Play music at a location for the player
* @param loc
* @param id
*/
public abstract void playMusic(final Location loc, final int id);
/**
* Check if the player is banned
* @return
*/
public abstract boolean isBanned();
/**
* Kick the player from the game
* @param message
*/
public abstract void kick(final String message);
/**
* Called when the player quits
*/
@ -388,7 +395,12 @@ public abstract class PlotPlayer implements CommandCaller {
UUIDHandler.getPlayers().remove(name);
PS.get().IMP.unregister(this);
}
/**
* Get the amount of clusters a player owns in the specific world
* @param world
* @return
*/
public int getPlayerClusterCount(final String world) {
final UUID uuid = getUUID();
int count = 0;
@ -399,7 +411,11 @@ public abstract class PlotPlayer implements CommandCaller {
}
return count;
}
/**
* Get the amount of clusters a player owns
* @return
*/
public int getPlayerClusterCount() {
final AtomicInteger count = new AtomicInteger();
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@ -410,7 +426,12 @@ public abstract class PlotPlayer implements CommandCaller {
});
return count.get();
}
/**
* Return a Set of all plots a player owns
* @param world
* @return
*/
public Set<Plot> getPlots(String world) {
UUID uuid = getUUID();
HashSet<Plot> plots = new HashSet<>();

View File

@ -1,22 +1,20 @@
package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.config.Settings;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
public class Rating {
/**
* This is a map of the rating category to the rating value
*/
private HashMap<String, Integer> ratingMap;
private boolean changed;
private int initial;
public Rating(int value) {
initial = value;
ratingMap = new HashMap<>();
@ -36,14 +34,14 @@ public class Rating {
ratingMap.put(null, value);
}
}
public List<String> getCategories() {
if (ratingMap.size() == 1) {
return new ArrayList<>(0);
}
return new ArrayList<>(ratingMap.keySet());
}
public double getAverageRating() {
double total = 0;
for (final Entry<String, Integer> entry : ratingMap.entrySet()) {
@ -51,11 +49,11 @@ public class Rating {
}
return total / ratingMap.size();
}
public Integer getRating(final String category) {
return ratingMap.get(category);
}
public boolean setRating(final String category, final int value) {
changed = true;
if (!ratingMap.containsKey(category)) {
@ -63,7 +61,7 @@ public class Rating {
}
return ratingMap.put(category, value) != null;
}
public int getAggregate() {
if (!changed) {
return initial;
@ -77,7 +75,6 @@ public class Rating {
} else {
return ratingMap.get(null);
}
}
}

View File

@ -5,45 +5,52 @@ import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.LazyBlock;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotBlock;
import com.intellectualcrafters.plot.object.PlotCluster;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.Rating;
import com.plotsquared.listener.PlayerBlockEventType;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.UUID;
public abstract class EventUtil {
public static EventUtil manager = null;
public abstract Rating callRating(final PlotPlayer player, final Plot plot, final Rating rating);
public abstract boolean callClaim(final PlotPlayer player, final Plot plot, final boolean auto);
public abstract boolean callTeleport(final PlotPlayer player, final Location from, final Plot plot);
public abstract boolean callClear(Plot plot);
public abstract void callDelete(Plot plot);
public abstract boolean callFlagAdd(final Flag flag, final Plot plot);
public abstract boolean callFlagRemove(final Flag flag, final Plot plot);
public abstract boolean callFlagRemove(final Flag flag, final PlotCluster cluster);
public abstract boolean callMerge(final Plot plot, final ArrayList<PlotId> plots);
public abstract boolean callUnlink(final PlotArea area, final ArrayList<PlotId> plots);
public abstract void callEntry(final PlotPlayer player, final Plot plot);
public abstract void callLeave(final PlotPlayer player, final Plot plot);
public abstract void callDenied(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added);
public abstract void callTrusted(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added);
public abstract void callMember(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added);
public void doJoinTask(final PlotPlayer pp) {
@ -272,7 +279,7 @@ public abstract class EventUtil {
if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
if (FlagManager.isPlotFlagTrue(plot, "mob-place")) {
return true;
}
@ -295,7 +302,7 @@ public abstract class EventUtil {
if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
}
if (FlagManager.isPlotFlagTrue(plot, "misc-place")) {
return true;
}

View File

@ -62,9 +62,9 @@ import java.util.regex.Matcher;
*
*/
public class MainUtil {
/**
*
*
* @deprecated
* @param loc
* @return
@ -91,7 +91,7 @@ public class MainUtil {
public static short[][] z_loc;
public static short[][][] CACHE_I = null;
public static short[][][] CACHE_J = null;
/**
* This cache is used for world generation and just saves a bit of calculation time when checking if something is in the plot area.
*/
@ -279,10 +279,10 @@ public class MainUtil {
}
return time;
}
/**
* Hashcode of a boolean array.<br>
* - Used for traversing mega plots quickly.
* - Used for traversing mega plots quickly.
* @param array
* @return hashcode
*/
@ -299,7 +299,7 @@ public class MainUtil {
}
return n;
}
/**
* Get a list of plot ids within a selection
* @param pos1
@ -315,11 +315,11 @@ public class MainUtil {
}
return myplots;
}
/**
* Get the name from a UUID<br>
* @param owner
* @return The player's name, None, Everyone or Unknown
* @return The player's name, None, Everyone or Unknown
*/
public static String getName(final UUID owner) {
if (owner == null) {
@ -333,10 +333,10 @@ public class MainUtil {
}
return name;
}
/**
* Get the corner locations for a list of regions<br>
* @see Plot#getCorners()
* @see Plot#getCorners()
* @param world
* @param regions
* @return
@ -378,12 +378,12 @@ public class MainUtil {
public static List<Plot> getPlotsBySearch(final String search) {
final String[] split = search.split(" ");
final int size = split.length * 2;
final List<UUID> uuids = new ArrayList<>();
PlotId id = null;
PlotArea area = null;
String alias = null;
for (final String term : split) {
try {
UUID uuid = UUIDHandler.getUUID(term, null);
@ -402,12 +402,12 @@ public class MainUtil {
}
}
}
final ArrayList<ArrayList<Plot>> plotList = new ArrayList<>(size);
for (int i = 0; i < size; i++) {
plotList.add(new ArrayList<Plot>());
}
for (final Plot plot : PS.get().getPlots()) {
int count = 0;
if (!uuids.isEmpty()) {
@ -443,10 +443,10 @@ public class MainUtil {
}
return plots;
}
/**
* Get the plot from a string<br>
* @param player Provides a context for what world to search in. Prefixing the term with 'world_name;' will override this context.
* @param player Provides a context for what world to search in. Prefixing the term with 'world_name;' will override this context.
* @param arg The search term
* @param message If a message should be sent to the player if a plot cannot be found
* @return The plot if only 1 result is found, or null
@ -512,7 +512,7 @@ public class MainUtil {
}
return area.getPlotAbs(id);
}
/**
* Resend the chunk at a location
* @param world
@ -552,9 +552,9 @@ public class MainUtil {
}
while (SetQueue.IMP.forceChunkSet());
}
/**
* Set a cubioid asynchronously to a set of blocks
* Set a cuboid asynchronously to a set of blocks
* @param world
* @param pos1
* @param pos2
@ -575,7 +575,7 @@ public class MainUtil {
}
}
}
/**
* Set a cuboid to a block
* @param world
@ -593,9 +593,9 @@ public class MainUtil {
}
while (SetQueue.IMP.forceChunkSet());
}
/**
* Set a cuboic asynchronously to a block
* Set a cuboid asynchronously to a block
* @param world
* @param pos1
* @param pos2
@ -610,7 +610,7 @@ public class MainUtil {
}
}
}
/**
* Synchronously set the biome in a selection
* @param world
@ -624,9 +624,9 @@ public class MainUtil {
RegionWrapper region = new RegionWrapper(p1x, p2x, p1z, p2z);
WorldUtil.IMP.setBiomes(world, region, biome);
}
/**
* Get the heighest block at a location
* Get the highest block at a location
* @param world
* @param x
* @param z
@ -639,11 +639,11 @@ public class MainUtil {
}
return result;
}
/**
* Send a message to the player
*
* @param plr Player to recieve message
* @param plr Player to receive message
* @param msg Message to send
*
* @return true Can be used in things such as commands (return PlayerFunctions.sendMessage(...))
@ -651,7 +651,7 @@ public class MainUtil {
public static boolean sendMessage(final PlotPlayer plr, final String msg) {
return sendMessage(plr, msg, true);
}
/**
* Send a message to console
* @param caption
@ -660,7 +660,7 @@ public class MainUtil {
public static void sendConsoleMessage(final C caption, final String... args) {
sendMessage(null, caption, args);
}
/**
* Send a message to a player
* @param plr Can be null to represent console, or use ConsolePlayer.getConsole()
@ -678,7 +678,7 @@ public class MainUtil {
}
return true;
}
/**
* Send a message to the player
*
@ -690,7 +690,7 @@ public class MainUtil {
public static boolean sendMessage(final PlotPlayer plr, final C c, final String... args) {
return sendMessage(plr, c, (Object[]) args);
}
/**
* Send a message to the player
*
@ -756,7 +756,7 @@ public class MainUtil {
}
return ratings;
}
/**
* Format a string with plot information:<br>
* @param info
@ -773,10 +773,10 @@ public class MainUtil {
final String trusted = getPlayerList(plot.getTrusted());
final String members = getPlayerList(plot.getMembers());
final String denied = getPlayerList(plot.getDenied());
final Flag descriptionFlag = FlagManager.getPlotFlagRaw(plot, "description");
final String description = descriptionFlag == null ? C.NONE.s() : descriptionFlag.getValueString();
final String flags;
if (!StringMan.join(FlagManager.getPlotFlags(plot.getArea(), plot.getSettings(), true).values(), "").isEmpty()) {
flags = StringMan.replaceFromMap(
@ -785,9 +785,9 @@ public class MainUtil {
flags = StringMan.replaceFromMap("$2" + C.NONE.s(), C.replacements);
}
final boolean build = plot.isAdded(player.getUUID());
final String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());
final String owner = plot.getOwners().isEmpty() ? "unowned" : getPlayerList(plot.getOwners());
info = info.replaceAll("%id%", plot.getId().toString());
info = info.replaceAll("%alias%", alias);
info = info.replaceAll("%num%", num + "");
@ -831,7 +831,7 @@ public class MainUtil {
}
whenDone.run(info);
}
/**
* Get a list of names given a list of uuids.<br>
* - Uses the format {@link C#PLOT_USER_LIST} for the returned string
@ -854,7 +854,7 @@ public class MainUtil {
}
return list.toString();
}
public static void getPersistentMeta(final UUID uuid, final String key, final RunnableVal<byte[]> result) {
PlotPlayer pp = UUIDHandler.getPlayer(uuid);
if (pp != null) {

Binary file not shown.