diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index b6cd5af3d..53c2fb330 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -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; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Alias.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Alias.java index 484ef667b..3211c57d4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Alias.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Alias.java @@ -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 ", 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()) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java index 0862f0393..3a305828c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java @@ -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 ") +@CommandDeclaration(command = "area", +permission = "plots.area", +category = CommandCategory.ADMINISTRATION, +requiredType = RequiredType.NONE, +description = "Create a new PlotArea", +aliases = "world", +usage = "/plot area ") 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; } - + } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index e8549367e..349e8afd3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -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) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/BO3.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/BO3.java index e775bfdfa..35a64bc13 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/BO3.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/BO3.java @@ -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 "); } - + @Override public boolean onCommand(final PlotPlayer plr, final String[] args) { final Location loc = plr.getLocation(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java index c1b53435c..164bc6438 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Claim.java @@ -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) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Clear.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Clear.java index de7960a52..2a5237448 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Clear.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Clear.java @@ -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(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index f5ff6050b..5581f44fe 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -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 diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Comment.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Comment.java index 22933b616..84ce0f413 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Comment.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Comment.java @@ -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) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Condense.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Condense.java index 413ce8c3b..0e36ee235 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Condense.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Condense.java @@ -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 + " [radius]"); return false; } - + public Set getPlots(final Collection plots, final int radius) { final HashSet outside = new HashSet<>(); for (final Plot plot : plots) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java index aad253e82..a0517700b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Confirm.java @@ -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); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java index 853fe0d03..cb822916e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Database.java @@ -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] " - -) +usage = "/plots database [area] ") public class Database extends SubCommand { - + public static void insertPlots(final SQLManager manager, final ArrayList 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) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java index 9bbd637ee..34d40e38d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Debug.java @@ -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"; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index adbc9a47d..77e978cef 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -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 allowed_params = Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen"); + final java.util.List 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() { @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 subcommand = new Command(args[1].split("\\.")[0]) { @Override diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java index 8b6423193..b5db5b061 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugPaste.java @@ -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) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Deny.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Deny.java index 709216de1..617212d8c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Deny.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -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 ", category = CommandCategory.SETTINGS, requiredType = RequiredType.NONE) +@CommandDeclaration(command = "deny", +aliases = { "d", "ban" }, +description = "Deny a user from a plot", +usage = "/plot deny ", +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; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Desc.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Desc.java index 9b6fae68e..a6ab5965e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Desc.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Desc.java @@ -34,10 +34,10 @@ permission = "plots.set.desc", description = "Set the plot description", usage = "/plot desc ", 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()) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java index 25d08e32c..7156180e7 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java @@ -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(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java index a27d11c31..c5a852d50 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java @@ -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(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java index 635af7030..f232baa7f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/GenerateDocs.java @@ -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 lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8); final List perms = getPerms(name, lines); final List 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 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 getUsage(String cmd, List lines) { final Pattern p = Pattern.compile("\"([^\"]*)\""); HashSet usages = new HashSet(); @@ -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); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java index a577ee8f0..060691cc9 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Grant.java @@ -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 [player]", - permission = "plots.grant", - requiredType = RequiredType.NONE -) +command = "grant", +category = CommandCategory.CLAIMING, +usage = "/plot grant [player]", +permission = "plots.grant", +requiredType = RequiredType.NONE) public class Grant extends SubCommand { @Override public boolean onCommand(final PlotPlayer plr, final String[] args) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Help.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Help.java index d9e5799ec..bc5f430aa 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Help.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Help.java @@ -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; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Home.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Home.java index 1ce99d601..8ebb68525 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Home.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Home.java @@ -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); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 13bc921ed..1be555389 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -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 ", category = CommandCategory.INFO) +@CommandDeclaration(command = "info", +aliases = "i", +description = "Display plot info", +usage = "/plot info ", +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": diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java index 123b34be6..4b35ea0bf 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Kick.java @@ -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(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 4d647cb44..6b9feb7b4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -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 { - private static MainCommand instance; private MainCommand() { @@ -86,11 +84,11 @@ public class MainCommand extends CommandManager { 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 { 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 { MainUtil.sendMessage(player, C.NO_PERMISSION, permission); return false; } - + public static List> getCommandAndAliases(final CommandCategory category, final PlotPlayer player) { final List> commands = new ArrayList<>(); for (final Command command : getInstance().getCommands()) { @@ -157,7 +155,7 @@ public class MainCommand extends CommandManager { } return commands; } - + public static List> getCommands(final CommandCategory category, final PlotPlayer player) { final List> commands = new ArrayList<>(); for (final Command command : new HashSet<>(getInstance().getCommands())) { @@ -171,7 +169,7 @@ public class MainCommand extends CommandManager { } 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 { 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 { } return true; } - + public int getMatch(String[] args, Command cmd) { int count = 0; String perm = cmd.getPermission(); @@ -353,7 +351,7 @@ public class MainCommand extends CommandManager { count += StringMan.intersection(desc, args); return count; } - + @Override public int handle(final PlotPlayer plr, final String input) { final String[] parts = input.split(" "); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index eac2244de..d44b57f24 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -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 [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 [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" }; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Middle.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Middle.java index 2ac52a9df..42d262edf 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Middle.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Middle.java @@ -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 diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java deleted file mode 100644 index 51d4e705d..000000000 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ /dev/null @@ -1,87 +0,0 @@ -//////////////////////////////////////////////////////////////////////////////////////////////////// -// PlotSquared - A plot manager and world generator for the Bukkit API / -// Copyright (c) 2014 IntellectualSites/IntellectualCrafters / -// / -// This program is free software; you can redistribute it and/or modify / -// it under the terms of the GNU General Public License as published by / -// the Free Software Foundation; either version 3 of the License, or / -// (at your option) any later version. / -// / -// This program is distributed in the hope that it will be useful, / -// but WITHOUT ANY WARRANTY; without even the implied warranty of / -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the / -// GNU General Public License for more details. / -// / -// You should have received a copy of the GNU General Public License / -// along with this program; if not, write to the Free Software Foundation, / -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA / -// / -// You can contact us via: support@intellectualsites.com / -//////////////////////////////////////////////////////////////////////////////////////////////////// -package com.intellectualcrafters.plot.commands; - -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.flag.Flag; -import com.intellectualcrafters.plot.flag.FlagManager; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotInventory; -import com.intellectualcrafters.plot.object.PlotItemStack; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.WorldUtil; -import com.plotsquared.general.commands.CommandDeclaration; - -@CommandDeclaration( -command = "music", -permission = "plots.music", -description = "Player music in a plot", -usage = "/plot music", -category = CommandCategory.APPEARANCE, -requiredType = RequiredType.NONE) -public class MusicSubcommand extends SubCommand { - - @Override - public boolean onCommand(final PlotPlayer player, final String[] args) { - final Location loc = player.getLocation(); - final Plot plot = loc.getPlotAbs(); - if (plot == null) { - return !sendMessage(player, C.NOT_IN_PLOT); - } - if (!plot.isAdded(player.getUUID())) { - sendMessage(player, C.NO_PLOT_PERMS); - return true; - } - final PlotInventory inv = new PlotInventory(player, 2, "Plot Jukebox") { - @Override - public boolean onClick(final int index) { - final PlotItemStack item = getItem(index); - if (item == null) { - return true; - } - final int id = item.id == 7 ? 0 : item.id; - if (id == 0) { - FlagManager.removePlotFlag(plot, "music"); - } else { - FlagManager.addPlotFlag(plot, new Flag(FlagManager.getFlag("music"), id)); - } - return false; - } - }; - int index = 0; - for (int i = 2256; i < 2268; i++) { - final String name = "&r&6" + WorldUtil.IMP.getClosestMatchingName(new PlotBlock((short) i, (byte) 0)); - final String[] lore = { "&r&aClick to play!" }; - final PlotItemStack item = new PlotItemStack(i, (byte) 0, 1, name, lore); - inv.setItem(index, item); - index++; - } - if (player.getMeta("music") != null) { - final String name = "&r&6Cancel music"; - final String[] lore = { "&r&cClick to cancel!" }; - inv.setItem(index, new PlotItemStack(7, (short) 0, 1, name, lore)); - } - inv.openInventory(); - return true; - } -} diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 224718ab7..148b3a3b4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -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 diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index ca2d1261a..c8bdbe8ab 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -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; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java index 712b689df..1f1bf2cba 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Save.java @@ -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; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java index 57e457c39..ab99b66a4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/SchematicCmd.java @@ -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 ") 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")) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index f99f89492..e96620962 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -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 ", command = "swap", description = "Swap two plots", aliases = { "switch" }, category = CommandCategory.CLAIMING, requiredType = RequiredType.NONE) +@CommandDeclaration(usage = "/plot swap ", +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(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java index be7337f0f..575ebc601 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -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) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java index aee84a6bb..ca8e893b5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Unlink.java @@ -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) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Update.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Update.java index 999fa284f..a96cb1b55 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Update.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Update.java @@ -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; } - + } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/list.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/list.java index 8dff2ef6d..609b9686f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -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 > [#]") -public class list extends SubCommand { - +public class List extends SubCommand { + private String[] getArgumentList(final PlotPlayer player) { - final List args = new ArrayList<>(); + final java.util.List 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 plots = null; - + + java.util.List 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 plots, final int pageSize, int page, final PlotArea area, final String[] args, final boolean sort) { + + public void displayPlots(final PlotPlayer player, java.util.List plots, final int pageSize, int page, final PlotArea area, final String[] args, final boolean sort) { // Header Iterator iter = plots.iterator(); while (iter.hasNext()) { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java index 6959bb66e..bcc33b6a3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -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())); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Location.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Location.java index c93dcd710..4dcdbc4e8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Location.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Location.java @@ -23,11 +23,11 @@ public class Location implements Cloneable, Comparable { 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 { 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 { 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 { 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 { 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 { 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 { } 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 { built = false; return this; } - + @Override public boolean equals(final Object o) { if (o == null) { @@ -200,7 +200,7 @@ public class Location implements Cloneable, Comparable { 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 { } return 1; } - + @Override public String toString() { return "\"plotsquaredlocation\":{" + "\"x\":" + x + ",\"y\":" + y + ",\"z\":" + z + ",\"yaw\":" + yaw + ",\"pitch\":" + pitch + ",\"world\":\"" + world + "\"}"; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index cc79417c2..d63e053a8 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -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 */ diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 40a9a0bae..70b18773f 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -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
*/ public abstract class PlotPlayer implements CommandCaller { - private Map metaMap = new HashMap<>(); - + /** * The metadata map */ private ConcurrentHashMap meta; - + /** * Efficiently wrap a Player, or OfflinePlayer object to get a PlotPlayer (or fetch if it's already cached)
* - 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
* - 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 @@ -71,7 +78,7 @@ public abstract class PlotPlayer implements CommandCaller { } return null; } - + public 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
* - 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 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
* === !IMPORTANT ===
@@ -236,58 +243,58 @@ public abstract class PlotPlayer implements CommandCaller { * @return UUID */ public abstract UUID getUUID(); - + /** * Check the player's permissions
* - 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() { @@ -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 getPlots(String world) { UUID uuid = getUUID(); HashSet plots = new HashSet<>(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Rating.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Rating.java index d5b91df97..6bdee240b 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Rating.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Rating.java @@ -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 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 getCategories() { if (ratingMap.size() == 1) { return new ArrayList<>(0); } return new ArrayList<>(ratingMap.keySet()); } - + public double getAverageRating() { double total = 0; for (final Entry 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); } - + } - } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java index 4df1f88df..d01dc7608 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java @@ -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 plots); - + public abstract boolean callUnlink(final PlotArea area, final ArrayList 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; } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 7dc12c94b..42a73e9fd 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -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.
- * - 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
* @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
- * @see Plot#getCorners() + * @see Plot#getCorners() * @param world * @param regions * @return @@ -378,12 +378,12 @@ public class MainUtil { public static List getPlotsBySearch(final String search) { final String[] split = search.split(" "); final int size = split.length * 2; - + final List 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> plotList = new ArrayList<>(size); for (int i = 0; i < size; i++) { plotList.add(new ArrayList()); } - + 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
- * @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:
* @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.
* - 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 result) { PlotPlayer pp = UUIDHandler.getPlayer(uuid); if (pp != null) { diff --git a/target/PlotSquared-Bukkit.jar b/target/PlotSquared-Bukkit.jar deleted file mode 100644 index 7c82a2f40..000000000 Binary files a/target/PlotSquared-Bukkit.jar and /dev/null differ