From cf517d5be0db40a8b2b858423c93b702a8c75fa7 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Sun, 20 Dec 2015 06:30:06 +1100 Subject: [PATCH] Cleanup --- pom.xml | 5 - .../plot/api/PlotAPI.java | 2 +- .../plot/commands/Cluster.java | 4 +- .../plot/config/Configuration.java | 23 +- .../plot/flag/FlagValue.java | 37 +- .../plot/object/PlotWorld.java | 8 - .../plot/util/MainUtil.java | 587 ++++++++++++------ .../plot/util/Permissions.java | 40 ++ .../com/plotsquared/bukkit/BukkitMain.java | 1 - .../plotme/ClassicPlotMeConnector.java | 18 +- .../database/plotme/PlotMeConnector_017.java | 11 +- .../com/plotsquared/sponge/SpongeMain.java | 49 +- .../sponge/events/ClusterFlagRemoveEvent.java | 8 +- .../sponge/events/PlayerClaimPlotEvent.java | 6 + .../sponge/events/PlayerEnterPlotEvent.java | 6 + .../sponge/events/PlayerEvent.java | 6 + .../sponge/events/PlotClearEvent.java | 8 +- .../sponge/events/PlotDeleteEvent.java | 6 + .../plotsquared/sponge/events/PlotEvent.java | 6 + .../sponge/events/PlotMergeEvent.java | 8 +- .../sponge/events/PlotUnlinkEvent.java | 8 +- .../sponge/generator/AugmentedPopulator.java | 6 +- .../sponge/generator/SpongeBasicGen.java | 2 - .../sponge/generator/SpongePlotGenerator.java | 61 +- .../sponge/generator/WorldModify.java | 7 +- .../sponge/util/SpongeBlockManager.java | 2 + .../sponge/util/SpongeCommand.java | 10 +- .../sponge/util/SpongeEconHandler.java | 33 +- .../sponge/util/SpongeEventUtil.java | 2 +- .../sponge/util/SpongeMetrics.java | 2 +- .../sponge/util/SpongeTaskManager.java | 2 +- .../uuid/SpongeLowerOfflineUUIDWrapper.java | 2 +- .../sponge/uuid/SpongeUUIDHandler.java | 2 +- 33 files changed, 680 insertions(+), 298 deletions(-) diff --git a/pom.xml b/pom.xml index 50ba19dbd..7755dd091 100644 --- a/pom.xml +++ b/pom.xml @@ -147,11 +147,6 @@ javax.websocket-api 1.1 - org.spongepowered spongeapi diff --git a/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index 6fdbe9ae3..88029db6c 100644 --- a/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -381,7 +381,7 @@ public class PlotAPI { * @see MainUtil#sendConsoleMessage(String) */ public void sendConsoleMessage(final String msg) { - MainUtil.sendConsoleMessage(msg); + PS.log(msg);; } /** diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java b/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java index 25f643cb8..641a4736f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Cluster.java @@ -112,8 +112,8 @@ public class Cluster extends SubCommand { return false; } // check pos1 / pos2 - PlotId pos1 = MainUtil.parseId(args[2]); - PlotId pos2 = MainUtil.parseId(args[3]); + PlotId pos1 = PlotId.fromString(args[2]); + PlotId pos2 = PlotId.fromString(args[3]); if ((pos1 == null) || (pos2 == null)) { MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID); return false; diff --git a/src/main/java/com/intellectualcrafters/plot/config/Configuration.java b/src/main/java/com/intellectualcrafters/plot/config/Configuration.java index 473375311..59446b92c 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/Configuration.java +++ b/src/main/java/com/intellectualcrafters/plot/config/Configuration.java @@ -126,27 +126,22 @@ public class Configuration { @Override public boolean validateValue(final String string) { try { - if (string.contains(":")) { - final String[] split = string.split(":"); - Short.parseShort(split[0]); - Short.parseShort(split[1]); - } else { - Short.parseShort(string); + final StringComparison.ComparisonResult value = BlockManager.manager.getClosestBlock(string); + if ((value == null) || (value.match > 1)) { + return false; } return true; - } catch (final Exception e) { - return false; - } + } catch (final Exception e) {} + return false; } @Override public PlotBlock parseString(final String string) { - if (string.contains(":")) { - final String[] split = string.split(":"); - return new PlotBlock(Short.parseShort(split[0]), Byte.parseByte(split[1])); - } else { - return new PlotBlock(Short.parseShort(string), (byte) 0); + final StringComparison.ComparisonResult value = BlockManager.manager.getClosestBlock(string); + if ((value == null) || (value.match > 1)) { + return null; } + return value.best; } }; public static final SettingValue BLOCKLIST = new SettingValue("BLOCKLIST") { diff --git a/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java b/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java index 540266445..04c13e2cc 100644 --- a/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java +++ b/src/main/java/com/intellectualcrafters/plot/flag/FlagValue.java @@ -6,6 +6,8 @@ import java.util.HashSet; import java.util.List; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.util.BlockManager; +import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.StringMan; /** @@ -276,7 +278,11 @@ public abstract class FlagValue { final short id = Short.parseShort(split[0]); return new PlotBlock(id, data); } catch (final Exception e) { - return null; + final StringComparison.ComparisonResult value = BlockManager.manager.getClosestBlock(t); + if ((value == null) || (value.match > 1)) { + return null; + } + return value.best; } } @@ -309,19 +315,28 @@ public abstract class FlagValue { public HashSet parse(final String t) { final HashSet list = new HashSet(); for (final String item : t.split(",")) { - final String[] split = item.split(":"); - byte data; - if (split.length == 2) { - if ("*".equals(split[1])) { - data = -1; + PlotBlock block; + try { + final String[] split = item.split(":"); + byte data; + if (split.length == 2) { + if ("*".equals(split[1])) { + data = -1; + } else { + data = Byte.parseByte(split[1]); + } } else { - data = Byte.parseByte(split[1]); + data = -1; } - } else { - data = -1; + final short id = Short.parseShort(split[0]); + block = new PlotBlock(id, data); + } catch (Exception e) { + final StringComparison.ComparisonResult value = BlockManager.manager.getClosestBlock(t); + if ((value == null) || (value.match > 1)) { + continue; + } + block = value.best; } - final short id = Short.parseShort(split[0]); - final PlotBlock block = new PlotBlock(id, data); list.add(block); } return list; diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java b/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java index 4f57f4866..b74b335c6 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotWorld.java @@ -53,8 +53,6 @@ public abstract class PlotWorld { public final static double PLOT_PRICE_DEFAULT = 100; public final static double MERGE_PRICE_DEFAULT = 100; public final static double SELL_PRICE_DEFAULT = 75; - public final static boolean PVP_DEFAULT = false; - public final static boolean PVE_DEFAULT = false; public final static boolean SPAWN_EGGS_DEFAULT = false; public final static boolean SPAWN_CUSTOM_DEFAULT = true; public final static boolean SPAWN_BREEDING_DEFAULT = false; @@ -80,8 +78,6 @@ public abstract class PlotWorld { public double PLOT_PRICE; public double MERGE_PRICE; public double SELL_PRICE; - public boolean PVP; - public boolean PVE; public boolean SPAWN_EGGS; public boolean SPAWN_CUSTOM; public boolean SPAWN_BREEDING; @@ -219,8 +215,6 @@ public abstract class PlotWorld { PS.debug("&cInvalid default flags for " + worldname + ": " + StringMan.join(flags, ",")); DEFAULT_FLAGS = new HashMap<>(); } - PVP = config.getBoolean("event.pvp"); - PVE = config.getBoolean("event.pve"); SPAWN_EGGS = config.getBoolean("event.spawn.egg"); SPAWN_CUSTOM = config.getBoolean("event.spawn.custom"); SPAWN_BREEDING = config.getBoolean("event.spawn.breeding"); @@ -250,8 +244,6 @@ public abstract class PlotWorld { options.put("economy.prices.sell", PlotWorld.SELL_PRICE_DEFAULT); options.put("chat.enabled", PlotWorld.PLOT_CHAT_DEFAULT); options.put("flags.default", null); - options.put("event.pvp", PlotWorld.PVP_DEFAULT); - options.put("event.pve", PlotWorld.PVE_DEFAULT); options.put("event.spawn.egg", PlotWorld.SPAWN_EGGS_DEFAULT); options.put("event.spawn.custom", PlotWorld.SPAWN_CUSTOM_DEFAULT); options.put("event.spawn.breeding", PlotWorld.SPAWN_BREEDING_DEFAULT); diff --git a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 48815679a..22b80b581 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -66,14 +66,42 @@ import com.plotsquared.listener.PlotListener; * */ public class MainUtil { + /** + * The runners are a list of plots that have currect asynchronous actions taking place.
+ * - At some point this could be replaced by using the plot metadata + */ public final static HashMap runners = new HashMap<>(); + + /** + * If the NMS code for sending chunk updates is functional
+ * - E.g. If using an older version of Bukkit, or before the plugin is updated to 1.5
+ * - Slower fallback code will be used if not.
+ */ public static boolean canSendChunk = false; - public static boolean canSetFast = true; - public static ArrayList runners_p = new ArrayList<>(); + + /** + * Cache for last auto claimed plot.
+ * - Used for efficiently calculating the next claimable plot
+ */ public static HashMap lastPlot = new HashMap<>(); + + /** + * Cache of the furthest claimed plot
+ * - Used for efficiently calculating the plot border distance + */ public static HashMap worldBorder = new HashMap<>(); + + /** + * Pseudorandom object
+ * - Not truly random, but good enough for a game
+ * - A lot more efficient than Random
+ */ public static PseudoRandom random = new PseudoRandom(); + /** + * Cache of mapping x,y,z coordinates to the chunk array
+ * - Used for efficent world generation
+ */ public static short[][] x_loc; public static short[][] y_loc; public static short[][] z_loc; @@ -137,14 +165,6 @@ public class MainUtil { regions_cache.add(new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getY(), pos2.getY(), pos1.getZ(), pos2.getZ())); return regions_cache; } - -// Create a list of ALL edges from your rectangles. One rectangle has 4 edges. -// Let the Edge be a class with properly defined compareTo() and equals(). -// Sort the edges list (uses comapreTo). -// Iterate through the list. If the same edge is present in the list TWICE, remove them both from the list. -// The remaining edges are the edges of your polygon. - - HashSet plots = getConnectedPlots(origin); regions_cache = new HashSet<>(); HashSet visited = new HashSet<>(); @@ -247,6 +267,12 @@ public class MainUtil { return regions_cache; } + /** + * Hashcode of a boolean array.
+ * - Used for traversing mega plots quickly. + * @param array + * @return hashcode + */ public static int hash(boolean[] array) { if (array.length == 4) { if (!array[0] && !array[1] && !array[2] && !array[3]) { @@ -261,6 +287,13 @@ public class MainUtil { return n; } + /** + * Check if a location is in a plot area (roads / plots).
+ * - A world that is a plot world may not be a plot area if clusters are used
+ * - A non plot world is not a plot area
+ * @param location + * @return + */ public static boolean isPlotArea(final Location location) { final PlotWorld plotworld = PS.get().getPlotWorld(location.getWorld()); if (plotworld == null) { @@ -272,6 +305,11 @@ public class MainUtil { return true; } + /** + * Get the name from a UUID
+ * @param owner + * @return The player's name, None, Everyone or Unknown + */ public static String getName(final UUID owner) { if (owner == null) { return C.NONE.s(); @@ -285,6 +323,12 @@ public class MainUtil { return name; } + /** + * Efficiently get a list of PlotPlayers inside a plot
+ * - PlotSquared caches player locations + * @param plot + * @return + */ public static List getPlayersInPlot(final Plot plot) { final ArrayList players = new ArrayList<>(); for (Entry entry : UUIDHandler.getPlayers().entrySet()) { @@ -296,6 +340,11 @@ public class MainUtil { return players; } + /** + * Retrigger plot entry functions for the players in a plot.
+ * - Used when plot settings are changed
+ * @param plot + */ public static void reEnterPlot(final Plot plot) { TaskManager.runTaskLater(new Runnable() { @Override @@ -308,6 +357,12 @@ public class MainUtil { }, 1); } + /** + * Break up a series of tasks so that they can run without lagging the server + * @param objects + * @param task + * @param whenDone + */ public static void objectTask(Collection objects, final RunnableVal task, final Runnable whenDone) { final Iterator iter = objects.iterator(); TaskManager.runTask(new Runnable() { @@ -328,21 +383,12 @@ public class MainUtil { }); } - public static void plotTask(Plot plot, RunnableVal run) { - if (!plot.isMerged()) { - run.value = plot; - run.run(); - return; - } - for (Plot current : getConnectedPlots(plot)) { - run.value = current; - run.run(); - if (run.value == null) { - break; - } - } - } - + /** + * Fuzzy plot search with spaces separating terms
+ * - Terms: id, alias, world, owner, trusted, member + * @param search + * @return + */ public static List getPlotsBySearch(final String search) { final String[] split = search.split(" "); final int size = split.length * 2; @@ -420,6 +466,13 @@ public class MainUtil { return plots; } + /** + * Get the plot from a string
+ * @param player Provides a context for what world to search in. Prefixing the term with 'world_name;' will override this context. + * @param arg The search term + * @param message If a message should be sent to the player if a plot cannot be found + * @return The plot if only 1 result is found, or null + */ public static Plot getPlotFromString(final PlotPlayer player, final String arg, final boolean message) { if (arg == null) { if (player == null) { @@ -565,6 +618,12 @@ public class MainUtil { return true; } + /** + * Check if a location is a plot area.
+ * - Directly checks the cluster manager
+ * @param location + * @return + */ public static boolean isPlotAreaAbs(final Location location) { if (!Settings.ENABLE_CLUSTERS) { return true; @@ -579,6 +638,11 @@ public class MainUtil { return true; } + /** + * Check if a location corresponds to a plot road i.e. A plot area but not inside a plot + * @param location + * @return + */ public static boolean isPlotRoad(final Location location) { final PlotWorld plotworld = PS.get().getPlotWorld(location.getWorld()); if (plotworld.TYPE == 2) { @@ -591,6 +655,12 @@ public class MainUtil { return manager.getPlotId(plotworld, location.getX(), location.getY(), location.getZ()) == null; } + /** + * Check if a plot is in a plot area.
+ * - Useful as plot objects can be created with any location which may not be valid. + * @param location + * @return + */ public static boolean isPlotArea(final Plot plot) { if (!Settings.ENABLE_CLUSTERS) { return true; @@ -602,18 +672,6 @@ public class MainUtil { return true; } - public static boolean enteredPlot(final Location l1, final Location l2) { - final PlotId p1 = MainUtil.getPlotId(l1); - final PlotId p2 = MainUtil.getPlotId(l2); - return (p2 != null) && ((p1 == null) || !p1.equals(p2)); - } - - public static boolean leftPlot(final Location l1, final Location l2) { - final PlotId p1 = MainUtil.getPlotId(l1); - final PlotId p2 = MainUtil.getPlotId(l2); - return (p1 != null) && ((p2 == null) || !p1.equals(p2)); - } - /** * Get the number of plots for a player * @@ -648,6 +706,12 @@ public class MainUtil { return count; } + /** + * Get the base plot for a plot + * @see Plot#getBasePlot(boolean) + * @param plot + * @return + */ public static Plot getPlot(Plot plot) { if (plot == null) { return null; @@ -655,10 +719,21 @@ public class MainUtil { return plot.getBasePlot(false); } + /** + * Get the plot at a location
+ * @param loc + * @return The plot at a location. The base plot will be returned if a mega plot. + */ public static Plot getPlot(Location loc) { return getPlot(getPlotAbs(loc)); } + /** + * Get the plot given the world and plot id + * @param world + * @param id + * @return The plot. The base plot will be returned if a mega plot. + */ public static Plot getPlot(String world, PlotId id) { if (id == null) { return null; @@ -666,6 +741,12 @@ public class MainUtil { return getPlot(getPlotAbs(world, id)); } + /** + * Get the default home location for a plot
+ * - Ignores any home location set for that specific plot + * @param plot + * @return + */ public static Location getDefaultHome(Plot plot) { plot = plot.getBasePlot(false); final PlotWorld plotworld = PS.get().getPlotWorld(plot.world); @@ -695,10 +776,16 @@ public class MainUtil { return new Location(plot.world, x, y + 1, z); } + /** + * Teleport a player to a plot and send them the teleport message. + * @param player + * @param from + * @param plot + * @return If the teleportation is allowed. + */ public static boolean teleportPlayer(final PlotPlayer player, final Location from, Plot plot) { plot = plot.getBasePlot(false); final boolean result = EventUtil.manager.callTeleport(player, from, plot); - if (result) { final Location location; if (PS.get().getPlotWorld(plot.world).HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) { @@ -734,6 +821,11 @@ public class MainUtil { return result; } + /** + * Get the plot border distance for a world
+ * @param worldname + * @return The border distance or Integer.MAX_VALUE if no border is set + */ public static int getBorder(final String worldname) { if (worldBorder.containsKey(worldname)) { final int border = worldBorder.get(worldname) + 16; @@ -746,6 +838,10 @@ public class MainUtil { return Integer.MAX_VALUE; } + /** + * Setup the plot border for a world (usually done when the world is created) + * @param world + */ public static void setupBorder(final String world) { final PlotWorld plotworld = PS.get().getPlotWorld(world); if (!plotworld.WORLD_BORDER) { @@ -759,10 +855,19 @@ public class MainUtil { } } + /** + * Resend the chunk at a location + * @param world + * @param loc + */ public static void update(final String world, final ChunkLoc loc) { BlockUpdateUtil.setBlockManager.update(world, Arrays.asList(loc)); } + /** + * Resend the chunks in a plot + * @param plot + */ public static void update(final Plot plot) { TaskManager.runTask(new Runnable() { @Override @@ -780,17 +885,6 @@ public class MainUtil { }); } - public static void createWorld(final String world, final String generator) {} - - public static PlotId parseId(final String arg) { - try { - final String[] split = arg.split(";"); - return new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - } catch (final Exception e) { - return null; - } - } - /** * direction 0 = north, 1 = south, etc: * @@ -952,6 +1046,12 @@ public class MainUtil { return true; } + /** + * Remove the south east road section of a plot
+ * - Used when a plot is merged
+ * @param plotworld + * @param plot + */ public static void removeRoadSouthEast(final PlotWorld plotworld, final Plot plot) { if ((plotworld.TYPE != 0) && (plotworld.TERRAIN > 1)) { if (plotworld.TERRAIN == 3) { @@ -969,6 +1069,12 @@ public class MainUtil { } } + /** + * Remove the east road section of a plot
+ * - Used when a plot is merged
+ * @param plotworld + * @param plot + */ public static void removeRoadEast(final PlotWorld plotworld, final Plot plot) { if ((plotworld.TYPE != 0) && (plotworld.TERRAIN > 1)) { if (plotworld.TERRAIN == 3) { @@ -986,6 +1092,12 @@ public class MainUtil { } } + /** + * Remove the south road section of a plot
+ * - Used when a plot is merged
+ * @param plotworld + * @param plot + */ public static void removeRoadSouth(final PlotWorld plotworld, final Plot plot) { if ((plotworld.TYPE != 0) && (plotworld.TERRAIN > 1)) { if (plotworld.TERRAIN == 3) { @@ -1063,6 +1175,12 @@ public class MainUtil { } } + /** + * Merge the plot settings
+ * - Used when a plot is merged
+ * @param a + * @param b + */ public static void mergeData(Plot a, Plot b) { HashMap flags1 = a.getFlags(); HashMap flags2 = b.getFlags(); @@ -1105,6 +1223,10 @@ public class MainUtil { } } + /** + * Remove the sign for a plot + * @param p + */ public static void removeSign(final Plot p) { if (!PS.get().isMainThread(Thread.currentThread())) { TaskManager.runTask(new Runnable() { @@ -1125,6 +1247,10 @@ public class MainUtil { BlockManager.setBlocks(world, new int[] { loc.getX() }, new int[] { loc.getY() }, new int[] { loc.getZ() }, new int[] { 0 }, new byte[] { 0 }); } + /** + * Set the sign for a plot + * @param p + */ public static void setSign(final Plot p) { if (p.owner == null) { setSign(null, p); @@ -1133,6 +1259,11 @@ public class MainUtil { setSign(UUIDHandler.getName(p.owner), p); } + /** + * Set the sign for a plot to a specific name + * @param name + * @param p + */ public static void setSign(final String name, final Plot p) { if (!PS.get().isMainThread(Thread.currentThread())) { TaskManager.runTask(new Runnable() { @@ -1158,6 +1289,13 @@ public class MainUtil { } } + /** + * Get the corner locations for a plot
+ * @see Plot#getCorners() + * @param world + * @param region + * @return + */ public static Location[] getCorners(String world, RegionWrapper region) { Location pos1 = new Location(world, region.minX, region.minY, region.minZ); Location pos2 = new Location(world, region.maxX, region.maxY, region.maxZ); @@ -1178,6 +1316,13 @@ public class MainUtil { return getCorners(plot.world, getRegions(plot)); } + /** + * Get the corner locations for a list of regions
+ * @see Plot#getCorners() + * @param world + * @param region + * @return + */ public static Location[] getCorners(String world, Collection regions) { Location min = null; Location max = null; @@ -1206,6 +1351,12 @@ public class MainUtil { return new Location[] { min, max }; } + /** + * Get the corner plot ids for a plot
+ * @see Plot#getCornerIds() + * @param plot + * @return + */ public static PlotId[] getCornerIds(Plot plot) { if (!plot.isMerged()) { return new PlotId[] { plot.id, plot.id }; @@ -1229,6 +1380,20 @@ public class MainUtil { return new PlotId[] { min, max }; } + /** + * Auto merge a plot in a specific direction
+ * @param plot The plot to merge + * @param dir The direction to merge
+ * -1 = All directions
+ * 0 = north
+ * 1 = east
+ * 2 = south
+ * 3 = west
+ * @param max The max number of merges to do + * @param uuid The UUID it is allowed to merge with + * @param removeRoads Wether to remove roads + * @return true if a merge takes place + */ public static boolean autoMerge(final Plot plot, int dir, int max, final UUID uuid, final boolean removeRoads) { if (plot == null) { return false; @@ -1294,9 +1459,13 @@ public class MainUtil { } return toReturn; } - + + /** + * Expand the world border to include the provided plot (if applicable) + * @param plot + */ public static void updateWorldBorder(final Plot plot) { - if (!worldBorder.containsKey(plot.world)) { + if (!plot.hasOwner() || !worldBorder.containsKey(plot.world)) { return; } final String world = plot.world; @@ -1360,22 +1529,6 @@ public class MainUtil { return p; } - public static String createId(final int x, final int z) { - return x + ";" + z; - } - - public static int square(final int x) { - return x * x; - } - - public static short[] getBlock(final String block) { - if (block.contains(":")) { - final String[] split = block.split(":"); - return new short[] { Short.parseShort(split[0]), Short.parseShort(split[1]) }; - } - return new short[] { Short.parseShort(block), 0 }; - } - /** * Clear a plot and associated sections: [sign, entities, border] * @@ -1391,6 +1544,18 @@ public class MainUtil { return true; } + /** + * Count the entities in a plot + * @see ChunkManager#countEntities(Plot) + * 0 = Entity + * 1 = Animal + * 2 = Monster + * 3 = Mob + * 4 = Boat + * 5 = Misc + * @param plot + * @return + */ public static int[] countEntities(Plot plot) { int[] count = new int[6]; for (Plot current : getConnectedPlots(plot)) { @@ -1405,6 +1570,13 @@ public class MainUtil { return count; } + /** + * Clear and unclaim a plot + * @see Plot#clear(Runnable) + * @param plot + * @param whenDone + * @return + */ public static boolean delete(final Plot plot, final Runnable whenDone) { // Plot is not claimed if (!plot.hasOwner()) { @@ -1423,6 +1595,14 @@ public class MainUtil { return true; } + /** + * Clear a plot (does not remove from database) + * @param plot + * @param isDelete Different procedures take place if the clearing is a deletion:
+ * - The sign, border and walls are also cleared on deletion
+ * @param whenDone A runnable that will execute when the clearing is done, or null + * @return + */ public static boolean clear(final Plot plot, final boolean isDelete, final Runnable whenDone) { if (!EventUtil.manager.callClear(plot.world, plot.id)) { return false; @@ -1478,6 +1658,13 @@ public class MainUtil { return true; } + /** + * Set a cuboid in the world to a set of blocks. + * @param world + * @param pos1 + * @param pos2 + * @param blocks If multiple blocks are provided, the result will be a random mix + */ public static void setCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { if (blocks.length == 1) { setSimpleCuboid(world, pos1, pos2, blocks[0]); @@ -1507,6 +1694,13 @@ public class MainUtil { BlockManager.setBlocks(world, xl, yl, zl, ids, data); } + /** + * Set a cubioid asynchronously to a set of blocks + * @param world + * @param pos1 + * @param pos2 + * @param blocks + */ public static void setCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock[] blocks) { if (blocks.length == 1) { setSimpleCuboidAsync(world, pos1, pos2, blocks[0]); @@ -1523,6 +1717,13 @@ public class MainUtil { } } + /** + * Set a cuboid to a block + * @param world + * @param pos1 + * @param pos2 + * @param newblock + */ public static void setSimpleCuboid(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { final int length = (pos2.getX() - pos1.getX()) * (pos2.getY() - pos1.getY()) * (pos2.getZ() - pos1.getZ()); final int[] xl = new int[length]; @@ -1546,6 +1747,13 @@ public class MainUtil { BlockManager.setBlocks(world, xl, yl, zl, ids, data); } + /** + * Set a cuboic asynchronously to a block + * @param world + * @param pos1 + * @param pos2 + * @param newblock + */ public static void setSimpleCuboidAsync(final String world, final Location pos1, final Location pos2, final PlotBlock newblock) { for (int y = pos1.getY(); y <= Math.min(255, pos2.getY()); y++) { for (int x = pos1.getX(); x <= pos2.getX(); x++) { @@ -1556,6 +1764,12 @@ public class MainUtil { } } + /** + * Set the biome for a plot asynchronously + * @param plot + * @param biome The biome e.g. "forest" + * @param whenDone The task to run when finished, or null + */ public static void setBiome(final Plot plot, final String biome, final Runnable whenDone) { final ArrayDeque regions = new ArrayDeque<>(getRegions(plot)); Runnable run = new Runnable() { @@ -1584,6 +1798,15 @@ public class MainUtil { run.run(); } + /** + * Synchronously set the biome in a selection + * @param world + * @param p1x + * @param p1z + * @param p2x + * @param p2z + * @param biome + */ public static void setBiome(final String world, final int p1x, final int p1z, final int p2x, final int p2z, final String biome) { final int length = ((p2x - p1x) + 1) * ((p2z - p1z) + 1); final int[] xl = new int[length]; @@ -1599,6 +1822,13 @@ public class MainUtil { BlockManager.setBiomes(world, xl, zl, biome); } + /** + * Get the heighest block at a location + * @param world + * @param x + * @param z + * @return + */ public static int getHeighestBlock(final String world, final int x, final int z) { final int result = BlockManager.manager.getHeighestBlock(world, x, z); if (result == 0) { @@ -1699,6 +1929,15 @@ public class MainUtil { return top; } + /** + * Gets the bottom location for a plot.
+ * - Does not respect mega plots
+ * - Merged plots, only the road will be considered part of the plot
+ * + * @param plot + * + * @return Location bottom of mega plot + */ public static Location getPlotBottomLoc_(Plot plot) { Location bot = getPlotBottomLocAbs(plot.world, plot.id); if (!plot.isMerged()) { @@ -1716,6 +1955,14 @@ public class MainUtil { return bot; } + /** + * Check if a selection of plots can be claimed + * @param player + * @param world + * @param pos1 + * @param pos2 + * @return + */ public static boolean canClaim(final PlotPlayer player, final String world, final PlotId pos1, final PlotId pos2) { for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -1809,6 +2056,13 @@ public class MainUtil { } } + /** + * Check if the plots in a selection are unowned + * @param world + * @param pos1 + * @param pos2 + * @return + */ public static boolean isUnowned(final String world, final PlotId pos1, final PlotId pos2) { for (int x = pos1.x; x <= pos2.x; x++) { for (int y = pos1.y; y <= pos2.y; y++) { @@ -1823,6 +2077,13 @@ public class MainUtil { return true; } + /** + * Swap the settings for two plots + * @param p1 + * @param p2 + * @param whenDone + * @return + */ public static boolean swapData(Plot p1, Plot p2, final Runnable whenDone) { if ((p1 == null) || (p1.owner == null)) { if ((p2 != null) && (p2.owner != null)) { @@ -1857,6 +2118,13 @@ public class MainUtil { return true; } + /** + * Move the settings for a plot + * @param pos1 + * @param pos2 + * @param whenDone + * @return + */ public static boolean moveData(final Plot pos1, final Plot pos2, final Runnable whenDone) { if (pos1.owner == null) { PS.debug(pos2 + " is unowned (single)"); @@ -1879,6 +2147,14 @@ public class MainUtil { return true; } + /** + * Move a plot physically, as well as the corresponding settings. + * @param origin + * @param destination + * @param whenDone + * @param allowSwap + * @return + */ public static boolean move(final Plot origin, final Plot destination, final Runnable whenDone, boolean allowSwap) { PlotId offset = new PlotId(destination.id.x - origin.id.x, destination.id.y - origin.id.y); Location db = destination.getBottomAbs(); @@ -1958,48 +2234,14 @@ public class MainUtil { } return true; } -// final com.intellectualcrafters.plot.object.Location bot1 = MainUtil.getPlotBottomLoc(plot1.world, plot1.id); -// final com.intellectualcrafters.plot.object.Location bot2 = MainUtil.getPlotBottomLoc(plot2.world, plot2.id); -// final Location top = MainUtil.getPlotTopLoc(plot1.world, plot1.id); -// if (plot1.owner == null) { -// PS.debug(plot2 + " is unowned (single)"); -// TaskManager.runTask(whenDone); -// return false; -// } -// final Plot pos1 = getBottomPlot(plot1); -// final Plot pos2 = getTopPlot(plot1); -// final PlotId size = MainUtil.getSize(plot1); -// if (!MainUtil.isUnowned(plot2.world, plot2.id, new PlotId((plot2.id.x + size.x) - 1, (plot2.id.y + size.y) - 1))) { -// PS.debug(plot2 + " is unowned (multi)"); -// TaskManager.runTask(whenDone); -// return false; -// } -// final int offset_x = plot2.id.x - pos1.id.x; -// final int offset_y = plot2.id.y - pos1.id.y; -// final ArrayList selection = getPlotSelectionIds(pos1.id, pos2.id); -// for (final PlotId id : selection) { -// final String worldOriginal = plot1.world; -// final PlotId idOriginal = new PlotId(id.x, id.y); -// final Plot plot = PS.get().getPlot(plot1.world, id); -// final Map> raw = PS.get().getAllPlotsRaw(); -// raw.get(plot1.world).remove(id); -// plot.id.x += offset_x; -// plot.id.y += offset_y; -// plot.id.recalculateHash(); -// raw.get(plot2.world).put(plot.id, plot); -// DBFunc.movePlot(getPlot(worldOriginal, idOriginal), getPlot(plot2.world, new PlotId(id.x + offset_x, id.y + offset_y))); -// } -// ChunkManager.manager.copyRegion(bot1, top, bot2, new Runnable() { -// @Override -// public void run() { -// final Location bot = bot1.clone().add(1, 0, 1); -// ChunkManager.manager.regenerateRegion(bot, top, null); -// TaskManager.runTaskLater(whenDone, 1); -// } -// }); -// return true; -// } + /** + * Copy a plot to a location, both physically and the settings + * @param origin + * @param destination + * @param whenDone + * @return + */ public static boolean copy(final Plot origin, final Plot destination, final Runnable whenDone) { PlotId offset = new PlotId(destination.id.x - origin.id.x, destination.id.y - origin.id.y); Location db = destination.getBottomAbs(); @@ -2085,14 +2327,22 @@ public class MainUtil { return sendMessage(plr, msg, true); } - public static void sendConsoleMessage(final String msg) { - sendMessage(null, msg); - } - + /** + * Send a message to console + * @param caption + * @param args + */ public static void sendConsoleMessage(final C caption, final String... args) { sendMessage(null, caption, args); } + /** + * Send a message to a player + * @param plr Can be null to represent console, or use ConsolePlayer.getConsole() + * @param msg + * @param prefix If the message should be prefixed with the configured prefix + * @return + */ public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) { if ((msg.length() > 0) && !msg.equals("")) { if (plr == null) { @@ -2104,73 +2354,6 @@ public class MainUtil { return true; } - public static String[] wordWrap(final String rawString, final int lineLength) { - if (rawString == null) { - return new String[] { "" }; - } - if ((rawString.length() <= lineLength) && (!rawString.contains("\n"))) { - return new String[] { rawString }; - } - final char[] rawChars = (rawString + ' ').toCharArray(); - StringBuilder word = new StringBuilder(); - StringBuilder line = new StringBuilder(); - final ArrayList lines = new ArrayList(); - int lineColorChars = 0; - for (int i = 0; i < rawChars.length; i++) { - final char c = rawChars[i]; - if (c == '\u00A7') { - word.append('\u00A7' + (rawChars[(i + 1)])); - lineColorChars += 2; - i++; - } else if ((c == ' ') || (c == '\n')) { - if ((line.length() == 0) && (word.length() > lineLength)) { - for (final String partialWord : word.toString().split("(?<=\\G.{" + lineLength + "})")) { - lines.add(partialWord); - } - } else if (((line.length() + word.length()) - lineColorChars) == lineLength) { - line.append(word); - lines.add(line.toString()); - line = new StringBuilder(); - lineColorChars = 0; - } else if (((line.length() + 1 + word.length()) - lineColorChars) > lineLength) { - for (final String partialWord : word.toString().split("(?<=\\G.{" + lineLength + "})")) { - lines.add(line.toString()); - line = new StringBuilder(partialWord); - } - lineColorChars = 0; - } else { - if (line.length() > 0) { - line.append(' '); - } - line.append(word); - } - word = new StringBuilder(); - if (c == '\n') { - lines.add(line.toString()); - line = new StringBuilder(); - } - } else { - word.append(c); - } - } - if (line.length() > 0) { - lines.add(line.toString()); - } - if ((lines.get(0).length() == 0) || (lines.get(0).charAt(0) != '\u00A7')) { - lines.set(0, "\u00A7f" + lines.get(0)); - } - for (int i = 1; i < lines.size(); i++) { - final String pLine = lines.get(i - 1); - final String subLine = lines.get(i); - - final char color = pLine.charAt(pLine.lastIndexOf('\u00A7') + 1); - if ((subLine.length() == 0) || (subLine.charAt(0) != '\u00A7')) { - lines.set(i, '\u00A7' + (color) + subLine); - } - } - return lines.toArray(new String[lines.size()]); - } - /** * Send a message to the player * @@ -2406,6 +2589,11 @@ public class MainUtil { return Permissions.hasPermissionRange(p, "plots.plot", Settings.MAX_PLOTS); } + /** + * Get the plot at a location + * @param loc + * @return The plot + */ public static Plot getPlotAbs(final Location loc) { final PlotId id = getPlotId(loc); if (id == null) { @@ -2414,6 +2602,11 @@ public class MainUtil { return getPlotAbs(loc.getWorld(), id); } + /** + * Get the plot and all connected plots at a location + * @param loc + * @return A set of plots + */ public static Set getPlots(final Location loc) { final PlotId id = getPlotId(loc); if (id == null) { @@ -2422,6 +2615,12 @@ public class MainUtil { return getPlots(loc.getWorld(), id); } + /** + * Get the average rating for a plot + * @see Plot#getAverageRating() + * @param plot + * @return + */ public static double getAverageRating(final Plot plot) { HashMap rating; if (plot.getSettings().ratings != null) { @@ -2452,6 +2651,12 @@ public class MainUtil { return val / size; } + /** + * If rating categories are enabled, get the average rating by category.
+ * - The index corresponds to the index of the category in the config + * @param plot + * @return + */ public static double[] getAverageRatings(final Plot plot) { HashMap rating; if (plot.getSettings().ratings != null) { @@ -2486,10 +2691,28 @@ public class MainUtil { return ratings; } + /** + * Set a component for a plot to the provided blocks
+ * - E.g. floor, wall, border etc.
+ * - The available components depend on the generator being used
+ * @param plot + * @param component + * @param blocks + * @return + */ public static boolean setComponent(final Plot plot, final String component, final PlotBlock[] blocks) { return PS.get().getPlotManager(plot.world).setComponent(PS.get().getPlotWorld(plot.world), plot.id, component, blocks); } + /** + * Format a string with plot information:
+ * %id%, %alias%, %num%, %desc%, %biome%, %owner%, %members%, %trusted%, %helpers%, %denied%, %flags%, %build%, %desc%, %rating% + * @param info + * @param plot + * @param player + * @param full + * @param whenDone + */ public static void format(String info, final Plot plot, final PlotPlayer player, final boolean full, final RunnableVal whenDone) { final int num = MainUtil.getConnectedPlots(plot).size(); final String alias = plot.getAlias().length() > 0 ? plot.getAlias() : C.NONE.s(); @@ -2553,6 +2776,12 @@ public class MainUtil { whenDone.run(info); } + /** + * Get a list of names given a list of uuids.
+ * - Uses the format {@link C#PLOT_USER_LIST} for the returned string + * @param uuids + * @return + */ public static String getPlayerList(final Collection uuids) { final ArrayList l = new ArrayList<>(uuids); if ((l == null) || (l.size() < 1)) { diff --git a/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index cf93cb97d..d82edf3bc 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -7,11 +7,29 @@ import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.PlotPlayer; import com.plotsquared.general.commands.CommandCaller; +/** + * The Permissions class handles checking user permissions.
+ * - This will respect * nodes and plots.admin and can be used to check permission ranges (e.g. plots.plot.5)
+ * - Checking the PlotPlayer class directly will not take the above into account
+ */ public class Permissions { + + /** + * Check if a player has a permission (C class helps keep track of permissions) + * @param player + * @param c + * @return + */ public static boolean hasPermission(final PlotPlayer player, final C c) { return hasPermission(player, c.s()); } + /** + * Check if a PlotPlayer has a permission + * @param player + * @param perm + * @return + */ public static boolean hasPermission(final PlotPlayer player, final String perm) { if (!Settings.PERMISSION_CACHING) { return hasPermission((CommandCaller) player, perm); @@ -31,6 +49,12 @@ public class Permissions { return result; } + /** + * Check if a CommandCaller (PlotPlayer implements CommandCaller) has a permission + * @param player + * @param perm + * @return + */ public static boolean hasPermission(final CommandCaller player, String perm) { if (player.hasPermission(perm) || player.hasPermission(C.PERMISSION_ADMIN.s())) { return true; @@ -49,6 +73,13 @@ public class Permissions { return false; } + /** + * Check if a PlotPlayer has a permission, and optionally send the no perm message if applicable. + * @param player + * @param perm + * @param notify + * @return + */ public static boolean hasPermission(final PlotPlayer player, final String perm, final boolean notify) { if (!hasPermission(player, perm)) { if (notify) { @@ -59,6 +90,15 @@ public class Permissions { return true; } + /** + * Check the the highest permission a PlotPlayer has within a specified range.
+ * - Excessively high values will lag
+ * - The default range that is checked is {@link Settings#MAX_PLOTS}
+ * @param player + * @param stub The permission stub to check e.g. for `plots.plot.#` the stub is `plots.plot` + * @param range The range to check + * @return The highest permission they have within that range + */ public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { if (player.hasPermission(C.PERMISSION_ADMIN.s())) { return Integer.MAX_VALUE; diff --git a/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/src/main/java/com/plotsquared/bukkit/BukkitMain.java index a4d95479a..f763a426a 100644 --- a/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -428,7 +428,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { try { BukkitSetBlockManager.setBlockManager = new SetBlockFast(); } catch (final Throwable e) { - MainUtil.canSetFast = false; BukkitSetBlockManager.setBlockManager = new SetBlockSlow(); } } diff --git a/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java b/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java index 26e421b74..3939b68d9 100644 --- a/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java +++ b/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java @@ -21,7 +21,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.UUIDHandler; public class ClassicPlotMeConnector extends APlotMeConnector { @@ -136,7 +135,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { if (name.length() > 0) { owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8)); } - MainUtil.sendConsoleMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); + PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); missing++; continue; } @@ -148,11 +147,10 @@ public class ClassicPlotMeConnector extends APlotMeConnector { plots.get(world).put(id, plot); } if (missing > 0) { - MainUtil.sendConsoleMessage("&cSome names could not be identified:"); - MainUtil.sendConsoleMessage("&7 - Empty quotes mean PlotMe just stored an unowned plot in the database"); - MainUtil.sendConsoleMessage("&7 - Names you have never seen before could be from people mistyping commands"); - MainUtil - .sendConsoleMessage("&7 - Converting from a non-uuid version of PlotMe can't identify owners if the playerdata files are deleted (these plots will remain unknown until the player connects)"); + PS.log("&cSome names could not be identified:"); + PS.log("&7 - Empty quotes mean PlotMe just stored an unowned plot in the database"); + PS.log("&7 - Names you have never seen before could be from people mistyping commands"); + PS.log("&7 - Converting from a non-uuid version of PlotMe can't identify owners if the playerdata files are deleted (these plots will remain unknown until the player connects)"); } for (final Entry> entry : merges.entrySet()) { @@ -171,7 +169,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { try { - MainUtil.sendConsoleMessage(" - " + prefix + "Denied"); + PS.log(" - " + prefix + "Denied"); stmt = connection.prepareStatement("SELECT * FROM `" + prefix + "Denied`"); r = stmt.executeQuery(); @@ -207,7 +205,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { } } if (denied == null) { - MainUtil.sendConsoleMessage("&6Could not identify denied for plot: " + id); + PS.log("&6Could not identify denied for plot: " + id); continue; } } @@ -251,7 +249,7 @@ public class ClassicPlotMeConnector extends APlotMeConnector { } } if (helper == null) { - MainUtil.sendConsoleMessage("&6Could not identify helper for plot: " + id); + PS.log("&6Could not identify helper for plot: " + id); continue; } } diff --git a/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java b/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java index a18b7f2e5..e53efb74e 100644 --- a/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java +++ b/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java @@ -19,7 +19,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.StringWrapper; -import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.UUIDHandler; public class PlotMeConnector_017 extends APlotMeConnector { @@ -123,7 +122,7 @@ public class PlotMeConnector_017 extends APlotMeConnector { } } if (owner == null) { - MainUtil.sendConsoleMessage("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); + PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + "'"); continue; } } @@ -145,7 +144,7 @@ public class PlotMeConnector_017 extends APlotMeConnector { r.close(); stmt.close(); try { - MainUtil.sendConsoleMessage(" - " + plugin + "core_denied"); + PS.log(" - " + plugin + "core_denied"); stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "core_denied`"); r = stmt.executeQuery(); @@ -153,14 +152,14 @@ public class PlotMeConnector_017 extends APlotMeConnector { final int key = r.getInt("plot_id"); final Plot plot = plots.get(key); if (plot == null) { - MainUtil.sendConsoleMessage("&6Denied (" + key + ") references deleted plot; ignoring entry."); + PS.log("&6Denied (" + key + ") references deleted plot; ignoring entry."); continue; } final UUID denied = UUID.fromString(r.getString("player")); plot.getDenied().add(denied); } - MainUtil.sendConsoleMessage(" - " + plugin + "core_allowed"); + PS.log(" - " + plugin + "core_allowed"); stmt = connection.prepareStatement("SELECT * FROM `" + plugin + "core_allowed`"); r = stmt.executeQuery(); @@ -168,7 +167,7 @@ public class PlotMeConnector_017 extends APlotMeConnector { final int key = r.getInt("plot_id"); final Plot plot = plots.get(key); if (plot == null) { - MainUtil.sendConsoleMessage("&6Allowed (" + key + ") references deleted plot; ignoring entry."); + PS.log("&6Allowed (" + key + ") references deleted plot; ignoring entry."); continue; } final UUID allowed = UUID.fromString(r.getString("player")); diff --git a/src/main/java/com/plotsquared/sponge/SpongeMain.java b/src/main/java/com/plotsquared/sponge/SpongeMain.java index e63f3633f..2d6b87ff2 100644 --- a/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -2,6 +2,7 @@ package com.plotsquared.sponge; import java.io.File; import java.lang.reflect.Field; +import java.lang.reflect.Method; import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.util.Arrays; @@ -28,7 +29,7 @@ import org.spongepowered.api.event.game.state.GameInitializationEvent; import org.spongepowered.api.event.game.state.GamePreInitializationEvent; import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.PluginContainer; -import org.spongepowered.api.service.profile.GameProfileResolver; +import org.spongepowered.api.profile.GameProfileManager; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.Texts; import org.spongepowered.api.text.translation.Translatable; @@ -36,6 +37,8 @@ import org.spongepowered.api.text.translation.Translation; import org.spongepowered.api.world.DimensionTypes; import org.spongepowered.api.world.GeneratorTypes; import org.spongepowered.api.world.World; +import org.spongepowered.api.world.WorldBuilder; +import org.spongepowered.api.world.gen.WorldGeneratorModifier; import com.google.inject.Inject; import com.intellectualcrafters.configuration.ConfigurationSection; @@ -80,13 +83,12 @@ import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeUUIDHandler; -import org.spongepowered.api.world.WorldBuilder; /** * Created by robin on 01/11/2014 */ -@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0", dependencies = "before:WorldEdit") +@Plugin(id = "PlotSquared", name = "PlotSquared", version = "3.0.0", dependencies = "before:WorldEdit,required-after:TotalEconomy") public class SpongeMain implements IPlotMain, PluginContainer { public static SpongeMain THIS; @@ -96,13 +98,12 @@ public class SpongeMain implements IPlotMain, PluginContainer { private Game game; private Server server; - private GameProfileResolver resolver; + private GameProfileManager resolver; private WorldModify modify; - private Object plugin; - // stuff // + @Override public Logger getLogger() { return logger; } @@ -115,12 +116,12 @@ public class SpongeMain implements IPlotMain, PluginContainer { return server; } - public GameProfileResolver getResolver() { + public GameProfileManager getResolver() { return resolver; } - public Object getPlugin() { - return plugin; + public SpongeMain getPlugin() { + return THIS; } public Text getText(final String m) { @@ -192,8 +193,8 @@ public class SpongeMain implements IPlotMain, PluginContainer { } @Override - public Object getInstance() { - return THIS; + public Optional getInstance() { + return Optional. of(THIS); } @Override @@ -223,7 +224,24 @@ public class SpongeMain implements IPlotMain, PluginContainer { @Listener public void onInit(final GamePreInitializationEvent event) { - log("P^2 PRE INIT"); + // Hook for Project Worlds + hookProjectWorlds(); + } + + public void hookProjectWorlds() { + Optional plugin = game.getPluginManager().getPlugin("Project Worlds"); + if (plugin.isPresent()) { + try { + Class clazz = Class.forName("com.gmail.trentech.pjw.modifiers.Modifiers"); + Method method = clazz.getMethod("put", String.class, WorldGeneratorModifier.class); + SpongeBasicGen generator = new SpongeBasicGen(null); + method.invoke(null, "plotsquared", new WorldModify(generator, false)); + log("Adding plotsquared modifier to Project Worlds"); + } + catch (Throwable e) { + e.printStackTrace(); + } + } } @Listener @@ -232,8 +250,7 @@ public class SpongeMain implements IPlotMain, PluginContainer { THIS = this; // - resolver = game.getServiceManager().provide(GameProfileResolver.class).get(); - plugin = this; + resolver = game.getServiceManager().provide(GameProfileManager.class).get(); server = game.getServer(); // @@ -318,7 +335,6 @@ public class SpongeMain implements IPlotMain, PluginContainer { PS.get().copyFile("data.txt", "config"); try { - final File id_file = new File(getDirectory(), "config" + File.separator + "ids.txt"); final List id_lines = Files.readAllLines(id_file.toPath(), StandardCharsets.UTF_8); @@ -494,7 +510,7 @@ public class SpongeMain implements IPlotMain, PluginContainer { @Override public void registerCommands() { - getGame().getCommandDispatcher().register(plugin, new SpongeCommand(), new String[] { "plots", "p", "plot", "ps", "plotsquared", "p2", "2" }); + getGame().getCommandManager().register(THIS, new SpongeCommand(), new String[] { "plots", "p", "plot", "ps", "plotsquared", "p2", "2" }); } @Override @@ -523,7 +539,6 @@ public class SpongeMain implements IPlotMain, PluginContainer { @Override public boolean initWorldEdit() { try { - log("CHECKING FOR WORLDEDIT!?"); Class.forName("com.sk89q.worldedit.WorldEdit"); return true; } catch (final Throwable e) { diff --git a/src/main/java/com/plotsquared/sponge/events/ClusterFlagRemoveEvent.java b/src/main/java/com/plotsquared/sponge/events/ClusterFlagRemoveEvent.java index 53b02d5a0..e1a3e72ae 100644 --- a/src/main/java/com/plotsquared/sponge/events/ClusterFlagRemoveEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/ClusterFlagRemoveEvent.java @@ -1,7 +1,8 @@ package com.plotsquared.sponge.events; -import org.spongepowered.api.event.impl.AbstractEvent; import org.spongepowered.api.event.Cancellable; +import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.impl.AbstractEvent; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.object.PlotCluster; @@ -44,4 +45,9 @@ public class ClusterFlagRemoveEvent extends AbstractEvent implements Cancellable public void setCancelled(final boolean cancel) { cancelled = cancel; } + + @Override + public Cause getCause() { + return null; + } } diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerClaimPlotEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerClaimPlotEvent.java index b1285ce3b..870f57339 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlayerClaimPlotEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlayerClaimPlotEvent.java @@ -2,6 +2,7 @@ package com.plotsquared.sponge.events; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.event.Cancellable; +import org.spongepowered.api.event.cause.Cause; import com.intellectualcrafters.plot.object.Plot; @@ -48,4 +49,9 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable { public void setCancelled(final boolean cancel) { cancelled = cancel; } + + @Override + public Cause getCause() { + return null; + } } diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerEnterPlotEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerEnterPlotEvent.java index 60299226a..bdfd66b69 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlayerEnterPlotEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlayerEnterPlotEvent.java @@ -1,6 +1,7 @@ package com.plotsquared.sponge.events; import org.spongepowered.api.entity.living.player.Player; +import org.spongepowered.api.event.cause.Cause; import com.intellectualcrafters.plot.object.Plot; @@ -27,4 +28,9 @@ public class PlayerEnterPlotEvent extends PlayerEvent { public Plot getPlot() { return plot; } + + @Override + public Cause getCause() { + return null; + } } diff --git a/src/main/java/com/plotsquared/sponge/events/PlayerEvent.java b/src/main/java/com/plotsquared/sponge/events/PlayerEvent.java index 3c30de943..7b07d320c 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlayerEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlayerEvent.java @@ -1,6 +1,7 @@ package com.plotsquared.sponge.events; import org.spongepowered.api.entity.living.player.Player; +import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.impl.AbstractEvent; public abstract class PlayerEvent extends AbstractEvent { @@ -15,4 +16,9 @@ public abstract class PlayerEvent extends AbstractEvent { return player; } + @Override + public Cause getCause() { + return null; + } + } diff --git a/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java index 7c1cdbfa9..5e3f533ba 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlotClearEvent.java @@ -1,7 +1,8 @@ package com.plotsquared.sponge.events; -import org.spongepowered.api.event.impl.AbstractEvent; import org.spongepowered.api.event.Cancellable; +import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.impl.AbstractEvent; import com.intellectualcrafters.plot.object.PlotId; @@ -48,4 +49,9 @@ public class PlotClearEvent extends AbstractEvent implements Cancellable { public void setCancelled(final boolean cancel) { cancelled = cancel; } + + @Override + public Cause getCause() { + return null; + } } diff --git a/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java index 214e74dcf..61a11422f 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlotDeleteEvent.java @@ -1,5 +1,6 @@ package com.plotsquared.sponge.events; +import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.impl.AbstractEvent; import com.intellectualcrafters.plot.object.PlotId; @@ -36,4 +37,9 @@ public class PlotDeleteEvent extends AbstractEvent { public String getWorld() { return world; } + + @Override + public Cause getCause() { + return null; + } } diff --git a/src/main/java/com/plotsquared/sponge/events/PlotEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotEvent.java index 6342628a5..0ee3788cf 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlotEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlotEvent.java @@ -1,5 +1,6 @@ package com.plotsquared.sponge.events; +import org.spongepowered.api.event.cause.Cause; import org.spongepowered.api.event.impl.AbstractEvent; import com.intellectualcrafters.plot.object.Plot; @@ -16,4 +17,9 @@ public abstract class PlotEvent extends AbstractEvent { return plot; } + @Override + public Cause getCause() { + return null; + } + } diff --git a/src/main/java/com/plotsquared/sponge/events/PlotMergeEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotMergeEvent.java index ff4110cbd..e23dadfa4 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlotMergeEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlotMergeEvent.java @@ -2,8 +2,9 @@ package com.plotsquared.sponge.events; import java.util.ArrayList; -import org.spongepowered.api.event.impl.AbstractEvent; import org.spongepowered.api.event.Cancellable; +import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.impl.AbstractEvent; import org.spongepowered.api.world.World; import com.intellectualcrafters.plot.object.Plot; @@ -57,4 +58,9 @@ public class PlotMergeEvent extends AbstractEvent implements Cancellable { public void setCancelled(final boolean cancel) { cancelled = cancel; } + + @Override + public Cause getCause() { + return null; + } } diff --git a/src/main/java/com/plotsquared/sponge/events/PlotUnlinkEvent.java b/src/main/java/com/plotsquared/sponge/events/PlotUnlinkEvent.java index 6496b8399..ded02c399 100644 --- a/src/main/java/com/plotsquared/sponge/events/PlotUnlinkEvent.java +++ b/src/main/java/com/plotsquared/sponge/events/PlotUnlinkEvent.java @@ -2,8 +2,9 @@ package com.plotsquared.sponge.events; import java.util.ArrayList; -import org.spongepowered.api.event.impl.AbstractEvent; import org.spongepowered.api.event.Cancellable; +import org.spongepowered.api.event.cause.Cause; +import org.spongepowered.api.event.impl.AbstractEvent; import org.spongepowered.api.world.World; import com.intellectualcrafters.plot.object.PlotId; @@ -46,4 +47,9 @@ public class PlotUnlinkEvent extends AbstractEvent implements Cancellable { public void setCancelled(final boolean cancel) { cancelled = cancel; } + + @Override + public Cause getCause() { + return null; + } } diff --git a/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java b/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java index 9104189f3..fd91ecbe5 100644 --- a/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java +++ b/src/main/java/com/plotsquared/sponge/generator/AugmentedPopulator.java @@ -15,7 +15,7 @@ import org.spongepowered.api.world.extent.ImmutableBlockVolume; import org.spongepowered.api.world.extent.MutableBlockVolume; import org.spongepowered.api.world.extent.StorageType; import org.spongepowered.api.world.extent.UnmodifiableBlockVolume; -import org.spongepowered.api.world.gen.GeneratorPopulator; +import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.Populator; import org.spongepowered.api.world.gen.WorldGenerator; @@ -38,7 +38,7 @@ public class AugmentedPopulator implements Populator { public final PlotWorld plotworld; public final PlotManager manager; public final SpongePlotGenerator generator; - public final GeneratorPopulator populator; + public final GenerationPopulator populator; public final PlotCluster cluster; public final Random r = new Random(); public final boolean p; @@ -54,7 +54,7 @@ public class AugmentedPopulator implements Populator { // Initialize any chach that's needed this.cluster = cluster; this.generator = generator; - populator = generator.getBaseGeneratorPopulator(); + populator = generator.getBaseGenerationPopulator(); plotworld = generator.getNewPlotWorld(worldname); manager = generator.getPlotManager(); this.p = p; diff --git a/src/main/java/com/plotsquared/sponge/generator/SpongeBasicGen.java b/src/main/java/com/plotsquared/sponge/generator/SpongeBasicGen.java index 7c27f9f35..4f514dc83 100644 --- a/src/main/java/com/plotsquared/sponge/generator/SpongeBasicGen.java +++ b/src/main/java/com/plotsquared/sponge/generator/SpongeBasicGen.java @@ -66,7 +66,6 @@ public class SpongeBasicGen extends SpongePlotGenerator { } pathWidthUpper = (short) (pathWidthLower + plotsize + 1); } - roadblock = SpongeMain.THIS.getBlockState(this.plotworld.ROAD_BLOCK); wallfilling = SpongeMain.THIS.getBlockState(this.plotworld.WALL_FILLING); wall = SpongeMain.THIS.getBlockState(this.plotworld.WALL_BLOCK); @@ -127,5 +126,4 @@ public class SpongeBasicGen extends SpongePlotGenerator { } return biome; } - } diff --git a/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java b/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java index 1bd651d8d..1a0a0c551 100644 --- a/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java +++ b/src/main/java/com/plotsquared/sponge/generator/SpongePlotGenerator.java @@ -1,10 +1,13 @@ package com.plotsquared.sponge.generator; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; +import org.spongepowered.api.world.biome.BiomeGenerationSettings; +import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.gen.BiomeGenerator; -import org.spongepowered.api.world.gen.GeneratorPopulator; +import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.Populator; import org.spongepowered.api.world.gen.WorldGenerator; @@ -14,14 +17,14 @@ import com.intellectualcrafters.plot.object.SetupObject; public abstract class SpongePlotGenerator implements WorldGenerator { - public final String world; + public String world; public SpongePlotGenerator(final String world) { this.world = world; } @Override - public GeneratorPopulator getBaseGeneratorPopulator() { + public GenerationPopulator getBaseGenerationPopulator() { return getGenerator(); } @@ -30,31 +33,55 @@ public abstract class SpongePlotGenerator implements WorldGenerator { return getPlotBiomeProvider(); } - @Override - public List getGeneratorPopulators() { - final List pops = new ArrayList<>(); - pops.addAll(getPlotPopulators()); - return pops; - } - @Override public List getPopulators() { return new ArrayList<>(); } - @Override - public void setBaseGeneratorPopulator(final GeneratorPopulator arg0) { - // TODO Auto-generated method stub - throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); - - } - @Override public void setBiomeGenerator(final BiomeGenerator biomeGenerator) { // TODO throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); } + @Override + public BiomeGenerationSettings getBiomeSettings(BiomeType type) { + // TODO Auto-generated method stub + throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); + } + + @Override + public List getGenerationPopulators() { + final List pops = new ArrayList<>(); + pops.addAll(getPlotPopulators()); + return pops; + } + + @Override + public List getGenerationPopulators(Class clazz) { + List list = getGenerationPopulators(); + Iterator iter = list.iterator(); + while (iter.hasNext()) { + GenerationPopulator pop = iter.next(); + if (!clazz.isInstance(pop)) { + iter.remove(); + } + } + return list; + } + + @Override + public List getPopulators(Class arg0) { + return new ArrayList<>(); + } + + @Override + public void setBaseGenerationPopulator(GenerationPopulator arg0) { + // TODO + throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); + + } + public abstract SpongePlotPopulator getGenerator(); public abstract BiomeGenerator getPlotBiomeProvider(); diff --git a/src/main/java/com/plotsquared/sponge/generator/WorldModify.java b/src/main/java/com/plotsquared/sponge/generator/WorldModify.java index 19acbd8fa..46f19a377 100644 --- a/src/main/java/com/plotsquared/sponge/generator/WorldModify.java +++ b/src/main/java/com/plotsquared/sponge/generator/WorldModify.java @@ -22,7 +22,8 @@ public class WorldModify implements WorldGeneratorModifier { @Override public void modifyWorldGenerator(final WorldCreationSettings world, final DataContainer settings, final WorldGenerator gen) { if (augment) { - final String worldname = plotgen.world; + final String worldname = world.getWorldName(); + plotgen.world = worldname; final PlotWorld plotworld = plotgen.getNewPlotWorld(worldname); if (plotworld.TYPE == 2) { for (final PlotCluster cluster : ClusterManager.getClusters(worldname)) { @@ -32,9 +33,9 @@ public class WorldModify implements WorldGeneratorModifier { new AugmentedPopulator(worldname, gen, plotgen, null, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2); } } else { - gen.getGeneratorPopulators().clear(); + gen.getGenerationPopulators().clear(); gen.getPopulators().clear(); - gen.setBaseGeneratorPopulator(plotgen.getBaseGeneratorPopulator()); + gen.setBaseGenerationPopulator(plotgen.getBaseGenerationPopulator()); gen.setBiomeGenerator(plotgen.getBiomeGenerator()); } } diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java b/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java index bfcf53636..7e47edad8 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java @@ -37,6 +37,7 @@ public class SpongeBlockManager extends BlockManager { @Override public StringComparison.ComparisonResult getClosestBlock(String name) { try { + double match; short id; byte data; @@ -94,6 +95,7 @@ public class SpongeBlockManager extends BlockManager { @Override public PlotBlock getPlotBlockFromString(final String block) { + dsa // TODO Auto-generated method stub return null; } diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java b/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java index 53222db6d..395a697e4 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java @@ -3,17 +3,17 @@ package com.plotsquared.sponge.util; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import java.util.Optional; import java.util.UUID; +import org.spongepowered.api.command.CommandCallable; +import org.spongepowered.api.command.CommandException; +import org.spongepowered.api.command.CommandResult; +import org.spongepowered.api.command.CommandSource; import org.spongepowered.api.entity.living.player.Player; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.Texts; -import org.spongepowered.api.util.command.CommandCallable; -import org.spongepowered.api.util.command.CommandException; -import org.spongepowered.api.util.command.CommandResult; -import org.spongepowered.api.util.command.CommandSource; -import java.util.Optional; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.PlotPlayer; diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeEconHandler.java b/src/main/java/com/plotsquared/sponge/util/SpongeEconHandler.java index 8752ab0e0..51fa1a85c 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeEconHandler.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeEconHandler.java @@ -1,34 +1,57 @@ package com.plotsquared.sponge.util; +import java.util.UUID; + +import org.apache.commons.lang.NotImplementedException; + +import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.object.SpongePlayer; public class SpongeEconHandler extends EconHandler { + private Object TE_SERVICE; + private Object EL_SERVICE; + + public SpongeEconHandler() { + try { + Class clazz = Class.forName("com.erigitic.service.TEService"); + this.TE_SERVICE = SpongeMain.THIS.getGame().getServiceManager().provide(clazz).get(); + + } catch (Exception e) { + try { + Class clazz = Class.forName("me.Flibio.EconomyLite.API.EconomyLiteAPI"); + this.EL_SERVICE = SpongeMain.THIS.getGame().getServiceManager().provide(clazz).get(); + } catch (Exception e2) { + PS.log("No economy service found! (EconomyLite, TotalEconomy)"); + } + } + } + @Override public void withdrawMoney(PlotPlayer player, double amount) { - // TODO Auto-generated method stub - + UUID uuid = ((SpongePlayer) player).player.getUniqueId(); } @Override public void depositMoney(PlotPlayer player, double amount) { - // TODO Auto-generated method stub - + UUID uuid = ((SpongePlayer) player).player.getUniqueId(); } @Override public void depositMoney(OfflinePlotPlayer player, double amount) { - // TODO Auto-generated method stub + UUID uuid = player.getUUID(); } @Override public void setPermission(String world, String player, String perm, boolean value) { // TODO Auto-generated method stub + throw new NotImplementedException("TODO/WIP/NOT IMPLEMENTED!"); } @Override diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java index b75844a3a..6d91b8177 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java @@ -4,7 +4,7 @@ import java.util.ArrayList; import java.util.UUID; import org.spongepowered.api.event.Event; -import org.spongepowered.api.service.event.EventManager; +import org.spongepowered.api.event.EventManager; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.object.Location; diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeMetrics.java b/src/main/java/com/plotsquared/sponge/util/SpongeMetrics.java index f5748047b..c8a029761 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeMetrics.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeMetrics.java @@ -51,7 +51,7 @@ import ninja.leaping.configurate.loader.ConfigurationLoader; import org.spongepowered.api.Game; import org.spongepowered.api.plugin.PluginContainer; -import org.spongepowered.api.service.scheduler.Task; +import org.spongepowered.api.scheduler.Task; import com.intellectualcrafters.plot.PS; diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeTaskManager.java b/src/main/java/com/plotsquared/sponge/util/SpongeTaskManager.java index 26b7dcf5b..27c6665cc 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeTaskManager.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeTaskManager.java @@ -3,7 +3,7 @@ package com.plotsquared.sponge.util; import java.util.HashMap; import java.util.concurrent.atomic.AtomicInteger; -import org.spongepowered.api.service.scheduler.Task; +import org.spongepowered.api.scheduler.Task; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.sponge.SpongeMain; diff --git a/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java b/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java index fcd3ab024..579f2f8c8 100644 --- a/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java +++ b/src/main/java/com/plotsquared/sponge/uuid/SpongeLowerOfflineUUIDWrapper.java @@ -2,8 +2,8 @@ package com.plotsquared.sponge.uuid; import java.util.UUID; -import org.spongepowered.api.GameProfile; import org.spongepowered.api.entity.living.player.Player; +import org.spongepowered.api.profile.GameProfile; import com.google.common.base.Charsets; import com.intellectualcrafters.plot.object.OfflinePlotPlayer; diff --git a/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java b/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java index eb4c9a2ba..4eac79f4e 100644 --- a/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java +++ b/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java @@ -2,7 +2,7 @@ package com.plotsquared.sponge.uuid; import java.util.UUID; -import org.spongepowered.api.GameProfile; +import org.spongepowered.api.profile.GameProfile; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.RunnableVal;