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

@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.SchematicHandler;
import com.intellectualcrafters.plot.util.SetQueue;
import com.intellectualcrafters.plot.util.UUIDHandler;
@ -156,7 +157,7 @@ public class PlotAPI {
*
* @return ChunkManager
*
* @see com.intellectualcrafters.plot.util.ChunkManager
* @see ChunkManager
*/
public ChunkManager getChunkManager() {
return ChunkManager.manager;
@ -176,7 +177,7 @@ public class PlotAPI {
*
* @return UUIDWrapper
*
* @see com.intellectualcrafters.plot.uuid.UUIDWrapper
* @see UUIDWrapper
*/
public UUIDWrapper getUUIDWrapper() {
return UUIDHandler.getUUIDWrapper();
@ -211,7 +212,7 @@ public class PlotAPI {
*
* @return Array of strings
*
* @see com.intellectualcrafters.plot.util.Permissions
* @see Permissions
* @deprecated Use {@link C} to list all the permissions
*/
@Deprecated
@ -231,7 +232,7 @@ public class PlotAPI {
*
* @return SchematicHandler
*
* @see com.intellectualcrafters.plot.util.SchematicHandler
* @see SchematicHandler
*/
public SchematicHandler getSchematicHandler() {
return SchematicHandler.manager;
@ -256,7 +257,7 @@ public class PlotAPI {
*
* @return PlotManager
*
* @see com.intellectualcrafters.plot.object.PlotManager
* @see PlotManager
* @see PS#getPlotManager(Plot)
*/
@Deprecated
@ -288,7 +289,7 @@ public class PlotAPI {
* @return PlotManager
*
* @see PS#getPlotManager(Plot)
* @see com.intellectualcrafters.plot.object.PlotManager
* @see PlotManager
*/
@Deprecated
public PlotManager getPlotManager(String world) {
@ -314,7 +315,7 @@ public class PlotAPI {
* @return The {@link PlotArea} for the world or null if not in plotworld
*
* @see #getPlotAreas(World)
* @see com.intellectualcrafters.plot.object.PlotArea
* @see PlotArea
*/
@Deprecated
public PlotArea getWorldSettings(World world) {
@ -332,7 +333,7 @@ public class PlotAPI {
* @return The {@link PlotArea} for the world or null if not in plotworld
*
* @see PS#getPlotArea(String, String)
* @see com.intellectualcrafters.plot.object.PlotArea
* @see PlotArea
*/
@Deprecated
public PlotArea getWorldSettings(String world) {
@ -392,7 +393,7 @@ public class PlotAPI {
* @param caption The caption
*
* @see #sendConsoleMessage(String)
* @see com.intellectualcrafters.plot.config.C
* @see C
*/
public void sendConsoleMessage(C caption) {
sendConsoleMessage(caption.s());
@ -403,8 +404,8 @@ public class PlotAPI {
*
* @param flag Flag that should be registered
*
* @see com.intellectualcrafters.plot.flag.FlagManager#addFlag(com.intellectualcrafters.plot.flag.AbstractFlag)
* @see com.intellectualcrafters.plot.flag.AbstractFlag
* @see FlagManager#addFlag(AbstractFlag)
* @see AbstractFlag
*/
public void addFlag(AbstractFlag flag) {
FlagManager.addFlag(flag);
@ -415,8 +416,8 @@ public class PlotAPI {
*
* @return array of Flag[]
*
* @see com.intellectualcrafters.plot.flag.FlagManager#getFlags()
* @see com.intellectualcrafters.plot.flag.AbstractFlag
* @see FlagManager#getFlags()
* @see AbstractFlag
*/
public AbstractFlag[] getFlags() {
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
@ -468,7 +469,7 @@ public class PlotAPI {
*
* @return plot if found, otherwise it creates a temporary plot
*
* @see #getPlot(org.bukkit.Location)
* @see #getPlot(Location)
* @see Plot
*/
public Plot getPlot(Player player) {
@ -638,7 +639,7 @@ public class PlotAPI {
* Register a subcommand.
* @deprecated Command registration is done on object creation
* @param c SubCommand, that we want to register
* @see com.intellectualcrafters.plot.commands.SubCommand
* @see SubCommand
*/
@Deprecated
public void registerCommand(SubCommand c) {

View File

@ -73,12 +73,6 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
@ -93,6 +87,13 @@ import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import java.util.UUID;
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
public static BukkitMain THIS;
@ -449,18 +450,15 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
TaskManager.runTaskLaterAsync(new Runnable() {
@Override
public void run() {
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
if (new LikePlotMeConverter().run(new ClassicPlotMeConnector())) {
return;
}
if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
return;
}
if (new LikePlotMeConverter("AthionPlots").run(new ClassicPlotMeConnector())) {
if (new LikePlotMeConverter().run(new PlotMeConnector_017())) {
return;
}
}
}, 20);
return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null;
return Bukkit.getPluginManager().getPlugin("PlotMe") != null;
}
@Override

View File

@ -113,29 +113,22 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
try {
byte[] bytes = resultSet.getBytes(column);
if (bytes != null) {
try {
ByteBuffer bb = ByteBuffer.wrap(bytes);
long high = bb.getLong();
long low = bb.getLong();
owner = new UUID(high, low);
} catch (Exception e) {
e.printStackTrace();
owner = UUID.nameUUIDFromBytes(bytes);
}
ByteBuffer bb = ByteBuffer.wrap(bytes);
long high = bb.getLong();
long low = bb.getLong();
owner = new UUID(high, low);
UUIDHandler.add(new StringWrapper(name), owner);
}
} catch (SQLException e) {
e.printStackTrace();
}
}
if (owner == null) {
if (name.isEmpty()) {
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
missing++;
continue;
}
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
if (name.isEmpty()) {
PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'");
missing++;
continue;
}
owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
}
} else {
UUIDHandler.add(new StringWrapper(name), owner);
@ -183,15 +176,10 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
try {
byte[] bytes = resultSet.getBytes("playerid");
if (bytes != null) {
try {
ByteBuffer bb = ByteBuffer.wrap(bytes);
long high = bb.getLong();
long low = bb.getLong();
denied = new UUID(high, low);
} catch (Exception e) {
e.printStackTrace();
denied = UUID.nameUUIDFromBytes(bytes);
}
ByteBuffer bb = ByteBuffer.wrap(bytes);
long mostSigBits = bb.getLong();
long leastSigBits = bb.getLong();
denied = new UUID(mostSigBits, leastSigBits);
UUIDHandler.add(new StringWrapper(name), denied);
}
} catch (SQLException e) {
@ -227,15 +215,10 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
try {
byte[] bytes = resultSet.getBytes("playerid");
if (bytes != null) {
try {
ByteBuffer bb = ByteBuffer.wrap(bytes);
long high = bb.getLong();
long low = bb.getLong();
helper = new UUID(high, low);
} catch (Exception e) {
e.printStackTrace();
helper = UUID.nameUUIDFromBytes(bytes);
}
ByteBuffer bb = ByteBuffer.wrap(bytes);
long mostSigBits = bb.getLong();
long leastSigBits = bb.getLong();
helper = new UUID(mostSigBits, leastSigBits);
UUIDHandler.add(new StringWrapper(name), helper);
}
} catch (SQLException e) {

View File

@ -24,6 +24,7 @@ import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@ -33,17 +34,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class LikePlotMeConverter {
private final String plugin;
/**
* Constructor.
*
* @param plugin Plugin Used to run the converter
*/
public LikePlotMeConverter(String plugin) {
this.plugin = plugin;
}
public static String getWorld(String world) {
for (World newWorld : Bukkit.getWorlds()) {
if (newWorld.getName().equalsIgnoreCase(world)) {
@ -58,11 +48,7 @@ public class LikePlotMeConverter {
}
public String getPlotMePath() {
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + this.plugin + File.separator;
}
public String getAthionPlotsPath() {
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + this.plugin + File.separator;
return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + "PlotMe" + File.separator;
}
public FileConfiguration getPlotMeConfig(String dataFolder) {
@ -131,31 +117,31 @@ public class LikePlotMeConverter {
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
Connection connection = connector.getPlotMeConnection(this.plugin, plotConfig, dataFolder);
Connection connection = connector.getPlotMeConnection("PlotMe", plotConfig, dataFolder);
if (!connector.isValidConnection(connection)) {
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
return false;
}
sendMessage(this.plugin + " conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
sendMessage("PlotMe conversion has started. To disable this, please set 'plotme-convert.enabled' to false in the 'settings.yml'");
mergeWorldYml(this.plugin, plotConfig);
mergeWorldYml("PlotMe", plotConfig);
sendMessage("Connecting to " + this.plugin + " DB");
sendMessage("Connecting to PlotMe DB");
ArrayList<Plot> createdPlots = new ArrayList<>();
sendMessage("Collecting plot data");
String dbPrefix = this.plugin.toLowerCase();
String dbPrefix = "PlotMe".toLowerCase();
sendMessage(" - " + dbPrefix + "Plots");
final Set<String> worlds = getPlotMeWorlds(plotConfig);
if (Settings.CONVERT_PLOTME) {
sendMessage("Updating bukkit.yml");
updateWorldYml(this.plugin, "bukkit.yml");
updateWorldYml(this.plugin, "plugins/Multiverse-Core/worlds.yml");
updateWorldYml("PlotMe", "bukkit.yml");
updateWorldYml("PlotMe", "plugins/Multiverse-Core/worlds.yml");
for (String world : plotConfig.getConfigurationSection("worlds").getKeys(false)) {
sendMessage("Copying config for: " + world);
try {
@ -188,24 +174,17 @@ public class LikePlotMeConverter {
for (String world : plots.keySet()) {
String actualWorldName = getWorld(world);
String plotMeWorldName = world.toLowerCase();
Integer pathwidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
/*
* TODO: dead code
*
if (pathwidth == null) {
pathwidth = 7;
}
*/
PS.get().config.set("worlds." + world + ".road.width", pathwidth);
Integer pathWidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
PS.get().config.set("worlds." + world + ".road.width", pathWidth);
Integer pathheight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
if (pathheight == 0) {
pathheight = 64;
int pathHeight = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
if (pathHeight == 0) {
pathHeight = 64;
}
PS.get().config.set("worlds." + world + ".road.height", pathheight);
PS.get().config.set("worlds." + world + ".wall.height", pathheight);
PS.get().config.set("worlds." + world + ".plot.height", pathheight);
Integer plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize"); //
PS.get().config.set("worlds." + world + ".road.height", pathHeight);
PS.get().config.set("worlds." + world + ".wall.height", pathHeight);
PS.get().config.set("worlds." + world + ".plot.height", pathHeight);
int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); //
if (plotSize == 0) {
plotSize = 32;
}
@ -218,7 +197,7 @@ public class LikePlotMeConverter {
PS.get().config.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
String road = plotmeDgYml.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5");
PS.get().config.set("worlds." + world + ".road.block", road);
Integer height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight"); //
if (height == 0) {
height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight"); //
if (height == 0) {
@ -364,7 +343,7 @@ public class LikePlotMeConverter {
}
}
});
} catch (Exception e) {
} catch (InterruptedException | SQLException e) {
e.printStackTrace();
PS.debug("&/end/");
}

View File

@ -19,7 +19,6 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
public class PlotMeConnector_017 extends APlotMeConnector {
@ -131,8 +130,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
Plot plot = new Plot(PlotArea.createGeneric(world), id, owner);
plots.put(key, plot);
}
for (Entry<Integer, Plot> entry : plots.entrySet()) {
Plot plot = entry.getValue();
for (Plot plot : plots.values()) {
HashMap<PlotId, boolean[]> mergeMap = merges.get(plot.getArea().worldname);
if (mergeMap != null) {
if (mergeMap.containsKey(plot.getId())) {
@ -180,8 +178,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
}
HashMap<String, HashMap<PlotId, Plot>> processed = new HashMap<>();
for (Entry<Integer, Plot> entry : plots.entrySet()) {
Plot plot = entry.getValue();
for (Plot plot : plots.values()) {
HashMap<PlotId, Plot> map = processed.get(plot.getArea().worldname);
if (map == null) {
map = new HashMap<>();

View File

@ -15,16 +15,17 @@ import com.intellectualcrafters.plot.util.PlotChunk;
import com.intellectualcrafters.plot.util.SetQueue;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.block.GenChunk;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.Set;
public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper<ChunkGenerator> {
private final PlotChunk<Chunk> chunkSetter;
@ -56,11 +57,11 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
}
}
}
random.state = c.getX() << 16 | c.getZ() & 0xFFFF;
BukkitPlotGenerator.this.random.state = c.getX() << 16 | c.getZ() & 0xFFFF;
PlotArea area = PS.get().getPlotArea(world.getName(), null);
SetQueue.ChunkWrapper wrap = SetQueue.IMP.new ChunkWrapper(area.worldname, c.getX(), c.getZ());
PlotChunk<?> chunk = SetQueue.IMP.queue.getChunk(wrap);
if (plotGenerator.populateChunk(chunk, area, random)) {
if (BukkitPlotGenerator.this.plotGenerator.populateChunk(chunk, area, BukkitPlotGenerator.this.random)) {
chunk.addToQueue();
}
}
@ -212,12 +213,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
} catch (Exception e) {
e.printStackTrace();
}
if (world == null) {
return populators;
}
ArrayList<BlockPopulator> toAdd = new ArrayList<BlockPopulator>();
List<BlockPopulator> existing = world.getPopulators();
for (BlockPopulator populator : populators) {
for (BlockPopulator populator : this.populators) {
if (!existing.contains(populator)) {
toAdd.add(populator);
}

View File

@ -28,16 +28,6 @@ import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlayerBlockEventType;
import com.plotsquared.listener.PlotListener;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@ -52,6 +42,7 @@ import org.bukkit.entity.Creature;
import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Fireball;
import org.bukkit.entity.Hanging;
import org.bukkit.entity.HumanEntity;
@ -119,6 +110,17 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set;
import java.util.UUID;
import java.util.regex.Pattern;
/**
* Player Events involving plots.
*
@ -361,7 +363,7 @@ public class PlayerEvents extends PlotListener implements Listener {
}
}
Player player = event.getPlayer();
BukkitPlayer pp = (BukkitPlayer) BukkitUtil.getPlayer(player);
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = pp.getCurrentPlot();
if (plot == null) {
return;
@ -564,14 +566,13 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
public void onChat(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
PlotPlayer plr = BukkitUtil.getPlayer(player);
Location loc = plr.getLocation();
PlotArea area = loc.getPlotArea();
if (area == null || (!area.PLOT_CHAT && !plr.getAttribute("chat"))) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer());
Location location = plotPlayer.getLocation();
PlotArea area = location.getPlotArea();
if (area == null || (!area.PLOT_CHAT && !plotPlayer.getAttribute("chat"))) {
return;
}
Plot plot = area.getPlot(loc);
Plot plot = area.getPlot(location);
if (plot == null) {
return;
}
@ -606,7 +607,7 @@ public class PlayerEvents extends PlotListener implements Listener {
}
@EventHandler(priority = EventPriority.LOWEST)
public void BlockDestroy(BlockBreakEvent event) {
public void blockDestroy(BlockBreakEvent event) {
Player player = event.getPlayer();
Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
PlotArea area = loc.getPlotArea();
@ -745,7 +746,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
Entity e = event.getEntity();
if (!(e instanceof org.bukkit.entity.FallingBlock)) {
if (!(e instanceof FallingBlock)) {
event.setCancelled(true);
}
}

View File

@ -45,7 +45,7 @@ public class BukkitChatManager extends ChatManager<FancyMessage> {
@Override
public void send(PlotMessage m, PlotPlayer player) {
if (ConsolePlayer.isConsole(player)) {
if (player instanceof ConsolePlayer) {
player.sendMessage(m.$(this).toOldMessageFormat());
} else {
m.$(this).send(((BukkitPlayer) player).player);

View File

@ -4,9 +4,12 @@ import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.commands.DebugUUID;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.command.ProxiedCommandSender;
import org.bukkit.command.RemoteConsoleCommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
@ -22,41 +25,19 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
}
@Override
public boolean onCommand(final CommandSender commandSender, org.bukkit.command.Command command, final String commandLabel, String[] args) {
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) {
if (commandSender instanceof Player) {
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
}
if (commandSender.getClass() == Bukkit.getConsoleSender().getClass()) {
if (commandSender instanceof ConsoleCommandSender || commandSender instanceof ProxiedCommandSender
|| commandSender instanceof RemoteConsoleCommandSender) {
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
}
@SuppressWarnings("deprecation")
ConsolePlayer sender = new ConsolePlayer() {
@Override
public void sendMessage(String message) {
commandSender.sendMessage(commandLabel);
}
@Override
public boolean hasPermission(String permission) {
return commandSender.hasPermission(commandLabel);
}
@Override
public String getName() {
if (commandSender.getName().equals("CONSOLE")) {
return "*";
}
return commandSender.getName();
}
};
sender.teleport(ConsolePlayer.getConsole().getLocationFull());
boolean result = MainCommand.onCommand(sender, args);
ConsolePlayer.getConsole().teleport(sender.getLocationFull());
return result;
return false;
}
@Override
public List<String> onTabComplete(CommandSender commandSender, org.bukkit.command.Command command, String s, String[] args) {
public List<String> onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
if (!(commandSender instanceof Player)) {
return null;
}

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;

View File

@ -76,10 +76,6 @@ import java.util.Collection;
import java.util.List;
import java.util.UUID;
/**
* Created by robin on 01/11/2014
*/
@Plugin(id = "com.plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.", url = "https://github.com/IntellectualSites/PlotSquared", version = "3.3.3")
public class SpongeMain implements IPlotMain {
public static SpongeMain THIS;
@ -169,7 +165,7 @@ public class SpongeMain implements IPlotMain {
@Override
public int[] getPluginVersion() {
PluginContainer plugin = this.game.getPluginManager().fromInstance(this).get();
String version = plugin.getVersion().get();
String version = plugin.getVersion().orElse("");
String[] split = version.split("\\.");
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
}

View File

@ -22,7 +22,7 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
}
@Override
public void color(final PlotMessage m, final String color) {
public void color(PlotMessage m, String color) {
TextColor tc = null;
TextStyle ts = null;
switch (color.charAt(1)) {
@ -114,10 +114,10 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
}
@Override
public void tooltip(final PlotMessage m, final PlotMessage... tooltips) {
final Text.Builder builder = Text.builder();
public void tooltip(PlotMessage m, PlotMessage... tooltips) {
Text.Builder builder = Text.builder();
boolean lb = false;
for (final PlotMessage tooltip : tooltips) {
for (PlotMessage tooltip : tooltips) {
if (lb) {
builder.append(Text.of("\n"));
}
@ -128,18 +128,18 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
}
@Override
public void command(final PlotMessage m, final String command) {
public void command(PlotMessage m, String command) {
apply(m, getChild(m).onClick(TextActions.runCommand(command)));
}
@Override
public void text(final PlotMessage m, final String text) {
public void text(PlotMessage m, String text) {
m.$(this).append(SpongeUtil.getText(text));
}
@Override
public void send(final PlotMessage m, final PlotPlayer player) {
if (ConsolePlayer.isConsole(player)) {
public void send(PlotMessage m, PlotPlayer player) {
if (player instanceof ConsolePlayer) {
player.sendMessage(m.$(this).build().toPlain());
} else {
((SpongePlayer) player).player.sendMessage(m.$(this).build());
@ -147,7 +147,7 @@ public class SpongeChatManager extends ChatManager<Text.Builder> {
}
@Override
public void suggest(final PlotMessage m, final String command) {
public void suggest(PlotMessage m, String command) {
apply(m, getChild(m).onClick(TextActions.suggestCommand(command)));
}
}

View File

@ -23,6 +23,7 @@ subprojects {
compile(group: 'com.sk89q', name: 'worldedit', version:'6.0.0-SNAPSHOT') {
exclude(module: 'bukkit-classloader-check')
}
compile 'com.google.guava:guava:10.0'
}
clean{
delete file("../target")