Optionals introduced, code cleaned, potential purge fix

This commit is contained in:
MattBDev
2016-04-01 19:14:46 -04:00
parent 3edfd39af9
commit 8243e0118a
42 changed files with 361 additions and 427 deletions

View File

@ -3,80 +3,82 @@ package com.intellectualcrafters.configuration;
import java.util.Map;
/**
* Represents a source of configurable options and settings
* Represents a source of configurable options and settings.
*/
public interface Configuration extends ConfigurationSection {
/**
* Sets the default value of the given path as provided.
* <p>
* If no source {@link Configuration} was provided as a default
*
* <p>If no source {@link Configuration} was provided as a default
* collection, then a new {@link MemoryConfiguration} will be created to
* hold the new default value.
* <p>
* If value is null, the value will be removed from the default
* Configuration source.
* hold the new default value.</p>
*
* <p>If value is null, the value will be removed from the default
* Configuration source.</p>
*
* @param path Path of the value to set.
* @param value Value to set the default to.
* @throws IllegalArgumentException Thrown if path is null.
*/
@Override void addDefault(final String path, final Object value);
@Override void addDefault(String path, Object value);
/**
* Sets the default values of the given paths as provided.
* <p>
* If no source {@link Configuration} was provided as a default
*
* <p>If no source {@link Configuration} was provided as a default
* collection, then a new {@link MemoryConfiguration} will be created to
* hold the new default values.
* hold the new default values.</p>
*
* @param defaults A map of Path->Values to add to defaults.
* @throws IllegalArgumentException Thrown if defaults is null.
*/
void addDefaults(final Map<String, Object> defaults);
void addDefaults(Map<String, Object> defaults);
/**
* Sets the default values of the given paths as provided.
* <p>
* If no source {@link Configuration} was provided as a default
*
* <p>If no source {@link Configuration} was provided as a default
* collection, then a new {@link MemoryConfiguration} will be created to
* hold the new default value.
* <p>
* This method will not hold a reference to the specified Configuration,
* hold the new default value.</p>
*
* <p>This method will not hold a reference to the specified Configuration,
* nor will it automatically update if that Configuration ever changes. If
* you require this, you should set the default source with {@link
* #setDefaults(com.intellectualcrafters.configuration.Configuration)}.
* #setDefaults(Configuration)}.</p>
*
* @param defaults A configuration holding a list of defaults to copy.
* @throws IllegalArgumentException Thrown if defaults is null or this.
*/
void addDefaults(final Configuration defaults);
/**
* Sets the source of all default values for this {@link Configuration}.
* <p>
* If a previous source was set, or previous default values were defined,
* then they will not be copied to the new source.
*
* @param defaults New source of default values for this configuration.
* @throws IllegalArgumentException Thrown if defaults is null or this.
*/
void setDefaults(final Configuration defaults);
void addDefaults(Configuration defaults);
/**
* Gets the source {@link Configuration} for this configuration.
*
* <p>
* If no configuration source was set, but default values were added, then
* a {@link MemoryConfiguration} will be returned. If no source was set
* and no defaults were set, then this method will return null.
* and no defaults were set, then this method will return null.</p>
*
* @return Configuration source for default values, or null if none exist.
*/
Configuration getDefaults();
/**
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
* Sets the source of all default values for this {@link Configuration}.
*
* <p>
* All setters through this method are chainable.
* If a previous source was set, or previous default values were defined,
* then they will not be copied to the new source.</p>
*
* @param defaults New source of default values for this configuration.
* @throws IllegalArgumentException Thrown if defaults is null or this.
*/
void setDefaults(Configuration defaults);
/**
* Gets the {@link ConfigurationOptions} for this {@link Configuration}.
*
* <p>All setters through this method are chainable.</p>
*
* @return Options for this configuration
*/

View File

@ -23,35 +23,35 @@ public class MemoryConfiguration extends MemorySection implements Configuration
* @param defaults Default value provider
* @throws IllegalArgumentException Thrown if defaults is null
*/
public MemoryConfiguration(final Configuration defaults) {
public MemoryConfiguration(Configuration defaults) {
this.defaults = defaults;
}
@Override
public void addDefault(final String path, final Object value) {
public void addDefault(String path, Object value) {
if (path == null) {
throw new NullPointerException("Path may not be null");
}
if (defaults == null) {
defaults = new MemoryConfiguration();
if (this.defaults == null) {
this.defaults = new MemoryConfiguration();
}
defaults.set(path, value);
this.defaults.set(path, value);
}
@Override
public void addDefaults(final Map<String, Object> defaults) {
public void addDefaults(Map<String, Object> defaults) {
if (defaults == null) {
throw new NullPointerException("Defaults may not be null");
}
for (final Map.Entry<String, Object> entry : defaults.entrySet()) {
for (Map.Entry<String, Object> entry : defaults.entrySet()) {
addDefault(entry.getKey(), entry.getValue());
}
}
@Override
public void addDefaults(final Configuration defaults) {
public void addDefaults(Configuration defaults) {
if (defaults == null) {
throw new NullPointerException("Defaults may not be null");
}
@ -60,19 +60,19 @@ public class MemoryConfiguration extends MemorySection implements Configuration
}
@Override
public void setDefaults(final Configuration defaults) {
public Configuration getDefaults() {
return this.defaults;
}
@Override
public void setDefaults(Configuration defaults) {
if (defaults == null) {
throw new NullPointerException("Defaults may not be null");
}
this.defaults = defaults;
}
@Override
public Configuration getDefaults() {
return defaults;
}
@Override
public ConfigurationSection getParent() {
return null;
@ -80,10 +80,10 @@ public class MemoryConfiguration extends MemorySection implements Configuration
@Override
public MemoryConfigurationOptions options() {
if (options == null) {
options = new MemoryConfigurationOptions(this);
if (this.options == null) {
this.options = new MemoryConfigurationOptions(this);
}
return options;
return this.options;
}
}

View File

@ -43,46 +43,46 @@ import java.util.Set;
public class Area extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer plr, String[] args) {
public boolean onCommand(final PlotPlayer player, String[] args) {
if (args.length == 0) {
C.COMMAND_SYNTAX.send(plr, getUsage());
C.COMMAND_SYNTAX.send(player, getUsage());
return false;
}
switch (args[0].toLowerCase()) {
case "c":
case "setup":
case "create":
if (!Permissions.hasPermission(plr, "plots.area.create")) {
C.NO_PERMISSION.send(plr, "plots.area.create");
if (!Permissions.hasPermission(player, "plots.area.create")) {
C.NO_PERMISSION.send(player, "plots.area.create");
return false;
}
switch (args.length) {
case 1:
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false;
case 2:
switch (args[1].toLowerCase()) {
case "pos1": { // Set position 1
HybridPlotWorld area = plr.getMeta("area_create_area");
HybridPlotWorld area = player.getMeta("area_create_area");
if (area == null) {
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false;
}
Location location = plr.getLocation();
plr.setMeta("area_pos1", location);
C.SET_ATTRIBUTE.send(plr, "area_pos1", location.getX() + "," + location.getZ());
MainUtil.sendMessage(plr, "You will now set pos2: /plot area create pos2"
Location location = player.getLocation();
player.setMeta("area_pos1", location);
C.SET_ATTRIBUTE.send(player, "area_pos1", location.getX() + "," + location.getZ());
MainUtil.sendMessage(player, "You will now set pos2: /plot area create pos2"
+ "\nNote: The chosen plot size may result in the created area not exactly matching your second position.");
return true;
}
case "pos2": // Set position 2 and finish creation for type=2 (partial)
final HybridPlotWorld area = plr.getMeta("area_create_area");
final HybridPlotWorld area = player.getMeta("area_create_area");
if (area == null) {
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false;
}
Location pos1 = plr.getLocation();
Location pos2 = plr.getMeta("area_pos1");
Location pos1 = player.getLocation();
Location pos2 = player.getMeta("area_pos1");
int dx = Math.abs(pos1.getX() - pos2.getX());
int dz = Math.abs(pos1.getZ() - pos2.getZ());
int numX = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
@ -99,7 +99,7 @@ public class Area extends SubCommand {
final RegionWrapper region = new RegionWrapper(bx, tx, bz, tz);
Set<PlotArea> areas = PS.get().getPlotAreas(area.worldname, region);
if (!areas.isEmpty()) {
C.CLUSTER_INTERSECTION.send(plr, areas.iterator().next().toString());
C.CLUSTER_INTERSECTION.send(player, areas.iterator().next().toString());
return false;
}
final SetupObject object = new SetupObject();
@ -125,8 +125,8 @@ public class Area extends SubCommand {
final String world = SetupUtils.manager.setupWorld(object);
if (WorldUtil.IMP.isWorld(world)) {
PS.get().loadWorld(world, null);
C.SETUP_FINISHED.send(plr);
plr.teleport(WorldUtil.IMP.getSpawn(world));
C.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world));
if (area.TERRAIN != 3) {
ChunkManager.largeRegionTask(world, region, new RunnableVal<ChunkLoc>() {
@Override
@ -136,12 +136,12 @@ public class Area extends SubCommand {
}, null);
}
} else {
MainUtil.sendMessage(plr, "An error occurred while creating the world: " + area.worldname);
MainUtil.sendMessage(player, "An error occurred while creating the world: " + area.worldname);
}
}
};
if (hasConfirmation(plr)) {
CmdConfirm.addPending(plr, "/plot area create pos2 (Creates world)", run);
if (hasConfirmation(player)) {
CmdConfirm.addPending(player, "/plot area create pos2 (Creates world)", run);
} else {
run.run();
}
@ -160,7 +160,7 @@ public class Area extends SubCommand {
final HybridPlotWorld pa = new HybridPlotWorld(object.world, id, new HybridGen(), null, null);
PlotArea other = PS.get().getPlotArea(pa.worldname, id);
if (other != null && Objects.equals(pa.id, other.id)) {
C.SETUP_WORLD_TAKEN.send(plr, pa.toString());
C.SETUP_WORLD_TAKEN.send(player, pa.toString());
return false;
}
Set<PlotArea> areas = PS.get().getPlotAreas(pa.worldname);
@ -172,7 +172,7 @@ public class Area extends SubCommand {
for (int i = 2; i < args.length; i++) {
String[] pair = args[i].split("=");
if (pair.length != 2) {
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false;
}
switch (pair[0].toLowerCase()) {
@ -218,13 +218,13 @@ public class Area extends SubCommand {
object.type = pa.TYPE;
break;
default:
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false;
}
}
if (pa.TYPE != 2) {
if (WorldUtil.IMP.isWorld(pa.worldname)) {
C.SETUP_WORLD_TAKEN.send(plr, pa.worldname);
C.SETUP_WORLD_TAKEN.send(player, pa.worldname);
return false;
}
Runnable run = new Runnable() {
@ -241,10 +241,10 @@ public class Area extends SubCommand {
object.setupGenerator = "PlotSquared";
String world = SetupUtils.manager.setupWorld(object);
if (WorldUtil.IMP.isWorld(world)) {
C.SETUP_FINISHED.send(plr);
plr.teleport(WorldUtil.IMP.getSpawn(world));
C.SETUP_FINISHED.send(player);
player.teleport(WorldUtil.IMP.getSpawn(world));
} else {
MainUtil.sendMessage(plr, "An error occurred while creating the world: " + pa.worldname);
MainUtil.sendMessage(player, "An error occurred while creating the world: " + pa.worldname);
}
try {
PS.get().config.save(PS.get().configFile);
@ -253,55 +253,55 @@ public class Area extends SubCommand {
}
}
};
if (hasConfirmation(plr)) {
CmdConfirm.addPending(plr, "/plot area " + StringMan.join(args, " "), run);
if (hasConfirmation(player)) {
CmdConfirm.addPending(player, "/plot area " + StringMan.join(args, " "), run);
} else {
run.run();
}
return true;
}
if (pa.id == null) {
C.COMMAND_SYNTAX.send(plr, "/plot area create [world[:id]] [<modifier>=<value>]...");
C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [<modifier>=<value>]...");
return false;
}
if (WorldUtil.IMP.isWorld(pa.worldname)) {
if (!plr.getLocation().getWorld().equals(pa.worldname)) {
plr.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
if (!player.getLocation().getWorld().equals(pa.worldname)) {
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
}
} else {
object.terrain = 0;
object.type = 0;
SetupUtils.manager.setupWorld(object);
plr.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
player.teleport(WorldUtil.IMP.getSpawn(pa.worldname));
}
plr.setMeta("area_create_area", pa);
MainUtil.sendMessage(plr, "$1Go to the first corner and use: $2/plot area create pos1");
player.setMeta("area_create_area", pa);
MainUtil.sendMessage(player, "$1Go to the first corner and use: $2/plot area create pos1");
break;
}
return true;
case "i":
case "info": {
if (!Permissions.hasPermission(plr, "plots.area.info")) {
C.NO_PERMISSION.send(plr, "plots.area.info");
if (!Permissions.hasPermission(player, "plots.area.info")) {
C.NO_PERMISSION.send(player, "plots.area.info");
return false;
}
PlotArea area;
switch (args.length) {
case 1:
area = plr.getApplicablePlotArea();
area = player.getApplicablePlotArea();
break;
case 2:
area = PS.get().getPlotAreaByString(args[1]);
break;
default:
C.COMMAND_SYNTAX.send(plr, "/plot area info [area]");
C.COMMAND_SYNTAX.send(player, "/plot area info [area]");
return false;
}
if (area == null) {
if (args.length == 2) {
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
} else {
C.NOT_IN_PLOT_WORLD.send(plr);
C.NOT_IN_PLOT_WORLD.send(player);
}
return false;
}
@ -331,13 +331,13 @@ public class Area extends SubCommand {
+ "\n$1Clusters: $2" + clusters
+ "\n$1Region: $2" + region
+ "\n$1Generator: $2" + generator;
MainUtil.sendMessage(plr, C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
MainUtil.sendMessage(player, C.PLOT_INFO_HEADER.s() + '\n' + value + '\n' + C.PLOT_INFO_FOOTER.s(), false);
return true;
}
case "l":
case "list":
if (!Permissions.hasPermission(plr, "plots.area.list")) {
C.NO_PERMISSION.send(plr, "plots.area.list");
if (!Permissions.hasPermission(player, "plots.area.list")) {
C.NO_PERMISSION.send(player, "plots.area.list");
return false;
}
int page;
@ -351,11 +351,11 @@ public class Area extends SubCommand {
break;
}
default:
C.COMMAND_SYNTAX.send(plr, "/plot area list [#]");
C.COMMAND_SYNTAX.send(player, "/plot area list [#]");
return false;
}
ArrayList<PlotArea> areas = new ArrayList<>(PS.get().getPlotAreas());
paginate(plr, areas, 8, page, new RunnableVal3<Integer, PlotArea, PlotMessage>() {
paginate(player, areas, 8, page, new RunnableVal3<Integer, PlotArea, PlotMessage>() {
@Override
public void run(Integer i, PlotArea area, PlotMessage message) {
String name;
@ -397,17 +397,17 @@ public class Area extends SubCommand {
case "clear":
case "reset":
case "regenerate": {
if (!Permissions.hasPermission(plr, "plots.area.regen")) {
C.NO_PERMISSION.send(plr, "plots.area.regen");
if (!Permissions.hasPermission(player, "plots.area.regen")) {
C.NO_PERMISSION.send(player, "plots.area.regen");
return false;
}
final PlotArea area = plr.getApplicablePlotArea();
final PlotArea area = player.getApplicablePlotArea();
if (area == null) {
C.NOT_IN_PLOT_WORLD.send(plr);
C.NOT_IN_PLOT_WORLD.send(player);
return false;
}
if (area.TYPE != 2) {
MainUtil.sendMessage(plr, "$4Stop the server and delete: " + area.worldname + "/region");
MainUtil.sendMessage(player, "$4Stop the server and delete: " + area.worldname + "/region");
return false;
}
ChunkManager.largeRegionTask(area.worldname, area.getRegion(), new RunnableVal<ChunkLoc>() {
@ -423,17 +423,17 @@ public class Area extends SubCommand {
case "teleport":
case "visit":
case "tp":
if (!Permissions.hasPermission(plr, "plots.area.tp")) {
C.NO_PERMISSION.send(plr, "plots.area.tp");
if (!Permissions.hasPermission(player, "plots.area.tp")) {
C.NO_PERMISSION.send(player, "plots.area.tp");
return false;
}
if (args.length != 2) {
C.COMMAND_SYNTAX.send(plr, "/plot visit [area]");
C.COMMAND_SYNTAX.send(player, "/plot visit [area]");
return false;
}
PlotArea area = PS.get().getPlotAreaByString(args[1]);
if (area == null) {
C.NOT_VALID_PLOT_WORLD.send(plr, args[1]);
C.NOT_VALID_PLOT_WORLD.send(player, args[1]);
return false;
}
Location center;
@ -445,18 +445,18 @@ public class Area extends SubCommand {
region.minZ + (region.maxZ - region.minZ) / 2);
center.setY(WorldUtil.IMP.getHighestBlock(area.worldname, center.getX(), center.getZ()));
}
plr.teleport(center);
player.teleport(center);
return true;
case "delete":
case "remove":
MainUtil.sendMessage(plr, "$1World creation settings may be stored in multiple locations:"
MainUtil.sendMessage(player, "$1World creation settings may be stored in multiple locations:"
+ "\n$3 - $2Bukkit bukkit.yml"
+ "\n$3 - $2PlotSquared settings.yml"
+ "\n$3 - $2Multiverse worlds.yml (or any world management plugin)"
+ "\n$1Stop the server and delete it from these locations.");
return true;
}
C.COMMAND_SYNTAX.send(plr, getUsage());
C.COMMAND_SYNTAX.send(player, getUsage());
return false;
}

View File

@ -12,6 +12,7 @@ import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Set;
@CommandDeclaration(command = "clear",
@ -20,7 +21,7 @@ import java.util.Set;
category = CommandCategory.APPEARANCE,
usage = "/plot clear [id]",
aliases = "reset",
confirmation=true)
confirmation = true)
public class Clear extends SubCommand {
@Override

View File

@ -37,6 +37,7 @@ import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
import com.plotsquared.listener.WEManager;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@ -46,6 +47,7 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.UUID;
import javax.script.Bindings;
import javax.script.ScriptContext;
import javax.script.ScriptEngine;
@ -145,7 +147,7 @@ public class DebugExec extends SubCommand {
@Override
public boolean onCommand(final PlotPlayer player, String[] args) {
java.util.List<String> allowed_params =
List<String> allowed_params =
Arrays.asList("calibrate-analysis", "remove-flag", "stop-expire", "start-expire", "show-expired", "update-expired", "seen", "list-scripts");
if (args.length > 0) {
String arg = args[0].toLowerCase();
@ -331,7 +333,7 @@ public class DebugExec extends SubCommand {
}
break;
case "list-scripts":
final String path = PS.get().IMP.getDirectory() + File.separator + "scripts";
String path = PS.get().IMP.getDirectory() + File.separator + "scripts";
File folder = new File(path);
File[] filesArray = folder.listFiles();
@ -416,7 +418,7 @@ public class DebugExec extends SubCommand {
default:
script = StringMan.join(args, " ");
}
if (!ConsolePlayer.isConsole(player)) {
if (!(player instanceof ConsolePlayer)) {
MainUtil.sendMessage(player, C.NOT_CONSOLE);
return false;
}
@ -436,13 +438,13 @@ public class DebugExec extends SubCommand {
} catch (ScriptException e) {
e.printStackTrace();
}
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
}
});
} else {
long start = System.currentTimeMillis();
Object result = this.engine.eval(script, this.scope);
ConsolePlayer.getConsole().sendMessage("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
PS.log("> " + (System.currentTimeMillis() - start) + "ms -> " + result);
}
return true;
} catch (ScriptException e) {

View File

@ -11,6 +11,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.HashSet;
@CommandDeclaration(
@ -21,7 +22,7 @@ import java.util.HashSet;
aliases = {"dispose", "del"},
category = CommandCategory.CLAIMING,
requiredType = RequiredType.NONE,
confirmation=true)
confirmation = true)
public class Delete extends SubCommand {
@Override

View File

@ -31,8 +31,8 @@ public class Deny extends SubCommand {
@Override
public boolean onCommand(PlotPlayer plr, String[] args) {
Location loc = plr.getLocation();
Plot plot = loc.getPlotAbs();
Location location = plr.getLocation();
Plot plot = location.getPlotAbs();
if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT);
}

View File

@ -1,5 +1,6 @@
package com.intellectualcrafters.plot.commands;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -155,9 +156,9 @@ public class Inbox extends SubCommand {
sendMessage(player, C.NO_PERM_INBOX_MODIFY);
}
inbox.clearInbox(plot);
ArrayList<PlotComment> comments = plot.getSettings().getComments(inbox.toString());
if (comments != null) {
plot.getSettings().removeComments(comments);
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(inbox.toString());
if (comments.isPresent()) {
plot.getSettings().removeComments(comments.get());
}
MainUtil.sendMessage(player, C.COMMENT_REMOVED, "*");
return true;

View File

@ -26,8 +26,8 @@ public class Kick extends SubCommand {
@Override
public boolean onCommand(PlotPlayer plr, String[] args) {
Location loc = plr.getLocation();
Plot plot = loc.getPlot();
Location location = plr.getLocation();
Plot plot = location.getPlot();
if (plot == null) {
return !sendMessage(plr, C.NOT_IN_PLOT);
}
@ -40,8 +40,8 @@ public class Kick extends SubCommand {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
return false;
}
Location otherLoc = player.getLocation();
if (!plr.getLocation().getWorld().equals(otherLoc.getWorld()) || !plot.equals(otherLoc.getPlot())) {
Location location2 = player.getLocation();
if (!plr.getLocation().getWorld().equals(location2.getWorld()) || !plot.equals(location2.getPlot())) {
MainUtil.sendMessage(plr, C.INVALID_PLAYER, args[0]);
return false;
}
@ -49,7 +49,7 @@ public class Kick extends SubCommand {
C.CANNOT_KICK_PLAYER.send(plr, player.getName());
return false;
}
Location spawn = WorldUtil.IMP.getSpawn(loc.getWorld());
Location spawn = WorldUtil.IMP.getSpawn(location.getWorld());
C.YOU_GOT_KICKED.send(player);
if (plot.equals(spawn.getPlot())) {
Location newSpawn = WorldUtil.IMP.getSpawn(player);

View File

@ -14,6 +14,7 @@ import com.intellectualcrafters.plot.util.EconHandler;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.general.commands.Command;
import com.plotsquared.general.commands.CommandDeclaration;
import java.util.Arrays;
/**
@ -113,14 +114,6 @@ public class MainCommand extends Command {
return instance;
}
@Deprecated
/**
* @Deprecated legacy
*/
public void addCommand(SubCommand command) {
PS.debug("Command registration is now done during instantiation");
}
public static boolean onCommand(final PlotPlayer player, String... args) {
if (args.length >= 1 && args[0].contains(":")) {
String[] split2 = args[0].split(":");
@ -181,6 +174,14 @@ public class MainCommand extends Command {
return true;
}
@Deprecated
/**
* @Deprecated legacy
*/
public void addCommand(SubCommand command) {
PS.debug("Command registration is now done during instantiation");
}
@Override
public void execute(PlotPlayer player, String[] args, RunnableVal3<Command, Runnable, Runnable> confirm, RunnableVal2<Command, CommandResult> whenDone) {
// Clear perm caching //
@ -192,7 +193,8 @@ public class MainCommand extends Command {
if (args.length >= 2) {
PlotArea area = player.getApplicablePlotArea();
Plot newPlot = Plot.fromString(area, args[0]);
if (newPlot != null && (ConsolePlayer.isConsole(player) || newPlot.getArea().equals(area) || Permissions.hasPermission(player, C.PERMISSION_ADMIN)) && !newPlot.isDenied(player.getUUID())) {
if (newPlot != null && (player instanceof ConsolePlayer || newPlot.getArea().equals(area) || Permissions
.hasPermission(player, C.PERMISSION_ADMIN)) && !newPlot.isDenied(player.getUUID())) {
// Save meta
loc = player.getMeta("location");
plot = player.getMeta("lastplot");

View File

@ -23,7 +23,7 @@ import java.util.UUID;
permission = "plots.merge", usage = "/plot merge <all|n|e|s|w> [removeroads]",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
confirmation=true)
confirmation = true)
public class Merge extends SubCommand {
public static final String[] values = new String[]{"north", "east", "south", "west", "auto"};

View File

@ -24,7 +24,7 @@ import java.util.UUID;
description = "Purge all plots for a world",
category = CommandCategory.ADMINISTRATION,
requiredType = RequiredType.CONSOLE,
confirmation=true)
confirmation = true)
public class Purge extends SubCommand {
@Override
@ -145,12 +145,14 @@ public class Purge extends SubCommand {
Runnable run = new Runnable() {
@Override
public void run() {
HashSet<Integer> ids = new HashSet<Integer>();
HashSet<Integer> ids = new HashSet<>();
for (Plot plot : toDelete) {
if (plot.temp != Integer.MAX_VALUE) {
ids.add(plot.temp);
PlotArea area = plot.getArea();
plot.getArea().removePlot(plot.getId());
for (PlotPlayer plotPlayer : plot.getPlayersInPlot()) {
plotPlayer.deleteMeta("lastplot");
}
}
}
DBFunc.purgeIds(ids);

View File

@ -141,7 +141,7 @@ public class SchematicCmd extends SubCommand {
// }
case "saveall":
case "exportall": {
if (!ConsolePlayer.isConsole(plr)) {
if (!(plr instanceof ConsolePlayer)) {
MainUtil.sendMessage(plr, C.NOT_CONSOLE);
return false;
}
@ -197,10 +197,9 @@ public class SchematicCmd extends SubCommand {
MainUtil.sendMessage(plr, C.NO_PLOT_PERMS);
return false;
}
Plot p2 = plot;
loc.getWorld();
Collection<Plot> plots = new ArrayList<Plot>();
plots.add(p2);
plots.add(plot);
boolean result = SchematicHandler.manager.exportAll(plots, null, null, new Runnable() {
@Override
public void run() {

View File

@ -3,7 +3,6 @@ package com.intellectualcrafters.plot.config;
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.configuration.file.YamlConfiguration;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.util.StringMan;
import com.plotsquared.general.commands.CommandCaller;
@ -621,14 +620,14 @@ public enum C {
* What locale category should this translation fall under.
*/
private final String category;
/**
* Translated.
*/
private String s;
/**
* Should the string be prefixed.
*/
private final boolean prefix;
/**
* Translated.
*/
private String s;
/**
* Constructor.
@ -799,7 +798,7 @@ public enum C {
public void send(CommandCaller plr, Object... args) {
String msg = format(this, args);
if (plr == null) {
ConsolePlayer.getConsole().sendMessage(msg);
PS.log(msg);
} else {
plr.sendMessage(msg);
}

View File

@ -1443,18 +1443,19 @@ public class SQLManager implements AbstractDB {
if (plot.temp > 0) {
return plot.temp;
}
PreparedStatement stmt = this.connection.prepareStatement(
"SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC");
stmt.setInt(1, plot.getId().x);
stmt.setInt(2, plot.getId().y);
stmt.setString(3, plot.getArea().toString());
ResultSet r = stmt.executeQuery();
int id = Integer.MAX_VALUE;
while (r.next()) {
id = r.getInt("id");
int id;
try (PreparedStatement statement = this.connection.prepareStatement(
"SELECT `id` FROM `" + this.prefix + "plot` WHERE `plot_id_x` = ? AND `plot_id_z` = ? AND world = ? ORDER BY `timestamp` ASC")) {
statement.setInt(1, plot.getId().x);
statement.setInt(2, plot.getId().y);
statement.setString(3, plot.getArea().toString());
try (ResultSet resultSet = statement.executeQuery()) {
id = Integer.MAX_VALUE;
while (resultSet.next()) {
id = resultSet.getInt("id");
}
}
}
r.close();
stmt.close();
if (id == Integer.MAX_VALUE || id == 0) {
if (plot.temp > 0) {
return plot.temp;
@ -1625,17 +1626,17 @@ public class SQLManager implements AbstractDB {
/*
* Getting plots
*/
Statement stmt = this.connection.createStatement();
Statement statement = this.connection.createStatement();
int id;
String o;
UUID user;
try (ResultSet r = stmt
try (ResultSet resultSet = statement
.executeQuery("SELECT `id`, `plot_id_x`, `plot_id_z`, `owner`, `world`, `timestamp` FROM `" + this.prefix + "plot`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) {
PlotId plot_id = new PlotId(r.getInt("plot_id_x"), r.getInt("plot_id_z"));
id = r.getInt("id");
String areaid = r.getString("world");
while (resultSet.next()) {
PlotId plot_id = new PlotId(resultSet.getInt("plot_id_x"), resultSet.getInt("plot_id_z"));
id = resultSet.getInt("id");
String areaid = resultSet.getString("world");
if (!areas.contains(areaid)) {
if (Settings.AUTO_PURGE) {
toDelete.add(id);
@ -1649,13 +1650,13 @@ public class SQLManager implements AbstractDB {
}
}
}
o = r.getString("owner");
o = resultSet.getString("owner");
user = uuids.get(o);
if (user == null) {
user = UUID.fromString(o);
uuids.put(o, user);
}
Timestamp timestamp = r.getTimestamp("timestamp");
Timestamp timestamp = resultSet.getTimestamp("timestamp");
long time = timestamp.getTime();
Plot p = new Plot(plot_id, user, new HashSet<UUID>(), new HashSet<UUID>(), new HashSet<UUID>(), "", null, null, null,
new boolean[]{false, false, false, false}, time, id);
@ -1682,7 +1683,7 @@ public class SQLManager implements AbstractDB {
deleteRows(toDelete, this.prefix + "plot", "id");
}
if (Settings.CACHE_RATINGS) {
try (ResultSet r = stmt.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + this.prefix + "plot_rating`")) {
try (ResultSet r = statement.executeQuery("SELECT `plot_plot_id`, `player`, `rating` FROM `" + this.prefix + "plot_rating`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) {
id = r.getInt("plot_plot_id");
@ -1709,7 +1710,7 @@ public class SQLManager implements AbstractDB {
/*
* Getting helpers
*/
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_helpers`")) {
try (ResultSet r = statement.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_helpers`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) {
id = r.getInt("plot_plot_id");
@ -1735,7 +1736,7 @@ public class SQLManager implements AbstractDB {
/*
* Getting trusted
*/
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_trusted`")) {
try (ResultSet r = statement.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_trusted`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) {
id = r.getInt("plot_plot_id");
@ -1761,7 +1762,7 @@ public class SQLManager implements AbstractDB {
/*
* Getting denied
*/
try (ResultSet r = stmt.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_denied`")) {
try (ResultSet r = statement.executeQuery("SELECT `user_uuid`, `plot_plot_id` FROM `" + this.prefix + "plot_denied`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) {
id = r.getInt("plot_plot_id");
@ -1783,7 +1784,7 @@ public class SQLManager implements AbstractDB {
deleteRows(toDelete, this.prefix + "plot_denied", "plot_plot_id");
}
try (ResultSet r = stmt.executeQuery("SELECT * FROM `" + this.prefix + "plot_settings`")) {
try (ResultSet r = statement.executeQuery("SELECT * FROM `" + this.prefix + "plot_settings`")) {
ArrayList<Integer> toDelete = new ArrayList<>();
while (r.next()) {
id = r.getInt("plot_plot_id");
@ -1860,7 +1861,7 @@ public class SQLManager implements AbstractDB {
+ ".yml.");
}
}
stmt.close();
statement.close();
deleteRows(toDelete, this.prefix + "plot_settings", "plot_plot_id");
}
if (!plots.entrySet().isEmpty()) {
@ -2012,7 +2013,7 @@ public class SQLManager implements AbstractDB {
stmt_prefix = " OR `id` = ";
}
stmt_prefix = "";
StringBuilder idstr = new StringBuilder("");
StringBuilder idstr = new StringBuilder();
for (Integer id : uniqueIds) {
idstr.append(stmt_prefix).append(id);
stmt_prefix = " OR `plot_plot_id` = ";

View File

@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.MathMan;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SchematicHandler.Dimension;
import com.intellectualcrafters.plot.util.SchematicHandler.Schematic;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
@ -163,11 +164,11 @@ public class HybridPlotWorld extends ClassicPlotWorld {
}
@Override
public boolean isCompatible(PlotArea plotworld) {
if (!(plotworld instanceof SquarePlotWorld)) {
public boolean isCompatible(PlotArea plotArea) {
if (!(plotArea instanceof SquarePlotWorld)) {
return false;
}
return ((SquarePlotWorld) plotworld).PLOT_WIDTH == this.PLOT_WIDTH;
return ((SquarePlotWorld) plotArea).PLOT_WIDTH == this.PLOT_WIDTH;
}
public void setupSchematics() {

View File

@ -39,10 +39,6 @@ public class ConsolePlayer extends PlotPlayer {
return instance;
}
public static boolean isConsole(PlotPlayer plr) {
return plr instanceof ConsolePlayer;
}
@Override
public long getPreviousLogin() {
return 0;
@ -133,7 +129,7 @@ public class ConsolePlayer extends PlotPlayer {
@Override
public PlotGameMode getGameMode() {
return PlotGameMode.CREATIVE;
return PlotGameMode.NOT_SET;
}
@Override

View File

@ -3,11 +3,6 @@ package com.intellectualcrafters.plot.object;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.util.MathMan;
/**
* Created 2015-02-11 for PlotSquared
*
*/
public class Location implements Cloneable, Comparable<Location> {
private int x;
@ -27,7 +22,7 @@ public class Location implements Cloneable, Comparable<Location> {
}
public Location() {
this("", 0, 0, 0, 0, 0);
this.world = "";
}
public Location(String world, int x, int y, int z) {

View File

@ -67,7 +67,7 @@ public abstract class PlotArea {
public int MAX_BUILD_HEIGHT = 256;
public int MIN_BUILD_HEIGHT = 1;
public PlotGameMode GAMEMODE = PlotGameMode.CREATIVE;
int hash;
private int hash;
private RegionWrapper region;
private ConcurrentHashMap<String, Object> meta;
private QuadMap<PlotCluster> clusters;
@ -180,13 +180,13 @@ public abstract class PlotArea {
/**
* Check if a PlotArea is compatible (move/copy etc)
* @param plotarea
* @param plotArea
* @return
*/
public boolean isCompatible(PlotArea plotarea) {
public boolean isCompatible(PlotArea plotArea) {
ConfigurationSection section = PS.get().config.getConfigurationSection("worlds");
for (ConfigurationNode setting : plotarea.getSettingNodes()) {
Object constant = section.get(plotarea.worldname + "." + setting.getConstant());
for (ConfigurationNode setting : plotArea.getSettingNodes()) {
Object constant = section.get(plotArea.worldname + "." + setting.getConstant());
if (constant == null) {
return false;
}
@ -358,7 +358,11 @@ public abstract class PlotArea {
@Override
public String toString() {
return this.id == null ? this.worldname : this.worldname + ";" + this.id;
if (this.id == null) {
return this.worldname;
} else {
return this.worldname + ";" + this.id;
}
}
@Override

View File

@ -17,7 +17,7 @@ public class PlotId {
* @param x The plot x coordinate
* @param y The plot y coordinate
*/
public PlotId(final int x, final int y) {
public PlotId(int x, int y) {
this.x = x;
this.y = y;
}
@ -29,11 +29,11 @@ public class PlotId {
*
* @return null if the string is invalid
*/
public static PlotId fromString(final String string) {
public static PlotId fromString(String string) {
if (string == null) {
return null;
}
final String[] parts = string.split(";");
String[] parts = string.split(";");
if (parts.length < 2) {
return null;
}
@ -42,7 +42,7 @@ public class PlotId {
try {
x = Integer.parseInt(parts[0]);
y = Integer.parseInt(parts[1]);
} catch (final Exception e) {
} catch (Exception e) {
return null;
}
return new PlotId(x, y);
@ -67,7 +67,7 @@ public class PlotId {
* @param direction
* @return PlotId
*/
public PlotId getRelative(final int direction) {
public PlotId getRelative(int direction) {
switch (direction) {
case 0:
return new PlotId(this.x, this.y - 1);
@ -92,7 +92,7 @@ public class PlotId {
}
@Override
public boolean equals(final Object obj) {
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
@ -105,8 +105,8 @@ public class PlotId {
if (getClass() != obj.getClass()) {
return false;
}
final PlotId other = (PlotId) obj;
return x == other.x && y == other.y;
PlotId other = (PlotId) obj;
return this.x == other.x && this.y == other.y;
}
/**
@ -116,7 +116,7 @@ public class PlotId {
*/
@Override
public String toString() {
return x + ";" + y;
return this.x + ";" + this.y;
}
/**
@ -125,15 +125,15 @@ public class PlotId {
* TODO maybe make x/y values private and add this to the mutators
*/
public void recalculateHash() {
hash = 0;
this.hash = 0;
hashCode();
}
@Override
public int hashCode() {
if (hash == 0) {
hash = (x << 16) | (y & 0xFFFF);
if (this.hash == 0) {
this.hash = (this.x << 16) | (this.y & 0xFFFF);
}
return hash;
return this.hash;
}
}

View File

@ -1,5 +1,6 @@
package com.intellectualcrafters.plot.object;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.comment.PlotComment;
@ -151,17 +152,17 @@ public class PlotSettings {
return "";
}
public ArrayList<PlotComment> getComments(String inbox) {
public Optional<ArrayList<PlotComment>> getComments(String inbox) {
ArrayList<PlotComment> c = new ArrayList<>();
if (this.comments == null) {
return null;
return Optional.absent();
}
for (PlotComment comment : this.comments) {
if (comment.inbox.equals(inbox)) {
c.add(comment);
}
}
return c;
return Optional.of(c);
}
public void setComments(List<PlotComment> comments) {

View File

@ -1,5 +1,6 @@
package com.intellectualcrafters.plot.object.comment;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -46,13 +47,13 @@ public class InboxOwner extends CommentInbox {
}
@Override
public boolean getComments(final Plot plot, final RunnableVal whenDone) {
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
if ((plot == null) || (plot.owner == null)) {
return false;
}
ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
if (comments != null) {
whenDone.value = comments;
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
if (comments.isPresent()) {
whenDone.value = comments.get();
TaskManager.runTask(whenDone);
return true;
}
@ -75,7 +76,7 @@ public class InboxOwner extends CommentInbox {
@Override
public boolean addComment(Plot plot, PlotComment comment) {
if ((plot == null) || (plot.owner == null)) {
if (plot.owner == null) {
return false;
}
plot.getSettings().addComment(comment);

View File

@ -1,5 +1,6 @@
package com.intellectualcrafters.plot.object.comment;
import com.google.common.base.Optional;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -42,13 +43,13 @@ public class InboxPublic extends CommentInbox {
}
@Override
public boolean getComments(final Plot plot, final RunnableVal whenDone) {
if ((plot == null) || (plot.owner == null)) {
public boolean getComments(final Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
if (plot.owner == null) {
return false;
}
ArrayList<PlotComment> comments = plot.getSettings().getComments(toString());
if (comments != null) {
whenDone.value = comments;
Optional<ArrayList<PlotComment>> comments = plot.getSettings().getComments(toString());
if (comments.isPresent()) {
whenDone.value = comments.get();
TaskManager.runTask(whenDone);
return true;
}
@ -69,7 +70,7 @@ public class InboxPublic extends CommentInbox {
@Override
public boolean addComment(Plot plot, PlotComment comment) {
if ((plot == null) || (plot.owner == null)) {
if (plot.owner == null) {
return false;
}
plot.getSettings().addComment(comment);

View File

@ -39,7 +39,7 @@ public class InboxReport extends CommentInbox {
}
@Override
public boolean getComments(Plot plot, final RunnableVal whenDone) {
public boolean getComments(Plot plot, final RunnableVal<List<PlotComment>> whenDone) {
DBFunc.getComments(null, toString(), new RunnableVal<List<PlotComment>>() {
@Override
public void run(List<PlotComment> value) {
@ -52,7 +52,7 @@ public class InboxReport extends CommentInbox {
@Override
public boolean addComment(Plot plot, PlotComment comment) {
if ((plot == null) || (plot.owner == null)) {
if (plot.owner == null) {
return false;
}
DBFunc.setComment(plot, comment);
@ -66,7 +66,7 @@ public class InboxReport extends CommentInbox {
@Override
public boolean removeComment(Plot plot, PlotComment comment) {
if (plot == null || plot.owner == null) {
if (plot.owner == null) {
return false;
}
DBFunc.removeComment(plot, comment);

View File

@ -7,7 +7,7 @@ public abstract class AbstractTitle {
public static AbstractTitle TITLE_CLASS;
public static void sendTitle(PlotPlayer player, String head, String sub) {
if (ConsolePlayer.isConsole(player)) {
if (player instanceof ConsolePlayer) {
return;
}
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {

View File

@ -2,12 +2,12 @@ package com.intellectualcrafters.plot.util;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.RegionWrapper;
import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper;
import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
@ -239,7 +239,7 @@ public abstract class ChunkManager {
for (ChunkLoc loc : chunks) {
String directory = world + File.separator + "region" + File.separator + "r." + loc.x + "." + loc.z + ".mca";
File file = new File(PS.get().IMP.getWorldContainer(), directory);
ConsolePlayer.getConsole().sendMessage("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
PS.log("&6 - Deleting file: " + file.getName() + " (max 1024 chunks)");
if (file.exists()) {
file.delete();
}

View File

@ -19,7 +19,7 @@ public abstract class EconHandler {
}
public double getMoney(PlotPlayer player) {
if (ConsolePlayer.isConsole(player)) {
if (player instanceof ConsolePlayer) {
return Double.MAX_VALUE;
}
return getBalance(player);

View File

@ -601,7 +601,8 @@ public class MainUtil {
public static boolean sendMessage(PlotPlayer player, String msg, boolean prefix) {
if (!msg.isEmpty()) {
if (player == null) {
ConsolePlayer.getConsole().sendMessage((prefix ? C.PREFIX.s() : "") + msg);
String message = (prefix ? C.PREFIX.s() : "") + msg;
PS.log(message);
} else {
player.sendMessage((prefix ? C.PREFIX.s() : "") + C.color(msg));
}
@ -638,7 +639,7 @@ public class MainUtil {
public void run() {
String m = C.format(c, args);
if (plr == null) {
ConsolePlayer.getConsole().sendMessage(m);
PS.log(m);
} else {
plr.sendMessage(m);
}

View File

@ -7,7 +7,6 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
@ -97,7 +96,7 @@ public abstract class UUIDHandlerImplementation {
try {
this.unknown.add(uuid);
} catch (Exception e) {
ConsolePlayer.getConsole().sendMessage("&c(minor) Invalid UUID mapping: " + uuid);
PS.log("&c(minor) Invalid UUID mapping: " + uuid);
e.printStackTrace();
}
return false;

View File

@ -1,10 +1,6 @@
package com.plotsquared.general.commands;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.MainUtil;
public abstract class Argument<T> {
@ -37,24 +33,18 @@ public abstract class Argument<T> {
return in;
}
};
public static Argument<String> PlayerName = new Argument<String>("PlayerName", "Dinnerbone") {
public static final Argument<String> PlayerName = new Argument<String>("PlayerName", "Dinnerbone") {
@Override
public String parse(String in) {
return in.length() <= 16 ? in : null;
}
};
public static Argument<PlotId> PlotID = new Argument<PlotId>("PlotID", new PlotId(-6, 3)) {
public static final Argument<PlotId> PlotID = new Argument<PlotId>("PlotID", new PlotId(-6, 3)) {
@Override
public PlotId parse(String in) {
return PlotId.fromString(in);
}
};
public static Argument<Plot> Plot = new Argument<Plot>("Plot", new Plot(PlotArea.createGeneric("world"), new PlotId(3, -6), null)) {
@Override
public Plot parse(String in) {
return MainUtil.getPlotFromString(ConsolePlayer.getConsole(), in, false);
}
};
private final String name;
private final T example;