From be9fb3bd3a06b326bf4340e69ab46a9d703aeb9c Mon Sep 17 00:00:00 2001 From: sauilitired Date: Mon, 20 Aug 2018 11:05:00 +0200 Subject: [PATCH] Remove deprecated methods without internal use. --- Bukkit/build.gradle | 1 + .../bukkit/listeners/EntityPortal_1_7_9.java | 2 +- .../plotsquared/plot/api/PlotAPI.java | 298 +----------------- Core/build.gradle | 1 + .../plotsquared/plot/PS.java | 31 +- .../plotsquared/plot/commands/Auto.java | 24 -- .../plotsquared/plot/object/Plot.java | 31 +- .../plotsquared/plot/object/PlotPlayer.java | 4 - .../plotsquared/plot/util/MainUtil.java | 13 - 9 files changed, 18 insertions(+), 387 deletions(-) diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index 7b3e5b761..112e1ddc1 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -11,6 +11,7 @@ dependencies { compile("net.milkbowl.vault:VaultAPI:1.6") { exclude module: 'bukkit' } + compileOnly 'org.projectlombok:lombok:1.16.18' } sourceCompatibility = 1.7 diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java index 8c4eeb9d0..cf757ab89 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java @@ -28,7 +28,7 @@ public class EntityPortal_1_7_9 implements Listener { List meta = entity.getMetadata("plotworld"); World world = entity.getLocation().getWorld(); if (meta == null || meta.isEmpty()) { - if (PS.get().isPlotWorld(world.getName())) { + if (PS.get().hasPlotArea(world.getName())) { entity.setMetadata("plotworld", new FixedMetadataValue((Plugin) PS.get().IMP, entity.getLocation())); } diff --git a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/plot/api/PlotAPI.java b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/plot/api/PlotAPI.java index 70b9ed4c0..93f458b34 100644 --- a/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/plot/api/PlotAPI.java +++ b/Bukkit/src/main/java/com/github/intellectualsites/plotsquared/plot/api/PlotAPI.java @@ -3,20 +3,23 @@ package com.github.intellectualsites.plotsquared.plot.api; import com.github.intellectualsites.plotsquared.bukkit.util.BukkitUtil; import com.github.intellectualsites.plotsquared.configuration.file.YamlConfiguration; import com.github.intellectualsites.plotsquared.plot.PS; -import com.github.intellectualsites.plotsquared.plot.commands.SubCommand; import com.github.intellectualsites.plotsquared.plot.config.C; import com.github.intellectualsites.plotsquared.plot.flag.Flag; -import com.github.intellectualsites.plotsquared.plot.flag.FlagManager; import com.github.intellectualsites.plotsquared.plot.flag.Flags; -import com.github.intellectualsites.plotsquared.plot.object.*; -import com.github.intellectualsites.plotsquared.plot.util.*; +import com.github.intellectualsites.plotsquared.plot.object.Plot; +import com.github.intellectualsites.plotsquared.plot.object.PlotArea; +import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer; +import com.github.intellectualsites.plotsquared.plot.util.ChunkManager; +import com.github.intellectualsites.plotsquared.plot.util.MainUtil; +import com.github.intellectualsites.plotsquared.plot.util.SchematicHandler; +import com.github.intellectualsites.plotsquared.plot.util.UUIDHandler; import com.github.intellectualsites.plotsquared.plot.util.block.GlobalBlockQueue; import com.github.intellectualsites.plotsquared.plot.uuid.UUIDWrapper; +import lombok.NoArgsConstructor; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.entity.Player; -import org.bukkit.plugin.java.JavaPlugin; import java.util.*; @@ -35,20 +38,9 @@ import java.util.*; * * @version 3.3.3 */ +@NoArgsConstructor public class PlotAPI { - /** - * Deprecated, does nothing. - * - * @param plugin not needed - * @deprecated Not needed - */ - @Deprecated public PlotAPI(JavaPlugin plugin) { - } - - public PlotAPI() { - } - /** * Get all plots. * @@ -146,44 +138,6 @@ public class PlotAPI { return UUIDHandler.getUUIDWrapper(); } - /** - * Do not use this. Instead use FlagManager.[method] in your code. - * - Flag related stuff - * - * @return FlagManager - * @deprecated Use {@link FlagManager} directly - */ - @Deprecated public FlagManager getFlagManager() { - return new FlagManager(); - } - - /** - * Do not use this. Instead use MainUtil.[method] in your code. - * - * @return MainUtil - * @deprecated Use {@link MainUtil} directly - */ - @Deprecated public MainUtil getMainUtil() { - return new MainUtil(); - } - - /** - * Do not use this. Instead use C.PERMISSION_[method] in your code. - * - * @return Array of strings - * @see Permissions - * @deprecated Use {@link C} to list all the permissions - */ - @Deprecated public String[] getPermissions() { - ArrayList perms = new ArrayList<>(); - for (C caption : C.values()) { - if ("static.permissions".equals(caption.getCategory())) { - perms.add(caption.s()); - } - } - return perms.toArray(new String[perms.size()]); - } - /** * SchematicHandler class contains methods related to pasting, reading * and writing schematics. @@ -195,32 +149,6 @@ public class PlotAPI { return SchematicHandler.manager; } - /** - * Use C.[caption] instead - * - * @return C - * @deprecated Use {@link C} - */ - @Deprecated public C[] getCaptions() { - return C.values(); - } - - /** - * Get the plot manager for a world. Most of these methods can be accessed - * through the MainUtil. - * - * @param world the world to retrieve the manager from - * @return PlotManager - * @see PlotManager - * @see PS#getPlotManager(Plot) - */ - @SuppressWarnings("deprecation") @Deprecated public PlotManager getPlotManager(World world) { - if (world == null) { - return null; - } - return getPlotManager(world.getName()); - } - /** * Get a list of PlotAreas in the world. * @@ -234,71 +162,6 @@ public class PlotAPI { return PS.get().getPlotAreas(world.getName()); } - /** - * Get the plot manager for a world. Contains useful low level methods for - * plot merging, clearing, and tessellation. - * - * @param world The world - * @return PlotManager - * @see PS#getPlotManager(Plot) - * @see PlotManager - */ - @Deprecated public PlotManager getPlotManager(String world) { - Set areas = PS.get().getPlotAreas(world); - switch (areas.size()) { - case 0: - return null; - case 1: - return areas.iterator().next().manager; - default: - PS.debug( - "PlotAPI#getPlotManager(org.bukkit.World) is deprecated and doesn't support multi plot area worlds."); - return null; - } - } - - /** - * Get the settings for a world (settings bundled in PlotArea class). You - * will need to downcast for the specific settings a Generator has. e.g. - * DefaultPlotWorld class implements PlotArea - * - * @param world The World - * @return The {@link PlotArea} for the world or null if not in plotworld - * @see #getPlotAreas(World) - * @see PlotArea - */ - @SuppressWarnings("deprecation") @Deprecated public PlotArea getWorldSettings(World world) { - if (world == null) { - return null; - } - return getWorldSettings(world.getName()); - } - - /** - * Get the settings for a world. - * - * @param world the world to retrieve settings from - * @return The {@link PlotArea} for the world or null if not in plotworld - * @see PS#getPlotArea(String, String) - * @see PlotArea - */ - @Deprecated public PlotArea getWorldSettings(String world) { - if (world == null) { - return null; - } - Set areas = PS.get().getPlotAreas(world); - switch (areas.size()) { - case 0: - return null; - case 1: - return areas.iterator().next(); - default: - PS.debug( - "PlotAPI#getWorldSettings(org.bukkit.World) is deprecated and doesn't support multi plot area worlds."); - return null; - } - } - /** * Send a message to a player. * @@ -351,26 +214,6 @@ public class PlotAPI { Flags.registerFlag(flag); } - /** - * Gets a plot based on the ID. - * - * @param world the world the plot is located in - * @param x The PlotID x coordinate - * @param z The PlotID y coordinate - * @return plot, null if ID is wrong - * @see PlotArea#getPlot(PlotId) - */ - @SuppressWarnings("deprecation") @Deprecated public Plot getPlot(World world, int x, int z) { - if (world == null) { - return null; - } - PlotArea area = getWorldSettings(world); - if (area == null) { - return null; - } - return area.getPlot(new PlotId(x, z)); - } - /** * Get a plot based on the location. * @@ -397,94 +240,6 @@ public class PlotAPI { return this.getPlot(player.getLocation()); } - /** - * Check whether or not a player has a plot. - * - * @param player Player that you want to check for - * @param world The world to check - * @return true if player has a plot, false if not. - * @see #getPlots(World, Player, boolean) - */ - @SuppressWarnings("deprecation") @Deprecated public boolean hasPlot(World world, - Player player) { - return getPlots(world, player, true).length > 0; - } - - /** - * Get all plots for the player. - * - * @param world The world to retrieve plots from - * @param player The player to search for - * @param justOwner should we just search for owner? Or with rights? - * @return An array of plots for the player - */ - @Deprecated public Plot[] getPlots(World world, Player player, boolean justOwner) { - ArrayList pPlots = new ArrayList<>(); - UUID uuid = BukkitUtil.getPlayer(player).getUUID(); - for (Plot plot : PS.get().getPlots(world.getName())) { - if (justOwner) { - if (plot.hasOwner() && plot.isOwner(uuid)) { - pPlots.add(plot); - } - } else if (plot.isAdded(uuid)) { - pPlots.add(plot); - } - } - return pPlots.toArray(new Plot[pPlots.size()]); - } - - /** - * Get all plots for the world. - * - * @param world to get plots of - * @return Plot[] - array of plot objects in world - * @see PS#getPlots(String) - * @see Plot - */ - @Deprecated public Plot[] getPlots(World world) { - if (world == null) { - return new Plot[0]; - } - Collection plots = PS.get().getPlots(world.getName()); - return plots.toArray(new Plot[plots.size()]); - } - - /** - * Get all plot worlds. - * - * @return World[] - array of plot worlds - */ - @SuppressWarnings("deprecation") @Deprecated public String[] getPlotWorlds() { - Set plotWorldStrings = PS.get().getPlotWorldStrings(); - return plotWorldStrings.toArray(new String[plotWorldStrings.size()]); - } - - /** - * Get if plotworld. - * - * @param world The world to check - * @return boolean (if plot world or not) - * @see PS#hasPlotArea(String) - */ - @Deprecated public boolean isPlotWorld(World world) { - return PS.get().hasPlotArea(world.getName()); - } - - /** - * Get plot locations. - * - * @param plot Plot to get the locations for - * @return [0] = bottomLc, [1] = topLoc, [2] = home - * @see Plot - * @deprecated As merged plots may not have a rectangular shape - */ - @SuppressWarnings("deprecation") @Deprecated public Location[] getLocations(Plot plot) { - Location bukkitBottom = BukkitUtil.getLocation(plot.getCorners()[0]); - Location bukkitTop = BukkitUtil.getLocation(plot.getCorners()[1]); - Location bukkitHome = BukkitUtil.getLocation(plot.getHome()); - return new Location[] {bukkitBottom, bukkitTop, bukkitHome}; - } - /** * Get home location. * @@ -496,30 +251,6 @@ public class PlotAPI { return BukkitUtil.getLocation(plot.getHome()); } - /** - * Get Bottom Location (min, min, min). - * - * @param plot Plot that you want to get the location for - * @return plot bottom location - * @see Plot - * @deprecated As merged plots may not have a rectangular shape - */ - @SuppressWarnings("deprecation") @Deprecated public Location getBottomLocation(Plot plot) { - return BukkitUtil.getLocation(plot.getCorners()[0]); - } - - /** - * Get Top Location (max, max, max). - * - * @param plot Plot that you want to get the location for - * @return plot top location - * @see Plot - * @deprecated As merged plots may not have a rectangular shape - */ - @SuppressWarnings("deprecation") @Deprecated public Location getTopLocation(Plot plot) { - return BukkitUtil.getLocation(plot.getCorners()[1]); - } - /** * Check whether or not a player is in a plot. * @@ -530,17 +261,6 @@ public class PlotAPI { return getPlot(player) != null; } - /** - * Register a subcommand. - * - * @param c SubCommand, that we want to register - * @see SubCommand - * @deprecated Command registration is done on object creation - */ - @Deprecated public void registerCommand(SubCommand c) { - PS.debug("SubCommands are now registered on creation"); - } - /** * Gets the PlotSquared class. * diff --git a/Core/build.gradle b/Core/build.gradle index 9ee8d429e..9439abb26 100644 --- a/Core/build.gradle +++ b/Core/build.gradle @@ -2,6 +2,7 @@ dependencies { testCompile 'junit:junit:4.12' compile 'org.yaml:snakeyaml:1.16' compile 'com.google.code.gson:gson:2.2.4' + compileOnly 'org.projectlombok:lombok:1.16.18' } sourceCompatibility = 1.7 diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PS.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PS.java index 686199d14..cc2cb0ea1 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PS.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/PS.java @@ -606,6 +606,7 @@ public class PS { * {@link #sortPlots(Collection, SortType, PlotArea)} which has * additional checks before calling this */ + // TODO: Re-evaluate deprecation of this, as it's being used internally @Deprecated public ArrayList sortPlotsByHash(Collection plots) { int hardmax = 256000; int max = 0; @@ -658,6 +659,7 @@ public class PS { * * @param input an array of plots to sort */ + // TODO: Re-evaluate deprecation of this, as it's being used internally @Deprecated public void sortPlotsByHash(Plot[] input) { List[] bucket = new ArrayList[32]; for (int i = 0; i < bucket.length; i++) { @@ -685,6 +687,7 @@ public class PS { } } + // TODO: Re-evaluate deprecation of this, as it's being used internally @Deprecated public ArrayList sortPlotsByTimestamp(Collection plots) { int hardMax = 256000; int max = 0; @@ -739,6 +742,7 @@ public class PS { * @return * @deprecated Unchecked, use {@link #sortPlots(Collection, SortType, PlotArea)} instead which will call this after checks */ + // TODO: Re-evaluate deprecation of this, as it's being used internally @Deprecated public List sortPlotsByModified(Collection input) { List list; if (input instanceof List) { @@ -976,18 +980,6 @@ public class PS { return new HashSet<>(myplots); } - /** - * Use {@link #hasPlotArea(String)}. - * Note: Worlds may have more than one plot area - * - * @param world the world - * @return if the world is a plotworld - * @deprecated - */ - @Deprecated public boolean isPlotWorld(String world) { - return hasPlotArea(world); - } - /** * Check if a plot world. * @@ -1880,21 +1872,6 @@ public class PS { return set; } - /** - * Not recommended for use since worlds can have multiple PlotAreas. - * - * @return Set of world names - */ - @Deprecated public Set getPlotWorldStrings() { - HashSet set = new HashSet<>(manager.getAllPlotAreas().length); - for (String world : manager.getAllWorlds()) { - if (manager.getPlotAreas(world, null).length != 0) { - set.add(world); - } - } - return set; - } - public boolean isAugmented(String world) { PlotArea[] areas = manager.getPlotAreas(world, null); if (areas == null) { diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java index 2e3cde17b..050a0b30f 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/commands/Auto.java @@ -55,30 +55,6 @@ public class Auto extends SubCommand { return true; } - /** - * Get the next plot id (spiral out from 0,0) - * - * @param start - * @return - */ - @Deprecated public static PlotId getNextPlot(PlotId start) { - int plots; - PlotId center; - center = new PlotId(0, 0); - plots = Integer.MAX_VALUE; - PlotId currentId; - for (int i = 0; i < plots; i++) { - if (start == null) { - start = new PlotId(0, 0); - } else { - start = start.getNextId(1); - } - currentId = new PlotId(center.x + start.x, center.y + start.y); - return currentId; - } - return null; - } - /** * Teleport the player home, or claim a new plot * diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java index b259737bf..9612bd048 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/Plot.java @@ -1639,39 +1639,11 @@ public class Plot { } } - /** - * Returns the top and bottom plot id.
- * - If the plot is not connected, it will return itself for the top/bottom
- * - the returned ids will not necessarily correspond to claimed plots if the connected plots do not form a rectangular shape - * - * @return new Plot[] { bottom, top } - * @deprecated as merged plots no longer need to be rectangular - */ - @Deprecated public PlotId[] getCornerIds() { - if (!this.isMerged()) { - return new PlotId[] {this.getId(), this.getId()}; - } - PlotId min = new PlotId(this.getId().x, this.getId().y); - PlotId max = new PlotId(this.getId().x, this.getId().y); - for (Plot current : this.getConnectedPlots()) { - if (current.getId().x < min.x) { - min.x = current.getId().x; - } else if (current.getId().x > max.x) { - max.x = current.getId().x; - } - if (current.getId().y < min.y) { - min.y = current.getId().y; - } else if (current.getId().y > max.y) { - max.y = current.getId().y; - } - } - return new PlotId[] {min, max}; - } - /** * @return * @deprecated in favor of getCorners()[0];
*/ + // Won't remove as suggestion also points to deprecated method @Deprecated public Location getBottom() { return this.getCorners()[0]; } @@ -1680,6 +1652,7 @@ public class Plot { * @return the top corner of the plot * @deprecated in favor of getCorners()[1]; */ + // Won't remove as suggestion also points to deprecated method @Deprecated public Location getTop() { return this.getCorners()[1]; } diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java index a31a5de14..98d41cbef 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/object/PlotPlayer.java @@ -300,10 +300,6 @@ public abstract class PlotPlayer implements CommandCaller, OfflinePlotPlayer { //////////////////////////////////////////////// - @Deprecated public long getPreviousLogin() { - return getLastPlayed(); - } - /** * Get this player's full location (including yaw/pitch) * diff --git a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java index 4eea4e801..784024c95 100644 --- a/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java +++ b/Core/src/main/java/com/github/intellectualsites/plotsquared/plot/util/MainUtil.java @@ -43,19 +43,6 @@ public class MainUtil { public static short[][][] CACHE_I = null; public static short[][][] CACHE_J = null; - /** - * @param location - * @return - * @deprecated - */ - @Deprecated public static PlotId getPlotId(Location location) { - PlotArea area = location.getPlotArea(); - return area == null ? - null : - area.getPlotManager() - .getPlotId(area, location.getX(), location.getY(), location.getZ()); - } - /** * This cache is used for world generation and just saves a bit of calculation time when checking if something is in the plot area. */