This commit is contained in:
manuelgu 2016-03-22 18:53:17 +01:00
parent 09ee7f3048
commit 84188f6557
46 changed files with 476 additions and 427 deletions

View File

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

View File

@ -33,13 +33,13 @@ import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration( @CommandDeclaration(
command = "setalias", command = "setalias",
permission = "plots.set.alias", permission = "plots.set.alias",
description = "Set the plot name", description = "Set the plot name",
usage = "/plot alias <alias>", usage = "/plot alias <alias>",
aliases = { "alias", "sa", "name", "rename", "setname", "seta" }, aliases = { "alias", "sa", "name", "rename", "setname", "seta" },
category = CommandCategory.SETTINGS, category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE) requiredType = RequiredType.NONE)
public class Alias extends SetCommand { public class Alias extends SetCommand {
@Override @Override
public boolean set(final PlotPlayer plr, final Plot plot, final String alias) { public boolean set(final PlotPlayer plr, final Plot plot, final String alias) {
if (alias.isEmpty()) { 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.StringMan;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Objects; import java.util.Objects;
import java.util.Set; import java.util.Set;
@CommandDeclaration(command = "area", permission = "plots.area", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, @CommandDeclaration(command = "area",
description = "Create a new PlotArea", aliases = "world", usage = "/plot area <create|info|list|tp|regen>") 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 { public class Area extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer plr, String[] args) {
if (args.length == 0) { if (args.length == 0) {
@ -380,7 +384,7 @@ public class Area extends SubCommand {
.text("\nClusters=").color("$1").text("" + clusters).color("$2") .text("\nClusters=").color("$1").text("" + clusters).color("$2")
.text("\nRegion=").color("$1").text(region).color("$2") .text("\nRegion=").color("$1").text(region).color("$2")
.text("\nGenerator=").color("$1").text(generator).color("$2"); .text("\nGenerator=").color("$1").text(generator).color("$2");
// type / terrain // type / terrain
String visit = "/plot area tp " + area.toString(); String visit = "/plot area tp " + area.toString();
message.text("[").color("$3") message.text("[").color("$3")
@ -457,5 +461,5 @@ public class Area extends SubCommand {
C.COMMAND_SYNTAX.send(plr, getUsage()); C.COMMAND_SYNTAX.send(plr, getUsage());
return false; return false;
} }
} }

View File

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

View File

@ -29,14 +29,19 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration; 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 class BO3 extends SubCommand {
public void noArgs(final PlotPlayer plr) { 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 export [category] [alias] [-r]");
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 import <file>"); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot bo3 import <file>");
} }
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation(); 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.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "claim", aliases = "c", description = "Claim the current plot you're standing on", category = CommandCategory.CLAIMING, @CommandDeclaration(command = "claim",
requiredType = RequiredType.NONE, permission = "plots.claim", usage = "/plot 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 { public class Claim extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String... args) { public boolean onCommand(final PlotPlayer plr, final String... args) {

View File

@ -20,8 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.Set;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.flag.FlagManager; 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.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Set;
@CommandDeclaration(command = "clear", description = "Clear a plot", permission = "plots.clear", category = CommandCategory.APPEARANCE, @CommandDeclaration(command = "clear",
usage = "/plot clear [id]", aliases = "reset") description = "Clear a plot",
permission = "plots.clear",
category = CommandCategory.APPEARANCE,
usage = "/plot clear [id]",
aliases = "reset")
public class Clear extends SubCommand { public class Clear extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String... args) { public boolean onCommand(final PlotPlayer plr, final String... args) {
final Location loc = plr.getLocation(); 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.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "cluster", aliases = "clusters", category = CommandCategory.ADMINISTRATION, requiredType = RequiredType.NONE, @CommandDeclaration(command = "cluster",
permission = "plots.cluster", description = "Manage a plot cluster") aliases = "clusters",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.NONE,
permission = "plots.cluster",
description = "Manage a plot cluster")
public class Cluster extends SubCommand { public class Cluster extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String... args) { public boolean onCommand(final PlotPlayer plr, final String... args) {
// list, create, delete, resize, invite, kick, leave, helpers, tp, sethome // list, create, delete, resize, invite, kick, leave, helpers, tp, sethome
if (args.length == 0) { if (args.length == 0) {
// return arguments // return arguments

View File

@ -20,9 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.Arrays;
import java.util.Map.Entry;
import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; 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.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration; 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 { public class Comment extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer player, final String[] args) { public boolean onCommand(final PlotPlayer player, final String[] args) {
if (args.length < 2) { 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.TaskManager;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@ -39,11 +38,15 @@ import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
@CommandDeclaration(command = "condense", permission = "plots.admin", 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 class Condense extends SubCommand {
public static boolean TASK = false; public static boolean TASK = false;
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String... args) { public boolean onCommand(final PlotPlayer plr, final String... args) {
if ((args.length != 2) && (args.length != 3)) { 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]"); MainUtil.sendMessage(plr, "/plot condense " + area.worldname + " <start|stop|info> [radius]");
return false; return false;
} }
public Set<PlotId> getPlots(final Collection<Plot> plots, final int radius) { public Set<PlotId> getPlots(final Collection<Plot> plots, final int radius) {
final HashSet<PlotId> outside = new HashSet<>(); final HashSet<PlotId> outside = new HashSet<>();
for (final Plot plot : plots) { 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.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; 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 { public class Confirm extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String... args) { public boolean onCommand(final PlotPlayer plr, final String... args) {
final CmdInstance command = CmdConfirm.getPending(plr); 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.MainUtil;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.io.File; import java.io.File;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
@ -27,11 +26,9 @@ category = CommandCategory.ADMINISTRATION,
permission = "plots.database", permission = "plots.database",
description = "Convert/Backup Storage", description = "Convert/Backup Storage",
requiredType = RequiredType.CONSOLE, requiredType = RequiredType.CONSOLE,
usage = "/plots database [area] <sqlite|mysql|import>" usage = "/plots database [area] <sqlite|mysql|import>")
)
public class Database extends SubCommand { public class Database extends SubCommand {
public static void insertPlots(final SQLManager manager, final ArrayList<Plot> plots, final PlotPlayer player) { public static void insertPlots(final SQLManager manager, final ArrayList<Plot> plots, final PlotPlayer player) {
TaskManager.runTaskAsync(new Runnable() { TaskManager.runTaskAsync(new Runnable() {
@Override @Override
@ -56,7 +53,7 @@ public class Database extends SubCommand {
} }
}); });
} }
@Override @Override
public boolean onCommand(final PlotPlayer player, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length < 1) { if (args.length < 1) {

View File

@ -28,9 +28,13 @@ import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration; 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 { public class Debug extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) { if ((args.length > 0) && args[0].equalsIgnoreCase("msg")) {
@ -70,11 +74,11 @@ public class Debug extends SubCommand {
} }
return true; return true;
} }
private String getSection(final String line, final String val) { private String getSection(final String line, final String val) {
return line.replaceAll("%val%", val) + "\n"; return line.replaceAll("%val%", val) + "\n";
} }
private String getLine(final String line, final String var, final Object val) { private String getLine(final String line, final String var, final Object val) {
return line.replaceAll("%var%", var).replaceAll("%val%", "" + val) + "\n"; 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.database.DBFunc;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.util.*; 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.Command;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import com.plotsquared.listener.WEManager; import com.plotsquared.listener.WEManager;
import javax.script.*;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.sql.Timestamp; 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", @CommandDeclaration(command = "debugexec",
category = CommandCategory.DEBUG) permission = "plots.admin",
description = "Mutli-purpose debug command",
aliases = "exec",
category = CommandCategory.DEBUG)
public class DebugExec extends SubCommand { public class DebugExec extends SubCommand {
private ScriptEngine engine; private ScriptEngine engine;
private Bindings scope; private Bindings scope;
public DebugExec() { public DebugExec() {
try { try {
if (PS.get() != null) { if (PS.get() != null) {
@ -64,15 +95,15 @@ public class DebugExec extends SubCommand {
} }
} catch (IOException | ScriptException e) {} } catch (IOException | ScriptException e) {}
} }
public ScriptEngine getEngine() { public ScriptEngine getEngine() {
return engine; return engine;
} }
public Bindings getScope() { public Bindings getScope() {
return scope; return scope;
} }
public void init() { public void init() {
if (engine != null) { if (engine != null) {
return; return;
@ -83,14 +114,14 @@ public class DebugExec extends SubCommand {
} }
final ScriptContext context = new SimpleScriptContext(); final ScriptContext context = new SimpleScriptContext();
scope = context.getBindings(ScriptContext.ENGINE_SCOPE); scope = context.getBindings(ScriptContext.ENGINE_SCOPE);
// stuff // stuff
scope.put("MainUtil", new MainUtil()); scope.put("MainUtil", new MainUtil());
scope.put("Settings", new Settings()); scope.put("Settings", new Settings());
scope.put("StringMan", new StringMan()); scope.put("StringMan", new StringMan());
scope.put("MathMan", new MathMan()); scope.put("MathMan", new MathMan());
scope.put("FlagManager", new FlagManager()); scope.put("FlagManager", new FlagManager());
// Classes // Classes
scope.put("Location", Location.class); scope.put("Location", Location.class);
scope.put("PlotBlock", PlotBlock.class); scope.put("PlotBlock", PlotBlock.class);
@ -98,7 +129,7 @@ public class DebugExec extends SubCommand {
scope.put("PlotId", PlotId.class); scope.put("PlotId", PlotId.class);
scope.put("Runnable", Runnable.class); scope.put("Runnable", Runnable.class);
scope.put("RunnableVal", RunnableVal.class); scope.put("RunnableVal", RunnableVal.class);
// Instances // Instances
scope.put("PS", PS.get()); scope.put("PS", PS.get());
scope.put("SetQueue", SetQueue.IMP); scope.put("SetQueue", SetQueue.IMP);
@ -120,16 +151,16 @@ public class DebugExec extends SubCommand {
scope.put("HybridUtils", HybridUtils.manager); scope.put("HybridUtils", HybridUtils.manager);
scope.put("IMP", PS.get().IMP); scope.put("IMP", PS.get().IMP);
scope.put("MainCommand", MainCommand.getInstance()); scope.put("MainCommand", MainCommand.getInstance());
// enums // enums
for (final Enum<?> value : C.values()) { for (final Enum<?> value : C.values()) {
scope.put("C_" + value.name(), value); scope.put("C_" + value.name(), value);
} }
} }
@Override @Override
public boolean onCommand(final PlotPlayer player, final String... args) { 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) { if (args.length > 0) {
final String arg = args[0].toLowerCase(); final String arg = args[0].toLowerCase();
String script; String script;
@ -152,7 +183,7 @@ public class DebugExec extends SubCommand {
HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() { HybridUtils.manager.analyzePlot(plot, new RunnableVal<PlotAnalysis>() {
@Override @Override
public void run(PlotAnalysis value) { 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; return true;
@ -219,11 +250,11 @@ public class DebugExec extends SubCommand {
} }
case "stop-rgar": case "stop-rgar":
if (!HybridUtils.UPDATE) { if (!HybridUtils.UPDATE) {
MainUtil.sendMessage(player, "&cTASK NOT RUNNING!"); MainUtil.sendMessage(player, "&cTask not running!");
return false; return false;
} }
HybridUtils.UPDATE = false; HybridUtils.UPDATE = false;
MainUtil.sendMessage(player, "&cCancelling task... (please wait)"); MainUtil.sendMessage(player, "&cCancelling task... (Please wait)");
return true; return true;
case "start-expire": case "start-expire":
if (ExpireManager.IMP == null) { if (ExpireManager.IMP == null) {
@ -246,11 +277,11 @@ public class DebugExec extends SubCommand {
} }
final UUID uuid = UUIDHandler.getUUID(args[1], null); final UUID uuid = UUIDHandler.getUUID(args[1], null);
if (uuid == 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); final OfflinePlotPlayer op = UUIDHandler.getUUIDWrapper().getOfflinePlayer(uuid);
if (op == null || op.getLastPlayed() == 0) { 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 Timestamp stamp = new Timestamp(op.getLastPlayed());
final Date date = new Date(stamp.getTime()); final Date date = new Date(stamp.getTime());
@ -269,8 +300,7 @@ public class DebugExec extends SubCommand {
case "addcmd": case "addcmd":
try { try {
final String cmd = StringMan.join(Files final String cmd = StringMan.join(Files
.readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), .readLines(MainUtil.getFile(new File(PS.get().IMP.getDirectory() + File.separator + "scripts"), args[1]), StandardCharsets.UTF_8),
StandardCharsets.UTF_8),
System.getProperty("line.separator")); System.getProperty("line.separator"));
final Command<PlotPlayer> subcommand = new Command<PlotPlayer>(args[1].split("\\.")[0]) { final Command<PlotPlayer> subcommand = new Command<PlotPlayer>(args[1].split("\\.")[0]) {
@Override @Override

View File

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

View File

@ -33,19 +33,23 @@ import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID; 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 class Deny extends SubCommand {
public Deny() { public Deny() {
requiredArguments = new Argument[] { Argument.PlayerName }; requiredArguments = new Argument[] { Argument.PlayerName };
} }
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation(); final Location loc = plr.getLocation();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if (plot == null) { if (plot == null) {
@ -73,7 +77,7 @@ public class Deny extends SubCommand {
MainUtil.sendMessage(plr, C.ALREADY_OWNER); MainUtil.sendMessage(plr, C.ALREADY_OWNER);
return false; return false;
} }
if (plot.getDenied().contains(uuid)) { if (plot.getDenied().contains(uuid)) {
MainUtil.sendMessage(plr, C.ALREADY_ADDED); MainUtil.sendMessage(plr, C.ALREADY_ADDED);
return false; return false;
@ -92,7 +96,7 @@ public class Deny extends SubCommand {
} }
return true; return true;
} }
private void handleKick(final PlotPlayer pp, final Plot plot) { private void handleKick(final PlotPlayer pp, final Plot plot) {
if (pp == null) { if (pp == null) {
return; return;

View File

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

View File

@ -34,9 +34,14 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.CommandDeclaration; 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 { public class Done extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation(); final Location loc = plr.getLocation();

View File

@ -17,9 +17,15 @@ import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.net.URL; 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 { public class Download extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
final String world = plr.getLocation().getWorld(); 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.object.PlotPlayer;
import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.Command; import com.plotsquared.general.commands.Command;
import java.io.File; import java.io.File;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.nio.file.Files; import java.nio.file.Files;
@ -45,17 +44,17 @@ public class GenerateDocs {
try { try {
final String clazz = command.getClass().getSimpleName(); final String clazz = command.getClass().getSimpleName();
final String name = command.getCommand(); final String name = command.getCommand();
// Header // 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 + ") "); 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> lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
final List<String> perms = getPerms(name, lines); final List<String> perms = getPerms(name, lines);
final List<String> usages = getUsage(name, lines); final List<String> usages = getUsage(name, lines);
final String comment = getComments(lines); final String comment = getComments(lines);
log("#### Description"); log("#### Description");
log("`" + command.getDescription() + "`"); log("`" + command.getDescription() + "`");
if (!comment.isEmpty()) { if (!comment.isEmpty()) {
@ -64,7 +63,7 @@ public class GenerateDocs {
log(comment); log(comment);
log("```"); log("```");
} }
log("#### Usage "); log("#### Usage ");
{ {
String mainUsage = command.getUsage().replaceAll("\\{label\\}", "plot"); String mainUsage = command.getUsage().replaceAll("\\{label\\}", "plot");
@ -79,18 +78,18 @@ public class GenerateDocs {
log("`" + mainUsage + "` "); log("`" + mainUsage + "` ");
} }
} }
if (command.getRequiredType() != RequiredType.NONE) { if (command.getRequiredType() != RequiredType.NONE) {
log("#### Required callers"); log("#### Required callers");
log("`" + command.getRequiredType().name() + "`"); log("`" + command.getRequiredType().name() + "`");
} }
final Set<String> aliases = command.getAliases(); final Set<String> aliases = command.getAliases();
if (!aliases.isEmpty()) { if (!aliases.isEmpty()) {
log("#### Aliases"); log("#### Aliases");
log("`" + StringMan.getString(command.getAliases()) + "`"); log("`" + StringMan.getString(command.getAliases()) + "`");
} }
log("#### Permissions"); log("#### Permissions");
if (!perms.isEmpty()) { if (!perms.isEmpty()) {
log("##### Primary"); log("##### Primary");
@ -108,7 +107,7 @@ public class GenerateDocs {
e.printStackTrace(); e.printStackTrace();
} }
} }
public static List<String> getUsage(String cmd, List<String> lines) { public static List<String> getUsage(String cmd, List<String> lines) {
final Pattern p = Pattern.compile("\"([^\"]*)\""); final Pattern p = Pattern.compile("\"([^\"]*)\"");
HashSet<String> usages = new HashSet<String>(); HashSet<String> usages = new HashSet<String>();
@ -136,7 +135,7 @@ public class GenerateDocs {
final Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)"); final Pattern p2 = Pattern.compile("C.PERMISSION_\\s*(\\w+)");
String last = null; String last = null;
for (final String line : lines) { for (final String line : lines) {
Matcher m2 = p2.matcher(line); Matcher m2 = p2.matcher(line);
while (m2.find()) { while (m2.find()) {
perms.add(C.valueOf("PERMISSION_" + m2.group(1)).s()); perms.add(C.valueOf("PERMISSION_" + m2.group(1)).s());
@ -215,7 +214,7 @@ public class GenerateDocs {
} }
return result.toString().trim(); return result.toString().trim();
} }
public static void log(final String s) { public static void log(final String s) {
System.out.println(s); System.out.println(s);
} }

View File

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

View File

@ -23,10 +23,14 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "home", aliases = { "h" }, description = "Go to your plot", usage = "/plot home [id|alias]", @CommandDeclaration(command = "home",
category = CommandCategory.TELEPORT, requiredType = RequiredType.NONE) aliases = { "h" },
description = "Go to your plot",
usage = "/plot home [id|alias]",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.NONE)
public class Home extends SubCommand { public class Home extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, String[] args) { public boolean onCommand(final PlotPlayer plr, String[] args) {
return MainCommand.getInstance().getCommand("visit").onCommand(plr, 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.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.UUID; 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 { public class Info extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer player, String[] args) { public boolean onCommand(final PlotPlayer player, String[] args) {
Plot plot; Plot plot;
@ -143,7 +146,7 @@ public class Info extends SubCommand {
}); });
return true; return true;
} }
private String getCaption(final String string) { private String getCaption(final String string) {
switch (string) { switch (string) {
case "trusted": case "trusted":

View File

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

View File

@ -36,9 +36,12 @@ import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "merge", aliases = "m", description = "Merge the plot you are standing on, with another plot", @CommandDeclaration(command = "merge",
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]", category = CommandCategory.SETTINGS, aliases = "m",
requiredType = RequiredType.NONE) 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 class Merge extends SubCommand {
public final static String[] values = new String[] { "north", "east", "south", "west", "auto" }; public final static String[] values = new String[] { "north", "east", "south", "west", "auto" };
public final static String[] aliases = new String[] { "n", "e", "s", "w", "all" }; 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 * @author manuelgu, altered by Citymonstret
*/ */
@CommandDeclaration( @CommandDeclaration(
command = "middle", command = "middle",
aliases = { "center" }, aliases = { "center" },
description = "Teleports you to the center of the current plot", description = "Teleports you to the center of the current plot",
usage = "/plot middle", usage = "/plot middle",
category = CommandCategory.TELEPORT, category = CommandCategory.TELEPORT,
requiredType = RequiredType.PLAYER requiredType = RequiredType.PLAYER)
)
public class Middle extends SubCommand { public class Middle extends SubCommand {
@Override @Override

View File

@ -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;
}
}

View File

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

View File

@ -20,8 +20,6 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import java.util.Objects;
import com.intellectualcrafters.configuration.ConfigurationSection; import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.MemorySection; import com.intellectualcrafters.configuration.MemorySection;
import com.intellectualcrafters.configuration.file.YamlConfiguration; 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.object.RunnableVal;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration; 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 { public class Reload extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
try { try {
@ -72,7 +75,7 @@ public class Reload extends SubCommand {
} }
} }
area.saveConfiguration(clone); area.saveConfiguration(clone);
// netSections is the combination of // netSections is the combination of
for (String key : clone.getKeys(true)) { for (String key : clone.getKeys(true)) {
if (clone.get(key) instanceof MemorySection) { if (clone.get(key) instanceof MemorySection) {
continue; continue;

View File

@ -14,17 +14,21 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.net.URL; import java.net.URL;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
@CommandDeclaration(command = "save", aliases = { "backup" }, description = "Save your plot", 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 { public class Save extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
if (!Settings.METRICS) { 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"); 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; return false;

View File

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

View File

@ -37,11 +37,11 @@ permission = "plots.target",
requiredType = RequiredType.NONE, requiredType = RequiredType.NONE,
category = CommandCategory.INFO) category = CommandCategory.INFO)
public class Target extends SubCommand { public class Target extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location ploc = plr.getLocation(); final Location ploc = plr.getLocation();
if (!PS.get().hasPlotArea(ploc.getWorld())) { if (!ploc.isPlotArea()) {
MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD); MainUtil.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
return false; return false;
} }
@ -56,7 +56,7 @@ public class Target extends SubCommand {
} }
} }
if (target == null) { if (target == null) {
C.FOUND_NO_PLOTS.send(plr); MainUtil.sendMessage(plr, C.FOUND_NO_PLOTS);
return false; return false;
} }
} else if ((target = MainUtil.getPlotFromString(plr, args[0], true)) == null) { } 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.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration; 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 { public class Unlink extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
final Location loc = plr.getLocation(); final Location loc = plr.getLocation();
final Plot plot = loc.getPlotAbs(); final Plot plot = loc.getPlotAbs();
if (plot == null) { 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.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@ -38,9 +37,7 @@ requiredType = RequiredType.NONE,
aliases = { "updateplugin" }, aliases = { "updateplugin" },
category = CommandCategory.ADMINISTRATION) category = CommandCategory.ADMINISTRATION)
public class Update extends SubCommand { public class Update extends SubCommand {
public static String version;
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
URL url; URL url;
@ -50,7 +47,7 @@ public class Update extends SubCommand {
try { try {
url = new URL(args[0]); url = new URL(args[0]);
} catch (final MalformedURLException e) { } 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]"); MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot update [url]");
return false; return false;
} }
@ -68,5 +65,5 @@ public class Update extends SubCommand {
} }
return true; 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.StringMan;
import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandler;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.UUID; import java.util.UUID;
@ -57,10 +55,10 @@ description = "List plots",
permission = "plots.list", permission = "plots.list",
category = CommandCategory.INFO, category = CommandCategory.INFO,
usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]") usage = "/plot list <forsale|mine|shared|world|top|all|unowned|unknown|player|world|done|fuzzy <search...>> [#]")
public class list extends SubCommand { public class List extends SubCommand {
private String[] getArgumentList(final PlotPlayer player) { 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")) { if ((EconHandler.manager != null) && Permissions.hasPermission(player, "plots.list.forsale")) {
args.add("forsale"); args.add("forsale");
} }
@ -102,11 +100,11 @@ public class list extends SubCommand {
} }
return args.toArray(new String[args.size()]); return args.toArray(new String[args.size()]);
} }
public void noArgs(final PlotPlayer plr) { public void noArgs(final PlotPlayer plr) {
MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(plr))); MainUtil.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + Arrays.toString(getArgumentList(plr)));
} }
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { public boolean onCommand(final PlotPlayer plr, final String[] args) {
if (args.length < 1) { if (args.length < 1) {
@ -125,9 +123,9 @@ public class list extends SubCommand {
page = -1; page = -1;
} }
} }
List<Plot> plots = null; java.util.List<Plot> plots = null;
final String world = plr.getLocation().getWorld(); final String world = plr.getLocation().getWorld();
final PlotArea area = plr.getApplicablePlotArea(); final PlotArea area = plr.getApplicablePlotArea();
final String arg = args[0].toLowerCase(); final String arg = args[0].toLowerCase();
@ -353,7 +351,7 @@ public class list extends SubCommand {
} }
} }
} }
if (plots == null) { if (plots == null) {
sendMessage(plr, C.DID_YOU_MEAN, new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch()); sendMessage(plr, C.DID_YOU_MEAN, new StringComparison<>(args[0], new String[]{"mine", "shared", "world", "all"}).getBestMatch());
return false; return false;
@ -366,8 +364,8 @@ public class list extends SubCommand {
displayPlots(plr, plots, 12, page, area, args, sort); displayPlots(plr, plots, 12, page, area, args, sort);
return true; 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 // Header
Iterator<Plot> iter = plots.iterator(); Iterator<Plot> iter = plots.iterator();
while (iter.hasNext()) { while (iter.hasNext()) {

View File

@ -25,10 +25,13 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.plotsquared.general.commands.CommandDeclaration; import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "plugin", permission = "plots.use", description = "Show plugin information", aliases = "version", @CommandDeclaration(command = "plugin",
category = CommandCategory.INFO) permission = "plots.use",
public class plugin extends SubCommand { description = "Show plugin information",
aliases = "version",
category = CommandCategory.INFO)
public class Plugin extends SubCommand {
@Override @Override
public boolean onCommand(final PlotPlayer plr, final String[] args) { 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())); 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; this.pitch = pitch;
built = false; built = false;
} }
public Location() { public Location() {
this("", 0, 0, 0, 0, 0); this("", 0, 0, 0, 0, 0);
} }
public Location(final String world, final int x, final int y, final int z) { public Location(final String world, final int x, final int y, final int z) {
this(world, x, y, z, 0f, 0f); this(world, x, y, z, 0f, 0f);
} }
@ -40,30 +40,30 @@ public class Location implements Cloneable, Comparable<Location> {
public int getX() { public int getX() {
return x; return x;
} }
public void setX(final int x) { public void setX(final int x) {
this.x = x; this.x = x;
built = false; built = false;
} }
public int getY() { public int getY() {
return y; return y;
} }
public void setY(final int y) { public void setY(final int y) {
this.y = y; this.y = y;
built = false; built = false;
} }
public int getZ() { public int getZ() {
return z; return z;
} }
public void setZ(final int z) { public void setZ(final int z) {
this.z = z; this.z = z;
built = false; built = false;
} }
public String getWorld() { public String getWorld() {
return world; return world;
} }
@ -76,7 +76,7 @@ public class Location implements Cloneable, Comparable<Location> {
public PlotArea getPlotArea() { public PlotArea getPlotArea() {
return PS.get().getPlotAreaAbs(this); return PS.get().getPlotAreaAbs(this);
} }
public Plot getOwnedPlot() { public Plot getOwnedPlot() {
PlotArea area = PS.get().getPlotAreaAbs(this); PlotArea area = PS.get().getPlotAreaAbs(this);
return area != null ? area.getOwnedPlot(this) : null; return area != null ? area.getOwnedPlot(this) : null;
@ -90,7 +90,7 @@ public class Location implements Cloneable, Comparable<Location> {
public boolean isPlotArea() { public boolean isPlotArea() {
return PS.get().getPlotAreaAbs(this) != null; return PS.get().getPlotAreaAbs(this) != null;
} }
public boolean isPlotRoad() { public boolean isPlotRoad() {
PlotArea area = PS.get().getPlotAreaAbs(this); PlotArea area = PS.get().getPlotAreaAbs(this);
return area != null && area.getPlotAbs(this) == null; return area != null && area.getPlotAbs(this) == null;
@ -119,25 +119,25 @@ public class Location implements Cloneable, Comparable<Location> {
public ChunkLoc getChunkLoc() { public ChunkLoc getChunkLoc() {
return new ChunkLoc(x >> 4, z >> 4); return new ChunkLoc(x >> 4, z >> 4);
} }
public float getYaw() { public float getYaw() {
return yaw; return yaw;
} }
public void setYaw(final float yaw) { public void setYaw(final float yaw) {
this.yaw = yaw; this.yaw = yaw;
built = false; built = false;
} }
public float getPitch() { public float getPitch() {
return pitch; return pitch;
} }
public void setPitch(final float pitch) { public void setPitch(final float pitch) {
this.pitch = pitch; this.pitch = pitch;
built = false; built = false;
} }
public Location add(final int x, final int y, final int z) { public Location add(final int x, final int y, final int z) {
this.x += x; this.x += x;
this.y += y; this.y += y;
@ -145,31 +145,31 @@ public class Location implements Cloneable, Comparable<Location> {
built = false; built = false;
return this; return this;
} }
public double getEuclideanDistanceSquared(final Location l2) { public double getEuclideanDistanceSquared(final Location l2) {
final double x = getX() - l2.getX(); final double x = getX() - l2.getX();
final double y = getY() - l2.getY(); final double y = getY() - l2.getY();
final double z = getZ() - l2.getZ(); final double z = getZ() - l2.getZ();
return x * x + y * y + z * z; return x * x + y * y + z * z;
} }
public double getEuclideanDistance(final Location l2) { public double getEuclideanDistance(final Location l2) {
return Math.sqrt(getEuclideanDistanceSquared(l2)); return Math.sqrt(getEuclideanDistanceSquared(l2));
} }
public boolean isInSphere(final Location origin, final int radius) { public boolean isInSphere(final Location origin, final int radius) {
return getEuclideanDistanceSquared(origin) < radius * radius; return getEuclideanDistanceSquared(origin) < radius * radius;
} }
@Override @Override
public int hashCode() { public int hashCode() {
return MathMan.pair((short) x, (short) z) * 17 + y; return MathMan.pair((short) x, (short) z) * 17 + y;
} }
public boolean isInAABB(final Location min, final Location max) { 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(); 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) { public void lookTowards(final int x, final int y) {
final double l = this.x - x; final double l = this.x - x;
final double c = Math.sqrt(l * l + 0.0); final double c = Math.sqrt(l * l + 0.0);
@ -180,7 +180,7 @@ public class Location implements Cloneable, Comparable<Location> {
} }
built = false; built = false;
} }
public Location subtract(final int x, final int y, final int z) { public Location subtract(final int x, final int y, final int z) {
this.x -= x; this.x -= x;
this.y -= y; this.y -= y;
@ -188,7 +188,7 @@ public class Location implements Cloneable, Comparable<Location> {
built = false; built = false;
return this; return this;
} }
@Override @Override
public boolean equals(final Object o) { public boolean equals(final Object o) {
if (o == null) { if (o == null) {
@ -200,7 +200,7 @@ public class Location implements Cloneable, Comparable<Location> {
final Location l = (Location) o; 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(); return x == l.getX() && y == l.getY() && z == l.getZ() && world.equals(l.getWorld()) && yaw == l.getY() && pitch == l.getPitch();
} }
@Override @Override
public int compareTo(final Location o) { public int compareTo(final Location o) {
if (x == o.getX() && y == o.getY() || z == o.getZ()) { if (x == o.getX() && y == o.getY() || z == o.getZ()) {
@ -211,7 +211,7 @@ public class Location implements Cloneable, Comparable<Location> {
} }
return 1; return 1;
} }
@Override @Override
public String toString() { public String toString() {
return "\"plotsquaredlocation\":{" + "\"x\":" + x + ",\"y\":" + y + ",\"z\":" + z + ",\"yaw\":" + yaw + ",\"pitch\":" + pitch + ",\"world\":\"" + world + "\"}"; 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.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.listener.PlotListener; import com.plotsquared.listener.PlotListener;
import java.awt.Rectangle; import java.awt.Rectangle;
import java.awt.geom.Area; import java.awt.geom.Area;
import java.awt.geom.PathIterator; import java.awt.geom.PathIterator;
@ -70,7 +69,6 @@ import java.util.concurrent.atomic.AtomicInteger;
*/ */
@SuppressWarnings("javadoc") @SuppressWarnings("javadoc")
public class Plot { public class Plot {
/** /**
* @deprecated raw access is deprecated * @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.commands.RequiredType;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; 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 com.plotsquared.general.commands.CommandCaller;
import java.util.HashMap;
import java.util.*; 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.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicInteger; 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> * - Can cast to: BukkitPlayer / SpongePlayer, which are the current implementations<br>
*/ */
public abstract class PlotPlayer implements CommandCaller { public abstract class PlotPlayer implements CommandCaller {
private Map<String, byte[]> metaMap = new HashMap<>(); private Map<String, byte[]> metaMap = new HashMap<>();
/** /**
* The metadata map * The metadata map
*/ */
private ConcurrentHashMap<String, Object> meta; private ConcurrentHashMap<String, Object> meta;
/** /**
* Efficiently wrap a Player, or OfflinePlayer object to get a PlotPlayer (or fetch if it's already cached)<br> * Efficiently wrap a Player, or OfflinePlayer object to get a PlotPlayer (or fetch if it's already cached)<br>
* - Accepts sponge/bukkit Player (online) * - Accepts sponge/bukkit Player (online)
@ -36,7 +43,7 @@ public abstract class PlotPlayer implements CommandCaller {
public static PlotPlayer wrap(final Object obj) { public static PlotPlayer wrap(final Object obj) {
return PS.get().IMP.wrapPlayer(obj); return PS.get().IMP.wrapPlayer(obj);
} }
/** /**
* Get the cached PlotPlayer from a username<br> * Get the cached PlotPlayer from a username<br>
* - This will return null if the player has not finished logging in or is not online * - 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) { public static PlotPlayer get(final String name) {
return UUIDHandler.getPlayer(name); return UUIDHandler.getPlayer(name);
} }
/** /**
* Set some session only metadata for the player * Set some session only metadata for the player
* @param key * @param key
@ -58,7 +65,7 @@ public abstract class PlotPlayer implements CommandCaller {
} }
meta.put(key, value); meta.put(key, value);
} }
/** /**
* Get the metadata for a key * Get the metadata for a key
* @param <T> * @param <T>
@ -71,7 +78,7 @@ public abstract class PlotPlayer implements CommandCaller {
} }
return null; return null;
} }
public <T> T getMeta(final String key, T def) { public <T> T getMeta(final String key, T def) {
if (meta != null) { if (meta != null) {
T value = (T) meta.get(key); T value = (T) meta.get(key);
@ -89,7 +96,7 @@ public abstract class PlotPlayer implements CommandCaller {
public Object deleteMeta(final String key) { public Object deleteMeta(final String key) {
return meta == null ? null : meta.remove(key); return meta == null ? null : meta.remove(key);
} }
/** /**
* Returns the player's name * Returns the player's name
* @see #getName() * @see #getName()
@ -98,7 +105,7 @@ public abstract class PlotPlayer implements CommandCaller {
public String toString() { public String toString() {
return getName(); return getName();
} }
/** /**
* Get the player's current plot<br> * 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 * - 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() { public Plot getCurrentPlot() {
return (Plot) getMeta("lastplot"); return (Plot) getMeta("lastplot");
} }
/** /**
* Get the total number of allowed plots * Get the total number of allowed plots
* Possibly relevant: (To increment the player's allowed plots, see the example script on the wiki) * 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() { public int getAllowedPlots() {
return Permissions.hasPermissionRange(this, "plots.plot", Settings.MAX_PLOTS); return Permissions.hasPermissionRange(this, "plots.plot", Settings.MAX_PLOTS);
} }
/** /**
* Get the number of plots the player owns * Get the number of plots the player owns
* *
@ -148,7 +155,7 @@ public abstract class PlotPlayer implements CommandCaller {
}); });
return count.get(); return count.get();
} }
/** /**
* Get the number of plots the player owns in the world * Get the number of plots the player owns in the world
* @param world * @param world
@ -170,7 +177,7 @@ public abstract class PlotPlayer implements CommandCaller {
} }
return count; return count;
} }
/** /**
* Get the plots the player owns * Get the plots the player owns
* @see PS for more searching functions * @see PS for more searching functions
@ -180,7 +187,7 @@ public abstract class PlotPlayer implements CommandCaller {
public Set<Plot> getPlots() { public Set<Plot> getPlots() {
return PS.get().getPlots(this); return PS.get().getPlots(this);
} }
/** /**
* Return the PlotArea the player is currently in, or null * Return the PlotArea the player is currently in, or null
* @return * @return
@ -188,18 +195,18 @@ public abstract class PlotPlayer implements CommandCaller {
public PlotArea getPlotAreaAbs() { public PlotArea getPlotAreaAbs() {
return PS.get().getPlotAreaAbs(getLocation()); return PS.get().getPlotAreaAbs(getLocation());
} }
public PlotArea getApplicablePlotArea() { public PlotArea getApplicablePlotArea() {
return PS.get().getApplicablePlotArea(getLocation()); return PS.get().getApplicablePlotArea(getLocation());
} }
@Override @Override
public RequiredType getSuperCaller() { public RequiredType getSuperCaller() {
return RequiredType.PLAYER; return RequiredType.PLAYER;
} }
/////////////// PLAYER META /////////////// /////////////// PLAYER META ///////////////
////////////// PARTIALLY IMPLEMENTED /////////// ////////////// PARTIALLY IMPLEMENTED ///////////
/** /**
* Get the player's last recorded location or null if they don't any plot relevant location * 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; return null;
} }
//////////////////////////////////////////////// ////////////////////////////////////////////////
/** /**
* Get the previous time the player logged in * Get the previous time the player logged in
* @return * @return
*/ */
public abstract long getPreviousLogin(); public abstract long getPreviousLogin();
/** /**
* Get the player's full location (including yaw/pitch) * Get the player's full location (including yaw/pitch)
* @return * @return
*/ */
public abstract Location getLocationFull(); public abstract Location getLocationFull();
/** /**
* Get the player's UUID<br> * Get the player's UUID<br>
* === !IMPORTANT ===<br> * === !IMPORTANT ===<br>
@ -236,58 +243,58 @@ public abstract class PlotPlayer implements CommandCaller {
* @return UUID * @return UUID
*/ */
public abstract UUID getUUID(); public abstract UUID getUUID();
/** /**
* Check the player's permissions<br> * Check the player's permissions<br>
* - Will be cached if permission caching is enabled * - Will be cached if permission caching is enabled
*/ */
@Override @Override
public abstract boolean hasPermission(final String perm); public abstract boolean hasPermission(final String perm);
/** /**
* Send the player a message * Send the player a message
*/ */
@Override @Override
public abstract void sendMessage(final String message); public abstract void sendMessage(final String message);
/** /**
* Teleport the player to a location * Teleport the player to a location
* @param loc * @param loc
*/ */
public abstract void teleport(final Location loc); public abstract void teleport(final Location loc);
/** /**
* Is the player online * Is the player online
* @return * @return
*/ */
public abstract boolean isOnline(); public abstract boolean isOnline();
/** /**
* Get the player's name * Get the player's name
* @return * @return
*/ */
public abstract String getName(); public abstract String getName();
/** /**
* Set the compass target * Set the compass target
* @param loc * @param loc
*/ */
public abstract void setCompassTarget(final Location loc); public abstract void setCompassTarget(final Location loc);
/** /**
* Load the player data from disk (if applicable) * Load the player data from disk (if applicable)
* @deprecated hacky * @deprecated hacky
*/ */
@Deprecated @Deprecated
public abstract void loadData(); public abstract void loadData();
/** /**
* Save the player data from disk (if applicable) * Save the player data from disk (if applicable)
* @deprecated hacky * @deprecated hacky
*/ */
@Deprecated @Deprecated
public abstract void saveData(); public abstract void saveData();
/** /**
* Set player data that will persist restarts * Set player data that will persist restarts
* - Please note that this is not intended to store large values * - 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; return getPersistentMeta("attrib_" + key)[0] == 1;
} }
/** /**
* Remove an attribute from a player * Remove an attribute from a player
* @param key * @param key
@ -323,50 +330,50 @@ public abstract class PlotPlayer implements CommandCaller {
* @param weather * @param weather
*/ */
public abstract void setWeather(final PlotWeather weather); public abstract void setWeather(final PlotWeather weather);
/** /**
* Get the player's gamemode * Get the player's gamemode
* @return * @return
*/ */
public abstract PlotGamemode getGamemode(); public abstract PlotGamemode getGamemode();
/** /**
* Set the player's gamemode * Set the player's gamemode
* @param gamemode * @param gamemode
*/ */
public abstract void setGamemode(final PlotGamemode gamemode); public abstract void setGamemode(final PlotGamemode gamemode);
/** /**
* Set the player's local time (ticks) * Set the player's local time (ticks)
* @param time * @param time
*/ */
public abstract void setTime(final long time); public abstract void setTime(final long time);
/** /**
* Set the player's fly mode * Set the player's fly mode
* @param fly * @param fly
*/ */
public abstract void setFlight(final boolean fly); public abstract void setFlight(final boolean fly);
/** /**
* Play music at a location for the player * Play music at a location for the player
* @param loc * @param loc
* @param id * @param id
*/ */
public abstract void playMusic(final Location loc, final int id); public abstract void playMusic(final Location loc, final int id);
/** /**
* Check if the player is banned * Check if the player is banned
* @return * @return
*/ */
public abstract boolean isBanned(); public abstract boolean isBanned();
/** /**
* Kick the player from the game * Kick the player from the game
* @param message * @param message
*/ */
public abstract void kick(final String message); public abstract void kick(final String message);
/** /**
* Called when the player quits * Called when the player quits
*/ */
@ -388,7 +395,12 @@ public abstract class PlotPlayer implements CommandCaller {
UUIDHandler.getPlayers().remove(name); UUIDHandler.getPlayers().remove(name);
PS.get().IMP.unregister(this); 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) { public int getPlayerClusterCount(final String world) {
final UUID uuid = getUUID(); final UUID uuid = getUUID();
int count = 0; int count = 0;
@ -399,7 +411,11 @@ public abstract class PlotPlayer implements CommandCaller {
} }
return count; return count;
} }
/**
* Get the amount of clusters a player owns
* @return
*/
public int getPlayerClusterCount() { public int getPlayerClusterCount() {
final AtomicInteger count = new AtomicInteger(); final AtomicInteger count = new AtomicInteger();
PS.get().foreachPlotArea(new RunnableVal<PlotArea>() { PS.get().foreachPlotArea(new RunnableVal<PlotArea>() {
@ -410,7 +426,12 @@ public abstract class PlotPlayer implements CommandCaller {
}); });
return count.get(); return count.get();
} }
/**
* Return a Set of all plots a player owns
* @param world
* @return
*/
public Set<Plot> getPlots(String world) { public Set<Plot> getPlots(String world) {
UUID uuid = getUUID(); UUID uuid = getUUID();
HashSet<Plot> plots = new HashSet<>(); HashSet<Plot> plots = new HashSet<>();

View File

@ -1,22 +1,20 @@
package com.intellectualcrafters.plot.object; package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.config.Settings;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
public class Rating { public class Rating {
/** /**
* This is a map of the rating category to the rating value * This is a map of the rating category to the rating value
*/ */
private HashMap<String, Integer> ratingMap; private HashMap<String, Integer> ratingMap;
private boolean changed; private boolean changed;
private int initial; private int initial;
public Rating(int value) { public Rating(int value) {
initial = value; initial = value;
ratingMap = new HashMap<>(); ratingMap = new HashMap<>();
@ -36,14 +34,14 @@ public class Rating {
ratingMap.put(null, value); ratingMap.put(null, value);
} }
} }
public List<String> getCategories() { public List<String> getCategories() {
if (ratingMap.size() == 1) { if (ratingMap.size() == 1) {
return new ArrayList<>(0); return new ArrayList<>(0);
} }
return new ArrayList<>(ratingMap.keySet()); return new ArrayList<>(ratingMap.keySet());
} }
public double getAverageRating() { public double getAverageRating() {
double total = 0; double total = 0;
for (final Entry<String, Integer> entry : ratingMap.entrySet()) { for (final Entry<String, Integer> entry : ratingMap.entrySet()) {
@ -51,11 +49,11 @@ public class Rating {
} }
return total / ratingMap.size(); return total / ratingMap.size();
} }
public Integer getRating(final String category) { public Integer getRating(final String category) {
return ratingMap.get(category); return ratingMap.get(category);
} }
public boolean setRating(final String category, final int value) { public boolean setRating(final String category, final int value) {
changed = true; changed = true;
if (!ratingMap.containsKey(category)) { if (!ratingMap.containsKey(category)) {
@ -63,7 +61,7 @@ public class Rating {
} }
return ratingMap.put(category, value) != null; return ratingMap.put(category, value) != null;
} }
public int getAggregate() { public int getAggregate() {
if (!changed) { if (!changed) {
return initial; return initial;
@ -77,7 +75,6 @@ public class Rating {
} else { } else {
return ratingMap.get(null); 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.config.Settings;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; 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 com.plotsquared.listener.PlayerBlockEventType;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.UUID; import java.util.UUID;
public abstract class EventUtil { public abstract class EventUtil {
public static EventUtil manager = null; public static EventUtil manager = null;
public abstract Rating callRating(final PlotPlayer player, final Plot plot, final Rating rating); 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 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 callTeleport(final PlotPlayer player, final Location from, final Plot plot);
public abstract boolean callClear(Plot plot); public abstract boolean callClear(Plot plot);
public abstract void callDelete(Plot plot); public abstract void callDelete(Plot plot);
public abstract boolean callFlagAdd(final Flag flag, final 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 Plot plot);
public abstract boolean callFlagRemove(final Flag flag, final PlotCluster cluster); public abstract boolean callFlagRemove(final Flag flag, final PlotCluster cluster);
public abstract boolean callMerge(final Plot plot, final ArrayList<PlotId> plots); public abstract boolean callMerge(final Plot plot, final ArrayList<PlotId> plots);
public abstract boolean callUnlink(final PlotArea area, 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 callEntry(final PlotPlayer player, final Plot plot);
public abstract void callLeave(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 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 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 abstract void callMember(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added);
public void doJoinTask(final PlotPlayer pp) { public void doJoinTask(final PlotPlayer pp) {
@ -272,7 +279,7 @@ public abstract class EventUtil {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "mob-place")) { if (FlagManager.isPlotFlagTrue(plot, "mob-place")) {
return true; return true;
} }
@ -295,7 +302,7 @@ public abstract class EventUtil {
if (!plot.hasOwner()) { if (!plot.hasOwner()) {
return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms); return Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED.s(), notifyPerms);
} }
if (FlagManager.isPlotFlagTrue(plot, "misc-place")) { if (FlagManager.isPlotFlagTrue(plot, "misc-place")) {
return true; return true;
} }

View File

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

Binary file not shown.