+ *
* @version 3.3.3
*/
public class PlotAPI {
/**
* Deprecated, does nothing.
+ *
* @param plugin not needed
* @deprecated Not needed
*/
- @Deprecated
- public PlotAPI(JavaPlugin plugin) {}
+ @Deprecated public PlotAPI(JavaPlugin plugin) {
+ }
- public PlotAPI(){}
+ public PlotAPI() {
+ }
/**
* Get all plots.
*
* @return all plots
- *
* @see PS#getPlots()
*/
public Set getAllPlots() {
@@ -74,7 +63,6 @@ public class PlotAPI {
* Return all plots for a player.
*
* @param player Player, whose plots to search for
- *
* @return all plots that a player owns
*/
public Set getPlayerPlots(Player player) {
@@ -93,8 +81,8 @@ public class PlotAPI {
/**
* Returns the PlotSquared configurations file.
- * @return main configuration
*
+ * @return main configuration
* @see PS#config
*/
public YamlConfiguration getConfig() {
@@ -103,8 +91,8 @@ public class PlotAPI {
/**
* Get the PlotSquared storage file.
- * @return storage configuration
*
+ * @return storage configuration
* @see PS#storage
*/
public YamlConfiguration getStorage() {
@@ -115,7 +103,6 @@ public class PlotAPI {
* Get the main class for this plugin. Only use this if you really need it.
*
* @return PlotSquared PlotSquared Main Class
- *
* @see PS
*/
public PS getMain() {
@@ -125,15 +112,14 @@ public class PlotAPI {
/**
* ChunkManager class contains several useful methods.
*
- *
Chunk deletion
- *
Moving or copying regions
- *
Plot swapping
- *
Entity Tracking
- *
Region Regeneration
+ *
Chunk deletion
+ *
Moving or copying regions
+ *
Plot swapping
+ *
Entity Tracking
+ *
Region Regeneration
*
*
* @return ChunkManager
- *
* @see ChunkManager
*/
public ChunkManager getChunkManager() {
@@ -142,6 +128,7 @@ public class PlotAPI {
/**
* Get the block/biome set queue
+ *
* @return GlobalBlockQueue.IMP
*/
public GlobalBlockQueue getBlockQueue() {
@@ -153,7 +140,6 @@ public class PlotAPI {
* to use the UUIDHandler class instead.
*
* @return UUIDWrapper
- *
* @see UUIDWrapper
*/
public UUIDWrapper getUUIDWrapper() {
@@ -162,14 +148,12 @@ public class PlotAPI {
/**
* Do not use this. Instead use FlagManager.[method] in your code.
- * - Flag related stuff
+ * - Flag related stuff
*
* @return FlagManager
- *
* @deprecated Use {@link FlagManager} directly
*/
- @Deprecated
- public FlagManager getFlagManager() {
+ @Deprecated public FlagManager getFlagManager() {
return new FlagManager();
}
@@ -179,8 +163,7 @@ public class PlotAPI {
* @return MainUtil
* @deprecated Use {@link MainUtil} directly
*/
- @Deprecated
- public MainUtil getMainUtil() {
+ @Deprecated public MainUtil getMainUtil() {
return new MainUtil();
}
@@ -188,12 +171,10 @@ public class PlotAPI {
* 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() {
+ @Deprecated public String[] getPermissions() {
ArrayList perms = new ArrayList<>();
for (C caption : C.values()) {
if ("static.permissions".equals(caption.getCategory())) {
@@ -208,7 +189,6 @@ public class PlotAPI {
* and writing schematics.
*
* @return SchematicHandler
- *
* @see SchematicHandler
*/
public SchematicHandler getSchematicHandler() {
@@ -221,8 +201,7 @@ public class PlotAPI {
* @return C
* @deprecated Use {@link C}
*/
- @Deprecated
- public C[] getCaptions() {
+ @Deprecated public C[] getCaptions() {
return C.values();
}
@@ -231,15 +210,11 @@ public class PlotAPI {
* 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) {
+ @SuppressWarnings("deprecation") @Deprecated public PlotManager getPlotManager(World world) {
if (world == null) {
return null;
}
@@ -248,6 +223,7 @@ public class PlotAPI {
/**
* Get a list of PlotAreas in the world.
+ *
* @param world The world to check for plot areas
* @return A set of PlotAreas
*/
@@ -263,14 +239,11 @@ public class PlotAPI {
* plot merging, clearing, and tessellation.
*
* @param world The world
- *
* @return PlotManager
- *
* @see PS#getPlotManager(Plot)
* @see PlotManager
*/
- @Deprecated
- public PlotManager getPlotManager(String world) {
+ @Deprecated public PlotManager getPlotManager(String world) {
Set areas = PS.get().getPlotAreas(world);
switch (areas.size()) {
case 0:
@@ -278,7 +251,8 @@ public class PlotAPI {
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.");
+ PS.debug(
+ "PlotAPI#getPlotManager(org.bukkit.World) is deprecated and doesn't support multi plot area worlds.");
return null;
}
}
@@ -289,15 +263,11 @@ public class PlotAPI {
* 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) {
+ @SuppressWarnings("deprecation") @Deprecated public PlotArea getWorldSettings(World world) {
if (world == null) {
return null;
}
@@ -308,14 +278,11 @@ public class PlotAPI {
* 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) {
+ @Deprecated public PlotArea getWorldSettings(String world) {
if (world == null) {
return null;
}
@@ -326,7 +293,8 @@ public class PlotAPI {
case 1:
return areas.iterator().next();
default:
- PS.debug("PlotAPI#getWorldSettings(org.bukkit.World) is deprecated and doesn't support multi plot area worlds.");
+ PS.debug(
+ "PlotAPI#getWorldSettings(org.bukkit.World) is deprecated and doesn't support multi plot area worlds.");
return null;
}
}
@@ -334,9 +302,8 @@ public class PlotAPI {
/**
* Send a message to a player.
*
- * @param player the recipient of the message
+ * @param player the recipient of the message
* @param caption the message
- *
* @see MainUtil#sendMessage(PlotPlayer, C, String...)
*/
public void sendMessage(Player player, C caption) {
@@ -348,7 +315,6 @@ public class PlotAPI {
*
* @param player the recipient of the message
* @param string the message
- *
* @see MainUtil#sendMessage(PlotPlayer, String)
*/
public void sendMessage(Player player, String string) {
@@ -359,7 +325,6 @@ public class PlotAPI {
* Send a message to the console. The message supports color codes.
*
* @param message the message
- *
* @see MainUtil#sendConsoleMessage(C, String...)
*/
public void sendConsoleMessage(String message) {
@@ -370,7 +335,6 @@ public class PlotAPI {
* Send a message to the console.
*
* @param caption the message
- *
* @see #sendConsoleMessage(String)
* @see C
*/
@@ -382,7 +346,6 @@ public class PlotAPI {
* Registers a flag for use in plots.
*
* @param flag the flag to register
- *
*/
public void addFlag(Flag> flag) {
Flags.registerFlag(flag);
@@ -392,16 +355,12 @@ public class PlotAPI {
* 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
- *
+ * @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) {
+ @SuppressWarnings("deprecation") @Deprecated public Plot getPlot(World world, int x, int z) {
if (world == null) {
return null;
}
@@ -416,9 +375,7 @@ public class PlotAPI {
* Get a plot based on the location.
*
* @param location the location to check
- *
* @return plot if found, otherwise it creates a temporary plot
- *
* @see Plot
*/
public Plot getPlot(Location location) {
@@ -432,9 +389,7 @@ public class PlotAPI {
* Get a plot based on the player location.
*
* @param player the player to check
- *
* @return plot if found, otherwise it creates a temporary plot
- *
* @see #getPlot(Location)
* @see Plot
*/
@@ -446,27 +401,24 @@ public class PlotAPI {
* Check whether or not a player has a plot.
*
* @param player Player that you want to check for
- * @param world The world to check
+ * @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) {
+ @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 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) {
+ @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())) {
@@ -485,14 +437,11 @@ public class PlotAPI {
* 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) {
+ @Deprecated public Plot[] getPlots(World world) {
if (world == null) {
return new Plot[0];
}
@@ -504,11 +453,8 @@ public class PlotAPI {
* Get all plot worlds.
*
* @return World[] - array of plot worlds
- *
*/
- @SuppressWarnings("deprecation")
- @Deprecated
- public String[] getPlotWorlds() {
+ @SuppressWarnings("deprecation") @Deprecated public String[] getPlotWorlds() {
Set plotWorldStrings = PS.get().getPlotWorldStrings();
return plotWorldStrings.toArray(new String[plotWorldStrings.size()]);
}
@@ -517,13 +463,10 @@ public class PlotAPI {
* 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) {
+ @Deprecated public boolean isPlotWorld(World world) {
return PS.get().hasPlotArea(world.getName());
}
@@ -531,29 +474,22 @@ public class PlotAPI {
* Get plot locations.
*
* @param plot Plot to get the locations for
- *
* @return [0] = bottomLc, [1] = topLoc, [2] = home
- *
- * @deprecated As merged plots may not have a rectangular shape
- *
* @see Plot
+ * @deprecated As merged plots may not have a rectangular shape
*/
- @SuppressWarnings("deprecation")
- @Deprecated
- public Location[] getLocations(Plot plot) {
+ @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};
+ return new Location[] {bukkitBottom, bukkitTop, bukkitHome};
}
/**
* Get home location.
*
* @param plot Plot that you want to get the location for
- *
* @return plot bottom location
- *
* @see Plot
*/
public Location getHomeLocation(Plot plot) {
@@ -564,16 +500,11 @@ public class PlotAPI {
* Get Bottom Location (min, min, min).
*
* @param plot Plot that you want to get the location for
- *
* @return plot bottom location
- *
- * @deprecated As merged plots may not have a rectangular shape
- *
* @see Plot
+ * @deprecated As merged plots may not have a rectangular shape
*/
- @SuppressWarnings("deprecation")
- @Deprecated
- public Location getBottomLocation(Plot plot) {
+ @SuppressWarnings("deprecation") @Deprecated public Location getBottomLocation(Plot plot) {
return BukkitUtil.getLocation(plot.getCorners()[0]);
}
@@ -581,16 +512,11 @@ public class PlotAPI {
* Get Top Location (max, max, max).
*
* @param plot Plot that you want to get the location for
- *
* @return plot top location
- *
- * @deprecated As merged plots may not have a rectangular shape
- *
* @see Plot
+ * @deprecated As merged plots may not have a rectangular shape
*/
- @SuppressWarnings("deprecation")
- @Deprecated
- public Location getTopLocation(Plot plot) {
+ @SuppressWarnings("deprecation") @Deprecated public Location getTopLocation(Plot plot) {
return BukkitUtil.getLocation(plot.getCorners()[1]);
}
@@ -598,9 +524,7 @@ public class PlotAPI {
* Check whether or not a player is in a plot.
*
* @param player who we're checking for
- *
* @return true if the player is in a plot, false if not-
- *
*/
public boolean isInPlot(Player player) {
return getPlot(player) != null;
@@ -608,12 +532,12 @@ public class PlotAPI {
/**
* Register a subcommand.
- * @deprecated Command registration is done on object creation
+ *
* @param c SubCommand, that we want to register
* @see SubCommand
+ * @deprecated Command registration is done on object creation
*/
- @Deprecated
- public void registerCommand(SubCommand c) {
+ @Deprecated public void registerCommand(SubCommand c) {
PS.debug("SubCommands are now registered on creation");
}
@@ -621,7 +545,6 @@ public class PlotAPI {
* Gets the PlotSquared class.
*
* @return PlotSquared Class
- *
* @see PS
*/
public PS getPlotSquared() {
@@ -633,9 +556,7 @@ public class PlotAPI {
*
* @param world Specify the world we want to select the plots from
* @param player Player, for whom we're getting the plot count
- *
* @return the number of plots the player has
- *
*/
public int getPlayerPlotCount(World world, Player player) {
if (world == null) {
@@ -649,11 +570,8 @@ public class PlotAPI {
*
* @param world Specify the world we want to select the plots from
* @param player Player, for whom we're getting the plots
- *
* @return a set containing the players plots
- *
* @see PS#getPlots(String, PlotPlayer)
- *
* @see Plot
*/
public Set getPlayerPlots(World world, Player player) {
@@ -667,9 +585,7 @@ public class PlotAPI {
* Gets the number of plots, which the player is able to build in.
*
* @param player player, for whom we're getting the plots
- *
* @return the number of allowed plots
- *
*/
public int getAllowedPlots(Player player) {
PlotPlayer plotPlayer = PlotPlayer.wrap(player);
@@ -680,10 +596,9 @@ public class PlotAPI {
* Gets the PlotPlayer for a player. The PlotPlayer is usually cached and
* will provide useful functions relating to players.
*
- * @see PlotPlayer#wrap(Object)
- *
* @param player the player to wrap
* @return a {@code PlotPlayer}
+ * @see PlotPlayer#wrap(Object)
*/
public PlotPlayer wrapPlayer(Player player) {
return PlotPlayer.wrap(player);
@@ -691,14 +606,13 @@ public class PlotAPI {
/**
* Get the PlotPlayer for a UUID.
- *
+ *
*
Please note that PlotSquared can be configured to provide
* different UUIDs than bukkit
*
- * @see PlotPlayer#wrap(Object)
- *
* @param uuid the uuid of the player to wrap
* @return a {@code PlotPlayer}
+ * @see PlotPlayer#wrap(Object)
*/
public PlotPlayer wrapPlayer(UUID uuid) {
return PlotPlayer.wrap(uuid);
@@ -707,10 +621,9 @@ public class PlotAPI {
/**
* Get the PlotPlayer for a username.
*
- * @see PlotPlayer#wrap(Object)
- *
* @param player the player to wrap
* @return a {@code PlotPlayer}
+ * @see PlotPlayer#wrap(Object)
*/
public PlotPlayer wrapPlayer(String player) {
return PlotPlayer.wrap(player);
@@ -718,14 +631,13 @@ public class PlotAPI {
/**
* Get the PlotPlayer for an offline player.
- *
+ *
*
Note that this will work if the player is offline, however not all
* functionality will work.
*
- * @see PlotPlayer#wrap(Object)
- *
* @param player the player to wrap
* @return a {@code PlotPlayer}
+ * @see PlotPlayer#wrap(Object)
*/
public PlotPlayer wrapPlayer(OfflinePlayer player) {
return PlotPlayer.wrap(player);
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java
index 059d65d46..d8e13d446 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java
@@ -1,7 +1,5 @@
package com.plotsquared.bukkit;
-import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
-
import com.intellectualcrafters.configuration.ConfigurationSection;
import com.intellectualcrafters.plot.IPlotMain;
import com.intellectualcrafters.plot.PS;
@@ -12,89 +10,27 @@ import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.HybridGen;
import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
-import com.intellectualcrafters.plot.object.Plot;
-import com.intellectualcrafters.plot.object.PlotArea;
-import com.intellectualcrafters.plot.object.PlotId;
-import com.intellectualcrafters.plot.object.PlotPlayer;
-import com.intellectualcrafters.plot.object.RunnableVal;
-import com.intellectualcrafters.plot.object.SetupObject;
+import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.chat.PlainChatManager;
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
-import com.intellectualcrafters.plot.util.AbstractTitle;
-import com.intellectualcrafters.plot.util.ChatManager;
-import com.intellectualcrafters.plot.util.ChunkManager;
-import com.intellectualcrafters.plot.util.ConsoleColors;
-import com.intellectualcrafters.plot.util.EconHandler;
-import com.intellectualcrafters.plot.util.EventUtil;
-import com.intellectualcrafters.plot.util.InventoryUtil;
-import com.intellectualcrafters.plot.util.MainUtil;
-import com.intellectualcrafters.plot.util.ReflectionUtils;
-import com.intellectualcrafters.plot.util.SchematicHandler;
-import com.intellectualcrafters.plot.util.SetupUtils;
-import com.intellectualcrafters.plot.util.StringMan;
-import com.intellectualcrafters.plot.util.TaskManager;
-import com.intellectualcrafters.plot.util.UUIDHandler;
-import com.intellectualcrafters.plot.util.UUIDHandlerImplementation;
-import com.intellectualcrafters.plot.util.WorldUtil;
+import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.util.block.QueueProvider;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector;
import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter;
import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
-import com.plotsquared.bukkit.listeners.ChunkListener;
-import com.plotsquared.bukkit.listeners.EntityPortal_1_7_9;
-import com.plotsquared.bukkit.listeners.EntitySpawnListener;
-import com.plotsquared.bukkit.listeners.PlayerEvents;
-import com.plotsquared.bukkit.listeners.PlayerEvents183;
-import com.plotsquared.bukkit.listeners.PlayerEvents_1_8;
-import com.plotsquared.bukkit.listeners.PlayerEvents_1_9;
-import com.plotsquared.bukkit.listeners.PlotPlusListener;
-import com.plotsquared.bukkit.listeners.PlotPlusListener_1_12;
-import com.plotsquared.bukkit.listeners.PlotPlusListener_Legacy;
-import com.plotsquared.bukkit.listeners.SingleWorldListener;
-import com.plotsquared.bukkit.listeners.WorldEvents;
+import com.plotsquared.bukkit.listeners.*;
import com.plotsquared.bukkit.titles.DefaultTitle_111;
-import com.plotsquared.bukkit.util.BukkitChatManager;
-import com.plotsquared.bukkit.util.BukkitChunkManager;
-import com.plotsquared.bukkit.util.BukkitCommand;
-import com.plotsquared.bukkit.util.BukkitEconHandler;
-import com.plotsquared.bukkit.util.BukkitEventUtil;
-import com.plotsquared.bukkit.util.BukkitHybridUtils;
-import com.plotsquared.bukkit.util.BukkitInventoryUtil;
-import com.plotsquared.bukkit.util.BukkitSchematicHandler;
-import com.plotsquared.bukkit.util.BukkitSetupUtils;
-import com.plotsquared.bukkit.util.BukkitTaskManager;
-import com.plotsquared.bukkit.util.BukkitUtil;
-import com.plotsquared.bukkit.util.BukkitVersion;
-import com.plotsquared.bukkit.util.Metrics;
-import com.plotsquared.bukkit.util.SendChunk;
-import com.plotsquared.bukkit.util.SetGenCB;
-import com.plotsquared.bukkit.util.block.BukkitLocalQueue;
-import com.plotsquared.bukkit.util.block.BukkitLocalQueue_1_7;
-import com.plotsquared.bukkit.util.block.BukkitLocalQueue_1_8;
-import com.plotsquared.bukkit.util.block.BukkitLocalQueue_1_8_3;
-import com.plotsquared.bukkit.util.block.BukkitLocalQueue_1_9;
-import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
-import com.plotsquared.bukkit.uuid.FileUUIDHandler;
-import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
-import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
-import com.plotsquared.bukkit.uuid.SQLUUIDHandler;
+import com.plotsquared.bukkit.util.*;
+import com.plotsquared.bukkit.util.block.*;
+import com.plotsquared.bukkit.uuid.*;
import com.sk89q.worldedit.WorldEdit;
-import java.io.File;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Chunk;
+import org.bukkit.*;
import org.bukkit.Location;
-import org.bukkit.OfflinePlayer;
-import org.bukkit.World;
import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@@ -107,8 +43,17 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
+import java.io.File;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
+
public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
+ public static WorldEdit worldEdit;
private static ConcurrentHashMap pluginMap;
static {
@@ -128,14 +73,15 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
iter.remove();
}
}
- Map lookupNames = (Map) lookupNamesField.get(manager);
+ Map lookupNames =
+ (Map) lookupNamesField.get(manager);
lookupNames.remove("PlotMe");
lookupNames.remove("PlotMe-DefaultGenerator");
pluginsField.set(manager, new ArrayList(plugins) {
- @Override
- public boolean add(Plugin plugin) {
+ @Override public boolean add(Plugin plugin) {
if (plugin.getName().startsWith("PlotMe")) {
- System.out.print("Disabling `" + plugin.getName() + "` for PlotMe conversion (configure in PlotSquared settings.yml)");
+ System.out.print("Disabling `" + plugin.getName()
+ + "` for PlotMe conversion (configure in PlotSquared settings.yml)");
} else {
return super.add(plugin);
}
@@ -143,8 +89,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
});
pluginMap = new ConcurrentHashMap(lookupNames) {
- @Override
- public Plugin put(String key, Plugin plugin) {
+ @Override public Plugin put(String key, Plugin plugin) {
if (!plugin.getName().startsWith("PlotMe")) {
return super.put(key, plugin);
}
@@ -153,17 +98,17 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
};
lookupNamesField.set(manager, pluginMap);
}
- } catch (Throwable ignore) {}
+ } catch (Throwable ignore) {
+ }
}
- public static WorldEdit worldEdit;
-
private int[] version;
private String name;
private SingleWorldListener singleWorldListener;
+ private Method methodUnloadChunk0;
+ private boolean methodUnloadSetup = false;
- @Override
- public int[] getServerVersion() {
+ @Override public int[] getServerVersion() {
if (this.version == null) {
try {
this.version = new int[3];
@@ -177,14 +122,13 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
e.printStackTrace();
PS.debug(StringMan.getString(Bukkit.getBukkitVersion()));
PS.debug(StringMan.getString(Bukkit.getBukkitVersion().split("-")[0].split("\\.")));
- return new int[]{1, 13, 0};
+ return new int[] {1, 13, 0};
}
}
return this.version;
}
- @Override
- public void onEnable() {
+ @Override public void onEnable() {
if (pluginMap != null) {
pluginMap.put("PlotMe-DefaultGenerator", this);
}
@@ -199,8 +143,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
if (Settings.Enabled_Components.WORLDS) {
TaskManager.IMP.taskRepeat(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
unload();
}
}, 20);
@@ -216,15 +159,13 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return singleWorldListener;
}
- private Method methodUnloadChunk0;
- private boolean methodUnloadSetup = false;
-
public void unload() {
if (!methodUnloadSetup) {
methodUnloadSetup = true;
try {
ReflectionUtils.RefClass classCraftWorld = getRefClass("{cb}.CraftWorld");
- methodUnloadChunk0 = classCraftWorld.getRealClass().getDeclaredMethod("unloadChunk0", int.class, int.class, boolean.class);
+ methodUnloadChunk0 = classCraftWorld.getRealClass()
+ .getDeclaredMethod("unloadChunk0", int.class, int.class, boolean.class);
methodUnloadChunk0.setAccessible(true);
} catch (Throwable ignore) {
ignore.printStackTrace();
@@ -238,7 +179,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
for (World world : Bukkit.getWorlds()) {
String name = world.getName();
char char0 = name.charAt(0);
- if (!Character.isDigit(char0) && char0 != '-') continue;
+ if (!Character.isDigit(char0) && char0 != '-')
+ continue;
if (!world.getPlayers().isEmpty()) {
continue;
}
@@ -265,19 +207,22 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
boolean result;
if (methodUnloadChunk0 != null) {
try {
- result = (boolean) methodUnloadChunk0.invoke(world, chunkI.getX(), chunkI.getZ(), true);
+ result = (boolean) methodUnloadChunk0
+ .invoke(world, chunkI.getX(), chunkI.getZ(), true);
} catch (Throwable e) {
methodUnloadChunk0 = null;
e.printStackTrace();
continue outer;
}
} else {
- result = world.unloadChunk(chunkI.getX(), chunkI.getZ(), true, false);
+ result = world
+ .unloadChunk(chunkI.getX(), chunkI.getZ(), true, false);
}
if (!result) {
continue outer;
}
- } while (index < chunks.length && System.currentTimeMillis() - start < 5);
+ } while (index < chunks.length
+ && System.currentTimeMillis() - start < 5);
return;
}
}
@@ -287,14 +232,12 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
}
- @Override
- public void onDisable() {
+ @Override public void onDisable() {
PS.get().disable();
Bukkit.getScheduler().cancelTasks(this);
}
- @Override
- public void log(String message) {
+ @Override public void log(String message) {
try {
message = C.color(message);
if (!Settings.Chat.CONSOLE_COLOR) {
@@ -306,32 +249,29 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
}
- @Override
- public void disable() {
+ @Override public void disable() {
onDisable();
}
- @Override
- public int[] getPluginVersion() {
+ @Override public int[] getPluginVersion() {
String ver = getDescription().getVersion();
if (ver.contains("-")) {
ver = ver.split("-")[0];
}
String[] split = ver.split("\\.");
- return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])};
+ return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1]),
+ Integer.parseInt(split[2])};
}
@Override public String getPluginVersionString() {
return getDescription().getVersion();
}
- @Override
- public String getPluginName() {
+ @Override public String getPluginName() {
return name;
}
- @Override
- public void registerCommands() {
+ @Override public void registerCommands() {
BukkitCommand bukkitCommand = new BukkitCommand();
PluginCommand plotCommand = getCommand("plots");
plotCommand.setExecutor(bukkitCommand);
@@ -339,30 +279,24 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
plotCommand.setTabCompleter(bukkitCommand);
}
- @Override
- public File getDirectory() {
+ @Override public File getDirectory() {
return getDataFolder();
}
- @Override
- public File getWorldContainer() {
+ @Override public File getWorldContainer() {
return Bukkit.getWorldContainer();
}
- @Override
- public TaskManager getTaskManager() {
+ @Override public TaskManager getTaskManager() {
return new BukkitTaskManager(this);
}
- @Override
- public void runEntityTask() {
+ @Override public void runEntityTask() {
PS.log(C.PREFIX + "KillAllEntities started.");
TaskManager.runTaskRepeat(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
PS.get().foreachPlotArea(new RunnableVal() {
- @Override
- public void run(PlotArea plotArea) {
+ @Override public void run(PlotArea plotArea) {
World world = Bukkit.getWorld(plotArea.worldname);
try {
if (world == null) {
@@ -416,7 +350,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case MINECART_TNT:
case BOAT:
if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
- com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation());
+ com.intellectualcrafters.plot.object.Location location =
+ BukkitUtil.getLocation(entity.getLocation());
Plot plot = location.getPlot();
if (plot == null) {
if (location.isPlotArea()) {
@@ -503,10 +438,13 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
Location location = entity.getLocation();
if (BukkitUtil.getLocation(location).isPlotRoad()) {
if (entity instanceof LivingEntity) {
- LivingEntity livingEntity = (LivingEntity) entity;
- if (!livingEntity.isLeashed() || !entity.hasMetadata("keep")) {
+ LivingEntity livingEntity =
+ (LivingEntity) entity;
+ if (!livingEntity.isLeashed() || !entity
+ .hasMetadata("keep")) {
Entity passenger = entity.getPassenger();
- if (!(passenger instanceof Player) && entity.getMetadata("keep").isEmpty()) {
+ if (!(passenger instanceof Player) && entity
+ .getMetadata("keep").isEmpty()) {
iterator.remove();
entity.remove();
continue;
@@ -514,7 +452,8 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
} else {
Entity passenger = entity.getPassenger();
- if (!(passenger instanceof Player) && entity.getMetadata("keep").isEmpty()) {
+ if (!(passenger instanceof Player) && entity
+ .getMetadata("keep").isEmpty()) {
iterator.remove();
entity.remove();
continue;
@@ -529,18 +468,28 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
LivingEntity livingEntity = (LivingEntity) entity;
List meta = entity.getMetadata("plot");
if (meta != null && !meta.isEmpty()) {
- if (livingEntity.isLeashed()) continue;
+ if (livingEntity.isLeashed())
+ continue;
- List keep = entity.getMetadata("keep");
- if (keep != null && !keep.isEmpty()) continue;
+ List keep =
+ entity.getMetadata("keep");
+ if (keep != null && !keep.isEmpty())
+ continue;
- PlotId originalPlotId = (PlotId) meta.get(0).value();
+ PlotId originalPlotId =
+ (PlotId) meta.get(0).value();
if (originalPlotId != null) {
- com.intellectualcrafters.plot.object.Location pLoc = BukkitUtil.getLocation(entity.getLocation());
+ com.intellectualcrafters.plot.object.Location
+ pLoc = BukkitUtil
+ .getLocation(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
- PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
- if (!originalPlotId.equals(currentPlotId) && (currentPlotId == null || !area.getPlot(originalPlotId).equals(area.getPlot(currentPlotId)))) {
+ PlotId currentPlotId =
+ PlotId.of(area.getPlotAbs(pLoc));
+ if (!originalPlotId.equals(currentPlotId)
+ && (currentPlotId == null || !area
+ .getPlot(originalPlotId)
+ .equals(area.getPlot(currentPlotId)))) {
iterator.remove();
entity.remove();
}
@@ -548,12 +497,17 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
} else {
//This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
- com.intellectualcrafters.plot.object.Location pLoc = BukkitUtil.getLocation(entity.getLocation());
+ com.intellectualcrafters.plot.object.Location pLoc =
+ BukkitUtil.getLocation(entity.getLocation());
PlotArea area = pLoc.getPlotArea();
if (area != null) {
- PlotId currentPlotId = PlotId.of(area.getPlotAbs(pLoc));
+ PlotId currentPlotId =
+ PlotId.of(area.getPlotAbs(pLoc));
if (currentPlotId != null) {
- entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, currentPlotId));
+ entity.setMetadata("plot",
+ new FixedMetadataValue(
+ (Plugin) PS.get().IMP,
+ currentPlotId));
}
}
}
@@ -571,8 +525,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}, 20);
}
- @Override
- public final ChunkGenerator getDefaultWorldGenerator(String world, String id) {
+ @Override public final ChunkGenerator getDefaultWorldGenerator(String world, String id) {
if (Settings.Enabled_Components.PLOTME_CONVERTER) {
initPlotMeConverter();
Settings.Enabled_Components.PLOTME_CONVERTER = false;
@@ -589,8 +542,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return (ChunkGenerator) result.specify(world);
}
- @Override
- public void registerPlayerEvents() {
+ @Override public void registerPlayerEvents() {
PlayerEvents main = new PlayerEvents();
getServer().getPluginManager().registerEvents(main, this);
try {
@@ -630,13 +582,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
}
- @Override
- public void registerInventoryEvents() {
+ @Override public void registerInventoryEvents() {
// Part of PlayerEvents - can be moved if necessary
}
- @Override
- public void registerPlotPlusEvents() {
+ @Override public void registerPlotPlusEvents() {
PlotPlusListener.startRunnable(this);
getServer().getPluginManager().registerEvents(new PlotPlusListener(), this);
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_12_0)) {
@@ -646,12 +596,10 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
}
- @Override
- public void registerForceFieldEvents() {
+ @Override public void registerForceFieldEvents() {
}
- @Override
- public boolean initWorldEdit() {
+ @Override public boolean initWorldEdit() {
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
worldEdit = WorldEdit.getInstance();
return true;
@@ -659,8 +607,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return false;
}
- @Override
- public EconHandler getEconomyHandler() {
+ @Override public EconHandler getEconomyHandler() {
try {
BukkitEconHandler econ = new BukkitEconHandler();
if (econ.init()) {
@@ -672,16 +619,16 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return null;
}
- @Override
- public QueueProvider initBlockQueue() {
+ @Override public QueueProvider initBlockQueue() {
try {
new SendChunk();
MainUtil.canSendChunk = true;
} catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
- PS.debug(SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
+ PS.debug(
+ SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
MainUtil.canSendChunk = false;
}
- if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_13_0)) {
+ if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_13_0)) {
return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
}
if (PS.get().checkVersion(getServerVersion(), BukkitVersion.v1_9_0)) {
@@ -696,13 +643,11 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return QueueProvider.of(BukkitLocalQueue_1_7.class, BukkitLocalQueue.class);
}
- @Override
- public WorldUtil initWorldUtil() {
+ @Override public WorldUtil initWorldUtil() {
return new BukkitUtil();
}
- @Override
- public boolean initPlotMeConverter() {
+ @Override public boolean initPlotMeConverter() {
if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) {
return true;
} else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) {
@@ -711,8 +656,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return false;
}
- @Override
- public GeneratorWrapper> getGenerator(String world, String name) {
+ @Override public GeneratorWrapper> getGenerator(String world, String name) {
if (name == null) {
return null;
}
@@ -728,23 +672,21 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
}
- @Override
- public HybridUtils initHybridUtils() {
+ @Override public HybridUtils initHybridUtils() {
return new BukkitHybridUtils();
}
- @Override
- public SetupUtils initSetupUtils() {
+ @Override public SetupUtils initSetupUtils() {
return new BukkitSetupUtils();
}
- @Override
- public UUIDHandlerImplementation initUUIDHandler() {
+ @Override public UUIDHandlerImplementation initUUIDHandler() {
boolean checkVersion = false;
try {
OfflinePlayer.class.getDeclaredMethod("getUniqueId");
checkVersion = true;
- } catch (Throwable ignore) {}
+ } catch (Throwable ignore) {
+ }
UUIDWrapper wrapper;
if (Settings.UUID.OFFLINE) {
if (Settings.UUID.FORCE_LOWERCASE) {
@@ -765,18 +707,20 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
Settings.UUID.OFFLINE = true;
}
if (!checkVersion) {
- PS.log(C.PREFIX + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
+ PS.log(C.PREFIX
+ + " &c[WARN] Titles are disabled - please update your version of Bukkit to support this feature.");
Settings.TITLES = false;
} else {
AbstractTitle.TITLE_CLASS = new DefaultTitle_111();
- if (wrapper instanceof DefaultUUIDWrapper || wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
+ if (wrapper instanceof DefaultUUIDWrapper
+ || wrapper.getClass() == OfflineUUIDWrapper.class && !Bukkit.getOnlineMode()) {
Settings.UUID.NATIVE_UUID_PROVIDER = true;
}
}
if (Settings.UUID.OFFLINE) {
- PS.log(C.PREFIX
- + " &6" + getPluginName() + " is using Offline Mode UUIDs either because of user preference, or because you are using an old version of "
- + "Bukkit");
+ PS.log(C.PREFIX + " &6" + getPluginName()
+ + " is using Offline Mode UUIDs either because of user preference, or because you are using an old version of "
+ + "Bukkit");
} else {
PS.log(C.PREFIX + " &6" + getPluginName() + " is using online UUIDs");
}
@@ -787,53 +731,45 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
}
- @Override
- public ChunkManager initChunkManager() {
+ @Override public ChunkManager initChunkManager() {
return new BukkitChunkManager();
}
- @Override
- public EventUtil initEventUtil() {
+ @Override public EventUtil initEventUtil() {
return new BukkitEventUtil();
}
- @Override
- public void unregister(PlotPlayer player) {
+ @Override public void unregister(PlotPlayer player) {
BukkitUtil.removePlayer(player.getName());
}
- @Override
- public void registerChunkProcessor() {
+ @Override public void registerChunkProcessor() {
getServer().getPluginManager().registerEvents(new ChunkListener(), this);
}
- @Override
- public void registerWorldEvents() {
+ @Override public void registerWorldEvents() {
getServer().getPluginManager().registerEvents(new WorldEvents(), this);
}
- @Override
- public IndependentPlotGenerator getDefaultGenerator() {
+ @Override public IndependentPlotGenerator getDefaultGenerator() {
return new HybridGen();
}
- @Override
- public InventoryUtil initInventoryUtil() {
+ @Override public InventoryUtil initInventoryUtil() {
return new BukkitInventoryUtil();
}
- @Override
- public void startMetrics() {
+ @Override public void startMetrics() {
new Metrics(this).start();
PS.log(C.PREFIX + "&6Metrics enabled.");
}
- @Override
- public void setGenerator(String worldName) {
+ @Override public void setGenerator(String worldName) {
World world = BukkitUtil.getWorld(worldName);
if (world == null) {
// create world
- ConfigurationSection worldConfig = PS.get().worlds.getConfigurationSection("worlds." + worldName);
+ ConfigurationSection worldConfig =
+ PS.get().worlds.getConfigurationSection("worlds." + worldName);
String manager = worldConfig.getString("generator.plugin", getPluginName());
SetupObject setup = new SetupObject();
setup.plotManager = manager;
@@ -865,19 +801,16 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
}
}
- @Override
- public SchematicHandler initSchematicHandler() {
+ @Override public SchematicHandler initSchematicHandler() {
return new BukkitSchematicHandler();
}
- @Override
- public AbstractTitle initTitleManager() {
+ @Override public AbstractTitle initTitleManager() {
// Already initialized in UUID handler
return AbstractTitle.TITLE_CLASS;
}
- @Override
- public PlotPlayer wrapPlayer(Object player) {
+ @Override public PlotPlayer wrapPlayer(Object player) {
if (player instanceof Player) {
return BukkitUtil.getPlayer((Player) player);
}
@@ -893,14 +826,12 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return null;
}
- @Override
- public String getNMSPackage() {
+ @Override public String getNMSPackage() {
String name = Bukkit.getServer().getClass().getPackage().getName();
return name.substring(name.lastIndexOf('.') + 1);
}
- @Override
- public ChatManager> initChatManager() {
+ @Override public ChatManager> initChatManager() {
if (Settings.Chat.INTERACTIVE) {
return new BukkitChatManager();
} else {
@@ -913,12 +844,12 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
return new BukkitPlotGenerator(generator);
}
- @Override
- public List getPluginIds() {
+ @Override public List getPluginIds() {
ArrayList names = new ArrayList<>();
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
- names.add(plugin.getName() + ';' + plugin.getDescription().getVersion() + ':' + plugin.isEnabled());
+ names.add(plugin.getName() + ';' + plugin.getDescription().getVersion() + ':' + plugin
+ .isEnabled());
}
return names;
}
-}
\ No newline at end of file
+}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/ArrayWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/ArrayWrapper.java
index 2dd68fa4e..269588f01 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/ArrayWrapper.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/ArrayWrapper.java
@@ -19,6 +19,8 @@ import java.util.Collection;
*/
public final class ArrayWrapper {
+ private E[] _array;
+
/**
* Creates an array wrapper with some elements.
*
@@ -28,7 +30,38 @@ public final class ArrayWrapper {
setArray(elements);
}
- private E[] _array;
+ /**
+ * Converts an iterable element collection to an array of elements.
+ * The iteration order of the specified object will be used as the array element order.
+ *
+ * @param list The iterable of objects which will be converted to an array.
+ * @param c The type of the elements of the array.
+ * @return An array of elements in the specified iterable.
+ */
+ @SuppressWarnings("unchecked") public static T[] toArray(Iterable extends T> list,
+ Class c) {
+ int size = -1;
+ if (list instanceof Collection>) {
+ @SuppressWarnings("rawtypes") Collection coll = (Collection) list;
+ size = coll.size();
+ }
+
+
+ if (size < 0) {
+ size = 0;
+ // Ugly hack: Count it ourselves
+ for (@SuppressWarnings("unused") T element : list) {
+ size++;
+ }
+ }
+
+ T[] result = (T[]) Array.newInstance(c, size);
+ int i = 0;
+ for (T element : list) { // Assumes iteration order is consistent
+ result[i++] = element; // Assign array element at index THEN increment counter
+ }
+ return result;
+ }
/**
* Retrieves a reference to the wrapped array instance.
@@ -54,9 +87,7 @@ public final class ArrayWrapper {
*
* @see Arrays#equals(Object[], Object[])
*/
- @SuppressWarnings("rawtypes")
- @Override
- public boolean equals(Object other) {
+ @SuppressWarnings("rawtypes") @Override public boolean equals(Object other) {
if (!(other instanceof ArrayWrapper)) {
return false;
}
@@ -69,43 +100,8 @@ public final class ArrayWrapper {
* @return This object's hash code.
* @see Arrays#hashCode(Object[])
*/
- @Override
- public int hashCode() {
+ @Override public int hashCode() {
return Arrays.hashCode(_array);
}
- /**
- * Converts an iterable element collection to an array of elements.
- * The iteration order of the specified object will be used as the array element order.
- *
- * @param list The iterable of objects which will be converted to an array.
- * @param c The type of the elements of the array.
- * @return An array of elements in the specified iterable.
- */
- @SuppressWarnings("unchecked")
- public static T[] toArray(Iterable extends T> list, Class c) {
- int size = -1;
- if (list instanceof Collection>) {
- @SuppressWarnings("rawtypes")
- Collection coll = (Collection) list;
- size = coll.size();
- }
-
-
- if (size < 0) {
- size = 0;
- // Ugly hack: Count it ourselves
- for (@SuppressWarnings("unused") T element : list) {
- size++;
- }
- }
-
- T[] result = (T[]) Array.newInstance(c, size);
- int i = 0;
- for (T element : list) { // Assumes iteration order is consistent
- result[i++] = element; // Assign array element at index THEN increment counter
- }
- return result;
- }
-
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java
index 0f1b0d529..544713a9c 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java
@@ -1,17 +1,11 @@
package com.plotsquared.bukkit.chat;
-import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
-
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonWriter;
-import org.bukkit.Achievement;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.Material;
-import org.bukkit.Statistic;
+import org.bukkit.*;
import org.bukkit.Statistic.Type;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
@@ -22,19 +16,12 @@ import org.bukkit.inventory.ItemStack;
import java.io.IOException;
import java.io.StringWriter;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
+import java.lang.reflect.*;
+import java.util.*;
import java.util.logging.Level;
+import static com.plotsquared.bukkit.chat.TextualComponent.rawText;
+
/**
* Represents a formattable message. Such messages can use elements such as colors, formatting codes, hover and click data, and other features provided by the vanilla Minecraft JSON message formatter.
* This class allows plugins to emulate the functionality of the vanilla Minecraft tellraw command.
@@ -45,7 +32,14 @@ import java.util.logging.Level;
* optionally initializing it with text. Further property-setting method calls will affect that editing component.
*
*/
-public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable, ConfigurationSerializable {
+public class FancyMessage
+ implements JsonRepresentedObject, Cloneable, Iterable, ConfigurationSerializable {
+
+ private static Constructor> nmsPacketPlayOutChatConstructor;
+ // The ChatSerializer's instance of Gson
+ private static Object nmsChatSerializerGsonInstance;
+ private static Method fromJsonMethod;
+ private static JsonParser _stringParser = new JsonParser();
static {
ConfigurationSerialization.registerClass(FancyMessage.class);
@@ -55,20 +49,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
private String jsonString;
private boolean dirty;
- private static Constructor> nmsPacketPlayOutChatConstructor;
-
- @Override
- public FancyMessage clone() throws CloneNotSupportedException {
- FancyMessage instance = (FancyMessage) super.clone();
- instance.messageParts = new ArrayList<>(messageParts.size());
- for (int i = 0; i < messageParts.size(); i++) {
- instance.messageParts.add(i, messageParts.get(i).clone());
- }
- instance.dirty = false;
- instance.jsonString = null;
- return instance;
- }
-
/**
* Creates a JSON message with text.
*
@@ -85,10 +65,12 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
dirty = false;
if (nmsPacketPlayOutChatConstructor == null) {
try {
- nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
+ nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
+ .getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
nmsPacketPlayOutChatConstructor.setAccessible(true);
} catch (NoSuchMethodException e) {
- Bukkit.getLogger().log(Level.SEVERE, "Could not find Minecraft method or constructor.", e);
+ Bukkit.getLogger()
+ .log(Level.SEVERE, "Could not find Minecraft method or constructor.", e);
} catch (SecurityException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not access constructor.", e);
}
@@ -102,6 +84,112 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
this((TextualComponent) null);
}
+ /**
+ * Deserializes a JSON-represented message from a mapping of key-value pairs.
+ * This is called by the Bukkit serialization API.
+ * It is not intended for direct public API consumption.
+ *
+ * @param serialized The key-value mapping which represents a fancy message.
+ */
+ @SuppressWarnings("unchecked") public static FancyMessage deserialize(
+ Map serialized) {
+ FancyMessage msg = new FancyMessage();
+ msg.messageParts = (List) serialized.get("messageParts");
+ msg.jsonString = serialized.containsKey("JSON") ? serialized.get("JSON").toString() : null;
+ msg.dirty = !serialized.containsKey("JSON");
+ return msg;
+ }
+
+ /**
+ * Deserializes a fancy message from its JSON representation. This JSON representation is of the format of
+ * that returned by {@link #toJSONString()}, and is compatible with vanilla inputs.
+ *
+ * @param json The JSON string which represents a fancy message.
+ * @return A {@code FancyMessage} representing the parameterized JSON message.
+ */
+ public static FancyMessage deserialize(String json) {
+ JsonObject serialized = _stringParser.parse(json).getAsJsonObject();
+ JsonArray extra = serialized.getAsJsonArray("extra"); // Get the extra component
+ FancyMessage returnVal = new FancyMessage();
+ returnVal.messageParts.clear();
+ for (JsonElement mPrt : extra) {
+ MessagePart component = new MessagePart();
+ JsonObject messagePart = mPrt.getAsJsonObject();
+ for (Map.Entry entry : messagePart.entrySet()) {
+ // Deserialize text
+ if (TextualComponent.isTextKey(entry.getKey())) {
+ // The map mimics the YAML serialization, which has a "key" field and one or more "value" fields
+ Map serializedMapForm =
+ new HashMap<>(); // Must be object due to Bukkit serializer API compliance
+ serializedMapForm.put("key", entry.getKey());
+ if (entry.getValue().isJsonPrimitive()) {
+ // Assume string
+ serializedMapForm.put("value", entry.getValue().getAsString());
+ } else {
+ // Composite object, but we assume each element is a string
+ for (Map.Entry compositeNestedElement : entry
+ .getValue().getAsJsonObject().entrySet()) {
+ serializedMapForm.put("value." + compositeNestedElement.getKey(),
+ compositeNestedElement.getValue().getAsString());
+ }
+ }
+ component.text = TextualComponent.deserialize(serializedMapForm);
+ } else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) {
+ if (entry.getValue().getAsBoolean()) {
+ component.styles
+ .add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
+ }
+ } else if (entry.getKey().equals("color")) {
+ component.color =
+ ChatColor.valueOf(entry.getValue().getAsString().toUpperCase());
+ } else if (entry.getKey().equals("clickEvent")) {
+ JsonObject object = entry.getValue().getAsJsonObject();
+ component.clickActionName = object.get("action").getAsString();
+ component.clickActionData = object.get("value").getAsString();
+ } else if (entry.getKey().equals("hoverEvent")) {
+ JsonObject object = entry.getValue().getAsJsonObject();
+ component.hoverActionName = object.get("action").getAsString();
+ if (object.get("value").isJsonPrimitive()) {
+ // Assume string
+ component.hoverActionData =
+ new JsonString(object.get("value").getAsString());
+ } else {
+ // Assume composite type
+ // The only composite type we currently store is another FancyMessage
+ // Therefore, recursion time!
+ component.hoverActionData = deserialize(object.get("value").toString() /* This should properly serialize the JSON object as a JSON string */);
+ }
+ } else if (entry.getKey().equals("insertion")) {
+ component.insertionData = entry.getValue().getAsString();
+ } else if (entry.getKey().equals("with")) {
+ for (JsonElement object : entry.getValue().getAsJsonArray()) {
+ if (object.isJsonPrimitive()) {
+ component.translationReplacements
+ .add(new JsonString(object.getAsString()));
+ } else {
+ // Only composite type stored in this array is - again - FancyMessages
+ // Recurse within this function to parse this as a translation replacement
+ component.translationReplacements.add(deserialize(object.toString()));
+ }
+ }
+ }
+ }
+ returnVal.messageParts.add(component);
+ }
+ return returnVal;
+ }
+
+ @Override public FancyMessage clone() throws CloneNotSupportedException {
+ FancyMessage instance = (FancyMessage) super.clone();
+ instance.messageParts = new ArrayList<>(messageParts.size());
+ for (int i = 0; i < messageParts.size(); i++) {
+ instance.messageParts.add(i, messageParts.get(i).clone());
+ }
+ instance.dirty = false;
+ instance.jsonString = null;
+ return instance;
+ }
+
/**
* Sets the text of the current editing component to a value.
*
@@ -242,8 +330,12 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
*/
public FancyMessage achievementTooltip(final Achievement which) {
try {
- Object achievement = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement", Achievement.class).invoke(null, which);
- return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name").get(achievement));
+ Object achievement = Reflection
+ .getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSAchievement",
+ Achievement.class).invoke(null, which);
+ return achievementTooltip(
+ (String) Reflection.getField(Reflection.getNMSClass("Achievement"), "name")
+ .get(achievement));
} catch (IllegalAccessException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
return this;
@@ -251,7 +343,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
return this;
} catch (InvocationTargetException e) {
- Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
+ Bukkit.getLogger()
+ .log(Level.WARNING, "A error has occurred during invoking of method.", e);
return this;
}
}
@@ -267,11 +360,16 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
public FancyMessage statisticTooltip(final Statistic which) {
Type type = which.getType();
if (type != Type.UNTYPED) {
- throw new IllegalArgumentException("That statistic requires an additional " + type + " parameter!");
+ throw new IllegalArgumentException(
+ "That statistic requires an additional " + type + " parameter!");
}
try {
- Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic", Statistic.class).invoke(null, which);
- return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
+ Object statistic = Reflection
+ .getMethod(Reflection.getOBCClass("CraftStatistic"), "getNMSStatistic",
+ Statistic.class).invoke(null, which);
+ return achievementTooltip(
+ (String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name")
+ .get(statistic));
} catch (IllegalAccessException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
return this;
@@ -279,7 +377,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
return this;
} catch (InvocationTargetException e) {
- Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
+ Bukkit.getLogger()
+ .log(Level.WARNING, "A error has occurred during invoking of method.", e);
return this;
}
}
@@ -299,11 +398,16 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
throw new IllegalArgumentException("That statistic needs no additional parameter!");
}
if ((type == Type.BLOCK && item.isBlock()) || type == Type.ENTITY) {
- throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
+ throw new IllegalArgumentException(
+ "Wrong parameter type for that statistic - needs " + type + "!");
}
try {
- Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic", Statistic.class, Material.class).invoke(null, which, item);
- return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
+ Object statistic = Reflection
+ .getMethod(Reflection.getOBCClass("CraftStatistic"), "getMaterialStatistic",
+ Statistic.class, Material.class).invoke(null, which, item);
+ return achievementTooltip(
+ (String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name")
+ .get(statistic));
} catch (IllegalAccessException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
return this;
@@ -311,7 +415,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
return this;
} catch (InvocationTargetException e) {
- Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
+ Bukkit.getLogger()
+ .log(Level.WARNING, "A error has occurred during invoking of method.", e);
return this;
}
}
@@ -331,11 +436,16 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
throw new IllegalArgumentException("That statistic needs no additional parameter!");
}
if (type != Type.ENTITY) {
- throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
+ throw new IllegalArgumentException(
+ "Wrong parameter type for that statistic - needs " + type + "!");
}
try {
- Object statistic = Reflection.getMethod(Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic", Statistic.class, EntityType.class).invoke(null, which, entity);
- return achievementTooltip((String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name").get(statistic));
+ Object statistic = Reflection
+ .getMethod(Reflection.getOBCClass("CraftStatistic"), "getEntityStatistic",
+ Statistic.class, EntityType.class).invoke(null, which, entity);
+ return achievementTooltip(
+ (String) Reflection.getField(Reflection.getNMSClass("Statistic"), "name")
+ .get(statistic));
} catch (IllegalAccessException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
return this;
@@ -343,7 +453,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
return this;
} catch (InvocationTargetException e) {
- Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
+ Bukkit.getLogger()
+ .log(Level.WARNING, "A error has occurred during invoking of method.", e);
return this;
}
}
@@ -356,7 +467,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
* @return This builder instance.
*/
public FancyMessage itemTooltip(final String itemJSON) {
- onHover("show_item", new JsonString(itemJSON)); // Seems a bit hacky, considering we have a JSON object as a parameter
+ onHover("show_item", new JsonString(
+ itemJSON)); // Seems a bit hacky, considering we have a JSON object as a parameter
return this;
}
@@ -369,8 +481,13 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
*/
public FancyMessage itemTooltip(final ItemStack itemStack) {
try {
- Object nmsItem = Reflection.getMethod(Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy", ItemStack.class).invoke(null, itemStack);
- return itemTooltip(Reflection.getMethod(Reflection.getNMSClass("ItemStack"), "save", Reflection.getNMSClass("NBTTagCompound")).invoke(nmsItem, Reflection.getNMSClass("NBTTagCompound").newInstance()).toString());
+ Object nmsItem = Reflection
+ .getMethod(Reflection.getOBCClass("inventory.CraftItemStack"), "asNMSCopy",
+ ItemStack.class).invoke(null, itemStack);
+ return itemTooltip(Reflection.getMethod(Reflection.getNMSClass("ItemStack"), "save",
+ Reflection.getNMSClass("NBTTagCompound"))
+ .invoke(nmsItem, Reflection.getNMSClass("NBTTagCompound").newInstance())
+ .toString());
} catch (Exception e) {
e.printStackTrace();
return this;
@@ -400,6 +517,22 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
tooltip(com.plotsquared.bukkit.chat.ArrayWrapper.toArray(lines, String.class));
return this;
}
+ /*
+
+ /**
+ * If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message.
+ * @param replacements The replacements, in order, that will be used in the language-specific message.
+ * @return This builder instance.
+ */ /* ------------
+ public FancyMessage translationReplacements(final Iterable extends CharSequence> replacements){
+ for(CharSequence str : replacements){
+ latest().translationReplacements.add(new JsonString(str));
+ }
+
+ return this;
+ }
+
+ */
/**
* Set the behavior of the current editing component to display raw text when the client hovers over the text.
@@ -453,15 +586,19 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
}
FancyMessage result = new FancyMessage();
- result.messageParts.clear(); // Remove the one existing text component that exists by default, which destabilizes the object
+ result.messageParts
+ .clear(); // Remove the one existing text component that exists by default, which destabilizes the object
for (int i = 0; i < lines.length; i++) {
try {
for (MessagePart component : lines[i]) {
if (component.clickActionData != null && component.clickActionName != null) {
- throw new IllegalArgumentException("The tooltip text cannot have click data.");
- } else if (component.hoverActionData != null && component.hoverActionName != null) {
- throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
+ throw new IllegalArgumentException(
+ "The tooltip text cannot have click data.");
+ } else if (component.hoverActionData != null
+ && component.hoverActionName != null) {
+ throw new IllegalArgumentException(
+ "The tooltip text cannot have a tooltip.");
}
if (component.hasText()) {
result.messageParts.add(component.clone());
@@ -475,7 +612,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
return this;
}
}
- return formattedTooltip(result.messageParts.isEmpty() ? null : result); // Throws NPE if size is 0, intended
+ return formattedTooltip(
+ result.messageParts.isEmpty() ? null : result); // Throws NPE if size is 0, intended
}
/**
@@ -486,7 +624,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
* @return This builder instance.
*/
public FancyMessage formattedTooltip(final Iterable lines) {
- return formattedTooltip(com.plotsquared.bukkit.chat.ArrayWrapper.toArray(lines, FancyMessage.class));
+ return formattedTooltip(
+ com.plotsquared.bukkit.chat.ArrayWrapper.toArray(lines, FancyMessage.class));
}
/**
@@ -503,22 +642,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
return this;
}
- /*
-
- /**
- * If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message.
- * @param replacements The replacements, in order, that will be used in the language-specific message.
- * @return This builder instance.
- */ /* ------------
- public FancyMessage translationReplacements(final Iterable extends CharSequence> replacements){
- for(CharSequence str : replacements){
- latest().translationReplacements.add(new JsonString(str));
- }
-
- return this;
- }
-
- */
/**
* If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message.
@@ -543,7 +666,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
* @return This builder instance.
*/
public FancyMessage translationReplacements(final Iterable replacements) {
- return translationReplacements(com.plotsquared.bukkit.chat.ArrayWrapper.toArray(replacements, FancyMessage.class));
+ return translationReplacements(
+ com.plotsquared.bukkit.chat.ArrayWrapper.toArray(replacements, FancyMessage.class));
}
/**
@@ -588,8 +712,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
return this;
}
- @Override
- public void writeJson(JsonWriter writer) throws IOException {
+ @Override public void writeJson(JsonWriter writer) throws IOException {
if (messageParts.size() == 1) {
latest().writeJson(writer);
} else {
@@ -641,8 +764,11 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
Player player = (Player) sender;
try {
Object handle = Reflection.getHandle(player);
- Object connection = Reflection.getField(handle.getClass(), "playerConnection").get(handle);
- Reflection.getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet")).invoke(connection, createChatPacket(jsonString));
+ Object connection =
+ Reflection.getField(handle.getClass(), "playerConnection").get(handle);
+ Reflection
+ .getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet"))
+ .invoke(connection, createChatPacket(jsonString));
} catch (IllegalArgumentException e) {
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
} catch (IllegalAccessException e) {
@@ -650,7 +776,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
} catch (InstantiationException e) {
Bukkit.getLogger().log(Level.WARNING, "Underlying class is abstract.", e);
} catch (InvocationTargetException e) {
- Bukkit.getLogger().log(Level.WARNING, "A error has occurred during invoking of method.", e);
+ Bukkit.getLogger()
+ .log(Level.WARNING, "A error has occurred during invoking of method.", e);
} catch (NoSuchMethodException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not find method.", e);
} catch (ClassNotFoundException e) {
@@ -658,11 +785,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
}
}
- // The ChatSerializer's instance of Gson
- private static Object nmsChatSerializerGsonInstance;
- private static Method fromJsonMethod;
-
- private Object createChatPacket(String json) throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
+ private Object createChatPacket(String json)
+ throws IllegalArgumentException, IllegalAccessException, InstantiationException,
+ InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
if (nmsChatSerializerGsonInstance == null) {
// Find the field and its value, completely bypassing obfuscation
Class> chatSerializerClazz;
@@ -673,7 +798,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
// Y = minor
// Z = revision
final String version = Reflection.getVersion();
- String[] split = version.substring(1, version.length() - 1).split("_"); // Remove trailing dot
+ String[] split =
+ version.substring(1, version.length() - 1).split("_"); // Remove trailing dot
//int majorVersion = Integer.parseInt(split[0]);
int minorVersion = Integer.parseInt(split[1]);
int revisionVersion = Integer.parseInt(split[2].substring(1)); // Substring to ignore R
@@ -689,11 +815,14 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
}
for (Field declaredField : chatSerializerClazz.getDeclaredFields()) {
- if (Modifier.isFinal(declaredField.getModifiers()) && Modifier.isStatic(declaredField.getModifiers()) && declaredField.getType().getName().endsWith("Gson")) {
+ if (Modifier.isFinal(declaredField.getModifiers()) && Modifier
+ .isStatic(declaredField.getModifiers()) && declaredField.getType().getName()
+ .endsWith("Gson")) {
// We've found our field
declaredField.setAccessible(true);
nmsChatSerializerGsonInstance = declaredField.get(null);
- fromJsonMethod = nmsChatSerializerGsonInstance.getClass().getMethod("fromJson", String.class, Class.class);
+ fromJsonMethod = nmsChatSerializerGsonInstance.getClass()
+ .getMethod("fromJson", String.class, Class.class);
break;
}
}
@@ -701,7 +830,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
// Since the method is so simple, and all the obfuscated methods have the same name, it's easier to reimplement 'IChatBaseComponent a(String)' than to reflectively call it
// Of course, the implementation may change, but fuzzy matches might break with signature changes
- Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, Reflection.getNMSClass("IChatBaseComponent"));
+ Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json,
+ Reflection.getNMSClass("IChatBaseComponent"));
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
}
@@ -782,26 +912,10 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
public Map serialize() {
HashMap map = new HashMap<>();
map.put("messageParts", messageParts);
-// map.put("JSON", toJSONString());
+ // map.put("JSON", toJSONString());
return map;
}
- /**
- * Deserializes a JSON-represented message from a mapping of key-value pairs.
- * This is called by the Bukkit serialization API.
- * It is not intended for direct public API consumption.
- *
- * @param serialized The key-value mapping which represents a fancy message.
- */
- @SuppressWarnings("unchecked")
- public static FancyMessage deserialize(Map serialized) {
- FancyMessage msg = new FancyMessage();
- msg.messageParts = (List) serialized.get("messageParts");
- msg.jsonString = serialized.containsKey("JSON") ? serialized.get("JSON").toString() : null;
- msg.dirty = !serialized.containsKey("JSON");
- return msg;
- }
-
/**
* Internally called method. Not for API consumption.
*/
@@ -809,78 +923,4 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
return messageParts.iterator();
}
- private static JsonParser _stringParser = new JsonParser();
-
- /**
- * Deserializes a fancy message from its JSON representation. This JSON representation is of the format of
- * that returned by {@link #toJSONString()}, and is compatible with vanilla inputs.
- *
- * @param json The JSON string which represents a fancy message.
- * @return A {@code FancyMessage} representing the parameterized JSON message.
- */
- public static FancyMessage deserialize(String json) {
- JsonObject serialized = _stringParser.parse(json).getAsJsonObject();
- JsonArray extra = serialized.getAsJsonArray("extra"); // Get the extra component
- FancyMessage returnVal = new FancyMessage();
- returnVal.messageParts.clear();
- for (JsonElement mPrt : extra) {
- MessagePart component = new MessagePart();
- JsonObject messagePart = mPrt.getAsJsonObject();
- for (Map.Entry entry : messagePart.entrySet()) {
- // Deserialize text
- if (TextualComponent.isTextKey(entry.getKey())) {
- // The map mimics the YAML serialization, which has a "key" field and one or more "value" fields
- Map serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance
- serializedMapForm.put("key", entry.getKey());
- if (entry.getValue().isJsonPrimitive()) {
- // Assume string
- serializedMapForm.put("value", entry.getValue().getAsString());
- } else {
- // Composite object, but we assume each element is a string
- for (Map.Entry compositeNestedElement : entry.getValue().getAsJsonObject().entrySet()) {
- serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString());
- }
- }
- component.text = TextualComponent.deserialize(serializedMapForm);
- } else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) {
- if (entry.getValue().getAsBoolean()) {
- component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
- }
- } else if (entry.getKey().equals("color")) {
- component.color = ChatColor.valueOf(entry.getValue().getAsString().toUpperCase());
- } else if (entry.getKey().equals("clickEvent")) {
- JsonObject object = entry.getValue().getAsJsonObject();
- component.clickActionName = object.get("action").getAsString();
- component.clickActionData = object.get("value").getAsString();
- } else if (entry.getKey().equals("hoverEvent")) {
- JsonObject object = entry.getValue().getAsJsonObject();
- component.hoverActionName = object.get("action").getAsString();
- if (object.get("value").isJsonPrimitive()) {
- // Assume string
- component.hoverActionData = new JsonString(object.get("value").getAsString());
- } else {
- // Assume composite type
- // The only composite type we currently store is another FancyMessage
- // Therefore, recursion time!
- component.hoverActionData = deserialize(object.get("value").toString() /* This should properly serialize the JSON object as a JSON string */);
- }
- } else if (entry.getKey().equals("insertion")) {
- component.insertionData = entry.getValue().getAsString();
- } else if (entry.getKey().equals("with")) {
- for (JsonElement object : entry.getValue().getAsJsonArray()) {
- if (object.isJsonPrimitive()) {
- component.translationReplacements.add(new JsonString(object.getAsString()));
- } else {
- // Only composite type stored in this array is - again - FancyMessages
- // Recurse within this function to parse this as a translation replacement
- component.translationReplacements.add(deserialize(object.toString()));
- }
- }
- }
- }
- returnVal.messageParts.add(component);
- }
- return returnVal;
- }
-
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonRepresentedObject.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonRepresentedObject.java
index 6092bce60..a4a66d3bf 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonRepresentedObject.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonRepresentedObject.java
@@ -11,6 +11,7 @@ interface JsonRepresentedObject {
/**
* Writes the JSON representation of this object to the specified writer.
+ *
* @param writer The JSON writer which will receive the object.
* @throws IOException If an error occurs writing to the stream.
*/
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonString.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonString.java
index 1fb197e8b..931ab9394 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonString.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/JsonString.java
@@ -20,8 +20,11 @@ final class JsonString implements JsonRepresentedObject, ConfigurationSerializab
_value = value == null ? null : value.toString();
}
- @Override
- public void writeJson(JsonWriter writer) throws IOException {
+ public static JsonString deserialize(Map map) {
+ return new JsonString(map.get("stringValue").toString());
+ }
+
+ @Override public void writeJson(JsonWriter writer) throws IOException {
writer.value(getValue());
}
@@ -35,12 +38,7 @@ final class JsonString implements JsonRepresentedObject, ConfigurationSerializab
return theSingleValue;
}
- public static JsonString deserialize(Map map) {
- return new JsonString(map.get("stringValue").toString());
- }
-
- @Override
- public String toString() {
+ @Override public String toString() {
return _value;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java
index a3ed7fa2b..31f6d2522 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java
@@ -19,43 +19,6 @@ import java.util.logging.Level;
*/
final class MessagePart implements JsonRepresentedObject, ConfigurationSerializable, Cloneable {
- ChatColor color = ChatColor.WHITE;
- ArrayList styles = new ArrayList<>();
- String clickActionName = null;
- String clickActionData = null;
- String hoverActionName = null;
- JsonRepresentedObject hoverActionData = null;
- TextualComponent text = null;
- String insertionData = null;
- ArrayList translationReplacements = new ArrayList<>();
-
- MessagePart(final TextualComponent text) {
- this.text = text;
- }
-
- MessagePart() {
- this.text = null;
- }
-
- boolean hasText() {
- return text != null;
- }
-
- @Override
- @SuppressWarnings("unchecked")
- public MessagePart clone() throws CloneNotSupportedException {
- MessagePart obj = (MessagePart) super.clone();
- obj.styles = (ArrayList) styles.clone();
- if (hoverActionData instanceof JsonString) {
- obj.hoverActionData = new JsonString(((JsonString) hoverActionData).getValue());
- } else if (hoverActionData instanceof FancyMessage) {
- obj.hoverActionData = ((FancyMessage) hoverActionData).clone();
- }
- obj.translationReplacements = (ArrayList) translationReplacements.clone();
- return obj;
-
- }
-
static final BiMap stylesToNames;
static {
@@ -83,6 +46,62 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
stylesToNames = builder.build();
}
+ static {
+ ConfigurationSerialization.registerClass(MessagePart.class);
+ }
+
+ ChatColor color = ChatColor.WHITE;
+ ArrayList styles = new ArrayList<>();
+ String clickActionName = null;
+ String clickActionData = null;
+ String hoverActionName = null;
+ JsonRepresentedObject hoverActionData = null;
+ TextualComponent text = null;
+ String insertionData = null;
+ ArrayList translationReplacements = new ArrayList<>();
+
+ MessagePart(final TextualComponent text) {
+ this.text = text;
+ }
+
+ MessagePart() {
+ this.text = null;
+ }
+
+ @SuppressWarnings("unchecked")
+ public static MessagePart deserialize(Map serialized) {
+ MessagePart part = new MessagePart((TextualComponent) serialized.get("text"));
+ part.styles = (ArrayList) serialized.get("styles");
+ part.color = ChatColor.getByChar(serialized.get("color").toString());
+ part.hoverActionName = (String) serialized.get("hoverActionName");
+ part.hoverActionData = (JsonRepresentedObject) serialized.get("hoverActionData");
+ part.clickActionName = (String) serialized.get("clickActionName");
+ part.clickActionData = (String) serialized.get("clickActionData");
+ part.insertionData = (String) serialized.get("insertion");
+ part.translationReplacements =
+ (ArrayList) serialized.get("translationReplacements");
+ return part;
+ }
+
+ boolean hasText() {
+ return text != null;
+ }
+
+ @Override @SuppressWarnings("unchecked") public MessagePart clone()
+ throws CloneNotSupportedException {
+ MessagePart obj = (MessagePart) super.clone();
+ obj.styles = (ArrayList) styles.clone();
+ if (hoverActionData instanceof JsonString) {
+ obj.hoverActionData = new JsonString(((JsonString) hoverActionData).getValue());
+ } else if (hoverActionData instanceof FancyMessage) {
+ obj.hoverActionData = ((FancyMessage) hoverActionData).clone();
+ }
+ obj.translationReplacements =
+ (ArrayList) translationReplacements.clone();
+ return obj;
+
+ }
+
public void writeJson(JsonWriter json) {
try {
json.beginObject();
@@ -92,24 +111,20 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
json.name(stylesToNames.get(style)).value(true);
}
if (clickActionName != null && clickActionData != null) {
- json.name("clickEvent")
- .beginObject()
- .name("action").value(clickActionName)
- .name("value").value(clickActionData)
- .endObject();
+ json.name("clickEvent").beginObject().name("action").value(clickActionName)
+ .name("value").value(clickActionData).endObject();
}
if (hoverActionName != null && hoverActionData != null) {
- json.name("hoverEvent")
- .beginObject()
- .name("action").value(hoverActionName)
- .name("value");
+ json.name("hoverEvent").beginObject().name("action").value(hoverActionName)
+ .name("value");
hoverActionData.writeJson(json);
json.endObject();
}
if (insertionData != null) {
json.name("insertion").value(insertionData);
}
- if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) {
+ if (translationReplacements.size() > 0 && text != null && TextualComponent
+ .isTranslatableText(text)) {
json.name("with").beginArray();
for (JsonRepresentedObject obj : translationReplacements) {
obj.writeJson(json);
@@ -118,7 +133,8 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
}
json.endObject();
} catch (IOException e) {
- Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e);
+ Bukkit.getLogger()
+ .log(Level.WARNING, "A problem occured during writing of JSON string", e);
}
}
@@ -136,22 +152,4 @@ final class MessagePart implements JsonRepresentedObject, ConfigurationSerializa
return map;
}
- @SuppressWarnings("unchecked")
- public static MessagePart deserialize(Map serialized) {
- MessagePart part = new MessagePart((TextualComponent) serialized.get("text"));
- part.styles = (ArrayList) serialized.get("styles");
- part.color = ChatColor.getByChar(serialized.get("color").toString());
- part.hoverActionName = (String) serialized.get("hoverActionName");
- part.hoverActionData = (JsonRepresentedObject) serialized.get("hoverActionData");
- part.clickActionName = (String) serialized.get("clickActionName");
- part.clickActionData = (String) serialized.get("clickActionData");
- part.insertionData = (String) serialized.get("insertion");
- part.translationReplacements = (ArrayList) serialized.get("translationReplacements");
- return part;
- }
-
- static {
- ConfigurationSerialization.registerClass(MessagePart.class);
- }
-
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java
index de315c06e..7ef4b5160 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/Reflection.java
@@ -28,10 +28,12 @@ public final class Reflection {
* Contains loaded methods in a cache.
* The map maps [types to maps of [method names to maps of [parameter types to method instances]]].
*/
- private static final Map, Map>, Method>>> _loadedMethods = new HashMap<>();
+ private static final Map, Map>, Method>>>
+ _loadedMethods = new HashMap<>();
private static String _versionString;
- private Reflection() { }
+ private Reflection() {
+ }
/**
* Gets the version string from the package name of the CraftBukkit server implementation.
@@ -109,8 +111,9 @@ public final class Reflection {
* @param obj The object for which to retrieve an NMS handle.
* @return The NMS handle of the specified object, or {@code null} if it could not be retrieved using {@code getHandle()}.
*/
- public synchronized static Object getHandle(Object obj) throws InvocationTargetException, IllegalAccessException, IllegalArgumentException {
- return getMethod(obj.getClass(), "getHandle").invoke(obj);
+ public synchronized static Object getHandle(Object obj)
+ throws InvocationTargetException, IllegalAccessException, IllegalArgumentException {
+ return getMethod(obj.getClass(), "getHandle").invoke(obj);
}
/**
@@ -181,7 +184,8 @@ public final class Reflection {
_loadedMethods.put(clazz, new HashMap>, Method>>());
}
- Map>, Method>> loadedMethodNames = _loadedMethods.get(clazz);
+ Map>, Method>> loadedMethodNames =
+ _loadedMethods.get(clazz);
if (!loadedMethodNames.containsKey(name)) {
loadedMethodNames.put(name, new HashMap>, Method>());
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java
index 44005ed39..cd62548df 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java
@@ -27,7 +27,8 @@ public abstract class TextualComponent implements Cloneable {
if (map.containsKey("key") && map.size() == 2 && map.containsKey("value")) {
// Arbitrary text component
return ArbitraryTextTypeComponent.deserialize(map);
- } else if (map.size() >= 2 && map.containsKey("key") && !map.containsKey("value") /* It contains keys that START WITH value */) {
+ } else if (map.size() >= 2 && map.containsKey("key") && !map
+ .containsKey("value") /* It contains keys that START WITH value */) {
// Complex JSON object
return ComplexTextTypeComponent.deserialize(map);
}
@@ -36,16 +37,18 @@ public abstract class TextualComponent implements Cloneable {
}
static boolean isTextKey(String key) {
- return key.equals("translate") || key.equals("text") || key.equals("score") || key.equals("selector");
+ return key.equals("translate") || key.equals("text") || key.equals("score") || key
+ .equals("selector");
}
static boolean isTranslatableText(TextualComponent component) {
- return component instanceof ComplexTextTypeComponent && component.getKey().equals("translate");
+ return component instanceof ComplexTextTypeComponent && component.getKey()
+ .equals("translate");
}
/**
* Create a textual component representing a string literal.
- *
+ *
*
This is the default type of textual component when a single string
* literal is given to a method.
*
@@ -73,7 +76,8 @@ public abstract class TextualComponent implements Cloneable {
}
private static void throwUnsupportedSnapshot() {
- throw new UnsupportedOperationException("This feature is only supported in snapshot releases.");
+ throw new UnsupportedOperationException(
+ "This feature is only supported in snapshot releases.");
}
/**
@@ -94,15 +98,15 @@ public abstract class TextualComponent implements Cloneable {
/**
* Create a textual component representing a scoreboard value.
* The client will see the score of the specified player for the specified objective as the text represented by this component.
- *
+ *
*
This method is currently guaranteed to throw an {@code UnsupportedOperationException}
* as it is only supported on snapshot clients.
*
- * @param playerName The name of the player whos score will be shown. If
- * this string represents the single-character sequence
- * "*", the viewing player's score will be displayed.
- * Standard minecraft selectors (@a, @p, etc)
- * are not supported.
+ * @param playerName The name of the player whos score will be shown. If
+ * this string represents the single-character sequence
+ * "*", the viewing player's score will be displayed.
+ * Standard minecraft selectors (@a, @p, etc)
+ * are not supported.
* @param scoreboardObjective The name of the objective for
* which to display the score.
* @return The text component representing the specified scoreboard score
@@ -112,10 +116,9 @@ public abstract class TextualComponent implements Cloneable {
throwUnsupportedSnapshot(); // Remove this line when the feature is released to non-snapshot versions, in addition to updating ALL THE
// OVERLOADS documentation accordingly
- return new ComplexTextTypeComponent("score", ImmutableMap.builder()
- .put("name", playerName)
- .put("objective", scoreboardObjective)
- .build());
+ return new ComplexTextTypeComponent("score",
+ ImmutableMap.builder().put("name", playerName)
+ .put("objective", scoreboardObjective).build());
}
/**
@@ -126,7 +129,7 @@ public abstract class TextualComponent implements Cloneable {
*
*
* @param selector The minecraft player or entity selector which will capture the entities whose string representations will be displayed in
- * the place of this text component.
+ * the place of this text component.
* @return The text component representing the name of the entities captured by the selector.
*/
public static TextualComponent selector(String selector) {
@@ -136,8 +139,7 @@ public abstract class TextualComponent implements Cloneable {
return new ArbitraryTextTypeComponent("selector", selector);
}
- @Override
- public String toString() {
+ @Override public String toString() {
return getReadableString();
}
@@ -155,8 +157,7 @@ public abstract class TextualComponent implements Cloneable {
* Clones a textual component instance.
* The returned object should not reference this textual component instance, but should maintain the same key and value.
*/
- @Override
- public abstract TextualComponent clone() throws CloneNotSupportedException;
+ @Override public abstract TextualComponent clone() throws CloneNotSupportedException;
/**
* Writes the text data represented by this textual component to the specified JSON writer object.
@@ -171,7 +172,8 @@ public abstract class TextualComponent implements Cloneable {
* Internal class used to represent all types of text components.
* Exception validating done is on keys and values.
*/
- private static final class ArbitraryTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
+ private static final class ArbitraryTextTypeComponent extends TextualComponent
+ implements ConfigurationSerializable {
private String key;
private String value;
@@ -182,16 +184,17 @@ public abstract class TextualComponent implements Cloneable {
}
public static ArbitraryTextTypeComponent deserialize(Map map) {
- return new ArbitraryTextTypeComponent(map.get("key").toString(), map.get("value").toString());
+ return new ArbitraryTextTypeComponent(map.get("key").toString(),
+ map.get("value").toString());
}
- @Override
- public String getKey() {
+ @Override public String getKey() {
return key;
}
public void setKey(String key) {
- Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
+ Preconditions
+ .checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
this.key = key;
}
@@ -204,20 +207,16 @@ public abstract class TextualComponent implements Cloneable {
this.value = value;
}
- @Override
- public TextualComponent clone() throws CloneNotSupportedException {
+ @Override public TextualComponent clone() throws CloneNotSupportedException {
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
return new ArbitraryTextTypeComponent(getKey(), getValue());
}
- @Override
- public void writeJson(JsonWriter writer) throws IOException {
+ @Override public void writeJson(JsonWriter writer) throws IOException {
writer.name(getKey()).value(getValue());
}
- @Override
- @SuppressWarnings("serial")
- public Map serialize() {
+ @Override @SuppressWarnings("serial") public Map serialize() {
return new HashMap() {
{
put("key", getKey());
@@ -226,19 +225,20 @@ public abstract class TextualComponent implements Cloneable {
};
}
- @Override
- public String getReadableString() {
+ @Override public String getReadableString() {
return getValue();
}
}
+
/**
* Internal class used to represent a text component with a nested JSON
* value.
- *
+ *
*
Exception validating done is on keys and values.
*/
- private static final class ComplexTextTypeComponent extends TextualComponent implements ConfigurationSerializable {
+ private static final class ComplexTextTypeComponent extends TextualComponent
+ implements ConfigurationSerializable {
private String key;
private Map value;
@@ -255,19 +255,20 @@ public abstract class TextualComponent implements Cloneable {
if (valEntry.getKey().equals("key")) {
key = (String) valEntry.getValue();
} else if (valEntry.getKey().startsWith("value.")) {
- value.put(valEntry.getKey().substring(6) /* Strips out the value prefix */, valEntry.getValue().toString());
+ value.put(valEntry.getKey().substring(6) /* Strips out the value prefix */,
+ valEntry.getValue().toString());
}
}
return new ComplexTextTypeComponent(key, value);
}
- @Override
- public String getKey() {
+ @Override public String getKey() {
return key;
}
public void setKey(String key) {
- Preconditions.checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
+ Preconditions
+ .checkArgument(key != null && !key.isEmpty(), "The key must be specified.");
this.key = key;
}
@@ -280,14 +281,12 @@ public abstract class TextualComponent implements Cloneable {
this.value = value;
}
- @Override
- public TextualComponent clone() {
+ @Override public TextualComponent clone() {
// Since this is a private and final class, we can just reinstantiate this class instead of casting super.clone
return new ComplexTextTypeComponent(getKey(), getValue());
}
- @Override
- public void writeJson(JsonWriter writer) throws IOException {
+ @Override public void writeJson(JsonWriter writer) throws IOException {
writer.name(getKey());
writer.beginObject();
for (Map.Entry jsonPair : value.entrySet()) {
@@ -296,9 +295,7 @@ public abstract class TextualComponent implements Cloneable {
writer.endObject();
}
- @Override
- @SuppressWarnings("serial")
- public Map serialize() {
+ @Override @SuppressWarnings("serial") public Map serialize() {
return new java.util.HashMap() {
{
put("key", getKey());
@@ -309,8 +306,7 @@ public abstract class TextualComponent implements Cloneable {
};
}
- @Override
- public String getReadableString() {
+ @Override public String getReadableString() {
return getKey();
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java b/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java
index b3934109a..fb664103a 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/commands/DebugUUID.java
@@ -11,11 +11,7 @@ import com.intellectualcrafters.plot.object.OfflinePlotPlayer;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.StringWrapper;
-import com.intellectualcrafters.plot.util.MainUtil;
-import com.intellectualcrafters.plot.util.StringMan;
-import com.intellectualcrafters.plot.util.TaskManager;
-import com.intellectualcrafters.plot.util.UUIDHandler;
-import com.intellectualcrafters.plot.util.WorldUtil;
+import com.intellectualcrafters.plot.util.*;
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
import com.plotsquared.bukkit.uuid.DatFileFilter;
import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper;
@@ -23,32 +19,22 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper;
import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper;
import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration;
+
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.UUID;
-@CommandDeclaration(
- command = "uuidconvert",
- permission = "plots.admin",
- description = "Debug UUID conversion",
- usage = "/plot uuidconvert ",
- requiredType = RequiredType.CONSOLE,
- category = CommandCategory.DEBUG)
+@CommandDeclaration(command = "uuidconvert", permission = "plots.admin", description = "Debug UUID conversion", usage = "/plot uuidconvert ", requiredType = RequiredType.CONSOLE, category = CommandCategory.DEBUG)
public class DebugUUID extends SubCommand {
public DebugUUID() {
super(Argument.String);
}
- @Override
- public boolean onCommand(final PlotPlayer player, String[] args) {
+ @Override public boolean onCommand(final PlotPlayer player, String[] args) {
final UUIDWrapper currentUUIDWrapper = UUIDHandler.getUUIDWrapper();
final UUIDWrapper newWrapper;
@@ -67,7 +53,8 @@ public class DebugUUID extends SubCommand {
Class> clazz = Class.forName(args[0]);
newWrapper = (UUIDWrapper) clazz.newInstance();
} catch (ClassNotFoundException | IllegalAccessException | InstantiationException ignored) {
- MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert ");
+ MainUtil.sendMessage(player, C.COMMAND_SYNTAX,
+ "/plot uuidconvert ");
return false;
}
}
@@ -75,23 +62,29 @@ public class DebugUUID extends SubCommand {
if (args.length != 2 || !"-o".equals(args[1])) {
MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot uuidconvert " + args[0] + " - o");
MainUtil.sendMessage(player, "&cBe aware of the following!");
- MainUtil.sendMessage(player, "&8 - &cUse the database command or another method to backup your plots beforehand");
- MainUtil.sendMessage(player, "&8 - &cIf the process is interrupted, all plots could be deleted");
+ MainUtil.sendMessage(player,
+ "&8 - &cUse the database command or another method to backup your plots beforehand");
+ MainUtil.sendMessage(player,
+ "&8 - &cIf the process is interrupted, all plots could be deleted");
MainUtil.sendMessage(player, "&8 - &cIf an error occurs, all plots could be deleted");
MainUtil.sendMessage(player, "&8 - &cPlot settings WILL be lost upon conversion");
- MainUtil.sendMessage(player, "&cTO REITERATE: BACK UP YOUR DATABASE BEFORE USING THIS!!!");
- MainUtil.sendMessage(player, "&7Retype the command with the override parameter when ready :)");
+ MainUtil
+ .sendMessage(player, "&cTO REITERATE: BACK UP YOUR DATABASE BEFORE USING THIS!!!");
+ MainUtil.sendMessage(player,
+ "&7Retype the command with the override parameter when ready :)");
return false;
}
- if (currentUUIDWrapper.getClass().getCanonicalName().equals(newWrapper.getClass().getCanonicalName())) {
+ if (currentUUIDWrapper.getClass().getCanonicalName()
+ .equals(newWrapper.getClass().getCanonicalName())) {
MainUtil.sendMessage(player, "&cUUID mode already in use!");
return false;
}
MainUtil.sendMessage(player, "&6Beginning UUID mode conversion");
MainUtil.sendMessage(player, "&7 - Disconnecting players");
for (Entry entry : UUIDHandler.getPlayers().entrySet()) {
- entry.getValue().kick("UUID conversion has been initiated. You may reconnect when finished.");
+ entry.getValue()
+ .kick("UUID conversion has been initiated. You may reconnect when finished.");
}
MainUtil.sendMessage(player, "&7 - Initializing map");
@@ -135,12 +128,14 @@ public class DebugUUID extends SubCommand {
OfflinePlotPlayer op = wrapper.getOfflinePlayer(uuid);
uuid = currentUUIDWrapper.getUUID(op);
uuid2 = newWrapper.getUUID(op);
- if (!uuid.equals(uuid2) && !uCMap.containsKey(uuid) && !uCReverse.containsKey(uuid2)) {
+ if (!uuid.equals(uuid2) && !uCMap.containsKey(uuid) && !uCReverse
+ .containsKey(uuid2)) {
uCMap.put(uuid, uuid2);
uCReverse.put(uuid2, uuid);
}
} catch (Throwable ignored) {
- MainUtil.sendMessage(player, C.PREFIX + "&6Invalid playerdata: " + uuid.toString() + ".dat");
+ MainUtil.sendMessage(player,
+ C.PREFIX + "&6Invalid playerdata: " + uuid.toString() + ".dat");
}
}
for (String name : names) {
@@ -175,8 +170,7 @@ public class DebugUUID extends SubCommand {
MainUtil.sendMessage(player, "&7 - Replacing cache");
TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
for (Entry entry : uCMap.entrySet()) {
String name = UUIDHandler.getName(entry.getKey());
if (name != null) {
@@ -189,7 +183,8 @@ public class DebugUUID extends SubCommand {
File file = new File(PS.get().IMP.getDirectory(), "uuids.txt");
if (file.exists()) {
try {
- List lines = Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
+ List lines =
+ Files.readAllLines(file.toPath(), StandardCharsets.UTF_8);
for (String line : lines) {
try {
line = line.trim();
@@ -199,7 +194,8 @@ public class DebugUUID extends SubCommand {
line = line.replaceAll("[\\|][0-9]+[\\|][0-9]+[\\|]", "");
String[] split = line.split("\\|");
String name = split[0];
- if (name.isEmpty() || name.length() > 16 || !StringMan.isAlphanumericUnd(name)) {
+ if (name.isEmpty() || name.length() > 16 || !StringMan
+ .isAlphanumericUnd(name)) {
continue;
}
UUID old = currentUUIDWrapper.getUUID(name);
@@ -249,12 +245,12 @@ public class DebugUUID extends SubCommand {
plot.owner = value;
}
}
- DBFunc.createPlotsAndData(new ArrayList<>(PS.get().getPlots()), new Runnable() {
- @Override
- public void run() {
- MainUtil.sendMessage(player, "&6Recovery was successful!");
- }
- });
+ DBFunc.createPlotsAndData(new ArrayList<>(PS.get().getPlots()),
+ new Runnable() {
+ @Override public void run() {
+ MainUtil.sendMessage(player, "&6Recovery was successful!");
+ }
+ });
return;
}
} catch (Exception e) {
@@ -272,18 +268,17 @@ public class DebugUUID extends SubCommand {
try {
PS.get().worlds.save(PS.get().worldsFile);
} catch (IOException ignored) {
- MainUtil.sendMessage(player, "Could not save configuration. It will need to be manual set!");
+ MainUtil.sendMessage(player,
+ "Could not save configuration. It will need to be manual set!");
}
MainUtil.sendMessage(player, "&7 - Populating tables");
TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
ArrayList plots = new ArrayList<>(PS.get().getPlots());
DBFunc.createPlotsAndData(plots, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
MainUtil.sendMessage(player, "&aConversion complete!");
}
});
@@ -291,7 +286,8 @@ public class DebugUUID extends SubCommand {
});
MainUtil.sendMessage(player, "&aIt is now safe for players to join");
- MainUtil.sendMessage(player, "&cConversion is still in progress, you will be notified when it is complete");
+ MainUtil.sendMessage(player,
+ "&cConversion is still in progress, you will be notified when it is complete");
}
});
return true;
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/APlotMeConnector.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/APlotMeConnector.java
index 1ebae3a93..8d006a943 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/APlotMeConnector.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/APlotMeConnector.java
@@ -13,9 +13,11 @@ import java.util.HashMap;
public abstract class APlotMeConnector {
- public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder);
+ public abstract Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig,
+ String dataFolder);
- public abstract HashMap> getPlotMePlots(Connection connection) throws SQLException;
+ public abstract HashMap> getPlotMePlots(Connection connection)
+ throws SQLException;
public abstract boolean accepts(String version);
@@ -31,9 +33,11 @@ public abstract class APlotMeConnector {
String wallBlock = plotConfig.getString("worlds." + world + ".WallBlockId"); //
PS.get().worlds.set("worlds." + actualWorldName + ".wall.block", wallBlock);
String floor = plotConfig.getString("worlds." + world + ".PlotFloorBlockId"); //
- PS.get().worlds.set("worlds." + actualWorldName + ".plot.floor", Collections.singletonList(floor));
+ PS.get().worlds
+ .set("worlds." + actualWorldName + ".plot.floor", Collections.singletonList(floor));
String filling = plotConfig.getString("worlds." + world + ".PlotFillingBlockId"); //
- PS.get().worlds.set("worlds." + actualWorldName + ".plot.filling", Collections.singletonList(filling));
+ PS.get().worlds
+ .set("worlds." + actualWorldName + ".plot.filling", Collections.singletonList(filling));
String road = plotConfig.getString("worlds." + world + ".RoadMainBlockId");
PS.get().worlds.set("worlds." + actualWorldName + ".road.block", road);
int height = plotConfig.getInt("worlds." + world + ".RoadHeight"); //
@@ -58,25 +62,26 @@ public abstract class APlotMeConnector {
return new Location(null, x, 1, z);
}
- public void setMerged(HashMap> merges, String world, PlotId id, int direction) {
+ public void setMerged(HashMap> merges, String world,
+ PlotId id, int direction) {
HashMap plots = merges.get(world);
PlotId id2 = new PlotId(id.x, id.y);
boolean[] merge1;
if (plots.containsKey(id)) {
merge1 = plots.get(id);
} else {
- merge1 = new boolean[] { false, false, false, false };
+ merge1 = new boolean[] {false, false, false, false};
}
boolean[] merge2;
if (plots.containsKey(id2)) {
merge2 = plots.get(id2);
} else {
- merge2 = new boolean[] { false, false, false, false };
+ merge2 = new boolean[] {false, false, false, false};
}
merge1[direction] = true;
merge2[(direction + 2) % 4] = true;
plots.put(id, merge1);
plots.put(id2, merge1);
}
-
+
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java
index 11cea6ddb..a67b0256e 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/ClassicPlotMeConnector.java
@@ -6,20 +6,12 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.SQLite;
-import com.intellectualcrafters.plot.object.Location;
-import com.intellectualcrafters.plot.object.Plot;
-import com.intellectualcrafters.plot.object.PlotArea;
-import com.intellectualcrafters.plot.object.PlotId;
-import com.intellectualcrafters.plot.object.StringWrapper;
+import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.UUIDHandler;
import java.io.File;
import java.nio.ByteBuffer;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.sql.*;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.UUID;
@@ -29,8 +21,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
private String plugin = "PlotMe";
private String prefix;
- @Override
- public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
+ @Override public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig,
+ String dataFolder) {
this.plugin = plugin.toLowerCase();
this.prefix = plotConfig.getString("mySQLprefix", this.plugin.toLowerCase());
try {
@@ -40,7 +32,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
String con = plotConfig.getString("mySQLconn");
return DriverManager.getConnection(con, user, password);
} else {
- return new SQLite(new File(dataFolder + File.separator + "plots.db")).openConnection();
+ return new SQLite(new File(dataFolder + File.separator + "plots.db"))
+ .openConnection();
}
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
@@ -48,13 +41,14 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
return null;
}
- @Override
- public HashMap> getPlotMePlots(Connection connection) throws SQLException {
+ @Override public HashMap> getPlotMePlots(Connection connection)
+ throws SQLException {
HashMap plotWidth = new HashMap<>();
HashMap roadWidth = new HashMap<>();
HashMap> plots = new HashMap<>();
HashMap> merges = new HashMap<>();
- PreparedStatement statement = connection.prepareStatement("SELECT * FROM `" + this.prefix + "Plots`");
+ PreparedStatement statement =
+ connection.prepareStatement("SELECT * FROM `" + this.prefix + "Plots`");
ResultSet resultSet = statement.executeQuery();
String column = null;
boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerid");
@@ -64,7 +58,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
} else if (checkUUID2) {
column = "ownerId";
}
- boolean merge = !"plotme".equalsIgnoreCase(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
+ boolean merge =
+ !"plotme".equalsIgnoreCase(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
int missing = 0;
while (resultSet.next()) {
PlotId id = new PlotId(resultSet.getInt("idX"), resultSet.getInt("idZ"));
@@ -122,7 +117,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
missing++;
continue;
}
- owner = UUID.nameUUIDFromBytes(("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
+ owner = UUID.nameUUIDFromBytes(
+ ("OfflinePlayer:" + name.toLowerCase()).getBytes(Charsets.UTF_8));
}
} else {
UUIDHandler.add(new StringWrapper(name), owner);
@@ -134,7 +130,8 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
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 "
+ 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)");
}
@@ -228,12 +225,13 @@ public class ClassicPlotMeConnector extends APlotMeConnector {
resultSet.close();
statement.close();
- } catch (SQLException ignored) {}
+ } catch (SQLException ignored) {
+ }
return plots;
}
- @Override
- public boolean accepts(String version) {
- return version == null || PS.get().canUpdate(version, "0.17.0") || PS.get().canUpdate("0.999.999", version);
+ @Override public boolean accepts(String version) {
+ return version == null || PS.get().canUpdate(version, "0.17.0") || PS.get()
+ .canUpdate("0.999.999", version);
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java
index 05d8f4a20..16fe01f39 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/LikePlotMeConverter.java
@@ -12,6 +12,11 @@ import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
+import org.bukkit.Bukkit;
+import org.bukkit.World;
+import org.bukkit.WorldCreator;
+import org.bukkit.command.CommandException;
+
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
@@ -20,17 +25,9 @@ import java.nio.file.Path;
import java.nio.file.Paths;
import java.sql.Connection;
import java.sql.SQLException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Set;
import java.util.concurrent.atomic.AtomicBoolean;
-import org.bukkit.Bukkit;
-import org.bukkit.World;
-import org.bukkit.WorldCreator;
-import org.bukkit.command.CommandException;
public class LikePlotMeConverter {
@@ -54,7 +51,8 @@ public class LikePlotMeConverter {
}
public String getPlotMePath() {
- return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator + plugin + File.separator;
+ return new File(".").getAbsolutePath() + File.separator + "plugins" + File.separator
+ + plugin + File.separator;
}
public FileConfiguration getPlotMeConfig(String dataFolder) {
@@ -71,8 +69,9 @@ public class LikePlotMeConverter {
public void mergeWorldYml(FileConfiguration plotConfig) {
try {
- File genConfig =
- new File("plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
+ File genConfig = new File(
+ "plugins" + File.separator + plugin + File.separator + "PlotMe-DefaultGenerator"
+ + File.separator + "config.yml");
if (genConfig.exists()) {
YamlConfiguration yml = YamlConfiguration.loadConfiguration(genConfig);
for (String key : yml.getKeys(true)) {
@@ -103,7 +102,8 @@ public class LikePlotMeConverter {
content = content.replace("AthionPlots", pluginName);
content = content.replace("PlotZWorld", pluginName);
Files.write(path, content.getBytes(StandardCharsets.UTF_8));
- } catch (IOException ignored) {}
+ } catch (IOException ignored) {
+ }
}
private void copyConfig(ConfigurationSection plotmeDgYml, String world) throws IOException {
@@ -111,20 +111,25 @@ public class LikePlotMeConverter {
String plotMeWorldName = world.toLowerCase();
Integer pathWidth = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PathWidth"); //
PS.get().worlds.set("worlds." + world + ".road.width", pathWidth);
- int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight", plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight", 64)); //
+ int height = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".RoadHeight",
+ plotmeDgYml.getInt("worlds." + plotMeWorldName + ".GroundHeight", 64)); //
PS.get().worlds.set("worlds." + world + ".road.height", height);
PS.get().worlds.set("worlds." + world + ".wall.height", height);
PS.get().worlds.set("worlds." + world + ".plot.height", height);
int plotSize = plotmeDgYml.getInt("worlds." + plotMeWorldName + ".PlotSize", 32); //
PS.get().worlds.set("worlds." + world + ".plot.size", plotSize);
- String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".UnclaimedBorder", plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44")); //
+ String wallblock = plotmeDgYml.getString("worlds." + plotMeWorldName + ".UnclaimedBorder",
+ plotmeDgYml.getString("worlds." + plotMeWorldName + ".WallBlock", "44")); //
PS.get().worlds.set("worlds." + world + ".wall.block", wallblock);
- String claimed = plotmeDgYml.getString("worlds." + plotMeWorldName + ".ProtectedWallBlock", "44:1"); //
+ String claimed =
+ plotmeDgYml.getString("worlds." + plotMeWorldName + ".ProtectedWallBlock", "44:1"); //
PS.get().worlds.set("worlds." + world + ".wall.block_claimed", claimed);
- String floor = plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
+ String floor =
+ plotmeDgYml.getString("worlds." + plotMeWorldName + ".PlotFloorBlock", "2"); //
PS.get().worlds.set("worlds." + world + ".plot.floor", Collections.singletonList(floor));
String filling = plotmeDgYml.getString("worlds." + plotMeWorldName + ".FillBlock", "3"); //
- PS.get().worlds.set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
+ PS.get().worlds
+ .set("worlds." + world + ".plot.filling", Collections.singletonList(filling));
String road = plotmeDgYml.getString("worlds." + plotMeWorldName + ".RoadMainBlock", "5");
PS.get().worlds.set("worlds." + world + ".road.block", road);
PS.get().worlds.set("worlds." + actualWorldName + ".road.height", height);
@@ -151,14 +156,15 @@ public class LikePlotMeConverter {
PS.debug("&3Using connector: " + connector.getClass().getCanonicalName());
- Connection connection = connector.getPlotMeConnection(plugin,plotConfig, dataFolder);
+ Connection connection = connector.getPlotMeConnection(plugin, plotConfig, dataFolder);
if (!connector.isValidConnection(connection)) {
sendMessage("Cannot connect to PlotMe DB. Conversion process will not continue");
return false;
}
- sendMessage("PlotMe conversion has started. To disable this, please set 'enabled-components -> plotme-converter' to false in the 'settings.yml'");
+ sendMessage(
+ "PlotMe conversion has started. To disable this, please set 'enabled-components -> plotme-converter' to false in the 'settings.yml'");
mergeWorldYml(plotConfig);
@@ -185,7 +191,7 @@ public class LikePlotMeConverter {
} catch (IOException e) {
e.printStackTrace();
sendMessage("&c-- &lFailed to save configuration for world '" + world
- + "'\nThis will need to be done using the setup command, or manually");
+ + "'\nThis will need to be done using the setup command, or manually");
}
}
}
@@ -201,7 +207,9 @@ public class LikePlotMeConverter {
sendMessage(" - " + dbPrefix + "Allowed");
sendMessage("Collected " + plotCount + " plots from PlotMe");
- File plotmeDgFile = new File(dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator + "config.yml");
+ File plotmeDgFile = new File(
+ dataFolder + File.separator + "PlotMe-DefaultGenerator" + File.separator
+ + "config.yml");
if (plotmeDgFile.exists()) {
YamlConfiguration plotmeDgYml = YamlConfiguration.loadConfiguration(plotmeDgFile);
try {
@@ -227,8 +235,9 @@ public class LikePlotMeConverter {
}
}
if (duplicate > 0) {
- PS.debug("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world
- + "'. Have you run the converter already?");
+ PS.debug("&c[WARNING] Found " + duplicate
+ + " duplicate plots already in DB for world: '" + world
+ + "'. Have you run the converter already?");
}
} else {
if (PS.get().plots_tmp != null) {
@@ -242,8 +251,9 @@ public class LikePlotMeConverter {
}
}
if (duplicate > 0) {
- PS.debug("&c[WARNING] Found " + duplicate + " duplicate plots already in DB for world: '" + world
- + "'. Have you run the converter already?");
+ PS.debug("&c[WARNING] Found " + duplicate
+ + " duplicate plots already in DB for world: '" + world
+ + "'. Have you run the converter already?");
}
continue;
}
@@ -255,18 +265,20 @@ public class LikePlotMeConverter {
Thread.sleep(1000);
final AtomicBoolean done = new AtomicBoolean(false);
DBFunc.createPlotsAndData(createdPlots, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
if (done.get()) {
done();
sendMessage("&aDatabase conversion is now complete!");
PS.debug("&c - Stop the server");
- PS.debug("&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml");
- PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
+ PS.debug(
+ "&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml");
+ PS.debug(
+ "&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
PS.debug("&c - Start the server");
PS.get().setPlots(DBFunc.getPlots());
} else {
- sendMessage("&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
+ sendMessage(
+ "&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
done.set(true);
}
}
@@ -278,57 +290,70 @@ public class LikePlotMeConverter {
sendMessage(" - &cFailed to save configuration.");
}
TaskManager.runTask(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
try {
boolean mv = false;
boolean mw = false;
- if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
- .isEnabled()) {
+ if ((Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null)
+ && Bukkit.getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
mv = true;
- } else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null) && Bukkit.getPluginManager().getPlugin("MultiWorld")
- .isEnabled()) {
+ } else if ((Bukkit.getPluginManager().getPlugin("MultiWorld") != null)
+ && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
mw = true;
}
for (String worldName : worlds) {
World world = Bukkit.getWorld(getWorld(worldName));
if (world == null) {
- sendMessage("&cInvalid world in PlotMe configuration: " + worldName);
+ sendMessage(
+ "&cInvalid world in PlotMe configuration: " + worldName);
continue;
}
String actualWorldName = world.getName();
- sendMessage("Reloading generator for world: '" + actualWorldName + "'...");
- if (!Bukkit.getWorlds().isEmpty() && Bukkit.getWorlds().get(0).getName().equals(worldName)) {
- sendMessage("&cYou need to stop the server to reload this world properly");
+ sendMessage(
+ "Reloading generator for world: '" + actualWorldName + "'...");
+ if (!Bukkit.getWorlds().isEmpty() && Bukkit.getWorlds().get(0).getName()
+ .equals(worldName)) {
+ sendMessage(
+ "&cYou need to stop the server to reload this world properly");
} else {
PS.get().removePlotAreas(actualWorldName);
if (mv) {
// unload world with MV
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv unload " + actualWorldName);
+ Bukkit.getServer()
+ .dispatchCommand(Bukkit.getServer().getConsoleSender(),
+ "mv unload " + actualWorldName);
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
// load world with MV
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
- "mv import " + actualWorldName + " normal -g " + PS.imp().getPluginName());
+ Bukkit.getServer()
+ .dispatchCommand(Bukkit.getServer().getConsoleSender(),
+ "mv import " + actualWorldName + " normal -g " + PS
+ .imp().getPluginName());
} else if (mw) {
// unload world with MW
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw unload " + actualWorldName);
+ Bukkit.getServer()
+ .dispatchCommand(Bukkit.getServer().getConsoleSender(),
+ "mw unload " + actualWorldName);
try {
Thread.sleep(1000);
} catch (InterruptedException ignored) {
Thread.currentThread().interrupt();
}
// load world with MW
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
- "mw create " + actualWorldName + " plugin:" + PS.imp().getPluginName());
+ Bukkit.getServer()
+ .dispatchCommand(Bukkit.getServer().getConsoleSender(),
+ "mw create " + actualWorldName + " plugin:" + PS.imp()
+ .getPluginName());
} else {
// Load using Bukkit API
// - User must set generator manually
Bukkit.getServer().unloadWorld(world, true);
- World myWorld = WorldCreator.name(actualWorldName).generator(new BukkitPlotGenerator(PS.get().IMP.getDefaultGenerator())).createWorld();
+ World myWorld = WorldCreator.name(actualWorldName).generator(
+ new BukkitPlotGenerator(PS.get().IMP.getDefaultGenerator()))
+ .createWorld();
myWorld.save();
}
}
@@ -340,11 +365,14 @@ public class LikePlotMeConverter {
done();
sendMessage("&aDatabase conversion is now complete!");
PS.debug("&c - Stop the server");
- PS.debug("&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml");
- PS.debug("&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
+ PS.debug(
+ "&c - Disable 'plotme-converter' and 'plotme-convert.cache-uuids' in the settings.yml");
+ PS.debug(
+ "&c - Correct any generator settings that haven't copied to 'settings.yml' properly");
PS.debug("&c - Start the server");
} else {
- sendMessage("&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
+ sendMessage(
+ "&cPlease wait until database conversion is complete. You will be notified with instructions when this happens!");
done.set(true);
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java
index 9567ebb8f..5617c1f9e 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java
@@ -5,19 +5,11 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.database.SQLite;
-import com.intellectualcrafters.plot.object.Location;
-import com.intellectualcrafters.plot.object.Plot;
-import com.intellectualcrafters.plot.object.PlotArea;
-import com.intellectualcrafters.plot.object.PlotId;
-import com.intellectualcrafters.plot.object.StringWrapper;
+import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.UUIDHandler;
import java.io.File;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
+import java.sql.*;
import java.util.HashMap;
import java.util.UUID;
@@ -25,8 +17,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
private String plugin;
- @Override
- public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig, String dataFolder) {
+ @Override public Connection getPlotMeConnection(String plugin, FileConfiguration plotConfig,
+ String dataFolder) {
this.plugin = plugin.toLowerCase();
try {
if (plotConfig.getBoolean("usemySQL")) {
@@ -39,7 +31,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
if (file.exists()) {
return new SQLite(file).openConnection();
}
- return new SQLite(new File(dataFolder + File.separator + "plots.db")).openConnection();
+ return new SQLite(new File(dataFolder + File.separator + "plots.db"))
+ .openConnection();
}
} catch (SQLException | ClassNotFoundException e) {
e.printStackTrace();
@@ -47,8 +40,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
return null;
}
- @Override
- public HashMap> getPlotMePlots(Connection connection) throws SQLException {
+ @Override public HashMap> getPlotMePlots(Connection connection)
+ throws SQLException {
ResultSet resultSet;
PreparedStatement statement;
HashMap plotWidth = new HashMap<>();
@@ -56,18 +49,21 @@ public class PlotMeConnector_017 extends APlotMeConnector {
HashMap plots = new HashMap<>();
HashMap> merges = new HashMap<>();
try {
- statement = connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_plots`");
+ statement =
+ connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_plots`");
resultSet = statement.executeQuery();
} catch (SQLException e) {
PS.debug("========= Table does not exist =========");
e.printStackTrace();
PS.debug("=======================================");
- PS.debug("&8 - &7The database does not match the version specified in the PlotMe config");
+ PS.debug(
+ "&8 - &7The database does not match the version specified in the PlotMe config");
PS.debug("&8 - &7Please correct this, or if you are unsure, the most common is 0.16.3");
return null;
}
boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerID");
- boolean merge = !"plotme".equals(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
+ boolean merge =
+ !"plotme".equals(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER;
while (resultSet.next()) {
int key = resultSet.getInt("plot_id");
PlotId id = new PlotId(resultSet.getInt("plotX"), resultSet.getInt("plotZ"));
@@ -115,7 +111,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
}
}
if (owner == null) {
- PS.log("&cCould not identify owner for plot: " + id + " -> '" + name + '\'');
+ PS.log(
+ "&cCould not identify owner for plot: " + id + " -> '" + name + '\'');
continue;
}
}
@@ -137,7 +134,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
statement.close();
try {
PS.log(" - " + this.plugin + "core_denied");
- statement = connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_denied`");
+ statement =
+ connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_denied`");
resultSet = statement.executeQuery();
while (resultSet.next()) {
@@ -153,7 +151,8 @@ public class PlotMeConnector_017 extends APlotMeConnector {
}
PS.log(" - " + this.plugin + "core_allowed");
- statement = connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_allowed`");
+ statement =
+ connection.prepareStatement("SELECT * FROM `" + this.plugin + "core_allowed`");
resultSet = statement.executeQuery();
while (resultSet.next()) {
@@ -186,8 +185,7 @@ public class PlotMeConnector_017 extends APlotMeConnector {
return processed;
}
- @Override
- public boolean accepts(String version) {
+ @Override public boolean accepts(String version) {
if (version == null) {
return false;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/ClusterFlagRemoveEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/ClusterFlagRemoveEvent.java
index 40e4a4e43..10ae21dac 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/ClusterFlagRemoveEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/ClusterFlagRemoveEvent.java
@@ -19,7 +19,7 @@ public class ClusterFlagRemoveEvent extends Event implements Cancellable {
/**
* PlotFlagRemoveEvent: Called when a flag is removed from a plot.
*
- * @param flag Flag that was removed
+ * @param flag Flag that was removed
* @param cluster PlotCluster from which the flag was removed
*/
public ClusterFlagRemoveEvent(Flag flag, PlotCluster cluster) {
@@ -49,18 +49,15 @@ public class ClusterFlagRemoveEvent extends Event implements Cancellable {
return this.flag;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
- @Override
- public boolean isCancelled() {
+ @Override public boolean isCancelled() {
return this.cancelled;
}
- @Override
- public void setCancelled(boolean b) {
+ @Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerClaimPlotEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerClaimPlotEvent.java
index 6972e1b56..e209849d5 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerClaimPlotEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerClaimPlotEvent.java
@@ -45,18 +45,15 @@ public class PlayerClaimPlotEvent extends PlayerEvent implements Cancellable {
return this.auto;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
- @Override
- public boolean isCancelled() {
+ @Override public boolean isCancelled() {
return this.cancelled;
}
- @Override
- public void setCancelled(boolean b) {
+ @Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerEnterPlotEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerEnterPlotEvent.java
index db860f35a..34c0f4f97 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerEnterPlotEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerEnterPlotEvent.java
@@ -34,8 +34,7 @@ public class PlayerEnterPlotEvent extends PlayerEvent {
return this.plot;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerLeavePlotEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerLeavePlotEvent.java
index 225d89042..0b9f671aa 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerLeavePlotEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerLeavePlotEvent.java
@@ -38,8 +38,7 @@ public class PlayerLeavePlotEvent extends PlayerEvent {
return this.plot;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotDeniedEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotDeniedEvent.java
index ab9b43b8b..a06962c16 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotDeniedEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotDeniedEvent.java
@@ -59,8 +59,7 @@ public class PlayerPlotDeniedEvent extends PlotEvent {
return this.initiator;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotHelperEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotHelperEvent.java
index 8fc635494..0e7b33200 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotHelperEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotHelperEvent.java
@@ -63,8 +63,7 @@ public class PlayerPlotHelperEvent extends PlotEvent {
return this.initiator;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java
index 2af07a33a..824c1d2d7 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerPlotTrustedEvent.java
@@ -63,8 +63,7 @@ public class PlayerPlotTrustedEvent extends PlotEvent {
return this.initiator;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerTeleportToPlotEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerTeleportToPlotEvent.java
index 069ade2ca..776fa0074 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerTeleportToPlotEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlayerTeleportToPlotEvent.java
@@ -9,9 +9,6 @@ import org.bukkit.event.player.PlayerEvent;
/**
* Called when a player teleports to a plot
- *
-
-
*/
public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellable {
@@ -37,8 +34,7 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
return handlers;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
@@ -60,13 +56,11 @@ public class PlayerTeleportToPlotEvent extends PlayerEvent implements Cancellabl
return this.plot;
}
- @Override
- public boolean isCancelled() {
+ @Override public boolean isCancelled() {
return this.cancelled;
}
- @Override
- public void setCancelled(boolean cancelled) {
+ @Override public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotClearEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotClearEvent.java
index 20ab1d519..124cccaa2 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotClearEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotClearEvent.java
@@ -7,12 +7,12 @@ import org.bukkit.event.HandlerList;
/**
* Called when a plot is cleared
- *
*/
public class PlotClearEvent extends PlotEvent implements Cancellable {
private static final HandlerList handlers = new HandlerList();
private boolean cancelled;
+
public PlotClearEvent(Plot plot) {
super(plot);
}
@@ -39,18 +39,15 @@ public class PlotClearEvent extends PlotEvent implements Cancellable {
return getPlot().getWorldName();
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
- @Override
- public boolean isCancelled() {
+ @Override public boolean isCancelled() {
return this.cancelled;
}
- @Override
- public void setCancelled(boolean b) {
+ @Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotComponentSetEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotComponentSetEvent.java
index d7b33a06b..2578007ab 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotComponentSetEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotComponentSetEvent.java
@@ -6,7 +6,6 @@ import org.bukkit.event.HandlerList;
/**
* Called when a plot component is set
- *
*/
public class PlotComponentSetEvent extends PlotEvent {
@@ -49,8 +48,7 @@ public class PlotComponentSetEvent extends PlotEvent {
return this.component;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotDeleteEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotDeleteEvent.java
index 126b735d7..3be92f7c8 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotDeleteEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotDeleteEvent.java
@@ -6,7 +6,6 @@ import org.bukkit.event.HandlerList;
/**
* Called when a plot is deleted
- *
*/
public class PlotDeleteEvent extends PlotEvent {
@@ -38,8 +37,7 @@ public class PlotDeleteEvent extends PlotEvent {
return getPlot().getWorldName();
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotFlagAddEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotFlagAddEvent.java
index 3ab3fc822..35249b696 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotFlagAddEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotFlagAddEvent.java
@@ -7,7 +7,6 @@ import org.bukkit.event.HandlerList;
/**
* Called when a Flag is added to a plot.
- *
*/
public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
@@ -39,18 +38,15 @@ public class PlotFlagAddEvent extends PlotEvent implements Cancellable {
return this.flag;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
- @Override
- public final boolean isCancelled() {
+ @Override public final boolean isCancelled() {
return this.cancelled;
}
- @Override
- public final void setCancelled(boolean cancelled) {
+ @Override public final void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotFlagRemoveEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotFlagRemoveEvent.java
index 0a8e9679b..bfa3850f7 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotFlagRemoveEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotFlagRemoveEvent.java
@@ -7,7 +7,6 @@ import org.bukkit.event.HandlerList;
/**
* Called when a flag is removed from a plot
- *
*/
public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
@@ -39,18 +38,15 @@ public class PlotFlagRemoveEvent extends PlotEvent implements Cancellable {
return this.flag;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
- @Override
- public final boolean isCancelled() {
+ @Override public final boolean isCancelled() {
return this.cancelled;
}
- @Override
- public final void setCancelled(boolean cancelled) {
+ @Override public final void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotMergeEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotMergeEvent.java
index c03733ef8..f7f4f9ef2 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotMergeEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotMergeEvent.java
@@ -45,18 +45,15 @@ public class PlotMergeEvent extends PlotEvent implements Cancellable {
return this.world;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
- @Override
- public boolean isCancelled() {
+ @Override public boolean isCancelled() {
return this.cancelled;
}
- @Override
- public void setCancelled(boolean b) {
+ @Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotRateEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotRateEvent.java
index 29aef2de8..801ab400d 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotRateEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotRateEvent.java
@@ -33,8 +33,7 @@ public class PlotRateEvent extends PlotEvent {
this.rating = rating;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotUnlinkEvent.java b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotUnlinkEvent.java
index fb37b3a39..d9caab923 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotUnlinkEvent.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/events/PlotUnlinkEvent.java
@@ -50,18 +50,15 @@ public class PlotUnlinkEvent extends Event implements Cancellable {
return this.area;
}
- @Override
- public HandlerList getHandlers() {
+ @Override public HandlerList getHandlers() {
return handlers;
}
- @Override
- public boolean isCancelled() {
+ @Override public boolean isCancelled() {
return this.cancelled;
}
- @Override
- public void setCancelled(boolean b) {
+ @Override public void setCancelled(boolean b) {
this.cancelled = b;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java
index 231d9c51c..9993e9eb9 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitAugmentedGenerator.java
@@ -8,7 +8,7 @@ import org.bukkit.generator.BlockPopulator;
import java.util.Random;
public class BukkitAugmentedGenerator extends BlockPopulator {
-
+
private static BukkitAugmentedGenerator generator;
public static BukkitAugmentedGenerator get(World world) {
@@ -24,8 +24,7 @@ public class BukkitAugmentedGenerator extends BlockPopulator {
return generator;
}
- @Override
- public void populate(World world, Random r, Chunk chunk) {
+ @Override public void populate(World world, Random r, Chunk chunk) {
AugmentedUtils.generate(world.getName(), chunk.getX(), chunk.getZ(), null);
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java
index c9b7c3169..c7ebefff7 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java
@@ -3,14 +3,7 @@ package com.plotsquared.bukkit.generator;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
-import com.intellectualcrafters.plot.object.ChunkLoc;
-import com.intellectualcrafters.plot.object.ChunkWrapper;
-import com.intellectualcrafters.plot.object.Location;
-import com.intellectualcrafters.plot.object.PlotArea;
-import com.intellectualcrafters.plot.object.PlotId;
-import com.intellectualcrafters.plot.object.PlotManager;
-import com.intellectualcrafters.plot.object.PseudoRandom;
-import com.intellectualcrafters.plot.object.SetupObject;
+import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.MainUtil;
@@ -20,26 +13,24 @@ import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.block.GenChunk;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Random;
-import java.util.Set;
import org.bukkit.Chunk;
import org.bukkit.World;
import org.bukkit.block.Biome;
import org.bukkit.generator.BlockPopulator;
import org.bukkit.generator.ChunkGenerator;
-public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrapper {
-
+import java.util.*;
+
+public class BukkitPlotGenerator extends ChunkGenerator
+ implements GeneratorWrapper {
+
private final GenChunk chunkSetter;
private final PseudoRandom random = new PseudoRandom();
private final IndependentPlotGenerator plotGenerator;
- private List populators;
private final ChunkGenerator platformGenerator;
private final boolean full;
private final HashMap dataMap = new HashMap<>();
+ private List populators;
private boolean loaded = false;
public BukkitPlotGenerator(IndependentPlotGenerator generator) {
@@ -53,12 +44,12 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
private LocalBlockQueue queue;
- @Override
- public void populate(World world, Random r, Chunk c) {
+ @Override public void populate(World world, Random r, Chunk c) {
if (queue == null) {
queue = GlobalBlockQueue.IMP.getNewQueue(world.getName(), false);
}
- byte[][] resultData = dataMap.isEmpty() ? null : dataMap.remove(new ChunkLoc(c.getX(), c.getZ()));
+ byte[][] resultData =
+ dataMap.isEmpty() ? null : dataMap.remove(new ChunkLoc(c.getX(), c.getZ()));
if (resultData == null) {
GenChunk result = BukkitPlotGenerator.this.chunkSetter;
// Set the chunk location
@@ -90,7 +81,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
PlotArea area = PS.get().getPlotArea(world.getName(), null);
ChunkWrapper wrap = new ChunkWrapper(area.worldname, c.getX(), c.getZ());
ScopedLocalBlockQueue chunk = queue.getForChunk(wrap.x, wrap.z);
- if (BukkitPlotGenerator.this.plotGenerator.populateChunk(chunk, area, BukkitPlotGenerator.this.random)) {
+ if (BukkitPlotGenerator.this.plotGenerator
+ .populateChunk(chunk, area, BukkitPlotGenerator.this.random)) {
queue.flush();
}
}
@@ -99,51 +91,49 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
this.full = true;
MainUtil.initCache();
}
-
+
public BukkitPlotGenerator(final String world, final ChunkGenerator cg) {
if (cg instanceof BukkitPlotGenerator) {
- throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName() + " is already a BukkitPlotGenerator!");
+ throw new IllegalArgumentException("ChunkGenerator: " + cg.getClass().getName()
+ + " is already a BukkitPlotGenerator!");
}
this.full = false;
PS.debug("BukkitPlotGenerator does not fully support: " + cg);
this.platformGenerator = cg;
this.plotGenerator = new IndependentPlotGenerator() {
- @Override
- public void processSetup(SetupObject setup) {}
-
- @Override
- public void initialize(PlotArea area) {}
-
- @Override
- public PlotManager getNewPlotManager() {
+ @Override public void processSetup(SetupObject setup) {
+ }
+
+ @Override public void initialize(PlotArea area) {
+ }
+
+ @Override public PlotManager getNewPlotManager() {
return PS.get().IMP.getDefaultGenerator().getNewPlotManager();
}
-
- @Override
- public String getName() {
+
+ @Override public String getName() {
return cg.getClass().getName();
}
-
+
@Override
public PlotArea getNewPlotArea(String world, String id, PlotId min, PlotId max) {
return PS.get().IMP.getDefaultGenerator().getNewPlotArea(world, id, min, max);
}
-
+
@Override
- public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings, PseudoRandom random) {
+ public void generateChunk(final ScopedLocalBlockQueue result, PlotArea settings,
+ PseudoRandom random) {
World w = BukkitUtil.getWorld(world);
Location min = result.getMin();
int cx = min.getX() >> 4;
int cz = min.getZ() >> 4;
Random r = new Random(MathMan.pair((short) cx, (short) cz));
BiomeGrid grid = new BiomeGrid() {
- @Override
- public void setBiome(int x, int z, Biome biome) {
+ @Override public void setBiome(int x, int z, Biome biome) {
result.setBiome(x, z, biome.name());
}
-
- @Override
- public Biome getBiome(int arg0, int arg1) {
+
+ @Override public Biome getBiome(int arg0, int arg1) {
return Biome.FOREST;
}
};
@@ -153,7 +143,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
if (data != null) {
return;
}
- } catch (Throwable ignored) {}
+ } catch (Throwable ignored) {
+ }
// Populator spillage
short[][] tmp = cg.generateExtBlockSections(w, r, cx, cz, grid);
if (tmp != null) {
@@ -187,29 +178,24 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
this.chunkSetter = new GenChunk(null, new ChunkWrapper(world, 0, 0));
MainUtil.initCache();
}
-
- @Override
- public void augment(PlotArea area) {
+
+ @Override public void augment(PlotArea area) {
BukkitAugmentedGenerator.get(BukkitUtil.getWorld(area.worldname));
}
-
- @Override
- public boolean isFull() {
+
+ @Override public boolean isFull() {
return this.full;
}
-
- @Override
- public IndependentPlotGenerator getPlotGenerator() {
+
+ @Override public IndependentPlotGenerator getPlotGenerator() {
return this.plotGenerator;
}
-
- @Override
- public ChunkGenerator getPlatformGenerator() {
+
+ @Override public ChunkGenerator getPlatformGenerator() {
return this.platformGenerator;
}
- @Override
- public List getDefaultPopulators(World world) {
+ @Override public List getDefaultPopulators(World world) {
try {
if (!this.loaded) {
String name = world.getName();
@@ -308,9 +294,9 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
}
ChunkManager.postProcessChunk(result);
}
-
- @Override
- public short[][] generateExtBlockSections(World world, Random r, int cx, int cz, BiomeGrid grid) {
+
+ @Override public short[][] generateExtBlockSections(World world, Random r, int cx, int cz,
+ BiomeGrid grid) {
GenChunk result = this.chunkSetter;
// Set the chunk location
result.setChunk(new ChunkWrapper(world.getName(), cx, cz));
@@ -339,21 +325,20 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
// Return the result data
return result.result;
}
-
+
/**
* Allow spawning everywhere.
+ *
* @param world Ignored
- * @param x Ignored
- * @param z Ignored
+ * @param x Ignored
+ * @param z Ignored
* @return always true
*/
- @Override
- public boolean canSpawn(World world, int x, int z) {
+ @Override public boolean canSpawn(World world, int x, int z) {
return true;
}
-
- @Override
- public String toString() {
+
+ @Override public String toString() {
if (this.platformGenerator == this) {
return this.plotGenerator.getName();
}
@@ -363,9 +348,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
return this.platformGenerator.getClass().getName();
}
}
-
- @Override
- public boolean equals(Object obj) {
+
+ @Override public boolean equals(Object obj) {
if (obj == null) {
return false;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java
index ca0dc871e..4448517cb 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ChunkListener.java
@@ -9,8 +9,6 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefClass;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefField;
import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod;
import com.intellectualcrafters.plot.util.TaskManager;
-import java.lang.reflect.Method;
-import java.util.HashSet;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.Material;
@@ -29,6 +27,8 @@ import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.event.world.ChunkUnloadEvent;
+import java.lang.reflect.Method;
+import java.util.HashSet;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
@@ -37,6 +37,7 @@ public class ChunkListener implements Listener {
private RefMethod methodGetHandleChunk;
private RefField mustSave;
private Chunk lastChunk;
+ private boolean ignoreUnload = false;
public ChunkListener() {
if (Settings.Chunk_Processor.AUTO_TRIM) {
@@ -46,7 +47,8 @@ public class ChunkListener implements Listener {
this.mustSave = classChunk.getField("mustSave");
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle");
} catch (Throwable ignored) {
- PS.debug(PS.imp().getPluginName() + "/Server not compatible for chunk processor trim/gc");
+ PS.debug(PS.imp().getPluginName()
+ + "/Server not compatible for chunk processor trim/gc");
Settings.Chunk_Processor.AUTO_TRIM = false;
}
}
@@ -57,8 +59,7 @@ public class ChunkListener implements Listener {
world.setAutoSave(false);
}
TaskManager.runTaskRepeat(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
try {
HashSet toUnload = new HashSet<>();
for (World world : Bukkit.getWorlds()) {
@@ -67,11 +68,14 @@ public class ChunkListener implements Listener {
continue;
}
Object w = world.getClass().getDeclaredMethod("getHandle").invoke(world);
- Object chunkMap = w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w);
- Method methodIsChunkInUse = chunkMap.getClass().getDeclaredMethod("isChunkInUse", int.class, int.class);
+ Object chunkMap =
+ w.getClass().getDeclaredMethod("getPlayerChunkMap").invoke(w);
+ Method methodIsChunkInUse = chunkMap.getClass()
+ .getDeclaredMethod("isChunkInUse", int.class, int.class);
Chunk[] chunks = world.getLoadedChunks();
for (Chunk chunk : chunks) {
- if ((boolean) methodIsChunkInUse.invoke(chunkMap, chunk.getX(), chunk.getZ())) {
+ if ((boolean) methodIsChunkInUse
+ .invoke(chunkMap, chunk.getX(), chunk.getZ())) {
continue;
}
int x = chunk.getX();
@@ -100,8 +104,6 @@ public class ChunkListener implements Listener {
}, 1);
}
- private boolean ignoreUnload = false;
-
public boolean unloadChunk(String world, Chunk chunk, boolean safe) {
if (safe && shouldSave(world, chunk.getX(), chunk.getZ())) {
return false;
@@ -144,8 +146,7 @@ public class ChunkListener implements Listener {
return plot != null && plot.hasOwner();
}
- @EventHandler
- public void onChunkUnload(ChunkUnloadEvent event) {
+ @EventHandler public void onChunkUnload(ChunkUnloadEvent event) {
if (ignoreUnload) {
return;
}
@@ -162,14 +163,12 @@ public class ChunkListener implements Listener {
event.setCancelled(true);
}
}
-
- @EventHandler
- public void onChunkLoad(ChunkLoadEvent event) {
+
+ @EventHandler public void onChunkLoad(ChunkLoadEvent event) {
processChunk(event.getChunk(), false);
}
-
- @EventHandler(priority = EventPriority.LOWEST)
- public void onItemSpawn(ItemSpawnEvent event) {
+
+ @EventHandler(priority = EventPriority.LOWEST) public void onItemSpawn(ItemSpawnEvent event) {
Item entity = event.getEntity();
Chunk chunk = entity.getLocation().getChunk();
if (chunk == this.lastChunk) {
@@ -189,14 +188,14 @@ public class ChunkListener implements Listener {
this.lastChunk = null;
}
}
-
+
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockPhysics(BlockPhysicsEvent event) {
if (Settings.Chunk_Processor.DISABLE_PHYSICS) {
event.setCancelled(true);
}
}
-
+
@EventHandler(priority = EventPriority.LOWEST)
public void onEntitySpawn(CreatureSpawnEvent event) {
LivingEntity entity = event.getEntity();
@@ -223,8 +222,7 @@ public class ChunkListener implements Listener {
TaskManager.index.incrementAndGet();
final Integer currentIndex = TaskManager.index.get();
Integer task = TaskManager.runTaskRepeat(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
if (!chunk.isLoaded()) {
Bukkit.getScheduler().cancelTask(TaskManager.tasks.get(currentIndex));
TaskManager.tasks.remove(currentIndex);
@@ -270,11 +268,13 @@ public class ChunkListener implements Listener {
ent.remove();
}
}
- PS.debug(C.PREFIX.s() + "&a detected unsafe chunk and processed: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
+ PS.debug(C.PREFIX.s() + "&a detected unsafe chunk and processed: " + (chunk.getX() << 4)
+ + "," + (chunk.getX() << 4));
}
if (tiles.length > Settings.Chunk_Processor.MAX_TILES) {
if (unload) {
- PS.debug(C.PREFIX.s() + "&c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (chunk.getX() << 4));
+ PS.debug(C.PREFIX.s() + "&c detected unsafe chunk: " + (chunk.getX() << 4) + "," + (
+ chunk.getX() << 4));
cleanChunk(chunk);
return true;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java
index 20f029a3f..4429dd64b 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntityPortal_1_7_9.java
@@ -1,7 +1,6 @@
package com.plotsquared.bukkit.listeners;
import com.intellectualcrafters.plot.PS;
-import java.util.List;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.ArmorStand;
@@ -17,62 +16,21 @@ import org.bukkit.metadata.FixedMetadataValue;
import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin;
+import java.util.List;
+
public class EntityPortal_1_7_9 implements Listener {
+ private static boolean ignoreTP = false;
+
public EntityPortal_1_7_9() {
}
- @EventHandler
- public void onVehicle(VehicleUpdateEvent event) {
- test(event.getVehicle());
- }
-
- @EventHandler
- public void onVehicle(VehicleDestroyEvent event) {
- test(event.getVehicle());
- }
-
- @EventHandler
- public void onVehicle(VehicleEntityCollisionEvent event) {
- test(event.getVehicle());
- }
-
- @EventHandler
- public void onVehicle(VehicleCreateEvent event) {
- test(event.getVehicle());
- }
-
- @EventHandler
- public void onVehicle(VehicleBlockCollisionEvent event) {
- test(event.getVehicle());
- }
-
- @EventHandler
- public void onTeleport(EntityTeleportEvent event) {
- Entity ent = event.getEntity();
- if (ent instanceof Vehicle || ent instanceof ArmorStand) test(event.getEntity());
- }
-
- @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
- public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException {
- test(event.getVehicle());
- }
-
- @EventHandler
- public void spawn(CreatureSpawnEvent event) {
- switch (event.getEntityType()) {
- case ARMOR_STAND:
- test(event.getEntity());
- }
- }
-
- private static boolean ignoreTP = false;
-
public static void test(Entity entity) {
List meta = entity.getMetadata("plotworld");
World world = entity.getLocation().getWorld();
if (meta == null || meta.isEmpty()) {
if (PS.get().isPlotWorld(world.getName())) {
- entity.setMetadata("plotworld", new FixedMetadataValue((Plugin) PS.get().IMP, entity.getLocation()));
+ entity.setMetadata("plotworld",
+ new FixedMetadataValue((Plugin) PS.get().IMP, entity.getLocation()));
}
} else {
Location origin = (Location) meta.get(0).value();
@@ -96,4 +54,42 @@ public class EntityPortal_1_7_9 implements Listener {
}
}
}
+
+ @EventHandler public void onVehicle(VehicleUpdateEvent event) {
+ test(event.getVehicle());
+ }
+
+ @EventHandler public void onVehicle(VehicleDestroyEvent event) {
+ test(event.getVehicle());
+ }
+
+ @EventHandler public void onVehicle(VehicleEntityCollisionEvent event) {
+ test(event.getVehicle());
+ }
+
+ @EventHandler public void onVehicle(VehicleCreateEvent event) {
+ test(event.getVehicle());
+ }
+
+ @EventHandler public void onVehicle(VehicleBlockCollisionEvent event) {
+ test(event.getVehicle());
+ }
+
+ @EventHandler public void onTeleport(EntityTeleportEvent event) {
+ Entity ent = event.getEntity();
+ if (ent instanceof Vehicle || ent instanceof ArmorStand)
+ test(event.getEntity());
+ }
+
+ @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
+ public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException {
+ test(event.getVehicle());
+ }
+
+ @EventHandler public void spawn(CreatureSpawnEvent event) {
+ switch (event.getEntityType()) {
+ case ARMOR_STAND:
+ test(event.getEntity());
+ }
+ }
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java
index 32bebe45b..aba9934f3 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java
@@ -52,9 +52,10 @@ public class EntitySpawnListener implements Listener {
event.setCancelled(true);
}
case SHULKER:
- if(!entity.hasMetadata("plot")) {
- entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId()));
- }
+ if (!entity.hasMetadata("plot")) {
+ entity.setMetadata("plot",
+ new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId()));
+ }
}
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java
index 32b421a56..7280c2b20 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java
@@ -9,19 +9,22 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
+import org.bukkit.entity.Player;
+import org.bukkit.util.Vector;
+
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
-import org.bukkit.entity.Player;
-import org.bukkit.util.Vector;
public class ForceFieldListener {
private static Set getNearbyPlayers(Player player, Plot plot) {
Set players = new HashSet<>();
- for (Player nearPlayer : Iterables.filter(player.getNearbyEntities(5d, 5d, 5d),Player.class)) {
+ for (Player nearPlayer : Iterables
+ .filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) {
PlotPlayer plotPlayer;
- if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) {
+ if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot
+ .equals(plotPlayer.getCurrentPlot())) {
continue;
}
if (!plot.isAdded(plotPlayer.getUUID())) {
@@ -32,9 +35,11 @@ public class ForceFieldListener {
}
private static PlotPlayer hasNearbyPermitted(Player player, Plot plot) {
- for (Player nearPlayer : Iterables.filter(player.getNearbyEntities(5d, 5d, 5d),Player.class)) {
+ for (Player nearPlayer : Iterables
+ .filter(player.getNearbyEntities(5d, 5d, 5d), Player.class)) {
PlotPlayer plotPlayer;
- if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot.equals(plotPlayer.getCurrentPlot())) {
+ if ((plotPlayer = BukkitUtil.getPlayer(nearPlayer)) == null || !plot
+ .equals(plotPlayer.getCurrentPlot())) {
continue;
}
if (plot.isAdded(plotPlayer.getUUID())) {
@@ -81,7 +86,8 @@ public class ForceFieldListener {
Set players = getNearbyPlayers(player, plot);
for (PlotPlayer oPlayer : players) {
if (!Permissions.hasPermission(oPlayer, C.PERMISSION_ADMIN_ENTRY_FORCEFIELD)) {
- ((BukkitPlayer) oPlayer).player.setVelocity(calculateVelocity(plotPlayer, oPlayer));
+ ((BukkitPlayer) oPlayer).player
+ .setVelocity(calculateVelocity(plotPlayer, oPlayer));
}
}
} else {
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
index fa4577e26..b7bf4a884 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java
@@ -15,18 +15,6 @@ import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.bukkit.util.BukkitVersion;
import com.plotsquared.listener.PlayerBlockEventType;
import com.plotsquared.listener.PlotListener;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map.Entry;
-import java.util.Objects;
-import java.util.Set;
-import java.util.UUID;
-import java.util.regex.Pattern;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -35,75 +23,17 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace;
import org.bukkit.block.BlockState;
import org.bukkit.command.PluginCommand;
-import org.bukkit.entity.Ageable;
-import org.bukkit.entity.Animals;
-import org.bukkit.entity.Arrow;
-import org.bukkit.entity.Creature;
-import org.bukkit.entity.EnderDragon;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.FallingBlock;
-import org.bukkit.entity.Fireball;
-import org.bukkit.entity.Hanging;
-import org.bukkit.entity.HumanEntity;
-import org.bukkit.entity.ItemFrame;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Monster;
-import org.bukkit.entity.Player;
-import org.bukkit.entity.Projectile;
-import org.bukkit.entity.TNTPrimed;
-import org.bukkit.entity.Tameable;
-import org.bukkit.entity.ThrownPotion;
-import org.bukkit.entity.Vehicle;
-import org.bukkit.entity.Villager;
+import org.bukkit.entity.*;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
-import org.bukkit.event.block.Action;
-import org.bukkit.event.block.BlockBreakEvent;
-import org.bukkit.event.block.BlockBurnEvent;
-import org.bukkit.event.block.BlockDamageEvent;
-import org.bukkit.event.block.BlockDispenseEvent;
-import org.bukkit.event.block.BlockFadeEvent;
-import org.bukkit.event.block.BlockFormEvent;
-import org.bukkit.event.block.BlockFromToEvent;
-import org.bukkit.event.block.BlockGrowEvent;
-import org.bukkit.event.block.BlockIgniteEvent;
-import org.bukkit.event.block.BlockPhysicsEvent;
-import org.bukkit.event.block.BlockPistonExtendEvent;
-import org.bukkit.event.block.BlockPistonRetractEvent;
-import org.bukkit.event.block.BlockPlaceEvent;
-import org.bukkit.event.block.BlockRedstoneEvent;
-import org.bukkit.event.block.BlockSpreadEvent;
-import org.bukkit.event.block.EntityBlockFormEvent;
-import org.bukkit.event.entity.CreatureSpawnEvent;
-import org.bukkit.event.entity.EntityChangeBlockEvent;
-import org.bukkit.event.entity.EntityCombustByEntityEvent;
-import org.bukkit.event.entity.EntityDamageByEntityEvent;
-import org.bukkit.event.entity.EntityDamageEvent;
-import org.bukkit.event.entity.EntityExplodeEvent;
-import org.bukkit.event.entity.ExplosionPrimeEvent;
-import org.bukkit.event.entity.PotionSplashEvent;
-import org.bukkit.event.entity.ProjectileHitEvent;
-import org.bukkit.event.entity.ProjectileLaunchEvent;
+import org.bukkit.event.block.*;
+import org.bukkit.event.entity.*;
import org.bukkit.event.hanging.HangingBreakByEntityEvent;
import org.bukkit.event.hanging.HangingPlaceEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
-import org.bukkit.event.player.AsyncPlayerChatEvent;
-import org.bukkit.event.player.PlayerBucketEmptyEvent;
-import org.bukkit.event.player.PlayerBucketFillEvent;
-import org.bukkit.event.player.PlayerChangedWorldEvent;
-import org.bukkit.event.player.PlayerCommandPreprocessEvent;
-import org.bukkit.event.player.PlayerEggThrowEvent;
-import org.bukkit.event.player.PlayerEvent;
-import org.bukkit.event.player.PlayerInteractEntityEvent;
-import org.bukkit.event.player.PlayerInteractEvent;
-import org.bukkit.event.player.PlayerJoinEvent;
-import org.bukkit.event.player.PlayerMoveEvent;
-import org.bukkit.event.player.PlayerQuitEvent;
-import org.bukkit.event.player.PlayerRespawnEvent;
-import org.bukkit.event.player.PlayerTeleportEvent;
+import org.bukkit.event.player.*;
import org.bukkit.event.vehicle.VehicleCreateEvent;
import org.bukkit.event.vehicle.VehicleDestroyEvent;
import org.bukkit.event.vehicle.VehicleMoveEvent;
@@ -117,9 +47,15 @@ import org.bukkit.projectiles.BlockProjectileSource;
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.util.Vector;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.*;
+import java.util.Map.Entry;
+import java.util.regex.Pattern;
+
/**
* Player Events involving plots.
- *
*/
public class PlayerEvents extends PlotListener implements Listener {
@@ -127,11 +63,24 @@ public class PlayerEvents extends PlotListener implements Listener {
private float lastRadius;
// To prevent recursion
private boolean tmpTeleport = true;
+ private Field fieldPlayer;
+ private PlayerMoveEvent moveTmp;
+ private boolean v112 =
+ PS.get().checkVersion(PS.imp().getServerVersion(), BukkitVersion.v1_12_0);
- public static void sendBlockChange(final org.bukkit.Location bloc, final Material type, final byte data) {
+ {
+ try {
+ fieldPlayer = PlayerEvent.class.getDeclaredField("player");
+ fieldPlayer.setAccessible(true);
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ }
+ }
+
+ public static void sendBlockChange(final org.bukkit.Location bloc, final Material type,
+ final byte data) {
TaskManager.runTaskLater(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
String world = bloc.getWorld().getName();
int x = bloc.getBlockX();
int z = bloc.getBlockZ();
@@ -140,7 +89,8 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer player = entry.getValue();
Location loc = player.getLocation();
if (loc.getWorld().equals(world)) {
- if (16 * Math.abs(loc.getX() - x) / 16 > distance || 16 * Math.abs(loc.getZ() - z) / 16 > distance) {
+ if (16 * Math.abs(loc.getX() - x) / 16 > distance
+ || 16 * Math.abs(loc.getZ() - z) / 16 > distance) {
continue;
}
((BukkitPlayer) player).player.sendBlockChange(bloc, type, data);
@@ -150,8 +100,213 @@ public class PlayerEvents extends PlotListener implements Listener {
}, 3);
}
- @EventHandler
- public void onRedstoneEvent(BlockRedstoneEvent event) {
+ public static boolean checkEntity(Plot plot, IntegerFlag... flags) {
+ if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(plot)) {
+ return true;
+ }
+ int[] mobs = null;
+ for (IntegerFlag flag : flags) {
+ int i;
+ switch (flag.getName()) {
+ case "entity-cap":
+ i = 0;
+ break;
+ case "mob-cap":
+ i = 3;
+ break;
+ case "hostile-cap":
+ i = 2;
+ break;
+ case "animal-cap":
+ i = 1;
+ break;
+ case "vehicle-cap":
+ i = 4;
+ break;
+ case "misc-cap":
+ i = 5;
+ break;
+ default:
+ i = 0;
+ }
+ int cap = plot.getFlag(flag, Integer.MAX_VALUE);
+ if (cap == Integer.MAX_VALUE) {
+ continue;
+ }
+ if (cap == 0) {
+ return true;
+ }
+ if (mobs == null) {
+ mobs = plot.countEntities();
+ }
+ if (mobs[i] >= cap) {
+ plot.setMeta("EntityCount", mobs);
+ plot.setMeta("EntityCountTime", System.currentTimeMillis());
+ return true;
+ }
+ }
+ if (mobs != null) {
+ for (IntegerFlag flag : flags) {
+ int i;
+ switch (flag.getName()) {
+ case "entity-cap":
+ i = 0;
+ break;
+ case "mob-cap":
+ i = 3;
+ break;
+ case "hostile-cap":
+ i = 2;
+ break;
+ case "animal-cap":
+ i = 1;
+ break;
+ case "vehicle-cap":
+ i = 4;
+ break;
+ case "misc-cap":
+ i = 5;
+ break;
+ default:
+ i = 0;
+ }
+ mobs[i]++;
+ }
+ plot.setMeta("EntityCount", mobs);
+ plot.setMeta("EntityCountTime", System.currentTimeMillis());
+ }
+ return false;
+ }
+
+ public static boolean checkEntity(Entity entity, Plot plot) {
+ if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot
+ .getArea().DEFAULT_FLAGS.isEmpty()) {
+ return false;
+ }
+ switch (entity.getType()) {
+ case PLAYER:
+ return false;
+ case LLAMA_SPIT:
+ case SMALL_FIREBALL:
+ case FIREBALL:
+ case DROPPED_ITEM:
+ case EGG:
+ case THROWN_EXP_BOTTLE:
+ case SPLASH_POTION:
+ case LINGERING_POTION:
+ case SNOWBALL:
+ case ENDER_PEARL:
+ case ARROW:
+ case TIPPED_ARROW:
+ case SPECTRAL_ARROW:
+ case SHULKER_BULLET:
+ case DRAGON_FIREBALL:
+ // projectile
+ case PRIMED_TNT:
+ case FALLING_BLOCK:
+ // Block entities
+ case ENDER_CRYSTAL:
+ case COMPLEX_PART:
+ case FISHING_HOOK:
+ case ENDER_SIGNAL:
+ case EXPERIENCE_ORB:
+ case LEASH_HITCH:
+ case FIREWORK:
+ case WEATHER:
+ case AREA_EFFECT_CLOUD:
+ case LIGHTNING:
+ case WITHER_SKULL:
+ case EVOKER_FANGS:
+ case UNKNOWN:
+ // non moving / unmovable
+ return checkEntity(plot, Flags.ENTITY_CAP);
+ case ITEM_FRAME:
+ case PAINTING:
+ case ARMOR_STAND:
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
+ // misc
+ case MINECART:
+ case MINECART_CHEST:
+ case MINECART_COMMAND:
+ case MINECART_FURNACE:
+ case MINECART_HOPPER:
+ case MINECART_MOB_SPAWNER:
+ case MINECART_TNT:
+ case BOAT:
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
+ case POLAR_BEAR:
+ case RABBIT:
+ case SHEEP:
+ case MUSHROOM_COW:
+ case OCELOT:
+ case PIG:
+ case SQUID:
+ case VILLAGER:
+ case IRON_GOLEM:
+ case WOLF:
+ case CHICKEN:
+ case COW:
+ case SNOWMAN:
+ case BAT:
+ case HORSE:
+ case DONKEY:
+ case LLAMA:
+ case MULE:
+ case ZOMBIE_HORSE:
+ case SKELETON_HORSE:
+ // animal
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
+ case BLAZE:
+ case CAVE_SPIDER:
+ case CREEPER:
+ case ENDERMAN:
+ case ENDERMITE:
+ case ENDER_DRAGON:
+ case GHAST:
+ case GIANT:
+ case GUARDIAN:
+ case MAGMA_CUBE:
+ case PIG_ZOMBIE:
+ case SILVERFISH:
+ case SKELETON:
+ case SLIME:
+ case SPIDER:
+ case WITCH:
+ case WITHER:
+ case ZOMBIE:
+ case SHULKER:
+ case HUSK:
+ case STRAY:
+ case ELDER_GUARDIAN:
+ case WITHER_SKELETON:
+ case VINDICATOR:
+ case EVOKER:
+ case VEX:
+ case ZOMBIE_VILLAGER:
+ // monster
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
+ default:
+ if (entity instanceof LivingEntity) {
+ if (entity instanceof Animals) {
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
+ } else if (entity instanceof Monster) {
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP,
+ Flags.HOSTILE_CAP);
+ } else {
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP);
+ }
+ }
+ if (entity instanceof Vehicle) {
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
+ }
+ if (entity instanceof Hanging) {
+ return checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
+ }
+ return checkEntity(plot, Flags.ENTITY_CAP);
+ }
+ }
+
+ @EventHandler public void onRedstoneEvent(BlockRedstoneEvent event) {
Block block = event.getBlock();
switch (block.getType()) {
case OBSERVER:
@@ -312,14 +467,13 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true);
return;
}
+ }
}
- }
- break;
+ break;
}
}
- @EventHandler
- public void onProjectileLaunch(ProjectileLaunchEvent event) {
+ @EventHandler public void onProjectileLaunch(ProjectileLaunchEvent event) {
Projectile entity = event.getEntity();
if (!(entity instanceof ThrownPotion)) {
return;
@@ -340,8 +494,7 @@ public class PlayerEvents extends PlotListener implements Listener {
}
}
- @EventHandler
- public boolean onProjectileHit(ProjectileHitEvent event) {
+ @EventHandler public boolean onProjectileHit(ProjectileHitEvent event) {
Projectile entity = event.getEntity();
Location loc = BukkitUtil.getLocation(entity);
if (!PS.get().hasPlotArea(loc.getWorld())) {
@@ -362,7 +515,8 @@ public class PlayerEvents extends PlotListener implements Listener {
}
return true;
}
- if (plot.isAdded(pp.getUUID()) || Permissions.hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
+ if (plot.isAdded(pp.getUUID()) || Permissions
+ .hasPermission(pp, C.PERMISSION_PROJECTILE_OTHER)) {
return true;
}
entity.remove();
@@ -373,7 +527,8 @@ public class PlayerEvents extends PlotListener implements Listener {
entity.remove();
return false;
}
- Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
+ Location sLoc =
+ BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
if (!area.contains(sLoc.getX(), sLoc.getZ())) {
entity.remove();
return false;
@@ -408,7 +563,8 @@ public class PlayerEvents extends PlotListener implements Listener {
case "/up":
case "worldedit:up":
case "worldedit:/up":
- if (plot == null || (!plot.isAdded(pp.getUUID()) && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER, true))) {
+ if (plot == null || (!plot.isAdded(pp.getUUID()) && !Permissions
+ .hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER, true))) {
event.setCancelled(true);
return;
}
@@ -418,7 +574,8 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
Optional> flag = plot.getFlag(Flags.BLOCKED_CMDS);
- if (flag.isPresent() && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
+ if (flag.isPresent() && !Permissions
+ .hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_BLOCKED_CMDS)) {
List blocked_cmds = flag.get();
String c = parts[0];
if (parts[0].contains(":")) {
@@ -501,8 +658,7 @@ public class PlayerEvents extends PlotListener implements Listener {
// Async
TaskManager.runTaskLaterAsync(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
if (!player.hasPlayedBefore() && player.isOnline()) {
player.saveData();
}
@@ -520,7 +676,8 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onTeleport(PlayerTeleportEvent event) {
- if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld().equals(event.getTo().getWorld())) {
+ if (event.getTo() == null || event.getFrom() == null || !event.getFrom().getWorld()
+ .equals(event.getTo().getWorld())) {
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
org.bukkit.Location to = event.getTo();
@@ -542,25 +699,14 @@ public class PlayerEvents extends PlotListener implements Listener {
playerMove(event);
}
- private Field fieldPlayer;
- {
- try {
- fieldPlayer = PlayerEvent.class.getDeclaredField("player");
- fieldPlayer.setAccessible(true);
- } catch (NoSuchFieldException e) {
- e.printStackTrace();
- }
- }
- private PlayerMoveEvent moveTmp;
- private boolean v112 = PS.get().checkVersion(PS.imp().getServerVersion(), BukkitVersion.v1_12_0);
-
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void vehicleMove(VehicleMoveEvent event) throws IllegalAccessException {
final org.bukkit.Location from = event.getFrom();
final org.bukkit.Location to = event.getTo();
int toX, toZ;
- if ((toX = MathMan.roundInt(to.getX())) != MathMan.roundInt(from.getX()) | (toZ = MathMan.roundInt(to.getZ())) != MathMan.roundInt(from.getZ())) {
+ if ((toX = MathMan.roundInt(to.getX())) != MathMan.roundInt(from.getX())
+ | (toZ = MathMan.roundInt(to.getZ())) != MathMan.roundInt(from.getZ())) {
Vehicle vehicle = event.getVehicle();
// Check allowed
@@ -571,21 +717,25 @@ public class PlayerEvents extends PlotListener implements Listener {
if (passenger instanceof Player) {
final Player player = (Player) passenger;
// reset
- if (moveTmp == null) moveTmp = new PlayerMoveEvent(null, from, to);
+ if (moveTmp == null)
+ moveTmp = new PlayerMoveEvent(null, from, to);
moveTmp.setFrom(from);
moveTmp.setTo(to);
moveTmp.setCancelled(false);
fieldPlayer.set(moveTmp, player);
List passengers;
- if (v112) passengers = vehicle.getPassengers();
- else passengers = null;
+ if (v112)
+ passengers = vehicle.getPassengers();
+ else
+ passengers = null;
this.playerMove(moveTmp);
org.bukkit.Location dest;
if (moveTmp.isCancelled()) {
dest = from;
- } else if (MathMan.roundInt(moveTmp.getTo().getX()) != toX || MathMan.roundInt(moveTmp.getTo().getZ()) != toZ) {
+ } else if (MathMan.roundInt(moveTmp.getTo().getX()) != toX
+ || MathMan.roundInt(moveTmp.getTo().getZ()) != toZ) {
dest = to;
} else {
dest = null;
@@ -595,7 +745,8 @@ public class PlayerEvents extends PlotListener implements Listener {
vehicle.eject();
vehicle.setVelocity(new Vector(0d, 0d, 0d));
vehicle.teleport(dest);
- for (final Entity entity : passengers) vehicle.addPassenger(entity);
+ for (final Entity entity : passengers)
+ vehicle.addPassenger(entity);
} else {
vehicle.eject();
vehicle.setVelocity(new Vector(0d, 0d, 0d));
@@ -624,7 +775,8 @@ public class PlayerEvents extends PlotListener implements Listener {
vehicle.remove();
}
} else if (toPlot != null) {
- vehicle.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, toPlot));
+ vehicle.setMetadata("plot",
+ new FixedMetadataValue((Plugin) PS.get().IMP, toPlot));
}
}
}
@@ -788,7 +940,8 @@ public class PlayerEvents extends PlotListener implements Listener {
}
}
}
- String partial = ChatColor.translateAlternateColorCodes('&',format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender));
+ String partial = ChatColor.translateAlternateColorCodes('&',
+ format.replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender));
if (plotPlayer.hasPermission("plots.chat.color")) {
message = C.color(message);
}
@@ -797,7 +950,8 @@ public class PlayerEvents extends PlotListener implements Listener {
receiver.sendMessage(full);
}
if (!spies.isEmpty()) {
- String spyMessage = C.PLOT_CHAT_SPY_FORMAT.s().replace("%plot_id%", id.x + ";" + id.y).replace("%sender%", sender).replace("%msg%", message);
+ String spyMessage = C.PLOT_CHAT_SPY_FORMAT.s().replace("%plot_id%", id.x + ";" + id.y)
+ .replace("%sender%", sender).replace("%msg%", message);
for (Player player : spies) {
player.sendMessage(spyMessage);
}
@@ -805,8 +959,7 @@ public class PlayerEvents extends PlotListener implements Listener {
PS.debug(full);
}
- @EventHandler(priority = EventPriority.LOWEST)
- public void blockDestroy(BlockBreakEvent event) {
+ @EventHandler(priority = EventPriority.LOWEST) public void blockDestroy(BlockBreakEvent event) {
Player player = event.getPlayer();
Location location = BukkitUtil.getLocation(event.getBlock().getLocation());
PlotArea area = location.getPlotArea();
@@ -817,21 +970,27 @@ public class PlayerEvents extends PlotListener implements Listener {
if (plot != null) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (event.getBlock().getY() == 0) {
- if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
+ if (!Permissions
+ .hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL)) {
+ MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
+ C.PERMISSION_ADMIN_DESTROY_GROUNDLEVEL);
event.setCancelled(true);
return;
}
- } else if ((location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT) && !Permissions
+ } else if (
+ (location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT)
+ && !Permissions
.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
event.setCancelled(true);
- MainUtil.sendMessage(plotPlayer, C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
+ MainUtil.sendMessage(plotPlayer,
+ C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
}
if (!plot.hasOwner()) {
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
return;
}
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
+ MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
+ C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true);
return;
}
@@ -839,17 +998,19 @@ public class PlayerEvents extends PlotListener implements Listener {
Optional> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock();
if (destroy.isPresent() && destroy.get()
- .contains(PlotBlock.get((short) block.getTypeId(), block.getData()))) {
+ .contains(PlotBlock.get((short) block.getTypeId(), block.getData()))) {
return;
}
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return;
}
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
+ MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
+ C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true);
} else if (Settings.Done.RESTRICT_BUILDING && plot.getFlags().containsKey(Flags.DONE)) {
if (!Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
+ MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
+ C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
return;
}
@@ -861,7 +1022,8 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
if (PS.get().worldedit != null && pp.getAttribute("worldedit")) {
- if (player.getItemInHand().getTypeId() == PS.get().worldedit.getConfiguration().wandItem) {
+ if (player.getItemInHand().getTypeId() == PS.get().worldedit
+ .getConfiguration().wandItem) {
return;
}
}
@@ -897,11 +1059,14 @@ public class PlayerEvents extends PlotListener implements Listener {
origin = (Plot) meta.get(0).value();
}
if (this.lastRadius != 0) {
- List nearby = event.getEntity().getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
+ List nearby = event.getEntity()
+ .getNearbyEntities(this.lastRadius, this.lastRadius, this.lastRadius);
for (Entity near : nearby) {
- if (near instanceof TNTPrimed || near.getType().equals(EntityType.MINECART_TNT)) {
+ if (near instanceof TNTPrimed || near.getType()
+ .equals(EntityType.MINECART_TNT)) {
if (!near.hasMetadata("plot")) {
- near.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
+ near.setMetadata("plot",
+ new FixedMetadataValue((Plugin) PS.get().IMP, plot));
}
}
}
@@ -911,7 +1076,8 @@ public class PlayerEvents extends PlotListener implements Listener {
while (iterator.hasNext()) {
Block block = iterator.next();
location = BukkitUtil.getLocation(block.getLocation());
- if (!area.contains(location.getX(), location.getZ()) || !origin.equals(area.getOwnedPlot(location))) {
+ if (!area.contains(location.getX(), location.getZ()) || !origin
+ .equals(area.getOwnedPlot(location))) {
iterator.remove();
}
}
@@ -960,7 +1126,8 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotArea area = location.getPlotArea();
if (area != null) {
Plot plot = area.getOwnedPlot(location);
- if (plot != null && Flags.MOB_BREAK.isTrue(plot)) return;
+ if (plot != null && Flags.MOB_BREAK.isTrue(plot))
+ return;
event.setCancelled(true);
}
}
@@ -1113,8 +1280,9 @@ public class PlayerEvents extends PlotListener implements Listener {
if (!plot.isAdded(plotPlayer.getUUID())) {
Optional> destroy = plot.getFlag(Flags.BREAK);
Block block = event.getBlock();
- if (destroy.isPresent() && destroy.get().contains(PlotBlock.get((short) block.getTypeId(), block.getData())) || Permissions
- .hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
+ if (destroy.isPresent() && destroy.get()
+ .contains(PlotBlock.get((short) block.getTypeId(), block.getData()))
+ || Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
return;
}
event.setCancelled(true);
@@ -1176,7 +1344,8 @@ public class PlayerEvents extends PlotListener implements Listener {
if (Flags.DISABLE_PHYSICS.isFalse(plot)) {
event.setCancelled(true);
return;
- } else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
+ } else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
+ .equals(plot, area.getOwnedPlot(fLocation))) {
event.setCancelled(true);
return;
}
@@ -1189,7 +1358,8 @@ public class PlayerEvents extends PlotListener implements Listener {
event.setCancelled(true);
}
}
- } else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects.equals(plot, area.getOwnedPlot(fLocation))) {
+ } else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects
+ .equals(plot, area.getOwnedPlot(fLocation))) {
event.setCancelled(true);
}
}
@@ -1230,11 +1400,13 @@ public class PlayerEvents extends PlotListener implements Listener {
List blocks = event.getBlocks();
for (Block b : blocks) {
Location bloc = BukkitUtil.getLocation(b.getLocation());
- if (!area.contains(bloc.getX(), bloc.getZ()) || !area.contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
+ if (!area.contains(bloc.getX(), bloc.getZ()) || !area
+ .contains(bloc.getX() + relative.getBlockX(), bloc.getZ() + relative.getBlockZ())) {
event.setCancelled(true);
return;
}
- if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
+ if (!plot.equals(area.getOwnedPlot(bloc)) || !plot.equals(area.getOwnedPlot(
+ bloc.add(relative.getBlockX(), relative.getBlockY(), relative.getBlockZ())))) {
event.setCancelled(true);
return;
}
@@ -1265,7 +1437,8 @@ public class PlayerEvents extends PlotListener implements Listener {
}
if (!this.pistonBlocks && block.getType() != Material.PISTON_BASE) {
BlockFace dir = event.getDirection();
- location = BukkitUtil.getLocation(block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
+ location = BukkitUtil.getLocation(block.getLocation()
+ .add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
if (location.getPlotArea() != null) {
event.setCancelled(true);
return;
@@ -1275,17 +1448,18 @@ public class PlayerEvents extends PlotListener implements Listener {
}
Plot plot = area.getOwnedPlot(location);
BlockFace dir = event.getDirection();
-// Location head = location.add(-dir.getModX(), -dir.getModY(), -dir.getModZ());
-//
-// if (!Objects.equals(plot, area.getOwnedPlot(head))) {
-// // FIXME: cancelling the event doesn't work here. See issue #1484
-// event.setCancelled(true);
-// return;
-// }
+ // Location head = location.add(-dir.getModX(), -dir.getModY(), -dir.getModZ());
+ //
+ // if (!Objects.equals(plot, area.getOwnedPlot(head))) {
+ // // FIXME: cancelling the event doesn't work here. See issue #1484
+ // event.setCancelled(true);
+ // return;
+ // }
if (this.pistonBlocks) {
try {
for (Block pulled : event.getBlocks()) {
- Location from = BukkitUtil.getLocation(pulled.getLocation().add(dir.getModX(), dir.getModY(), dir.getModZ()));
+ Location from = BukkitUtil.getLocation(
+ pulled.getLocation().add(dir.getModX(), dir.getModY(), dir.getModZ()));
Location to = BukkitUtil.getLocation(pulled.getLocation());
if (!area.contains(to.getX(), to.getZ())) {
event.setCancelled(true);
@@ -1303,7 +1477,8 @@ public class PlayerEvents extends PlotListener implements Listener {
}
}
if (!this.pistonBlocks && block.getType() != Material.PISTON_BASE) {
- location = BukkitUtil.getLocation(block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
+ location = BukkitUtil.getLocation(
+ block.getLocation().add(dir.getModX() * 2, dir.getModY() * 2, dir.getModZ() * 2));
if (!area.contains(location)) {
event.setCancelled(true);
return;
@@ -1321,14 +1496,18 @@ public class PlayerEvents extends PlotListener implements Listener {
switch (type) {
case WATER_BUCKET:
case LAVA_BUCKET: {
- if (event.getBlock().getType() == Material.DROPPER) return;
- BlockFace targetFace = ((org.bukkit.material.Dispenser) event.getBlock().getState().getData()).getFacing();
- Location location = BukkitUtil.getLocation(event.getBlock().getRelative(targetFace).getLocation());
+ if (event.getBlock().getType() == Material.DROPPER)
+ return;
+ BlockFace targetFace =
+ ((org.bukkit.material.Dispenser) event.getBlock().getState().getData())
+ .getFacing();
+ Location location =
+ BukkitUtil.getLocation(event.getBlock().getRelative(targetFace).getLocation());
if (location.isPlotRoad()) {
event.setCancelled(true);
}
}
- }
+ }
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -1494,7 +1673,8 @@ public class PlayerEvents extends PlotListener implements Listener {
}
lb = new BukkitLazyBlock(blockId, block);
ItemStack hand = player.getItemInHand();
- if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK || !player.isSneaking())) {
+ if (eventType != null && (eventType != PlayerBlockEventType.INTERACT_BLOCK
+ || !player.isSneaking())) {
break;
}
Material type = (hand == null) ? null : hand.getType();
@@ -1504,7 +1684,8 @@ public class PlayerEvents extends PlotListener implements Listener {
break;
}
if (id < 198) {
- location = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());
+ location = BukkitUtil
+ .getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_BLOCK;
lb = new BukkitLazyBlock(id, block);
break;
@@ -1518,7 +1699,8 @@ public class PlayerEvents extends PlotListener implements Listener {
eventType = PlayerBlockEventType.SPAWN_MOB;
break;
case ARMOR_STAND:
- location = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());
+ location = BukkitUtil
+ .getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_MISC;
break;
case WRITTEN_BOOK:
@@ -1560,7 +1742,8 @@ public class PlayerEvents extends PlotListener implements Listener {
break;
case PAINTING:
case ITEM_FRAME:
- location = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation());
+ location = BukkitUtil
+ .getLocation(block.getRelative(event.getBlockFace()).getLocation());
eventType = PlayerBlockEventType.PLACE_HANGING;
break;
default:
@@ -1579,7 +1762,8 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
if (PS.get().worldedit != null && pp.getAttribute("worldedit")) {
- if (player.getItemInHand().getTypeId() == PS.get().worldedit.getConfiguration().wandItem) {
+ if (player.getItemInHand().getTypeId() == PS.get().worldedit
+ .getConfiguration().wandItem) {
return;
}
}
@@ -1673,219 +1857,15 @@ public class PlayerEvents extends PlotListener implements Listener {
entity.remove();
}
} else if (event.getTo() == Material.AIR) {
- event.getEntity().setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
+ event.getEntity()
+ .setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
}
}
- @EventHandler
- public void onPrime(ExplosionPrimeEvent event) {
+ @EventHandler public void onPrime(ExplosionPrimeEvent event) {
this.lastRadius = event.getRadius() + 1;
}
- public static boolean checkEntity(Plot plot, IntegerFlag... flags) {
- if (Settings.Done.RESTRICT_BUILDING && Flags.DONE.isSet(plot)) {
- return true;
- }
- int[] mobs = null;
- for (IntegerFlag flag : flags) {
- int i;
- switch (flag.getName()) {
- case "entity-cap":
- i = 0;
- break;
- case "mob-cap":
- i = 3;
- break;
- case "hostile-cap":
- i = 2;
- break;
- case "animal-cap":
- i = 1;
- break;
- case "vehicle-cap":
- i = 4;
- break;
- case "misc-cap":
- i = 5;
- break;
- default:
- i = 0;
- }
- int cap = plot.getFlag(flag, Integer.MAX_VALUE);
- if (cap == Integer.MAX_VALUE) {
- continue;
- }
- if (cap == 0) {
- return true;
- }
- if (mobs == null) {
- mobs = plot.countEntities();
- }
- if (mobs[i] >= cap) {
- plot.setMeta("EntityCount", mobs);
- plot.setMeta("EntityCountTime", System.currentTimeMillis());
- return true;
- }
- }
- if (mobs != null) {
- for (IntegerFlag flag : flags) {
- int i;
- switch (flag.getName()) {
- case "entity-cap":
- i = 0;
- break;
- case "mob-cap":
- i = 3;
- break;
- case "hostile-cap":
- i = 2;
- break;
- case "animal-cap":
- i = 1;
- break;
- case "vehicle-cap":
- i = 4;
- break;
- case "misc-cap":
- i = 5;
- break;
- default:
- i = 0;
- }
- mobs[i]++;
- }
- plot.setMeta("EntityCount", mobs);
- plot.setMeta("EntityCountTime", System.currentTimeMillis());
- }
- return false;
- }
-
- public static boolean checkEntity(Entity entity, Plot plot) {
- if (plot == null || !plot.hasOwner() || plot.getFlags().isEmpty() && plot.getArea().DEFAULT_FLAGS.isEmpty()) {
- return false;
- }
- switch (entity.getType()) {
- case PLAYER:
- return false;
- case LLAMA_SPIT:
- case SMALL_FIREBALL:
- case FIREBALL:
- case DROPPED_ITEM:
- case EGG:
- case THROWN_EXP_BOTTLE:
- case SPLASH_POTION:
- case LINGERING_POTION:
- case SNOWBALL:
- case ENDER_PEARL:
- case ARROW:
- case TIPPED_ARROW:
- case SPECTRAL_ARROW:
- case SHULKER_BULLET:
- case DRAGON_FIREBALL:
- // projectile
- case PRIMED_TNT:
- case FALLING_BLOCK:
- // Block entities
- case ENDER_CRYSTAL:
- case COMPLEX_PART:
- case FISHING_HOOK:
- case ENDER_SIGNAL:
- case EXPERIENCE_ORB:
- case LEASH_HITCH:
- case FIREWORK:
- case WEATHER:
- case AREA_EFFECT_CLOUD:
- case LIGHTNING:
- case WITHER_SKULL:
- case EVOKER_FANGS:
- case UNKNOWN:
- // non moving / unmovable
- return checkEntity(plot, Flags.ENTITY_CAP);
- case ITEM_FRAME:
- case PAINTING:
- case ARMOR_STAND:
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
- // misc
- case MINECART:
- case MINECART_CHEST:
- case MINECART_COMMAND:
- case MINECART_FURNACE:
- case MINECART_HOPPER:
- case MINECART_MOB_SPAWNER:
- case MINECART_TNT:
- case BOAT:
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
- case POLAR_BEAR:
- case RABBIT:
- case SHEEP:
- case MUSHROOM_COW:
- case OCELOT:
- case PIG:
- case SQUID:
- case VILLAGER:
- case IRON_GOLEM:
- case WOLF:
- case CHICKEN:
- case COW:
- case SNOWMAN:
- case BAT:
- case HORSE:
- case DONKEY:
- case LLAMA:
- case MULE:
- case ZOMBIE_HORSE:
- case SKELETON_HORSE:
- // animal
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
- case BLAZE:
- case CAVE_SPIDER:
- case CREEPER:
- case ENDERMAN:
- case ENDERMITE:
- case ENDER_DRAGON:
- case GHAST:
- case GIANT:
- case GUARDIAN:
- case MAGMA_CUBE:
- case PIG_ZOMBIE:
- case SILVERFISH:
- case SKELETON:
- case SLIME:
- case SPIDER:
- case WITCH:
- case WITHER:
- case ZOMBIE:
- case SHULKER:
- case HUSK:
- case STRAY:
- case ELDER_GUARDIAN:
- case WITHER_SKELETON:
- case VINDICATOR:
- case EVOKER:
- case VEX:
- case ZOMBIE_VILLAGER:
- // monster
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
- default:
- if (entity instanceof LivingEntity) {
- if (entity instanceof Animals) {
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP);
- } else if (entity instanceof Monster) {
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP);
- } else {
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP);
- }
- }
- if (entity instanceof Vehicle) {
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.VEHICLE_CAP);
- }
- if (entity instanceof Hanging) {
- return checkEntity(plot, Flags.ENTITY_CAP, Flags.MISC_CAP);
- }
- return checkEntity(plot, Flags.ENTITY_CAP);
- }
- }
-
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockBurn(BlockBurnEvent event) {
Block b = event.getBlock();
@@ -1939,7 +1919,8 @@ public class PlayerEvents extends PlotListener implements Listener {
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
@@ -1956,7 +1937,7 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
if (ignitingEntity != null) {
- if (!plot.getFlag(Flags.BLOCK_IGNITION,false)) {
+ if (!plot.getFlag(Flags.BLOCK_IGNITION, false)) {
event.setCancelled(true);
return;
}
@@ -1968,7 +1949,8 @@ public class PlayerEvents extends PlotListener implements Listener {
Entity shooter = (Entity) fireball.getShooter();
location = BukkitUtil.getLocation(shooter.getLocation());
} else if (fireball.getShooter() instanceof BlockProjectileSource) {
- Block shooter = ((BlockProjectileSource) fireball.getShooter()).getBlock();
+ Block shooter =
+ ((BlockProjectileSource) fireball.getShooter()).getBlock();
location = BukkitUtil.getLocation(shooter.getLocation());
}
if (location != null && !plot.equals(location.getPlot())) {
@@ -1980,10 +1962,13 @@ public class PlayerEvents extends PlotListener implements Listener {
} else if (event.getIgnitingBlock() != null) {
Block ignitingBlock = event.getIgnitingBlock();
Plot plotIgnited = BukkitUtil.getLocation(ignitingBlock.getLocation()).getPlot();
- if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (!plot.getFlag(Flags.BLOCK_IGNITION,false)
- || plotIgnited == null || !plotIgnited.equals(plot))
- || (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
- !plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null || !plotIgnited.equals(plot))) {
+ if (igniteCause == BlockIgniteEvent.IgniteCause.FLINT_AND_STEEL && (
+ !plot.getFlag(Flags.BLOCK_IGNITION, false) || plotIgnited == null
+ || !plotIgnited.equals(plot)) ||
+ (igniteCause == BlockIgniteEvent.IgniteCause.SPREAD
+ || igniteCause == BlockIgniteEvent.IgniteCause.LAVA) && (
+ !plot.getFlag(Flags.BLOCK_IGNITION).or(false) || plotIgnited == null
+ || !plotIgnited.equals(plot))) {
event.setCancelled(true);
}
}
@@ -1993,7 +1978,9 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBucketEmpty(PlayerBucketEmptyEvent event) {
BlockFace bf = event.getBlockFace();
- Block b = event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ()).getBlock();
+ Block b =
+ event.getBlockClicked().getLocation().add(bf.getModX(), bf.getModY(), bf.getModZ())
+ .getBlock();
Location location = BukkitUtil.getLocation(b.getLocation());
PlotArea area = location.getPlotArea();
if (area == null) {
@@ -2052,8 +2039,7 @@ public class PlayerEvents extends PlotListener implements Listener {
BukkitUtil.getPlayer(player).deleteMeta("inventory");
}
- @EventHandler(priority = EventPriority.MONITOR)
- public void onLeave(PlayerQuitEvent event) {
+ @EventHandler(priority = EventPriority.MONITOR) public void onLeave(PlayerQuitEvent event) {
if (TaskManager.TELEPORT_QUEUE.contains(event.getPlayer().getName())) {
TaskManager.TELEPORT_QUEUE.remove(event.getPlayer().getName());
}
@@ -2082,12 +2068,14 @@ public class PlayerEvents extends PlotListener implements Listener {
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
return;
}
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
+ MainUtil
+ .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true);
} else if (!plot.isAdded(plotPlayer.getUUID())) {
Optional> use = plot.getFlag(Flags.USE);
Block block = event.getBlockClicked();
- if (use.isPresent() && use.get().contains(PlotBlock.get(block.getTypeId(), block.getData()))) {
+ if (use.isPresent() && use.get()
+ .contains(PlotBlock.get(block.getTypeId(), block.getData()))) {
return;
}
if (Permissions.hasPermission(plotPlayer, C.PERMISSION_ADMIN_BUILD_OTHER)) {
@@ -2135,15 +2123,17 @@ public class PlayerEvents extends PlotListener implements Listener {
} else {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true);
}
return;
}
if (!plot.isAdded(pp.getUUID())) {
- if (!plot.getFlag(Flags.HANGING_PLACE,false)) {
+ if (!plot.getFlag(Flags.HANGING_PLACE, false)) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_OTHER)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_OTHER);
event.setCancelled(true);
}
return;
@@ -2170,12 +2160,14 @@ public class PlayerEvents extends PlotListener implements Listener {
Plot plot = area.getPlot(location);
if (plot == null) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_ROAD)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_ROAD);
event.setCancelled(true);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
@@ -2183,7 +2175,8 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true);
}
}
@@ -2200,14 +2193,18 @@ public class PlayerEvents extends PlotListener implements Listener {
Plot plot = area.getPlot(BukkitUtil.getLocation(event.getEntity()));
if (plot != null) {
if (!plot.hasOwner()) {
- if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
- MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_UNOWNED);
+ if (!Permissions
+ .hasPermission(player, C.PERMISSION_ADMIN_DESTROY_UNOWNED)) {
+ MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT,
+ C.PERMISSION_ADMIN_DESTROY_UNOWNED);
event.setCancelled(true);
}
} else if (!plot.isAdded(player.getUUID())) {
if (!plot.getFlag(Flags.HANGING_BREAK, false)) {
- if (!Permissions.hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
- MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
+ if (!Permissions
+ .hasPermission(player, C.PERMISSION_ADMIN_DESTROY_OTHER)) {
+ MainUtil.sendMessage(player, C.NO_PERMISSION_EVENT,
+ C.PERMISSION_ADMIN_DESTROY_OTHER);
event.setCancelled(true);
}
}
@@ -2236,7 +2233,8 @@ public class PlayerEvents extends PlotListener implements Listener {
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_INTERACT_UNOWNED)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_INTERACT_UNOWNED);
event.setCancelled(true);
}
} else if (!plot.isAdded(pp.getUUID())) {
@@ -2247,7 +2245,8 @@ public class PlayerEvents extends PlotListener implements Listener {
if (entity instanceof Animals && plot.getFlag(Flags.ANIMAL_INTERACT, false)) {
return;
}
- if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot.getFlag(Flags.TAMED_INTERACT, false)) {
+ if (entity instanceof Tameable && ((Tameable) entity).isTamed() && plot
+ .getFlag(Flags.TAMED_INTERACT, false)) {
return;
}
if (entity instanceof Vehicle && plot.getFlag(Flags.VEHICLE_USE, false)) {
@@ -2283,13 +2282,15 @@ public class PlayerEvents extends PlotListener implements Listener {
Plot plot = area.getPlot(l);
if (plot == null) {
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.road")) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.road");
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.road");
event.setCancelled(true);
}
} else {
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.unowned")) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.unowned");
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT,
+ "plots.admin.vehicle.break.unowned");
event.setCancelled(true);
return;
}
@@ -2300,7 +2301,8 @@ public class PlayerEvents extends PlotListener implements Listener {
return;
}
if (!Permissions.hasPermission(pp, "plots.admin.vehicle.break.other")) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.other");
+ MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT,
+ "plots.admin.vehicle.break.other");
event.setCancelled(true);
}
}
@@ -2327,19 +2329,19 @@ public class PlayerEvents extends PlotListener implements Listener {
}
}
- @SuppressWarnings("deprecation")
- @EventHandler(priority = EventPriority.HIGHEST)
+ @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGHEST)
public void onEntityCombustByEntity(EntityCombustByEntityEvent event) {
EntityDamageByEntityEvent eventChange = null;
if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_11_0)) {
eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(),
- EntityDamageEvent.DamageCause.FIRE_TICK, (double)event.getDuration());
+ EntityDamageEvent.DamageCause.FIRE_TICK, (double) event.getDuration());
} else {
try {
- Constructor constructor = EntityDamageByEntityEvent.class.getConstructor(Entity.class,
- Entity.class, EntityDamageEvent.DamageCause.class, Integer.TYPE);
+ Constructor constructor = EntityDamageByEntityEvent.class
+ .getConstructor(Entity.class, Entity.class, EntityDamageEvent.DamageCause.class,
+ Integer.TYPE);
eventChange = constructor.newInstance(event.getCombuster(), event.getEntity(),
- EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
+ EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration());
} catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) {
e.printStackTrace();
}
@@ -2379,7 +2381,8 @@ public class PlayerEvents extends PlotListener implements Listener {
Location dloc = BukkitUtil.getLocation(damager);
Location vloc = BukkitUtil.getLocation(victim);
PlotArea dArea = dloc.getPlotArea();
- PlotArea vArea = dArea != null && dArea.contains(vloc.getX(), vloc.getZ()) ? dArea : vloc.getPlotArea();
+ PlotArea vArea =
+ dArea != null && dArea.contains(vloc.getX(), vloc.getZ()) ? dArea : vloc.getPlotArea();
if (dArea == null && vArea == null) {
return true;
}
@@ -2435,7 +2438,8 @@ public class PlayerEvents extends PlotListener implements Listener {
player = (Player) shooter;
} else { // shooter is not player
if (shooter instanceof BlockProjectileSource) {
- Location sLoc = BukkitUtil.getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
+ Location sLoc = BukkitUtil
+ .getLocation(((BlockProjectileSource) shooter).getBlock().getLocation());
dplot = dArea.getPlot(sLoc);
}
player = null;
@@ -2446,76 +2450,92 @@ public class PlayerEvents extends PlotListener implements Listener {
if (player != null) {
PlotPlayer plotPlayer = BukkitUtil.getPlayer(player);
if (victim instanceof Hanging) { // hanging
- if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot.isAdded(plotPlayer.getUUID()))) {
+ if (plot != null && (plot.getFlag(Flags.HANGING_BREAK, false) || plot
+ .isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
+ MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
+ "plots.admin.destroy." + stub);
return false;
}
} else if (victim.getEntityId() == 30) {
- if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot.isAdded(plotPlayer.getUUID()))) {
+ if (plot != null && (plot.getFlag(Flags.MISC_BREAK, false) || plot
+ .isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub);
+ MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
+ "plots.admin.destroy." + stub);
return false;
}
- } else if (victim instanceof Monster || victim instanceof EnderDragon) { // victim is monster
- if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot
- .isAdded(plotPlayer.getUUID()))) {
+ } else if (victim instanceof Monster
+ || victim instanceof EnderDragon) { // victim is monster
+ if (plot != null && (plot.getFlag(Flags.HOSTILE_ATTACK, false) || plot
+ .getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
+ MainUtil
+ .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
} else if (victim instanceof Tameable) { // victim is tameable
- if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
+ if (plot != null && (plot.getFlag(Flags.TAMED_ATTACK, false) || plot
+ .getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
+ MainUtil
+ .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
} else if (victim instanceof Player) {
if (plot != null) {
- if (Flags.PVP.isFalse(plot) && !Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
+ if (Flags.PVP.isFalse(plot) && !Permissions
+ .hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
+ MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
+ "plots.admin.pvp." + stub);
return false;
} else {
return true;
}
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pvp." + stub)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
+ MainUtil
+ .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub);
return false;
}
} else if (victim instanceof Creature) { // victim is animal
- if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot.getFlag(Flags.PVE, false) || plot
- .isAdded(plotPlayer.getUUID()))) {
+ if (plot != null && (plot.getFlag(Flags.ANIMAL_ATTACK, false) || plot
+ .getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
+ MainUtil
+ .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
} else if (victim instanceof Vehicle) { // Vehicles are managed in vehicle destroy event
return true;
} else { // victim is something else
- if (plot != null && (plot.getFlag(Flags.PVE, false) || plot.isAdded(plotPlayer.getUUID()))) {
+ if (plot != null && (plot.getFlag(Flags.PVE, false) || plot
+ .isAdded(plotPlayer.getUUID()))) {
return true;
}
if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
+ MainUtil
+ .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.pve." + stub);
return false;
}
}
return true;
- } else if (dplot != null && (!(dplot.equals(vplot)) || (vplot != null && Objects.equals(dplot.owner, vplot.owner)))) {
+ } else if (dplot != null && (!(dplot.equals(vplot)) || (vplot != null && Objects
+ .equals(dplot.owner, vplot.owner)))) {
return vplot != null && Flags.PVE.isTrue(vplot);
}
- return ((vplot != null && Flags.PVE.isTrue(vplot)) || !(damager instanceof Arrow && !(victim instanceof Creature)));
+ return ((vplot != null && Flags.PVE.isTrue(vplot)) || !(damager instanceof Arrow
+ && !(victim instanceof Creature)));
}
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
@@ -2530,17 +2550,20 @@ public class PlayerEvents extends PlotListener implements Listener {
Plot plot = area.getPlot(l);
if (plot == null) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.road")) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
+ MainUtil
+ .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.road");
event.setHatching(false);
}
} else if (!plot.hasOwner()) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.unowned")) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.unowned");
+ MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT,
+ "plots.admin.projectile.unowned");
event.setHatching(false);
}
} else if (!plot.isAdded(plotPlayer.getUUID())) {
if (!Permissions.hasPermission(plotPlayer, "plots.admin.projectile.other")) {
- MainUtil.sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
+ MainUtil
+ .sendMessage(plotPlayer, C.NO_PERMISSION_EVENT, "plots.admin.projectile.other");
event.setHatching(false);
}
}
@@ -2557,14 +2580,16 @@ public class PlayerEvents extends PlotListener implements Listener {
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = area.getPlot(location);
if (plot != null) {
- if ((location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT) && !Permissions
- .hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
+ if ((location.getY() > area.MAX_BUILD_HEIGHT || location.getY() < area.MIN_BUILD_HEIGHT)
+ && !Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_HEIGHTLIMIT)) {
event.setCancelled(true);
- MainUtil.sendMessage(pp, C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
+ MainUtil.sendMessage(pp,
+ C.HEIGHT_LIMIT.s().replace("{limit}", String.valueOf(area.MAX_BUILD_HEIGHT)));
}
if (!plot.hasOwner()) {
if (!Permissions.hasPermission(pp, C.PERMISSION_ADMIN_BUILD_UNOWNED)) {
- MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
+ MainUtil
+ .sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_BUILD_UNOWNED);
event.setCancelled(true);
return;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java
index ffc23d1e1..e221af62b 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java
@@ -11,9 +11,6 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlotListener;
-import java.util.HashSet;
-import java.util.List;
-import java.util.UUID;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
@@ -31,12 +28,17 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.PlayerInventory;
import org.bukkit.inventory.meta.ItemMeta;
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+
public class PlayerEvents_1_8 extends PlotListener implements Listener {
-
+
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInventoryClick(InventoryClickEvent event) {
- if (!event.isLeftClick() || (event.getAction() != InventoryAction.PLACE_ALL) || event.isShiftClick()) {
+ if (!event.isLeftClick() || (event.getAction() != InventoryAction.PLACE_ALL) || event
+ .isShiftClick()) {
return;
}
HumanEntity entity = event.getWhoClicked();
@@ -71,7 +73,8 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
switch (newItem.getType()) {
case BANNER:
case SKULL_ITEM:
- if (newMeta != null) break;
+ if (newMeta != null)
+ break;
default:
return;
}
@@ -89,9 +92,11 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
switch (stateType) {
case STANDING_BANNER:
case WALL_BANNER:
- if (itemType == Material.BANNER) break;
+ if (itemType == Material.BANNER)
+ break;
case SKULL:
- if (itemType == Material.SKULL_ITEM) break;
+ if (itemType == Material.SKULL_ITEM)
+ break;
default:
return;
}
@@ -124,15 +129,18 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener {
}
}
if (cancelled) {
- if ((current.getType() == newItem.getType()) && (current.getDurability() == newItem.getDurability())) {
- event.setCursor(new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
+ if ((current.getType() == newItem.getType()) && (current.getDurability() == newItem
+ .getDurability())) {
+ event.setCursor(
+ new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
event.setCancelled(true);
return;
}
- event.setCursor(new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
+ event.setCursor(
+ new ItemStack(newItem.getType(), newItem.getAmount(), newItem.getDurability()));
}
}
-
+
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onInteract(PlayerInteractAtEntityEvent e) {
Entity entity = e.getRightClicked();
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java
index 7b9d43100..f22ee5aa6 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java
@@ -8,10 +8,6 @@ import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
import com.plotsquared.bukkit.util.BukkitUtil;
import com.plotsquared.listener.PlotListener;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map.Entry;
-import java.util.UUID;
import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.block.Block;
@@ -27,6 +23,11 @@ import org.bukkit.event.player.PlayerDropItemEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map.Entry;
+import java.util.UUID;
+
public class PlotPlusListener extends PlotListener implements Listener {
private static final HashMap feedRunnable = new HashMap<>();
@@ -34,10 +35,10 @@ public class PlotPlusListener extends PlotListener implements Listener {
public static void startRunnable(JavaPlugin plugin) {
plugin.getServer().getScheduler().scheduleSyncRepeatingTask(plugin, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
if (!healRunnable.isEmpty()) {
- for (Iterator> iterator = healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
+ for (Iterator> iterator =
+ healRunnable.entrySet().iterator(); iterator.hasNext(); ) {
Entry entry = iterator.next();
Interval value = entry.getValue();
++value.count;
@@ -56,7 +57,8 @@ public class PlotPlusListener extends PlotListener implements Listener {
}
}
if (!feedRunnable.isEmpty()) {
- for (Iterator> iterator = feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
+ for (Iterator> iterator =
+ feedRunnable.entrySet().iterator(); iterator.hasNext(); ) {
Entry entry = iterator.next();
Interval value = entry.getValue();
++value.count;
@@ -78,8 +80,7 @@ public class PlotPlusListener extends PlotListener implements Listener {
}, 0L, 20L);
}
- @EventHandler(priority = EventPriority.HIGH)
- public void onInteract(BlockDamageEvent event) {
+ @EventHandler(priority = EventPriority.HIGH) public void onInteract(BlockDamageEvent event) {
Player player = event.getPlayer();
if (player.getGameMode() != GameMode.SURVIVAL) {
return;
@@ -97,9 +98,8 @@ public class PlotPlusListener extends PlotListener implements Listener {
}
}
}
-
- @EventHandler(priority = EventPriority.HIGH)
- public void onDamage(EntityDamageEvent event) {
+
+ @EventHandler(priority = EventPriority.HIGH) public void onDamage(EntityDamageEvent event) {
if (event.getEntityType() != EntityType.PLAYER) {
return;
}
@@ -112,9 +112,8 @@ public class PlotPlusListener extends PlotListener implements Listener {
event.setCancelled(true);
}
}
-
- @EventHandler
- public void onItemDrop(PlayerDropItemEvent event) {
+
+ @EventHandler public void onItemDrop(PlayerDropItemEvent event) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
@@ -128,9 +127,8 @@ public class PlotPlusListener extends PlotListener implements Listener {
}
}
}
-
- @EventHandler
- public void onPlotEnter(PlayerEnterPlotEvent event) {
+
+ @EventHandler public void onPlotEnter(PlayerEnterPlotEvent event) {
Player player = event.getPlayer();
Plot plot = event.getPlot();
Optional feed = plot.getFlag(Flags.FEED);
@@ -144,17 +142,15 @@ public class PlotPlusListener extends PlotListener implements Listener {
healRunnable.put(player.getName(), new Interval(value[0], value[1], 20));
}
}
-
- @EventHandler
- public void onPlayerQuit(PlayerQuitEvent event) {
+
+ @EventHandler public void onPlayerQuit(PlayerQuitEvent event) {
Player player = event.getPlayer();
String name = player.getName();
feedRunnable.remove(name);
healRunnable.remove(name);
}
-
- @EventHandler
- public void onPlotLeave(PlayerLeavePlotEvent event) {
+
+ @EventHandler public void onPlotLeave(PlayerLeavePlotEvent event) {
Player leaver = event.getPlayer();
Plot plot = event.getPlot();
if (!plot.hasOwner()) {
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener_1_12.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener_1_12.java
index 12cc6ab7e..b83f1b1c5 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener_1_12.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener_1_12.java
@@ -4,16 +4,16 @@ import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
-import java.util.UUID;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityPickupItemEvent;
+import java.util.UUID;
+
public class PlotPlusListener_1_12 implements Listener {
- @EventHandler
- public void onItemPickup(EntityPickupItemEvent event) {
+ @EventHandler public void onItemPickup(EntityPickupItemEvent event) {
LivingEntity ent = event.getEntity();
if (ent instanceof Player) {
Player player = (Player) ent;
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener_Legacy.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener_Legacy.java
index ce0c57f4e..a5d2eb634 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener_Legacy.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener_Legacy.java
@@ -4,15 +4,15 @@ import com.intellectualcrafters.plot.flag.Flags;
import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.util.BukkitUtil;
-import java.util.UUID;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerPickupItemEvent;
+import java.util.UUID;
+
public class PlotPlusListener_Legacy implements Listener {
- @EventHandler
- public void onItemPickup(PlayerPickupItemEvent event) {
+ @EventHandler public void onItemPickup(PlayerPickupItemEvent event) {
Player player = event.getPlayer();
PlotPlayer pp = BukkitUtil.getPlayer(player);
Plot plot = BukkitUtil.getLocation(player).getOwnedPlot();
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/SingleWorldListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/SingleWorldListener.java
index 146d30f53..9e68384f1 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/SingleWorldListener.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/SingleWorldListener.java
@@ -4,8 +4,6 @@ import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
import com.intellectualcrafters.plot.util.ReflectionUtils;
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
import org.bukkit.Bukkit;
import org.bukkit.Chunk;
import org.bukkit.World;
@@ -16,6 +14,8 @@ import org.bukkit.event.world.ChunkEvent;
import org.bukkit.event.world.ChunkLoadEvent;
import org.bukkit.plugin.Plugin;
+import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass;
@@ -42,10 +42,14 @@ public class SingleWorldListener implements Listener {
public void markChunkAsClean(Chunk chunk) {
try {
Object nmsChunk = methodGetHandleChunk.invoke(chunk);
- if (done != null) this.done.set(nmsChunk, true);
- if (mustSave != null) this.mustSave.set(nmsChunk, false);
- if (lit != null) this.lit.set(nmsChunk, false);
- if (s != null) this.s.set(nmsChunk, false);
+ if (done != null)
+ this.done.set(nmsChunk, true);
+ if (mustSave != null)
+ this.mustSave.set(nmsChunk, false);
+ if (lit != null)
+ this.lit.set(nmsChunk, false);
+ if (s != null)
+ this.s.set(nmsChunk, false);
} catch (Throwable e) {
e.printStackTrace();
}
@@ -55,19 +59,20 @@ public class SingleWorldListener implements Listener {
World world = event.getWorld();
String name = world.getName();
PlotAreaManager man = PS.get().getPlotAreaManager();
- if (!(man instanceof SinglePlotAreaManager)) return;
- if (!isPlotId(name)) return;
+ if (!(man instanceof SinglePlotAreaManager))
+ return;
+ if (!isPlotId(name))
+ return;
markChunkAsClean(event.getChunk());
}
-// @EventHandler
-// public void onPopulate(ChunkPopulateEvent event) {
-// handle(event);
-// }
+ // @EventHandler
+ // public void onPopulate(ChunkPopulateEvent event) {
+ // handle(event);
+ // }
- @EventHandler(priority = EventPriority.LOWEST)
- public void onChunkLoad(ChunkLoadEvent event) {
+ @EventHandler(priority = EventPriority.LOWEST) public void onChunkLoad(ChunkLoadEvent event) {
handle(event);
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/WorldEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/WorldEvents.java
index 1e80cc19b..44f884372 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/WorldEvents.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/WorldEvents.java
@@ -13,7 +13,7 @@ import org.bukkit.event.world.WorldInitEvent;
import org.bukkit.generator.ChunkGenerator;
public class WorldEvents implements Listener {
-
+
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onWorldInit(WorldInitEvent event) {
World world = event.getWorld();
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitLazyBlock.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitLazyBlock.java
index 7a26d21a5..2a1a44314 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitLazyBlock.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitLazyBlock.java
@@ -24,8 +24,7 @@ public class BukkitLazyBlock extends LazyBlock {
this.block = block;
}
- @Override
- public PlotBlock getPlotBlock() {
+ @Override public PlotBlock getPlotBlock() {
if (this.pb != null) {
return this.pb;
}
@@ -127,8 +126,7 @@ public class BukkitLazyBlock extends LazyBlock {
}
- @Override
- public int getId() {
+ @Override public int getId() {
if (this.id == 0) {
this.id = this.block.getTypeId();
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitOfflinePlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitOfflinePlayer.java
index 715b92bee..8b770badd 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitOfflinePlayer.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitOfflinePlayer.java
@@ -19,23 +19,19 @@ public class BukkitOfflinePlayer implements OfflinePlotPlayer {
this.player = player;
}
- @Override
- public UUID getUUID() {
+ @Override public UUID getUUID() {
return this.player.getUniqueId();
}
- @Override
- public long getLastPlayed() {
+ @Override public long getLastPlayed() {
return this.player.getLastPlayed();
}
- @Override
- public boolean isOnline() {
+ @Override public boolean isOnline() {
return this.player.isOnline();
}
- @Override
- public String getName() {
+ @Override public String getName() {
return this.player.getName();
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java
index efeb04e11..7814c8706 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java
@@ -6,7 +6,6 @@ import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.*;
import com.plotsquared.bukkit.util.BukkitUtil;
-import org.apache.commons.lang.StringUtils;
import org.bukkit.Effect;
import org.bukkit.GameMode;
import org.bukkit.WeatherType;
@@ -14,15 +13,14 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventException;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
+import org.bukkit.permissions.PermissionAttachmentInfo;
+import org.bukkit.plugin.RegisteredListener;
import java.util.Set;
import java.util.UUID;
-import org.bukkit.permissions.PermissionAttachmentInfo;
-import org.bukkit.plugin.RegisteredListener;
-
public class BukkitPlayer extends PlotPlayer {
-
+
public final Player player;
public boolean offline;
private UUID uuid;
@@ -31,6 +29,7 @@ public class BukkitPlayer extends PlotPlayer {
/**
*
Please do not use this method. Instead use
* BukkitUtil.getPlayer(Player), as it caches player objects.
+ *
* @param player
*/
public BukkitPlayer(Player player) {
@@ -44,14 +43,12 @@ public class BukkitPlayer extends PlotPlayer {
super.populatePersistentMetaMap();
}
- @Override
- public Location getLocation() {
+ @Override public Location getLocation() {
Location location = super.getLocation();
return location == null ? BukkitUtil.getLocation(this.player) : location;
}
-
- @Override
- public UUID getUUID() {
+
+ @Override public UUID getUUID() {
if (this.uuid == null) {
this.uuid = UUIDHandler.getUUID(this);
}
@@ -62,8 +59,7 @@ public class BukkitPlayer extends PlotPlayer {
return this.player.getLastPlayed();
}
- @Override
- public boolean canTeleport(Location loc) {
+ @Override public boolean canTeleport(Location loc) {
org.bukkit.Location to = BukkitUtil.getLocation(loc);
org.bukkit.Location from = player.getLocation();
PlayerTeleportEvent event = new PlayerTeleportEvent(player, from, to);
@@ -95,16 +91,14 @@ public class BukkitPlayer extends PlotPlayer {
return true;
}
- @Override
- public boolean hasPermission(String permission) {
+ @Override public boolean hasPermission(String permission) {
if (this.offline && EconHandler.manager != null) {
return EconHandler.manager.hasPermission(getName(), permission);
}
return this.player.hasPermission(permission);
}
- @Override
- public int hasPermissionRange(String stub, int range) {
+ @Override public int hasPermissionRange(String stub, int range) {
if (hasPermission(C.PERMISSION_ADMIN.s())) {
return Integer.MAX_VALUE;
}
@@ -131,8 +125,10 @@ public class BukkitPlayer extends PlotPlayer {
String end = perm.substring(stubPlus.length());
if (MathMan.isInteger(end)) {
int val = Integer.parseInt(end);
- if (val > range) return val;
- if (val > max) max = val;
+ if (val > range)
+ return val;
+ if (val > max)
+ max = val;
}
}
}
@@ -146,57 +142,52 @@ public class BukkitPlayer extends PlotPlayer {
return max;
}
- @Override
- public boolean isPermissionSet(String permission) {
+ @Override public boolean isPermissionSet(String permission) {
return this.player.isPermissionSet(permission);
}
- @Override
- public void sendMessage(String message) {
- if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (System.currentTimeMillis() - this.getMeta("lastMessageTime") > 5000)) {
+ @Override public void sendMessage(String message) {
+ if (!StringMan.isEqual(this.getMeta("lastMessage"), message) || (
+ System.currentTimeMillis() - this.getMeta("lastMessageTime") > 5000)) {
setMeta("lastMessage", message);
setMeta("lastMessageTime", System.currentTimeMillis());
this.player.sendMessage(message);
}
}
-
- @Override
- public void teleport(Location location) {
+
+ @Override public void teleport(Location location) {
if (Math.abs(location.getX()) >= 30000000 || Math.abs(location.getZ()) >= 30000000) {
return;
}
this.player.teleport(
- new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5, location.getY(), location.getZ() + 0.5,
- location.getYaw(), location.getPitch()), TeleportCause.COMMAND);
+ new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX() + 0.5,
+ location.getY(), location.getZ() + 0.5, location.getYaw(), location.getPitch()),
+ TeleportCause.COMMAND);
}
-
- @Override
- public String getName() {
+
+ @Override public String getName() {
if (this.name == null) {
this.name = this.player.getName();
}
return this.name;
}
-
- @Override
- public boolean isOnline() {
+
+ @Override public boolean isOnline() {
return !this.offline && this.player.isOnline();
}
-
- @Override
- public void setCompassTarget(Location location) {
+
+ @Override public void setCompassTarget(Location location) {
this.player.setCompassTarget(
- new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX(), location.getY(), location.getZ()));
-
+ new org.bukkit.Location(BukkitUtil.getWorld(location.getWorld()), location.getX(),
+ location.getY(), location.getZ()));
+
}
-
- @Override
- public Location getLocationFull() {
+
+ @Override public Location getLocationFull() {
return BukkitUtil.getLocationFull(this.player);
}
- @Override
- public void setWeather(PlotWeather weather) {
+ @Override public void setWeather(PlotWeather weather) {
switch (weather) {
case CLEAR:
this.player.setPlayerWeather(WeatherType.CLEAR);
@@ -212,9 +203,8 @@ public class BukkitPlayer extends PlotPlayer {
break;
}
}
-
- @Override
- public PlotGameMode getGameMode() {
+
+ @Override public PlotGameMode getGameMode() {
switch (this.player.getGameMode()) {
case ADVENTURE:
return PlotGameMode.ADVENTURE;
@@ -228,9 +218,8 @@ public class BukkitPlayer extends PlotPlayer {
return PlotGameMode.NOT_SET;
}
}
-
- @Override
- public void setGameMode(PlotGameMode gameMode) {
+
+ @Override public void setGameMode(PlotGameMode gameMode) {
switch (gameMode) {
case ADVENTURE:
this.player.setGameMode(GameMode.ADVENTURE);
@@ -249,34 +238,29 @@ public class BukkitPlayer extends PlotPlayer {
break;
}
}
-
- @Override
- public void setTime(long time) {
+
+ @Override public void setTime(long time) {
if (time != Long.MAX_VALUE) {
this.player.setPlayerTime(time, false);
} else {
this.player.resetPlayerTime();
}
}
-
- @Override
- public void setFlight(boolean fly) {
- this.player.setAllowFlight(fly);
- }
- @Override
- public boolean getFlight() {
+ @Override public boolean getFlight() {
return player.getAllowFlight();
}
- @Override
- public void playMusic(Location location, int id) {
+ @Override public void setFlight(boolean fly) {
+ this.player.setAllowFlight(fly);
+ }
+
+ @Override public void playMusic(Location location, int id) {
//noinspection deprecation
this.player.playEffect(BukkitUtil.getLocation(location), Effect.RECORD_PLAY, id);
}
-
- @Override
- public void kick(String message) {
+
+ @Override public void kick(String message) {
this.player.kickPlayer(message);
}
@@ -286,8 +270,7 @@ public class BukkitPlayer extends PlotPlayer {
}
}
- @Override
- public boolean isBanned() {
+ @Override public boolean isBanned() {
return this.player.isBanned();
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java
index 33dc737ab..a96d62db0 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java
@@ -2,34 +2,11 @@ package com.plotsquared.bukkit.object.entity;
import com.intellectualcrafters.plot.PS;
import com.plotsquared.bukkit.util.BukkitVersion;
-import org.bukkit.Art;
-import org.bukkit.DyeColor;
-import org.bukkit.Location;
-import org.bukkit.Rotation;
-import org.bukkit.TreeSpecies;
-import org.bukkit.World;
+import org.bukkit.*;
import org.bukkit.block.BlockFace;
-import org.bukkit.entity.Ageable;
-import org.bukkit.entity.ArmorStand;
-import org.bukkit.entity.Bat;
-import org.bukkit.entity.Boat;
-import org.bukkit.entity.EnderDragon;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Guardian;
-import org.bukkit.entity.Horse;
-import org.bukkit.entity.IronGolem;
-import org.bukkit.entity.Item;
-import org.bukkit.entity.ItemFrame;
-import org.bukkit.entity.LivingEntity;
-import org.bukkit.entity.Painting;
-import org.bukkit.entity.Rabbit;
+import org.bukkit.entity.*;
import org.bukkit.entity.Rabbit.Type;
-import org.bukkit.entity.Sheep;
-import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Skeleton.SkeletonType;
-import org.bukkit.entity.Slime;
-import org.bukkit.entity.Tameable;
import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
@@ -87,7 +64,8 @@ public class EntityWrapper {
if (depth == 1) {
return;
}
- if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_10_0) || entity instanceof ArmorStand) {
+ if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_10_0)
+ || entity instanceof ArmorStand) {
if (!entity.hasGravity()) {
this.noGravity = true;
}
@@ -220,13 +198,16 @@ public class EntityWrapper {
storeLiving((LivingEntity) entity);
return;
case SKELETON:
- this.dataByte = getOrdinal(SkeletonType.values(),((Skeleton)entity).getSkeletonType());
+ this.dataByte =
+ getOrdinal(SkeletonType.values(), ((Skeleton) entity).getSkeletonType());
storeLiving((LivingEntity) entity);
return;
case ARMOR_STAND:
ArmorStand stand = (ArmorStand) entity;
- this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(),
- stand.getLeggings().clone(), stand.getBoots().clone()};
+ this.inventory =
+ new ItemStack[] {stand.getItemInHand().clone(), stand.getHelmet().clone(),
+ stand.getChestplate().clone(), stand.getLeggings().clone(),
+ stand.getBoots().clone()};
storeLiving(stand);
this.stand = new ArmorStandStats();
@@ -315,13 +296,11 @@ public class EntityWrapper {
}
}
- @Override
- public boolean equals(Object obj) {
+ @Override public boolean equals(Object obj) {
return this.hash == obj.hashCode();
}
- @Override
- public int hashCode() {
+ @Override public int hashCode() {
return this.hash;
}
@@ -473,7 +452,8 @@ public class EntityWrapper {
if (this.base.passenger != null) {
try {
entity.setPassenger(this.base.passenger.spawn(world, xOffset, zOffset));
- } catch (Exception ignored) { }
+ } catch (Exception ignored) {
+ }
}
if (this.base.fall != 0) {
entity.setFallDistance(this.base.fall);
@@ -488,7 +468,8 @@ public class EntityWrapper {
if (this.depth == 1) {
return entity;
}
- if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_10_0) || entity instanceof ArmorStand) {
+ if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_10_0)
+ || entity instanceof ArmorStand) {
if (this.noGravity) {
entity.setGravity(false);
}
@@ -642,27 +623,37 @@ public class EntityWrapper {
stand.setBoots(this.inventory[4]);
}
if (this.stand.head[0] != 0 || this.stand.head[1] != 0 || this.stand.head[2] != 0) {
- EulerAngle pose = new EulerAngle(this.stand.head[0], this.stand.head[1], this.stand.head[2]);
+ EulerAngle pose =
+ new EulerAngle(this.stand.head[0], this.stand.head[1], this.stand.head[2]);
stand.setHeadPose(pose);
}
if (this.stand.body[0] != 0 || this.stand.body[1] != 0 || this.stand.body[2] != 0) {
- EulerAngle pose = new EulerAngle(this.stand.body[0], this.stand.body[1], this.stand.body[2]);
+ EulerAngle pose =
+ new EulerAngle(this.stand.body[0], this.stand.body[1], this.stand.body[2]);
stand.setBodyPose(pose);
}
- if (this.stand.leftLeg[0] != 0 || this.stand.leftLeg[1] != 0 || this.stand.leftLeg[2] != 0) {
- EulerAngle pose = new EulerAngle(this.stand.leftLeg[0], this.stand.leftLeg[1], this.stand.leftLeg[2]);
+ if (this.stand.leftLeg[0] != 0 || this.stand.leftLeg[1] != 0
+ || this.stand.leftLeg[2] != 0) {
+ EulerAngle pose = new EulerAngle(this.stand.leftLeg[0], this.stand.leftLeg[1],
+ this.stand.leftLeg[2]);
stand.setLeftLegPose(pose);
}
- if (this.stand.rightLeg[0] != 0 || this.stand.rightLeg[1] != 0 || this.stand.rightLeg[2] != 0) {
- EulerAngle pose = new EulerAngle(this.stand.rightLeg[0], this.stand.rightLeg[1], this.stand.rightLeg[2]);
+ if (this.stand.rightLeg[0] != 0 || this.stand.rightLeg[1] != 0
+ || this.stand.rightLeg[2] != 0) {
+ EulerAngle pose = new EulerAngle(this.stand.rightLeg[0], this.stand.rightLeg[1],
+ this.stand.rightLeg[2]);
stand.setRightLegPose(pose);
}
- if (this.stand.leftArm[0] != 0 || this.stand.leftArm[1] != 0 || this.stand.leftArm[2] != 0) {
- EulerAngle pose = new EulerAngle(this.stand.leftArm[0], this.stand.leftArm[1], this.stand.leftArm[2]);
+ if (this.stand.leftArm[0] != 0 || this.stand.leftArm[1] != 0
+ || this.stand.leftArm[2] != 0) {
+ EulerAngle pose = new EulerAngle(this.stand.leftArm[0], this.stand.leftArm[1],
+ this.stand.leftArm[2]);
stand.setLeftArmPose(pose);
}
- if (this.stand.rightArm[0] != 0 || this.stand.rightArm[1] != 0 || this.stand.rightArm[2] != 0) {
- EulerAngle pose = new EulerAngle(this.stand.rightArm[0], this.stand.rightArm[1], this.stand.rightArm[2]);
+ if (this.stand.rightArm[0] != 0 || this.stand.rightArm[1] != 0
+ || this.stand.rightArm[2] != 0) {
+ EulerAngle pose = new EulerAngle(this.stand.rightArm[0], this.stand.rightArm[1],
+ this.stand.rightArm[2]);
stand.setRightArmPose(pose);
}
if (this.stand.invisible) {
@@ -716,7 +707,7 @@ public class EntityWrapper {
}
restoreLiving((LivingEntity) entity);
return entity;
- // END LIVING
+ // END LIVING
}
}
@@ -729,9 +720,7 @@ public class EntityWrapper {
return 0;
}
- @SuppressWarnings("deprecation")
- @Override
- public String toString() {
+ @SuppressWarnings("deprecation") @Override public String toString() {
return String.format("[%s, x=%s, y=%s, z=%s]", type.getName(), x, y, z);
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/schematic/StateWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/schematic/StateWrapper.java
index 3431e6b77..35f58e446 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/schematic/StateWrapper.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/schematic/StateWrapper.java
@@ -1,10 +1,6 @@
package com.plotsquared.bukkit.object.schematic;
-import com.intellectualcrafters.jnbt.ByteTag;
-import com.intellectualcrafters.jnbt.CompoundTag;
-import com.intellectualcrafters.jnbt.ListTag;
-import com.intellectualcrafters.jnbt.ShortTag;
-import com.intellectualcrafters.jnbt.Tag;
+import com.intellectualcrafters.jnbt.*;
import com.intellectualcrafters.plot.object.schematic.ItemType;
import com.intellectualcrafters.plot.util.MathMan;
import com.plotsquared.bukkit.util.BukkitUtil;
@@ -89,7 +85,8 @@ public class StateWrapper {
InventoryHolder inv = (InventoryHolder) this.state;
ItemStack[] contents = inv.getInventory().getContents();
Map values = new HashMap<>();
- values.put("Items", new ListTag("Items", CompoundTag.class, serializeInventory(contents)));
+ values.put("Items",
+ new ListTag("Items", CompoundTag.class, serializeInventory(contents)));
return new CompoundTag(values);
}
return null;
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java
index 98ea32db9..0bb28c81e 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java
@@ -12,13 +12,14 @@ public class DefaultTitleManager extends TitleManager {
/**
* Create a new 1.8 title.
*
- * @param title Title text
- * @param subtitle Subtitle text
- * @param fadeInTime Fade in time
- * @param stayTime Stay on screen time
+ * @param title Title text
+ * @param subtitle Subtitle text
+ * @param fadeInTime Fade in time
+ * @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
- DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
+ DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime,
+ int fadeOutTime) {
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
}
@@ -32,7 +33,8 @@ public class DefaultTitleManager extends TitleManager {
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
}
- @Override public void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
+ @Override public void send(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if (this.packetTitle != null) {
// First reset previous settings
resetTitle(player);
@@ -41,38 +43,44 @@ public class DefaultTitleManager extends TitleManager {
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
- Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE)
- .newInstance(actions[2], null, this.fadeInTime * (this.ticks ? 1 : 20),
- this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20));
+ Object packet = this.packetTitle
+ .getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE,
+ Integer.TYPE, Integer.TYPE)
+ .newInstance(actions[2], null, this.fadeInTime * (this.ticks ? 1 : 20),
+ this.stayTime * (this.ticks ? 1 : 20),
+ this.fadeOutTime * (this.ticks ? 1 : 20));
// Send if set
if (this.fadeInTime != -1 && this.fadeOutTime != -1 && this.stayTime != -1) {
sendPacket.invoke(connection, packet);
}
// Send title
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
- "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
- + '}');
- packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
+ "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle())
+ + "\",color:" + this.titleColor.name().toLowerCase() + '}');
+ packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
+ .newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
if (!this.getSubtitle().isEmpty()) {
// Send subtitle if present
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
- "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
- .toLowerCase() + '}');
- packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
+ "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle())
+ + "\",color:" + this.subtitleColor.name().toLowerCase() + '}');
+ packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
+ .newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
}
}
- @Override
- public void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
+ @Override public void clearTitle(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
- Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[3], null);
+ Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
+ .newInstance(actions[3], null);
sendPacket.invoke(connection, packet);
}
@@ -84,14 +92,15 @@ public class DefaultTitleManager extends TitleManager {
* @throws ReflectiveOperationException
* @throws SecurityException
*/
- @Override
- public void resetTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
+ @Override public void resetTitle(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
- Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[4], null);
+ Object packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
+ .newInstance(actions[4], null);
sendPacket.invoke(connection, packet);
}
@@ -108,7 +117,8 @@ public class DefaultTitleManager extends TitleManager {
Method getMethod(Class> clazz, String name, Class>... args) {
for (Method m : clazz.getMethods()) {
- if (m.getName().equals(name) && (args.length == 0 || classListEqual(args, m.getParameterTypes()))) {
+ if (m.getName().equals(name) && (args.length == 0 || classListEqual(args,
+ m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java
index 559e296fd..5a5a0dd3f 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager_183.java
@@ -11,29 +11,29 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
/**
* Create a new 1.8 title.
*
- * @param title Title text
- * @param subtitle Subtitle text
- * @param fadeInTime Fade in time
- * @param stayTime Stay on screen time
+ * @param title Title text
+ * @param subtitle Subtitle text
+ * @param fadeInTime Fade in time
+ * @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
- DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
+ DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime,
+ int fadeOutTime) {
super(title, subtitle, fadeInTime, stayTime, fadeOutTime);
}
/**
* Load spigot and NMS classes.
*/
- @Override
- void loadClasses() {
+ @Override void loadClasses() {
this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle");
this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent");
this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction");
this.nmsChatSerializer = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
}
- @Override
- public void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
+ @Override public void send(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if (this.packetTitle != null) {
// First reset previous settings
resetTitle(player);
@@ -43,26 +43,29 @@ public class DefaultTitleManager_183 extends DefaultTitleManager {
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
Object packet = this.packetTitle
- .getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE, Integer.TYPE, Integer.TYPE)
- .newInstance(actions[2], null,
- this.fadeInTime * (this.ticks ? 1 : 20),
- this.stayTime * (this.ticks ? 1 : 20), this.fadeOutTime * (this.ticks ? 1 : 20));
+ .getConstructor(this.packetActions, this.chatBaseComponent, Integer.TYPE,
+ Integer.TYPE, Integer.TYPE)
+ .newInstance(actions[2], null, this.fadeInTime * (this.ticks ? 1 : 20),
+ this.stayTime * (this.ticks ? 1 : 20),
+ this.fadeOutTime * (this.ticks ? 1 : 20));
// Send if set
if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
sendPacket.invoke(connection, packet);
}
// Send title
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
- "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
- + "}");
- packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[0], serialized);
+ "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle())
+ + "\",color:" + this.titleColor.name().toLowerCase() + "}");
+ packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
+ .newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
if (!this.getSubtitle().isEmpty()) {
// Send subtitle if present
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
- "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
- .toLowerCase() + "}");
- packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent).newInstance(actions[1], serialized);
+ "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle())
+ + "\",color:" + this.subtitleColor.name().toLowerCase() + "}");
+ packet = this.packetTitle.getConstructor(this.packetActions, this.chatBaseComponent)
+ .newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_111.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_111.java
index be6cfc568..274b0e96c 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_111.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_111.java
@@ -7,8 +7,7 @@ import com.plotsquared.bukkit.object.BukkitPlayer;
import com.plotsquared.bukkit.util.BukkitVersion;
import org.bukkit.entity.Player;
-@SuppressWarnings("deprecation")
-public class DefaultTitle_111 extends AbstractTitle {
+@SuppressWarnings("deprecation") public class DefaultTitle_111 extends AbstractTitle {
private final boolean valid;
@@ -24,7 +23,8 @@ public class DefaultTitle_111 extends AbstractTitle {
TitleManager_1_11 title = new TitleManager_1_11(head, sub, in, delay, out);
title.send(playerObj);
return;
- } catch (Throwable ignored) {}
+ } catch (Throwable ignored) {
+ }
}
AbstractTitle.TITLE_CLASS = new DefaultTitle_180();
AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out);
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java
index f6f90c2f2..cf88d7fd5 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java
@@ -6,8 +6,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.entity.Player;
-@SuppressWarnings("deprecation")
-public class DefaultTitle_19 extends AbstractTitle {
+@SuppressWarnings("deprecation") public class DefaultTitle_19 extends AbstractTitle {
@Override
public void sendTitle(PlotPlayer player, String head, String sub, int in, int delay, int out) {
@@ -15,8 +14,7 @@ public class DefaultTitle_19 extends AbstractTitle {
final Player playerObj = ((BukkitPlayer) player).player;
playerObj.sendTitle(head, sub);
TaskManager.runTaskLater(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
playerObj.sendTitle("", "");
}
}, delay * 20);
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java
index cf8e87b95..98a093646 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java
@@ -13,10 +13,10 @@ public class HackTitleManager extends TitleManager {
/**
* Create a new 1.8 title.
*
- * @param title Title text
- * @param subtitle Subtitle text
- * @param fadeInTime Fade in time
- * @param stayTime Stay on screen time
+ * @param title Title text
+ * @param subtitle Subtitle text
+ * @param fadeInTime Fade in time
+ * @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
@@ -26,14 +26,14 @@ public class HackTitleManager extends TitleManager {
/**
* Load spigot and NMS classes.
*/
- @Override
- void loadClasses() {
+ @Override void loadClasses() {
this.packetTitle = getClass("org.spigotmc.ProtocolInjector$PacketTitle");
this.packetActions = getClass("org.spigotmc.ProtocolInjector$PacketTitle$Action");
this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer");
}
- @Override public void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
+ @Override public void send(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) {
// First reset previous settings
resetTitle(player);
@@ -42,8 +42,9 @@ public class HackTitleManager extends TitleManager {
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
- Object packet = this.packetTitle.getConstructor(this.packetActions, Integer.TYPE, Integer.TYPE, Integer.TYPE).newInstance(actions[2],
- this.fadeInTime * (this.ticks ? 1 : 20),
+ Object packet = this.packetTitle
+ .getConstructor(this.packetActions, Integer.TYPE, Integer.TYPE, Integer.TYPE)
+ .newInstance(actions[2], this.fadeInTime * (this.ticks ? 1 : 20),
this.stayTime * (this.ticks ? 1 : 20),
this.fadeOutTime * (this.ticks ? 1 : 20));
// Send if set
@@ -52,43 +53,49 @@ public class HackTitleManager extends TitleManager {
}
// Send title
Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
- "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle()) + "\",color:" + this.titleColor.name().toLowerCase()
- + "}");
- packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
- .newInstance(actions[0], serialized);
+ "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getTitle())
+ + "\",color:" + this.titleColor.name().toLowerCase() + "}");
+ packet = this.packetTitle
+ .getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
+ .newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
if (!this.getSubtitle().isEmpty()) {
// Send subtitle if present
serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null,
- "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name()
- .toLowerCase() + "}");
- packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent"))
- .newInstance(actions[1], serialized);
+ "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle())
+ + "\",color:" + this.subtitleColor.name().toLowerCase() + "}");
+ packet = this.packetTitle.getConstructor(this.packetActions,
+ Reflection.getNMSClass("IChatBaseComponent"))
+ .newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
}
}
- @Override public void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
+ @Override public void clearTitle(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
- Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
+ Object packet =
+ this.packetTitle.getConstructor(this.packetActions).newInstance(actions[3]);
sendPacket.invoke(connection, packet);
}
}
- @Override public void resetTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
+ @Override public void resetTitle(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
if ((getProtocolVersion(player) >= 47) && isSpigot()) {
// Send timings first
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = this.packetActions.getEnumConstants();
Method sendPacket = getMethod(connection.getClass(), "sendPacket");
- Object packet = this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
+ Object packet =
+ this.packetTitle.getConstructor(this.packetActions).newInstance(actions[4]);
sendPacket.invoke(connection, packet);
}
}
@@ -102,7 +109,8 @@ public class HackTitleManager extends TitleManager {
* @throws ReflectiveOperationException
* @throws SecurityException
*/
- private int getProtocolVersion(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
+ private int getProtocolVersion(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException {
Object handle = getHandle(player);
Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object networkManager = getValue("networkManager", connection);
@@ -127,15 +135,18 @@ public class HackTitleManager extends TitleManager {
private Class> getClass(String namespace) {
try {
return Class.forName(namespace);
- } catch (ClassNotFoundException ignored) {}
+ } catch (ClassNotFoundException ignored) {
+ }
return null;
}
- private Field getField(String name, Class> clazz) throws NoSuchFieldException, SecurityException {
+ private Field getField(String name, Class> clazz)
+ throws NoSuchFieldException, SecurityException {
return clazz.getDeclaredField(name);
}
- private Object getValue(String name, Object obj) throws ReflectiveOperationException, SecurityException, IllegalArgumentException {
+ private Object getValue(String name, Object obj)
+ throws ReflectiveOperationException, SecurityException, IllegalArgumentException {
Field f = getField(name, obj.getClass());
f.setAccessible(true);
return f.get(obj);
@@ -154,7 +165,8 @@ public class HackTitleManager extends TitleManager {
private Method getMethod(Class> clazz, String name, Class>... args) {
for (Method m : clazz.getMethods()) {
- if (m.getName().equals(name) && ((args.length == 0) || classListEqual(args, m.getParameterTypes()))) {
+ if (m.getName().equals(name) && ((args.length == 0) || classListEqual(args,
+ m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java
index 91a5d68a0..ccc870dd9 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java
@@ -12,17 +12,13 @@ import java.util.Map;
public abstract class TitleManager {
private static final Map, Class>> CORRESPONDING_TYPES = new HashMap<>();
- /* Title packet */
- Class> packetTitle;
- /* Title packet actions ENUM */
- Class> packetActions;
- /* Chat serializer */
- Class> nmsChatSerializer;
+ /* Title packet */ Class> packetTitle;
+ /* Title packet actions ENUM */ Class> packetActions;
+ /* Chat serializer */ Class> nmsChatSerializer;
Class> chatBaseComponent;
ChatColor titleColor = ChatColor.WHITE;
ChatColor subtitleColor = ChatColor.WHITE;
- /* Title timings */
- int fadeInTime = -1;
+ /* Title timings */ int fadeInTime = -1;
int stayTime = -1;
int fadeOutTime = -1;
boolean ticks = false;
@@ -34,10 +30,10 @@ public abstract class TitleManager {
/**
* Create a new 1.8 title.
*
- * @param title Title text
- * @param subtitle Subtitle text
- * @param fadeInTime Fade in time
- * @param stayTime Stay on screen time
+ * @param title Title text
+ * @param subtitle Subtitle text
+ * @param fadeInTime Fade in time
+ * @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
TitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
@@ -154,7 +150,8 @@ public abstract class TitleManager {
* @throws ReflectiveOperationException
* @throws SecurityException
*/
- public abstract void send(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
+ public abstract void send(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
/**
* Broadcasts the title to all players.
@@ -175,7 +172,8 @@ public abstract class TitleManager {
* @throws ReflectiveOperationException
* @throws SecurityException
*/
- public abstract void clearTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
+ public abstract void clearTitle(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
/**
* Resets the title settings.
@@ -185,7 +183,8 @@ public abstract class TitleManager {
* @throws ReflectiveOperationException
* @throws SecurityException
*/
- public abstract void resetTitle(Player player) throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
+ public abstract void resetTitle(Player player)
+ throws IllegalArgumentException, ReflectiveOperationException, SecurityException;
private Class> getPrimitiveType(Class> clazz) {
if (CORRESPONDING_TYPES.containsKey(clazz)) {
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager_1_11.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager_1_11.java
index 935f3d850..a1ed0ec61 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager_1_11.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager_1_11.java
@@ -1,14 +1,14 @@
package com.plotsquared.bukkit.titles;
+import org.bukkit.Bukkit;
+import org.bukkit.ChatColor;
+import org.bukkit.entity.Player;
+
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.util.HashMap;
import java.util.Map;
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.entity.Player;
-
/**
* Minecraft 1.8 Title
* For 1.11
@@ -17,6 +17,8 @@ import org.bukkit.entity.Player;
* @version 1.1.0
*/
public class TitleManager_1_11 {
+ private static final Map, Class>> CORRESPONDING_TYPES =
+ new HashMap, Class>>();
/* Title packet */
private static Class> packetTitle;
/* Title packet actions ENUM */
@@ -43,8 +45,6 @@ public class TitleManager_1_11 {
private int fadeOutTime = -1;
private boolean ticks = false;
- private static final Map, Class>> CORRESPONDING_TYPES = new HashMap, Class>>();
-
public TitleManager_1_11() {
loadClasses();
}
@@ -98,7 +98,8 @@ public class TitleManager_1_11 {
* @param stayTime Stay on screen time
* @param fadeOutTime Fade out time
*/
- public TitleManager_1_11(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) {
+ public TitleManager_1_11(String title, String subtitle, int fadeInTime, int stayTime,
+ int fadeOutTime) {
this.title = title;
this.subtitle = subtitle;
this.fadeInTime = fadeInTime;
@@ -107,6 +108,15 @@ public class TitleManager_1_11 {
loadClasses();
}
+ private static boolean equalsTypeArray(Class>[] a, Class>[] o) {
+ if (a.length != o.length)
+ return false;
+ for (int i = 0; i < a.length; i++)
+ if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]))
+ return false;
+ return true;
+ }
+
/**
* Load spigot and NMS classes
*/
@@ -118,23 +128,13 @@ public class TitleManager_1_11 {
nmsChatSerializer = getNMSClass("ChatComponentText");
nmsPlayer = getNMSClass("EntityPlayer");
nmsPlayerConnection = getNMSClass("PlayerConnection");
- playerConnection = getField(nmsPlayer,
- "playerConnection");
+ playerConnection = getField(nmsPlayer, "playerConnection");
sendPacket = getMethod(nmsPlayerConnection, "sendPacket");
obcPlayer = getOBCClass("entity.CraftPlayer");
methodPlayerGetHandle = getMethod("getHandle", obcPlayer);
}
}
- /**
- * Set title text
- *
- * @param title Title
- */
- public void setTitle(String title) {
- this.title = title;
- }
-
/**
* Get title text
*
@@ -145,12 +145,12 @@ public class TitleManager_1_11 {
}
/**
- * Set subtitle text
+ * Set title text
*
- * @param subtitle Subtitle text
+ * @param title Title
*/
- public void setSubtitle(String subtitle) {
- this.subtitle = subtitle;
+ public void setTitle(String title) {
+ this.title = title;
}
/**
@@ -163,48 +163,12 @@ public class TitleManager_1_11 {
}
/**
- * Set the title color
+ * Set subtitle text
*
- * @param color Chat color
+ * @param subtitle Subtitle text
*/
- public void setTitleColor(ChatColor color) {
- this.titleColor = color;
- }
-
- /**
- * Set the subtitle color
- *
- * @param color Chat color
- */
- public void setSubtitleColor(ChatColor color) {
- this.subtitleColor = color;
- }
-
- /**
- * Set title fade in time
- *
- * @param time Time
- */
- public void setFadeInTime(int time) {
- this.fadeInTime = time;
- }
-
- /**
- * Set title fade out time
- *
- * @param time Time
- */
- public void setFadeOutTime(int time) {
- this.fadeOutTime = time;
- }
-
- /**
- * Set title stay time
- *
- * @param time Time
- */
- public void setStayTime(int time) {
- this.stayTime = time;
+ public void setSubtitle(String subtitle) {
+ this.subtitle = subtitle;
}
/**
@@ -235,12 +199,10 @@ public class TitleManager_1_11 {
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = packetActions.getEnumConstants();
- Object packet = packetTitle.getConstructor(packetActions,
- chatBaseComponent, Integer.TYPE, Integer.TYPE,
- Integer.TYPE).newInstance(actions[3], null,
- fadeInTime * (ticks ? 1 : 20),
- stayTime * (ticks ? 1 : 20),
- fadeOutTime * (ticks ? 1 : 20));
+ Object packet = packetTitle
+ .getConstructor(packetActions, chatBaseComponent, Integer.TYPE, Integer.TYPE,
+ Integer.TYPE).newInstance(actions[3], null, fadeInTime * (ticks ? 1 : 20),
+ stayTime * (ticks ? 1 : 20), fadeOutTime * (ticks ? 1 : 20));
// Send if set
if (fadeInTime != -1 && fadeOutTime != -1 && stayTime != -1)
sendPacket.invoke(connection, packet);
@@ -248,22 +210,18 @@ public class TitleManager_1_11 {
Object serialized;
if (!subtitle.equals("")) {
// Send subtitle if present
- serialized = nmsChatSerializer.getConstructor(String.class)
- .newInstance(subtitleColor +
- ChatColor.translateAlternateColorCodes('&',
- subtitle));
- packet = packetTitle.getConstructor(packetActions,
- chatBaseComponent).newInstance(actions[1],
- serialized);
+ serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
+ subtitleColor + ChatColor.translateAlternateColorCodes('&', subtitle));
+ packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
+ .newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
}
// Send title
- serialized = nmsChatSerializer.getConstructor(
- String.class).newInstance(titleColor +
- ChatColor.translateAlternateColorCodes('&', title));
- packet = packetTitle.getConstructor(packetActions,
- chatBaseComponent).newInstance(actions[0], serialized);
+ serialized = nmsChatSerializer.getConstructor(String.class)
+ .newInstance(titleColor + ChatColor.translateAlternateColorCodes('&', title));
+ packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
+ .newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
@@ -278,19 +236,12 @@ public class TitleManager_1_11 {
Object connection = playerConnection.get(handle);
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
Object packet = TitleManager_1_11.packetTitle.getConstructor(
- new Class[]{TitleManager_1_11.packetActions, chatBaseComponent,
- Integer.TYPE, Integer.TYPE, Integer.TYPE})
- .newInstance(
- actions[3],
- null,
- this.fadeInTime
- * (this.ticks ? 1 : 20),
- this.stayTime
- * (this.ticks ? 1 : 20),
- this.fadeOutTime
- * (this.ticks ? 1 : 20));
- if ((this.fadeInTime != -1) && (this.fadeOutTime != -1)
- && (this.stayTime != -1)) {
+ new Class[] {TitleManager_1_11.packetActions, chatBaseComponent, Integer.TYPE,
+ Integer.TYPE, Integer.TYPE})
+ .newInstance(actions[3], null, this.fadeInTime * (this.ticks ? 1 : 20),
+ this.stayTime * (this.ticks ? 1 : 20),
+ this.fadeOutTime * (this.ticks ? 1 : 20));
+ if ((this.fadeInTime != -1) && (this.fadeOutTime != -1) && (this.stayTime != -1)) {
sendPacket.invoke(connection, packet);
}
} catch (Exception e) {
@@ -303,21 +254,14 @@ public class TitleManager_1_11 {
if (TitleManager_1_11.packetTitle != null) {
try {
Object handle = getHandle(player);
- Object connection = getField(handle.getClass(),
- "playerConnection").get(handle);
+ Object connection = getField(handle.getClass(), "playerConnection").get(handle);
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
- Method sendPacket = getMethod(connection.getClass(),
- "sendPacket");
- Object serialized = nmsChatSerializer.getConstructor(
- String.class)
- .newInstance(titleColor +
- ChatColor.translateAlternateColorCodes('&',
- this.title));
- Object packet = TitleManager_1_11.packetTitle
- .getConstructor(
- new Class[]{TitleManager_1_11.packetActions,
- chatBaseComponent}).newInstance(
- actions[0], serialized);
+ Method sendPacket = getMethod(connection.getClass(), "sendPacket");
+ Object serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
+ titleColor + ChatColor.translateAlternateColorCodes('&', this.title));
+ Object packet = TitleManager_1_11.packetTitle.getConstructor(
+ new Class[] {TitleManager_1_11.packetActions, chatBaseComponent})
+ .newInstance(actions[0], serialized);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
@@ -331,16 +275,11 @@ public class TitleManager_1_11 {
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = TitleManager_1_11.packetActions.getEnumConstants();
- Object serialized = nmsChatSerializer.getConstructor(
- String.class)
- .newInstance(subtitleColor +
- ChatColor.translateAlternateColorCodes('&',
- this.subtitle));
- Object packet = TitleManager_1_11.packetTitle
- .getConstructor(
- new Class[]{TitleManager_1_11.packetActions,
- chatBaseComponent}).newInstance(
- actions[1], serialized);
+ Object serialized = nmsChatSerializer.getConstructor(String.class).newInstance(
+ subtitleColor + ChatColor.translateAlternateColorCodes('&', this.subtitle));
+ Object packet = TitleManager_1_11.packetTitle.getConstructor(
+ new Class[] {TitleManager_1_11.packetActions, chatBaseComponent})
+ .newInstance(actions[1], serialized);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
@@ -368,8 +307,8 @@ public class TitleManager_1_11 {
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = packetActions.getEnumConstants();
- Object packet = packetTitle.getConstructor(packetActions,
- chatBaseComponent).newInstance(actions[4], null);
+ Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
+ .newInstance(actions[4], null);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
@@ -387,8 +326,8 @@ public class TitleManager_1_11 {
Object handle = getHandle(player);
Object connection = playerConnection.get(handle);
Object[] actions = packetActions.getEnumConstants();
- Object packet = packetTitle.getConstructor(packetActions,
- chatBaseComponent).newInstance(actions[5], null);
+ Object packet = packetTitle.getConstructor(packetActions, chatBaseComponent)
+ .newInstance(actions[5], null);
sendPacket.invoke(connection, packet);
} catch (Exception e) {
e.printStackTrace();
@@ -396,8 +335,7 @@ public class TitleManager_1_11 {
}
private Class> getPrimitiveType(Class> clazz) {
- return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES
- .get(clazz) : clazz;
+ return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz;
}
private Class>[] toPrimitiveTypeArray(Class>[] classes) {
@@ -408,15 +346,6 @@ public class TitleManager_1_11 {
return types;
}
- private static boolean equalsTypeArray(Class>[] a, Class>[] o) {
- if (a.length != o.length)
- return false;
- for (int i = 0; i < a.length; i++)
- if (!a[i].equals(o[i]) && !a[i].isAssignableFrom(o[i]))
- return false;
- return true;
- }
-
private Object getHandle(Player player) {
try {
return methodPlayerGetHandle.invoke(player);
@@ -426,8 +355,7 @@ public class TitleManager_1_11 {
}
}
- private Method getMethod(String name, Class> clazz,
- Class>... paramTypes) {
+ private Method getMethod(String name, Class> clazz, Class>... paramTypes) {
Class>[] t = toPrimitiveTypeArray(paramTypes);
for (Method m : clazz.getMethods()) {
Class>[] types = toPrimitiveTypeArray(m.getParameterTypes());
@@ -465,7 +393,6 @@ public class TitleManager_1_11 {
return clazz;
}
-
private Field getField(Class> clazz, String name) {
try {
Field field = clazz.getDeclaredField(name);
@@ -479,9 +406,8 @@ public class TitleManager_1_11 {
private Method getMethod(Class> clazz, String name, Class>... args) {
for (Method m : clazz.getMethods())
- if (m.getName().equals(name)
- && (args.length == 0 || ClassListEqual(args,
- m.getParameterTypes()))) {
+ if (m.getName().equals(name) && (args.length == 0 || ClassListEqual(args,
+ m.getParameterTypes()))) {
m.setAccessible(true);
return m;
}
@@ -504,23 +430,68 @@ public class TitleManager_1_11 {
return titleColor;
}
+ /**
+ * Set the title color
+ *
+ * @param color Chat color
+ */
+ public void setTitleColor(ChatColor color) {
+ this.titleColor = color;
+ }
+
public ChatColor getSubtitleColor() {
return subtitleColor;
}
+ /**
+ * Set the subtitle color
+ *
+ * @param color Chat color
+ */
+ public void setSubtitleColor(ChatColor color) {
+ this.subtitleColor = color;
+ }
+
public int getFadeInTime() {
return fadeInTime;
}
+ /**
+ * Set title fade in time
+ *
+ * @param time Time
+ */
+ public void setFadeInTime(int time) {
+ this.fadeInTime = time;
+ }
+
public int getFadeOutTime() {
return fadeOutTime;
}
+ /**
+ * Set title fade out time
+ *
+ * @param time Time
+ */
+ public void setFadeOutTime(int time) {
+ this.fadeOutTime = time;
+ }
+
public int getStayTime() {
return stayTime;
}
+ /**
+ * Set title stay time
+ *
+ * @param time Time
+ */
+ public void setStayTime(int time) {
+ this.stayTime = time;
+ }
+
public boolean isTicks() {
return ticks;
}
-}
\ No newline at end of file
+}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChatManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChatManager.java
index 3e7c226f5..7c6a6b4a0 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChatManager.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChatManager.java
@@ -15,18 +15,15 @@ import java.util.List;
public class BukkitChatManager extends ChatManager {
- @Override
- public FancyMessage builder() {
+ @Override public FancyMessage builder() {
return new FancyMessage("");
}
- @Override
- public void color(PlotMessage message, String color) {
+ @Override public void color(PlotMessage message, String color) {
message.$(this).color(ChatColor.getByChar(C.color(color).substring(1)));
}
- @Override
- public void tooltip(PlotMessage message, PlotMessage... tooltips) {
+ @Override public void tooltip(PlotMessage message, PlotMessage... tooltips) {
List lines = new ArrayList<>();
for (PlotMessage tooltip : tooltips) {
lines.add(tooltip.$(this));
@@ -34,18 +31,15 @@ public class BukkitChatManager extends ChatManager {
message.$(this).formattedTooltip(lines);
}
- @Override
- public void command(PlotMessage message, String command) {
+ @Override public void command(PlotMessage message, String command) {
message.$(this).command(command);
}
- @Override
- public void text(PlotMessage message, String text) {
+ @Override public void text(PlotMessage message, String text) {
message.$(this).then(ChatColor.stripColor(text));
}
- @Override
- public void send(PlotMessage plotMessage, PlotPlayer player) {
+ @Override public void send(PlotMessage plotMessage, PlotPlayer player) {
if (player instanceof ConsolePlayer || !Settings.Chat.INTERACTIVE) {
player.sendMessage(plotMessage.$(this).toOldMessageFormat());
} else {
@@ -53,8 +47,7 @@ public class BukkitChatManager extends ChatManager {
}
}
- @Override
- public void suggest(PlotMessage plotMessage, String command) {
+ @Override public void suggest(PlotMessage plotMessage, String command) {
plotMessage.$(this).suggest(command);
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java
index e39ab5f4e..24369a585 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java
@@ -2,61 +2,23 @@ package com.plotsquared.bukkit.util;
import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.generator.AugmentedUtils;
-import com.intellectualcrafters.plot.object.BlockLoc;
-import com.intellectualcrafters.plot.object.ChunkLoc;
+import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.object.Location;
-import com.intellectualcrafters.plot.object.Plot;
-import com.intellectualcrafters.plot.object.PlotArea;
-import com.intellectualcrafters.plot.object.PlotBlock;
-import com.intellectualcrafters.plot.object.PlotLoc;
-import com.intellectualcrafters.plot.object.RegionWrapper;
-import com.intellectualcrafters.plot.object.RunnableVal;
import com.intellectualcrafters.plot.util.ChunkManager;
import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.block.GlobalBlockQueue;
import com.intellectualcrafters.plot.util.block.LocalBlockQueue;
import com.intellectualcrafters.plot.util.block.ScopedLocalBlockQueue;
import com.plotsquared.bukkit.object.entity.EntityWrapper;
-import org.bukkit.Bukkit;
-import org.bukkit.Chunk;
-import org.bukkit.DyeColor;
-import org.bukkit.Material;
-import org.bukkit.Note;
-import org.bukkit.SkullType;
-import org.bukkit.World;
-import org.bukkit.block.Banner;
-import org.bukkit.block.Beacon;
-import org.bukkit.block.Block;
-import org.bukkit.block.BlockFace;
-import org.bukkit.block.BlockState;
-import org.bukkit.block.BrewingStand;
-import org.bukkit.block.CommandBlock;
-import org.bukkit.block.CreatureSpawner;
-import org.bukkit.block.Dispenser;
-import org.bukkit.block.Dropper;
-import org.bukkit.block.Furnace;
-import org.bukkit.block.Hopper;
-import org.bukkit.block.Jukebox;
-import org.bukkit.block.NoteBlock;
-import org.bukkit.block.Sign;
-import org.bukkit.block.Skull;
+import org.bukkit.*;
+import org.bukkit.block.*;
import org.bukkit.block.banner.Pattern;
-import org.bukkit.entity.Animals;
-import org.bukkit.entity.Creature;
-import org.bukkit.entity.Entity;
-import org.bukkit.entity.EntityType;
-import org.bukkit.entity.Player;
+import org.bukkit.entity.*;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
import java.util.Map.Entry;
-import java.util.Set;
public class BukkitChunkManager extends ChunkManager {
@@ -73,7 +35,8 @@ public class BukkitChunkManager extends ChunkManager {
return 0;
}
- public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2, RegionWrapper r1, RegionWrapper r2) {
+ public static ContentMap swapChunk(World world1, World world2, Chunk pos1, Chunk pos2,
+ RegionWrapper r1, RegionWrapper r2) {
ContentMap map = new ContentMap();
int relX = r2.minX - r1.minX;
int relZ = r2.minZ - r1.minZ;
@@ -127,8 +90,7 @@ public class BukkitChunkManager extends ChunkManager {
return map;
}
- @Override
- public Set getChunkChunks(String world) {
+ @Override public Set getChunkChunks(String world) {
Set chunks = super.getChunkChunks(world);
for (Chunk chunk : Bukkit.getWorld(world).getLoadedChunks()) {
ChunkLoc loc = new ChunkLoc(chunk.getX() >> 5, chunk.getZ() >> 5);
@@ -139,13 +101,15 @@ public class BukkitChunkManager extends ChunkManager {
return chunks;
}
- @Override
- public boolean copyRegion(Location pos1, Location pos2, Location newPos, final Runnable whenDone) {
+ @Override public boolean copyRegion(Location pos1, Location pos2, Location newPos,
+ final Runnable whenDone) {
final int relX = newPos.getX() - pos1.getX();
final int relZ = newPos.getZ() - pos1.getZ();
- Location pos4 = new Location(newPos.getWorld(), newPos.getX() + relX, 256, newPos.getZ() + relZ);
+ Location pos4 =
+ new Location(newPos.getWorld(), newPos.getX() + relX, 256, newPos.getZ() + relZ);
- final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
+ final RegionWrapper region =
+ new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
final World oldWorld = Bukkit.getWorld(pos1.getWorld());
final World newWorld = Bukkit.getWorld(newPos.getWorld());
final String newWorldName = newWorld.getName();
@@ -153,8 +117,7 @@ public class BukkitChunkManager extends ChunkManager {
final ContentMap map = new ContentMap();
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(newWorldName, false);
ChunkManager.chunkTask(pos1, pos2, new RunnableVal() {
- @Override
- public void run(int[] value) {
+ @Override public void run(int[] value) {
int bx = value[2];
int bz = value[3];
int tx = value[4];
@@ -171,8 +134,7 @@ public class BukkitChunkManager extends ChunkManager {
}
}
}, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
for (Entry entry : map.allBlocks.entrySet()) {
PlotLoc loc = entry.getKey();
PlotBlock[] blocks = entry.getValue();
@@ -185,8 +147,7 @@ public class BukkitChunkManager extends ChunkManager {
}
queue.enqueue();
GlobalBlockQueue.IMP.addTask(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
map.restoreBlocks(newWorld, 0, 0);
map.restoreEntities(newWorld, relX, relZ);
TaskManager.runTask(whenDone);
@@ -197,8 +158,8 @@ public class BukkitChunkManager extends ChunkManager {
return true;
}
- @Override
- public boolean regenerateRegion(final Location pos1, final Location pos2, final boolean ignoreAugment, final Runnable whenDone) {
+ @Override public boolean regenerateRegion(final Location pos1, final Location pos2,
+ final boolean ignoreAugment, final Runnable whenDone) {
final String world = pos1.getWorld();
final int p1x = pos1.getX();
@@ -219,8 +180,7 @@ public class BukkitChunkManager extends ChunkManager {
}
final World worldObj = Bukkit.getWorld(world);
TaskManager.runTask(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
long start = System.currentTimeMillis();
while (!chunks.isEmpty() && System.currentTimeMillis() - start < 5) {
final ChunkLoc chunk = chunks.remove(0);
@@ -235,11 +195,11 @@ public class BukkitChunkManager extends ChunkManager {
continue;
}
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
- RegionWrapper currentPlotClear = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
+ RegionWrapper currentPlotClear =
+ new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
if (xxb >= p1x && xxt <= p2x && zzb >= p1z && zzt <= p2z) {
AugmentedUtils.bypass(ignoreAugment, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
queue.regenChunkSafe(chunk.x, chunk.z);
}
});
@@ -306,11 +266,9 @@ public class BukkitChunkManager extends ChunkManager {
}
map.saveEntitiesOut(chunkObj, currentPlotClear);
AugmentedUtils.bypass(ignoreAugment, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
setChunkInPlotArea(null, new RunnableVal() {
- @Override
- public void run(ScopedLocalBlockQueue value) {
+ @Override public void run(ScopedLocalBlockQueue value) {
Location min = value.getMin();
int bx = min.getX();
int bz = min.getZ();
@@ -319,7 +277,8 @@ public class BukkitChunkManager extends ChunkManager {
PlotLoc loc = new PlotLoc(bx + x, bz + z);
PlotBlock[] ids = map.allBlocks.get(loc);
if (ids != null) {
- for (int y = 0; y < Math.min(128, ids.length); y++) {
+ for (int y = 0;
+ y < Math.min(128, ids.length); y++) {
PlotBlock id = ids[y];
if (id != null) {
value.setBlock(x, y, z, id);
@@ -327,7 +286,8 @@ public class BukkitChunkManager extends ChunkManager {
value.setBlock(x, y, z, 0, (byte) 0);
}
}
- for (int y = Math.min(128, ids.length); y < ids.length; y++) {
+ for (int y = Math.min(128, ids.length);
+ y < ids.length; y++) {
PlotBlock id = ids[y];
if (id != null) {
value.setBlock(x, y, z, id);
@@ -353,8 +313,7 @@ public class BukkitChunkManager extends ChunkManager {
return true;
}
- @Override
- public void clearAllEntities(Location pos1, Location pos2) {
+ @Override public void clearAllEntities(Location pos1, Location pos2) {
String world = pos1.getWorld();
List entities = BukkitUtil.getEntities(world);
int bx = pos1.getX();
@@ -364,26 +323,24 @@ public class BukkitChunkManager extends ChunkManager {
for (Entity entity : entities) {
if (!(entity instanceof Player)) {
org.bukkit.Location location = entity.getLocation();
- if (location.getX() >= bx && location.getX() <= tx && location.getZ() >= bz && location.getZ() <= tz) {
+ if (location.getX() >= bx && location.getX() <= tx && location.getZ() >= bz
+ && location.getZ() <= tz) {
entity.remove();
}
}
}
}
- @Override
- public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
+ @Override public boolean loadChunk(String world, ChunkLoc loc, boolean force) {
return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(force);
}
- @SuppressWarnings("deprecation")
- @Override
- public void unloadChunk(final String world, final ChunkLoc loc, final boolean save, final boolean safe) {
+ @SuppressWarnings("deprecation") @Override
+ public void unloadChunk(final String world, final ChunkLoc loc, final boolean save,
+ final boolean safe) {
if (!PS.get().isMainThread(Thread.currentThread())) {
TaskManager.runTask(new Runnable() {
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
+ @SuppressWarnings("deprecation") @Override public void run() {
BukkitUtil.getWorld(world).unloadChunk(loc.x, loc.z, save, safe);
}
});
@@ -392,10 +349,12 @@ public class BukkitChunkManager extends ChunkManager {
}
}
- @Override
- public void swap(Location bot1, Location top1, Location bot2, Location top2, final Runnable whenDone) {
- RegionWrapper region1 = new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
- RegionWrapper region2 = new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
+ @Override public void swap(Location bot1, Location top1, Location bot2, Location top2,
+ final Runnable whenDone) {
+ RegionWrapper region1 =
+ new RegionWrapper(bot1.getX(), top1.getX(), bot1.getZ(), top1.getZ());
+ RegionWrapper region2 =
+ new RegionWrapper(bot2.getX(), top2.getX(), bot2.getZ(), top2.getZ());
final World world1 = Bukkit.getWorld(bot1.getWorld());
World world2 = Bukkit.getWorld(bot2.getWorld());
@@ -412,8 +371,7 @@ public class BukkitChunkManager extends ChunkManager {
}
}
GlobalBlockQueue.IMP.addTask(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
for (ContentMap map : maps) {
map.restoreBlocks(world1, 0, 0);
map.restoreEntities(world1, 0, 0);
@@ -423,10 +381,10 @@ public class BukkitChunkManager extends ChunkManager {
});
}
- @Override
- public int[] countEntities(Plot plot) {
+ @Override public int[] countEntities(Plot plot) {
int[] existing = (int[]) plot.getMeta("EntityCount");
- if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime") < 1000)) {
+ if (existing != null && (System.currentTimeMillis() - (long) plot.getMeta("EntityCountTime")
+ < 1000)) {
return existing;
}
PlotArea area = plot.getArea();
@@ -542,7 +500,7 @@ public class BukkitChunkManager extends ChunkManager {
case ARMOR_STAND:
count[5]++;
break;
- // misc
+ // misc
case MINECART:
case MINECART_CHEST:
case MINECART_COMMAND:
@@ -705,7 +663,8 @@ public class BukkitChunkManager extends ChunkManager {
}
}
- public void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ, boolean delete) {
+ public void saveEntitiesIn(Chunk chunk, RegionWrapper region, int offsetX, int offsetZ,
+ boolean delete) {
for (Entity entity : chunk.getEntities()) {
Location loc = BukkitUtil.getLocation(entity);
int x = loc.getX();
@@ -743,26 +702,30 @@ public class BukkitChunkManager extends ChunkManager {
public void restoreBlocks(World world, int xOffset, int zOffset) {
for (Entry blockLocEntry : this.chestContents.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof InventoryHolder) {
InventoryHolder chest = (InventoryHolder) state;
chest.getInventory().setContents(blockLocEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate chest: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate chest: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (IllegalArgumentException ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate chest (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate chest (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocEntry : this.signContents.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Sign) {
Sign sign = (Sign) state;
@@ -773,95 +736,105 @@ public class BukkitChunkManager extends ChunkManager {
}
state.update(true);
} else {
- PS.debug(
- "&c[WARN] Plot clear failed to regenerate sign: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y
- + ',' + (
- blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate sign: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (IndexOutOfBoundsException ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate sign: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
- + ',' + (
- blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate sign: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocEntry : this.dispenserContents.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Dispenser) {
- ((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
+ ((InventoryHolder) state).getInventory()
+ .setContents(blockLocEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (IllegalArgumentException ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate dispenser (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate dispenser (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocEntry : this.dropperContents.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Dropper) {
- ((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
+ ((InventoryHolder) state).getInventory()
+ .setContents(blockLocEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate dispenser: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (IllegalArgumentException ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate dispenser (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate dispenser (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocEntry : this.beaconContents.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Beacon) {
- ((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
+ ((InventoryHolder) state).getInventory()
+ .setContents(blockLocEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate beacon: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate beacon: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (IllegalArgumentException ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate beacon (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate beacon (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocMaterialEntry : this.jukeboxDisc.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocMaterialEntry.getKey().x + xOffset, blockLocMaterialEntry.getKey().y, blockLocMaterialEntry
- .getKey().z + zOffset);
+ Block block = world.getBlockAt(blockLocMaterialEntry.getKey().x + xOffset,
+ blockLocMaterialEntry.getKey().y,
+ blockLocMaterialEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Jukebox) {
((Jukebox) state).setPlaying(blockLocMaterialEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to restore jukebox: " + (blockLocMaterialEntry.getKey().x + xOffset) + ','
- + blockLocMaterialEntry
- .getKey().y + ',' + (
- blockLocMaterialEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore jukebox: " + (
+ blockLocMaterialEntry.getKey().x + xOffset) + ','
+ + blockLocMaterialEntry.getKey().y + ',' + (
+ blockLocMaterialEntry.getKey().z + zOffset));
}
} catch (Exception ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate jukebox (e): " + (blockLocMaterialEntry.getKey().x + xOffset) + ','
- + blockLocMaterialEntry
- .getKey().y + ',' + (
- blockLocMaterialEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate jukebox (e): " + (
+ blockLocMaterialEntry.getKey().x + xOffset) + ',' + blockLocMaterialEntry
+ .getKey().y + ',' + (blockLocMaterialEntry.getKey().z + zOffset));
}
}
for (Entry blockLocEntry : this.skullData.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Skull) {
Object[] data = blockLocEntry.getValue();
@@ -872,193 +845,210 @@ public class BukkitChunkManager extends ChunkManager {
((Skull) state).setSkullType((SkullType) data[3]);
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to restore skull: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore skull: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (Exception e) {
- PS.debug("&c[WARN] Plot clear failed to regenerate skull (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate skull (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
e.printStackTrace();
}
}
for (Entry blockLocEntry : this.hopperContents.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Hopper) {
- ((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
+ ((InventoryHolder) state).getInventory()
+ .setContents(blockLocEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate hopper: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate hopper: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (IllegalArgumentException ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate hopper (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate hopper (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocNoteEntry : this.noteBlockContents.entrySet()) {
try {
- Block block = world.getBlockAt(
- blockLocNoteEntry.getKey().x + xOffset, blockLocNoteEntry.getKey().y, blockLocNoteEntry.getKey().z + zOffset);
+ Block block = world.getBlockAt(blockLocNoteEntry.getKey().x + xOffset,
+ blockLocNoteEntry.getKey().y, blockLocNoteEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof NoteBlock) {
((NoteBlock) state).setNote(blockLocNoteEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate note block: " + (blockLocNoteEntry.getKey().x + xOffset) + ','
- + blockLocNoteEntry
- .getKey().y + ',' + (
- blockLocNoteEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate note block: " + (
+ blockLocNoteEntry.getKey().x + xOffset) + ',' + blockLocNoteEntry
+ .getKey().y + ',' + (blockLocNoteEntry.getKey().z + zOffset));
}
} catch (Exception ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate note block (e): " + (blockLocNoteEntry.getKey().x + xOffset) + ','
- + blockLocNoteEntry
- .getKey().y + ',' + (
- blockLocNoteEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate note block (e): " + (
+ blockLocNoteEntry.getKey().x + xOffset) + ',' + blockLocNoteEntry.getKey().y
+ + ',' + (blockLocNoteEntry.getKey().z + zOffset));
}
}
for (Entry blockLocShortEntry : this.brewTime.entrySet()) {
try {
- Block block = world.getBlockAt(
- blockLocShortEntry.getKey().x + xOffset, blockLocShortEntry.getKey().y, blockLocShortEntry.getKey().z + zOffset);
+ Block block = world.getBlockAt(blockLocShortEntry.getKey().x + xOffset,
+ blockLocShortEntry.getKey().y, blockLocShortEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof BrewingStand) {
((BrewingStand) state).setBrewingTime(blockLocShortEntry.getValue());
} else {
- PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking: " + (blockLocShortEntry.getKey().x + xOffset) + ','
- + blockLocShortEntry
- .getKey().y + ',' + (
- blockLocShortEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking: " + (
+ blockLocShortEntry.getKey().x + xOffset) + ',' + blockLocShortEntry
+ .getKey().y + ',' + (blockLocShortEntry.getKey().z + zOffset));
}
} catch (Exception ignored) {
- PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking (e): " + (blockLocShortEntry.getKey().x + xOffset) + ','
- + blockLocShortEntry.getKey().y + ',' + (blockLocShortEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore brewing stand cooking (e): " + (
+ blockLocShortEntry.getKey().x + xOffset) + ',' + blockLocShortEntry
+ .getKey().y + ',' + (blockLocShortEntry.getKey().z + zOffset));
}
}
- for (Entry blockLocEntityTypeEntry : this.spawnerData.entrySet()) {
+ for (Entry blockLocEntityTypeEntry : this.spawnerData
+ .entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntityTypeEntry.getKey().x + xOffset, blockLocEntityTypeEntry.getKey().y, blockLocEntityTypeEntry
- .getKey().z + zOffset);
+ Block block = world.getBlockAt(blockLocEntityTypeEntry.getKey().x + xOffset,
+ blockLocEntityTypeEntry.getKey().y,
+ blockLocEntityTypeEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof CreatureSpawner) {
- ((CreatureSpawner) state).setSpawnedType(blockLocEntityTypeEntry.getValue());
+ ((CreatureSpawner) state)
+ .setSpawnedType(blockLocEntityTypeEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to restore spawner type: " + (blockLocEntityTypeEntry.getKey().x + xOffset) + ','
- + blockLocEntityTypeEntry
- .getKey().y + ',' + (
- blockLocEntityTypeEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore spawner type: " + (
+ blockLocEntityTypeEntry.getKey().x + xOffset) + ','
+ + blockLocEntityTypeEntry.getKey().y + ',' + (
+ blockLocEntityTypeEntry.getKey().z + zOffset));
}
} catch (Exception ignored) {
- PS.debug("&c[WARN] Plot clear failed to restore spawner type (e): " + (blockLocEntityTypeEntry.getKey().x + xOffset) + ','
- + blockLocEntityTypeEntry.getKey().y + ',' + (blockLocEntityTypeEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore spawner type (e): " + (
+ blockLocEntityTypeEntry.getKey().x + xOffset) + ','
+ + blockLocEntityTypeEntry.getKey().y + ',' + (
+ blockLocEntityTypeEntry.getKey().z + zOffset));
}
}
for (Entry blockLocStringEntry : this.cmdData.entrySet()) {
try {
- Block block = world.getBlockAt(
- blockLocStringEntry.getKey().x + xOffset, blockLocStringEntry.getKey().y, blockLocStringEntry.getKey().z + zOffset);
+ Block block = world.getBlockAt(blockLocStringEntry.getKey().x + xOffset,
+ blockLocStringEntry.getKey().y, blockLocStringEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof CommandBlock) {
((CommandBlock) state).setCommand(blockLocStringEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to restore command block: " + (blockLocStringEntry.getKey().x + xOffset) + ','
- + blockLocStringEntry
- .getKey().y + ',' + (
- blockLocStringEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore command block: " + (
+ blockLocStringEntry.getKey().x + xOffset) + ',' + blockLocStringEntry
+ .getKey().y + ',' + (blockLocStringEntry.getKey().z + zOffset));
}
} catch (Exception ignored) {
- PS.debug("&c[WARN] Plot clear failed to restore command block (e): " + (blockLocStringEntry.getKey().x + xOffset) + ','
- + blockLocStringEntry
- .getKey().y + ',' + (
- blockLocStringEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore command block (e): " + (
+ blockLocStringEntry.getKey().x + xOffset) + ',' + blockLocStringEntry
+ .getKey().y + ',' + (blockLocStringEntry.getKey().z + zOffset));
}
}
- for (Entry blockLocEntry : this.brewingStandContents.entrySet()) {
+ for (Entry blockLocEntry : this.brewingStandContents
+ .entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof BrewingStand) {
- ((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
+ ((InventoryHolder) state).getInventory()
+ .setContents(blockLocEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand: " + (blockLocEntry.getKey().x + xOffset) + ','
- + blockLocEntry
- .getKey().y + ',' + (
- blockLocEntry.getKey().z
- + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (IllegalArgumentException ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand (e): " + (blockLocEntry.getKey().x + xOffset) + ','
- + blockLocEntry.getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocEntry : this.furnaceTime.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Furnace) {
Short[] time = blockLocEntry.getValue();
((Furnace) state).setBurnTime(time[0]);
((Furnace) state).setCookTime(time[1]);
} else {
- PS.debug(
- "&c[WARN] Plot clear failed to restore furnace cooking: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore furnace cooking: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (Exception ignored) {
- PS.debug(
- "&c[WARN] Plot clear failed to restore furnace cooking (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to restore furnace cooking (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocEntry : this.furnaceContents.entrySet()) {
try {
- Block block =
- world.getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y, blockLocEntry.getKey().z + zOffset);
+ Block block = world
+ .getBlockAt(blockLocEntry.getKey().x + xOffset, blockLocEntry.getKey().y,
+ blockLocEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Furnace) {
- ((InventoryHolder) state).getInventory().setContents(blockLocEntry.getValue());
+ ((InventoryHolder) state).getInventory()
+ .setContents(blockLocEntry.getValue());
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate furnace: " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate furnace: " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y
+ + ',' + (blockLocEntry.getKey().z + zOffset));
}
} catch (IllegalArgumentException ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate furnace (e): " + (blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry
- .getKey().y + ',' + (blockLocEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate furnace (e): " + (
+ blockLocEntry.getKey().x + xOffset) + ',' + blockLocEntry.getKey().y + ','
+ + (blockLocEntry.getKey().z + zOffset));
}
}
for (Entry blockLocByteEntry : this.bannerBase.entrySet()) {
try {
- Block block = world.getBlockAt(
- blockLocByteEntry.getKey().x + xOffset, blockLocByteEntry.getKey().y, blockLocByteEntry.getKey().z + zOffset);
+ Block block = world.getBlockAt(blockLocByteEntry.getKey().x + xOffset,
+ blockLocByteEntry.getKey().y, blockLocByteEntry.getKey().z + zOffset);
BlockState state = block.getState();
if (state instanceof Banner) {
Banner banner = (Banner) state;
DyeColor base = blockLocByteEntry.getValue();
- List patterns = this.bannerPatterns.get(blockLocByteEntry.getKey());
+ List patterns =
+ this.bannerPatterns.get(blockLocByteEntry.getKey());
banner.setBaseColor(base);
banner.setPatterns(patterns);
state.update(true);
} else {
- PS.debug("&c[WARN] Plot clear failed to regenerate banner: " + (blockLocByteEntry.getKey().x + xOffset) + ','
- + blockLocByteEntry.getKey().y + ',' + (blockLocByteEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate banner: " + (
+ blockLocByteEntry.getKey().x + xOffset) + ',' + blockLocByteEntry
+ .getKey().y + ',' + (blockLocByteEntry.getKey().z + zOffset));
}
} catch (Exception ignored) {
- PS.debug("&c[WARN] Plot clear failed to regenerate banner (e): " + (blockLocByteEntry.getKey().x + xOffset) + ','
- + blockLocByteEntry.getKey().y + ',' + (blockLocByteEntry.getKey().z + zOffset));
+ PS.debug("&c[WARN] Plot clear failed to regenerate banner (e): " + (
+ blockLocByteEntry.getKey().x + xOffset) + ',' + blockLocByteEntry.getKey().y
+ + ',' + (blockLocByteEntry.getKey().z + zOffset));
}
}
}
- public void saveBlocks(World world, int maxY, int x, int z, int offsetX, int offsetZ, boolean storeNormal) {
+ public void saveBlocks(World world, int maxY, int x, int z, int offsetX, int offsetZ,
+ boolean storeNormal) {
maxY = Math.min(255, maxY);
PlotBlock[] ids;
if (storeNormal) {
@@ -1082,7 +1072,8 @@ public class BukkitChunkManager extends ChunkManager {
BlockLoc bl = new BlockLoc(x + offsetX, y, z + offsetZ);
if (block.getState() instanceof InventoryHolder) {
InventoryHolder inventoryHolder = (InventoryHolder) block.getState();
- ItemStack[] inventory = inventoryHolder.getInventory().getContents().clone();
+ ItemStack[] inventory =
+ inventoryHolder.getInventory().getContents().clone();
switch (id) {
case CHEST:
this.chestContents.put(bl, inventory);
@@ -1105,7 +1096,8 @@ public class BukkitChunkManager extends ChunkManager {
if (time > 0) {
this.brewTime.put(bl, time);
}
- ItemStack[] invBre = brewingStand.getInventory().getContents().clone();
+ ItemStack[] invBre =
+ brewingStand.getInventory().getContents().clone();
this.brewingStandContents.put(bl, invBre);
break;
case FURNACE:
@@ -1113,10 +1105,11 @@ public class BukkitChunkManager extends ChunkManager {
Furnace furnace = (Furnace) inventoryHolder;
short burn = furnace.getBurnTime();
short cook = furnace.getCookTime();
- ItemStack[] invFur = furnace.getInventory().getContents().clone();
+ ItemStack[] invFur =
+ furnace.getInventory().getContents().clone();
this.furnaceContents.put(bl, invFur);
if (cook != 0) {
- this.furnaceTime.put(bl, new Short[]{burn, cook});
+ this.furnaceTime.put(bl, new Short[] {burn, cook});
}
break;
}
@@ -1144,7 +1137,8 @@ public class BukkitChunkManager extends ChunkManager {
}
} else if (block.getState() instanceof Skull) {
Skull skull = (Skull) block.getState();
- this.skullData.put(bl, new Object[]{skull.hasOwner(), skull.getOwner(), skull.getRotation(), skull.getSkullType()});
+ this.skullData.put(bl, new Object[] {skull.hasOwner(), skull.getOwner(),
+ skull.getRotation(), skull.getSkullType()});
} else if (block.getState() instanceof Banner) {
Banner banner = (Banner) block.getState();
DyeColor base = banner.getBaseColor();
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java
index d97271f4b..5dc54c5a4 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java
@@ -4,13 +4,7 @@ import com.intellectualcrafters.plot.commands.MainCommand;
import com.intellectualcrafters.plot.object.ConsolePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer;
import com.plotsquared.bukkit.commands.DebugUUID;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.command.ConsoleCommandSender;
-import org.bukkit.command.ProxiedCommandSender;
-import org.bukkit.command.RemoteConsoleCommandSender;
-import org.bukkit.command.TabCompleter;
+import org.bukkit.command.*;
import org.bukkit.entity.Player;
import java.util.ArrayList;
@@ -25,19 +19,22 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
}
@Override
- public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) {
+ public boolean onCommand(CommandSender commandSender, Command command, String commandLabel,
+ String[] args) {
if (commandSender instanceof Player) {
return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), args);
}
- if (commandSender instanceof ConsoleCommandSender || commandSender instanceof ProxiedCommandSender
- || commandSender instanceof RemoteConsoleCommandSender) {
+ if (commandSender instanceof ConsoleCommandSender
+ || commandSender instanceof ProxiedCommandSender
+ || commandSender instanceof RemoteConsoleCommandSender) {
return MainCommand.onCommand(ConsolePlayer.getConsole(), args);
}
return false;
}
@Override
- public List onTabComplete(CommandSender commandSender, Command command, String s, String[] args) {
+ public List onTabComplete(CommandSender commandSender, Command command, String s,
+ String[] args) {
if (!(commandSender instanceof Player)) {
return null;
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java
index 830afe93c..248a88ca0 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java
@@ -24,7 +24,8 @@ public class BukkitEconHandler extends EconHandler {
}
private boolean setupPermissions() {
- RegisteredServiceProvider permissionProvider = Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
+ RegisteredServiceProvider permissionProvider =
+ Bukkit.getServer().getServicesManager().getRegistration(Permission.class);
if (permissionProvider != null) {
this.perms = permissionProvider.getProvider();
}
@@ -35,15 +36,15 @@ public class BukkitEconHandler extends EconHandler {
if (Bukkit.getServer().getPluginManager().getPlugin("Vault") == null) {
return false;
}
- RegisteredServiceProvider economyProvider = Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
+ RegisteredServiceProvider economyProvider =
+ Bukkit.getServer().getServicesManager().getRegistration(Economy.class);
if (economyProvider != null) {
this.econ = economyProvider.getProvider();
}
return this.econ != null;
}
- @Override
- public double getMoney(PlotPlayer player) {
+ @Override public double getMoney(PlotPlayer player) {
double bal = super.getMoney(player);
if (Double.isNaN(bal)) {
return this.econ.getBalance(((BukkitPlayer) player).player);
@@ -51,28 +52,23 @@ public class BukkitEconHandler extends EconHandler {
return bal;
}
- @Override
- public void withdrawMoney(PlotPlayer player, double amount) {
+ @Override public void withdrawMoney(PlotPlayer player, double amount) {
this.econ.withdrawPlayer(((BukkitPlayer) player).player, amount);
}
- @Override
- public void depositMoney(PlotPlayer player, double amount) {
+ @Override public void depositMoney(PlotPlayer player, double amount) {
this.econ.depositPlayer(((BukkitPlayer) player).player, amount);
}
- @Override
- public void depositMoney(OfflinePlotPlayer player, double amount) {
+ @Override public void depositMoney(OfflinePlotPlayer player, double amount) {
this.econ.depositPlayer(((BukkitOfflinePlayer) player).player, amount);
}
- @Override
- public boolean hasPermission(String world, String player, String perm) {
+ @Override public boolean hasPermission(String world, String player, String perm) {
return this.perms.playerHas(world, Bukkit.getOfflinePlayer(player), perm);
}
- @Override
- public double getBalance(PlotPlayer player) {
+ @Override public double getBalance(PlotPlayer player) {
return this.econ.getBalance(player.getName());
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java
index b004e6ff4..4fe906beb 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java
@@ -1,30 +1,9 @@
package com.plotsquared.bukkit.util;
import com.intellectualcrafters.plot.flag.Flag;
-import com.intellectualcrafters.plot.object.Location;
-import com.intellectualcrafters.plot.object.Plot;
-import com.intellectualcrafters.plot.object.PlotArea;
-import com.intellectualcrafters.plot.object.PlotCluster;
-import com.intellectualcrafters.plot.object.PlotId;
-import com.intellectualcrafters.plot.object.PlotPlayer;
-import com.intellectualcrafters.plot.object.Rating;
+import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.EventUtil;
-import com.plotsquared.bukkit.events.ClusterFlagRemoveEvent;
-import com.plotsquared.bukkit.events.PlayerClaimPlotEvent;
-import com.plotsquared.bukkit.events.PlayerEnterPlotEvent;
-import com.plotsquared.bukkit.events.PlayerLeavePlotEvent;
-import com.plotsquared.bukkit.events.PlayerPlotDeniedEvent;
-import com.plotsquared.bukkit.events.PlayerPlotHelperEvent;
-import com.plotsquared.bukkit.events.PlayerPlotTrustedEvent;
-import com.plotsquared.bukkit.events.PlayerTeleportToPlotEvent;
-import com.plotsquared.bukkit.events.PlotClearEvent;
-import com.plotsquared.bukkit.events.PlotComponentSetEvent;
-import com.plotsquared.bukkit.events.PlotDeleteEvent;
-import com.plotsquared.bukkit.events.PlotFlagAddEvent;
-import com.plotsquared.bukkit.events.PlotFlagRemoveEvent;
-import com.plotsquared.bukkit.events.PlotMergeEvent;
-import com.plotsquared.bukkit.events.PlotRateEvent;
-import com.plotsquared.bukkit.events.PlotUnlinkEvent;
+import com.plotsquared.bukkit.events.*;
import com.plotsquared.bukkit.object.BukkitPlayer;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -48,83 +27,67 @@ public class BukkitEventUtil extends EventUtil {
return !(event instanceof Cancellable) || !((Cancellable) event).isCancelled();
}
- @Override
- public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
+ @Override public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) {
return callEvent(new PlayerClaimPlotEvent(getPlayer(player), plot, auto));
}
- @Override
- public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
+ @Override public boolean callTeleport(PlotPlayer player, Location from, Plot plot) {
return callEvent(new PlayerTeleportToPlotEvent(getPlayer(player), from, plot));
}
- @Override
- public boolean callComponentSet(Plot plot, String component) {
+ @Override public boolean callComponentSet(Plot plot, String component) {
return callEvent(new PlotComponentSetEvent(plot, component));
}
- @Override
- public boolean callClear(Plot plot) {
+ @Override public boolean callClear(Plot plot) {
return callEvent(new PlotClearEvent(plot));
}
- @Override
- public void callDelete(Plot plot) {
+ @Override public void callDelete(Plot plot) {
callEvent(new PlotDeleteEvent(plot));
}
- @Override
- public boolean callFlagAdd(Flag flag, Plot plot) {
+ @Override public boolean callFlagAdd(Flag flag, Plot plot) {
return callEvent(new PlotFlagAddEvent(flag, plot));
}
- @Override
- public boolean callFlagRemove(Flag> flag, Plot plot, Object value) {
+ @Override public boolean callFlagRemove(Flag> flag, Plot plot, Object value) {
return callEvent(new PlotFlagRemoveEvent(flag, plot));
}
- @Override
- public boolean callMerge(Plot plot, ArrayList plots) {
+ @Override public boolean callMerge(Plot plot, ArrayList plots) {
return callEvent(new PlotMergeEvent(BukkitUtil.getWorld(plot.getWorldName()), plot, plots));
}
- @Override
- public boolean callUnlink(PlotArea area, ArrayList plots) {
+ @Override public boolean callUnlink(PlotArea area, ArrayList plots) {
return callEvent(new PlotUnlinkEvent(BukkitUtil.getWorld(area.worldname), area, plots));
}
- @Override
- public void callEntry(PlotPlayer player, Plot plot) {
+ @Override public void callEntry(PlotPlayer player, Plot plot) {
callEvent(new PlayerEnterPlotEvent(getPlayer(player), plot));
}
- @Override
- public void callLeave(PlotPlayer player, Plot plot) {
+ @Override public void callLeave(PlotPlayer player, Plot plot) {
callEvent(new PlayerLeavePlotEvent(getPlayer(player), plot));
}
- @Override
- public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
+ @Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotDeniedEvent(getPlayer(initiator), plot, player, added));
}
- @Override
- public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
+ @Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotTrustedEvent(getPlayer(initiator), plot, player, added));
}
- @Override
- public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
+ @Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
callEvent(new PlayerPlotHelperEvent(getPlayer(initiator), plot, player, added));
}
- @Override
- public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) {
+ @Override public boolean callFlagRemove(Flag flag, Object object, PlotCluster cluster) {
return callEvent(new ClusterFlagRemoveEvent(flag, cluster));
}
- @Override
- public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
+ @Override public Rating callRating(PlotPlayer player, Plot plot, Rating rating) {
PlotRateEvent event = new PlotRateEvent(player, rating, plot);
Bukkit.getServer().getPluginManager().callEvent(event);
return event.getRating();
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java
index 225998ab2..68b729948 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java
@@ -26,8 +26,8 @@ import java.util.Random;
public class BukkitHybridUtils extends HybridUtils {
- @Override
- public void analyzeRegion(final String world, final RegionWrapper region, final RunnableVal whenDone) {
+ @Override public void analyzeRegion(final String world, final RegionWrapper region,
+ final RunnableVal whenDone) {
// int diff, int variety, int vertices, int rotation, int height_sd
/*
* diff: compare to base by looping through all blocks
@@ -41,8 +41,7 @@ public class BukkitHybridUtils extends HybridUtils {
*
*/
TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
final World worldObj = Bukkit.getWorld(world);
final ChunkGenerator gen = worldObj.getGenerator();
@@ -50,12 +49,10 @@ public class BukkitHybridUtils extends HybridUtils {
return;
}
final BiomeGrid nullBiomeGrid = new BiomeGrid() {
- @Override
- public void setBiome(int a, int b, Biome c) {
+ @Override public void setBiome(int a, int b, Biome c) {
}
- @Override
- public Biome getBiome(int a, int b) {
+ @Override public Biome getBiome(int a, int b) {
return null;
}
};
@@ -82,15 +79,14 @@ public class BukkitHybridUtils extends HybridUtils {
final short[][][] newBlocks = new short[256][width][length];
final Runnable run = new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
ChunkManager.chunkTask(bot, top, new RunnableVal() {
- @Override
- public void run(int[] value) {
+ @Override public void run(int[] value) {
// [chunkx, chunkz, pos1x, pos1z, pos2x, pos2z, isedge]
int X = value[0];
int Z = value[1];
- short[][] result = gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid);
+ short[][] result =
+ gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid);
int xb = (X << 4) - bx;
int zb = (Z << 4) - bz;
for (int i = 0; i < result.length; i++) {
@@ -125,11 +121,9 @@ public class BukkitHybridUtils extends HybridUtils {
}
}, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
int size = width * length;
int[] changes = new int[size];
int[] faces = new int[size];
@@ -151,7 +145,8 @@ public class BukkitHybridUtils extends HybridUtils {
} else {
// check vertices
// modifications_adjacent
- if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1 && y < 255) {
+ if (x > 0 && z > 0 && y > 0 && x < width - 1
+ && z < length - 1 && y < 255) {
if (newBlocks[y - 1][x][z] == 0) {
faces[i]++;
}
@@ -172,12 +167,15 @@ public class BukkitHybridUtils extends HybridUtils {
}
}
- Material material = Material.getMaterial(now);
+ Material material =
+ Material.getMaterial(now);
if (material != null) {
- Class extends MaterialData> md = material.getData();
+ Class extends MaterialData> md =
+ material.getData();
if (md.equals(Directional.class)) {
data[i] += 8;
- } else if (!md.equals(MaterialData.class)) {
+ } else if (!md
+ .equals(MaterialData.class)) {
data[i]++;
}
}
@@ -199,11 +197,14 @@ public class BukkitHybridUtils extends HybridUtils {
analysis.air = (int) (MathMan.getMean(air) * 100);
analysis.variety = (int) (MathMan.getMean(variety) * 100);
- analysis.changes_sd = (int) MathMan.getSD(changes, analysis.changes);
- analysis.faces_sd = (int) MathMan.getSD(faces, analysis.faces);
+ analysis.changes_sd =
+ (int) MathMan.getSD(changes, analysis.changes);
+ analysis.faces_sd =
+ (int) MathMan.getSD(faces, analysis.faces);
analysis.data_sd = (int) MathMan.getSD(data, analysis.data);
analysis.air_sd = (int) MathMan.getSD(air, analysis.air);
- analysis.variety_sd = (int) MathMan.getSD(variety, analysis.variety);
+ analysis.variety_sd =
+ (int) MathMan.getSD(variety, analysis.variety);
System.gc();
System.gc();
whenDone.value = analysis;
@@ -219,8 +220,7 @@ public class BukkitHybridUtils extends HybridUtils {
MainUtil.initCache();
ChunkManager.chunkTask(bot, top, new RunnableVal() {
- @Override
- public void run(int[] value) {
+ @Override public void run(int[] value) {
int X = value[0];
int Z = value[1];
worldObj.loadChunk(X, Z);
@@ -269,8 +269,7 @@ public class BukkitHybridUtils extends HybridUtils {
worldObj.unloadChunkRequest(X, Z, true);
}
}, new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
TaskManager.runTaskAsync(run);
}
}, 5);
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java
index cd2c12d51..0de2e354b 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java
@@ -45,8 +45,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
return stack;
}
- @Override
- public void open(PlotInventory inv) {
+ @Override public void open(PlotInventory inv) {
BukkitPlayer bp = (BukkitPlayer) inv.player;
Inventory inventory = Bukkit.createInventory(null, inv.size * 9, inv.getTitle());
PlotItemStack[] items = inv.getItems();
@@ -60,8 +59,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
bp.player.openInventory(inventory);
}
- @Override
- public void close(PlotInventory inv) {
+ @Override public void close(PlotInventory inv) {
if (!inv.isOpen()) {
return;
}
@@ -70,8 +68,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
bp.player.closeInventory();
}
- @Override
- public void setItem(PlotInventory inv, int index, PlotItemStack item) {
+ @Override public void setItem(PlotInventory inv, int index, PlotItemStack item) {
BukkitPlayer bp = (BukkitPlayer) inv.player;
InventoryView opened = bp.player.getOpenInventory();
if (!inv.isOpen()) {
@@ -103,8 +100,7 @@ public class BukkitInventoryUtil extends InventoryUtil {
return new PlotItemStack(id, data, amount, name, lore);
}
- @Override
- public PlotItemStack[] getItems(PlotPlayer player) {
+ @Override public PlotItemStack[] getItems(PlotPlayer player) {
BukkitPlayer bp = (BukkitPlayer) player;
PlayerInventory inv = bp.player.getInventory();
PlotItemStack[] items = new PlotItemStack[36];
@@ -114,13 +110,13 @@ public class BukkitInventoryUtil extends InventoryUtil {
return items;
}
- @Override
- public boolean isOpen(PlotInventory inv) {
+ @Override public boolean isOpen(PlotInventory inv) {
if (!inv.isOpen()) {
return false;
}
BukkitPlayer bp = (BukkitPlayer) inv.player;
InventoryView opened = bp.player.getOpenInventory();
- return inv.isOpen() && opened.getType() == InventoryType.CRAFTING && opened.getTitle() == null;
+ return inv.isOpen() && opened.getType() == InventoryType.CRAFTING
+ && opened.getTitle() == null;
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java
index df957892e..ab2e815ce 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java
@@ -1,12 +1,6 @@
package com.plotsquared.bukkit.util;
-import com.intellectualcrafters.jnbt.ByteArrayTag;
-import com.intellectualcrafters.jnbt.CompoundTag;
-import com.intellectualcrafters.jnbt.IntTag;
-import com.intellectualcrafters.jnbt.ListTag;
-import com.intellectualcrafters.jnbt.ShortTag;
-import com.intellectualcrafters.jnbt.StringTag;
-import com.intellectualcrafters.jnbt.Tag;
+import com.intellectualcrafters.jnbt.*;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.RegionWrapper;
@@ -22,24 +16,18 @@ import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.BlockState;
-import java.util.ArrayDeque;
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import java.util.*;
/**
* Schematic Handler.
*/
public class BukkitSchematicHandler extends SchematicHandler {
- @Override
- public void getCompoundTag(final String world, final Set regions, final RunnableVal whenDone) {
+ @Override public void getCompoundTag(final String world, final Set regions,
+ final RunnableVal whenDone) {
// async
TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
// Main positions
Location[] corners = MainUtil.getCorners(world, regions);
final Location bot = corners[0];
@@ -67,16 +55,18 @@ public class BukkitSchematicHandler extends SchematicHandler {
// Queue
final ArrayDeque queue = new ArrayDeque<>(regions);
TaskManager.runTask(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
if (queue.isEmpty()) {
TaskManager.runTaskAsync(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
schematic.put("Blocks", new ByteArrayTag("Blocks", blocks));
schematic.put("Data", new ByteArrayTag("Data", blockData));
- schematic.put("Entities", new ListTag("Entities", CompoundTag.class, new ArrayList()));
- schematic.put("TileEntities", new ListTag("TileEntities", CompoundTag.class, tileEntities));
+ schematic.put("Entities",
+ new ListTag("Entities", CompoundTag.class,
+ new ArrayList()));
+ schematic.put("TileEntities",
+ new ListTag("TileEntities", CompoundTag.class,
+ tileEntities));
whenDone.value = new CompoundTag("Schematic", schematic);
TaskManager.runTask(whenDone);
System.gc();
@@ -111,10 +101,10 @@ public class BukkitSchematicHandler extends SchematicHandler {
final World worldObj = Bukkit.getWorld(world);
// Main thread
TaskManager.runTask(new Runnable() {
- @Override
- public void run() {
+ @Override public void run() {
long start = System.currentTimeMillis();
- while (!chunks.isEmpty() && System.currentTimeMillis() - start < 20) {
+ while (!chunks.isEmpty()
+ && System.currentTimeMillis() - start < 20) {
// save schematics
ChunkLoc chunk = chunks.remove(0);
Chunk bc = worldObj.getChunkAt(chunk.x, chunk.z);
@@ -259,15 +249,20 @@ public class BukkitSchematicHandler extends SchematicHandler {
// TODO implement fully
BlockState state = block.getState();
if (state != null) {
- StateWrapper wrapper = new StateWrapper(state);
+ StateWrapper wrapper =
+ new StateWrapper(state);
CompoundTag rawTag = wrapper.getTag();
if (rawTag != null) {
- Map values = new HashMap<>(rawTag.getValue());
- values.put("id", new StringTag("id", wrapper.getId()));
+ Map values =
+ new HashMap<>(
+ rawTag.getValue());
+ values.put("id", new StringTag("id",
+ wrapper.getId()));
values.put("x", new IntTag("x", x));
values.put("y", new IntTag("y", y));
values.put("z", new IntTag("z", z));
- CompoundTag tileEntityTag = new CompoundTag(values);
+ CompoundTag tileEntityTag =
+ new CompoundTag(values);
tileEntities.add(tileEntityTag);
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java
index 04d1b2d07..27d93b81b 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java
@@ -9,25 +9,21 @@ import com.intellectualcrafters.plot.object.PlotArea;
import com.intellectualcrafters.plot.object.SetupObject;
import com.intellectualcrafters.plot.util.SetupUtils;
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
+import org.bukkit.*;
+import org.bukkit.World.Environment;
+import org.bukkit.entity.Player;
+import org.bukkit.generator.ChunkGenerator;
+import org.bukkit.plugin.Plugin;
+
import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map.Entry;
import java.util.Objects;
-import org.bukkit.Bukkit;
-import org.bukkit.Chunk;
-import org.bukkit.World;
-import org.bukkit.World.Environment;
-import org.bukkit.WorldCreator;
-import org.bukkit.WorldType;
-import org.bukkit.entity.Player;
-import org.bukkit.generator.ChunkGenerator;
-import org.bukkit.plugin.Plugin;
public class BukkitSetupUtils extends SetupUtils {
- @Override
- public void updateGenerators() {
+ @Override public void updateGenerators() {
if (!SetupUtils.generators.isEmpty()) {
return;
}
@@ -54,8 +50,7 @@ public class BukkitSetupUtils extends SetupUtils {
}
}
- @Override
- public void unload(String worldName, boolean save) {
+ @Override public void unload(String worldName, boolean save) {
World world = Bukkit.getWorld(worldName);
if (world == null) {
return;
@@ -76,8 +71,7 @@ public class BukkitSetupUtils extends SetupUtils {
Bukkit.unloadWorld(world, false);
}
- @Override
- public String setupWorld(SetupObject object) {
+ @Override public String setupWorld(SetupObject object) {
SetupUtils.manager.updateGenerators();
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
String world = object.world;
@@ -89,13 +83,15 @@ public class BukkitSetupUtils extends SetupUtils {
if (!PS.get().worlds.contains(worldPath)) {
PS.get().worlds.createSection(worldPath);
}
- ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
+ ConfigurationSection worldSection =
+ PS.get().worlds.getConfigurationSection(worldPath);
String areaName = object.id + "-" + object.min + "-" + object.max;
String areaPath = "areas." + areaName;
if (!worldSection.contains(areaPath)) {
worldSection.createSection(areaPath);
}
- ConfigurationSection areaSection = worldSection.getConfigurationSection(areaPath);
+ ConfigurationSection areaSection =
+ worldSection.getConfigurationSection(areaPath);
HashMap options = new HashMap<>();
for (ConfigurationNode step : steps) {
options.put(step.getConstant(), step.getValue());
@@ -103,7 +99,8 @@ public class BukkitSetupUtils extends SetupUtils {
options.put("generator.type", object.type);
options.put("generator.terrain", object.terrain);
options.put("generator.plugin", object.plotManager);
- if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
+ if (object.setupGenerator != null && !object.setupGenerator
+ .equals(object.plotManager)) {
options.put("generator.init", object.setupGenerator);
}
for (Entry entry : options.entrySet()) {
@@ -129,15 +126,18 @@ public class BukkitSetupUtils extends SetupUtils {
if (!PS.get().worlds.contains(worldPath)) {
PS.get().worlds.createSection(worldPath);
}
- ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
+ ConfigurationSection worldSection =
+ PS.get().worlds.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
PS.get().worlds.set("worlds." + world + ".generator.type", object.type);
PS.get().worlds.set("worlds." + world + ".generator.terrain", object.terrain);
PS.get().worlds.set("worlds." + world + ".generator.plugin", object.plotManager);
- if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
- PS.get().worlds.set("worlds." + world + ".generator.init", object.setupGenerator);
+ if (object.setupGenerator != null && !object.setupGenerator
+ .equals(object.plotManager)) {
+ PS.get().worlds
+ .set("worlds." + world + ".generator.init", object.setupGenerator);
}
GeneratorWrapper> gen = SetupUtils.generators.get(object.setupGenerator);
if (gen != null && gen.isFull()) {
@@ -150,7 +150,8 @@ public class BukkitSetupUtils extends SetupUtils {
if (!PS.get().worlds.contains(worldPath)) {
PS.get().worlds.createSection(worldPath);
}
- ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
+ ConfigurationSection worldSection =
+ PS.get().worlds.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
@@ -164,17 +165,19 @@ public class BukkitSetupUtils extends SetupUtils {
e.printStackTrace();
}
if (object.setupGenerator != null) {
- if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
- .isEnabled()) {
- Bukkit.getServer()
- .dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal -g " + object.setupGenerator);
+ if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit
+ .getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
+ Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
+ "mv create " + world + " normal -g " + object.setupGenerator);
setGenerator(world, object.setupGenerator);
if (Bukkit.getWorld(world) != null) {
return world;
}
}
- if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world + " plugin:" + object.setupGenerator);
+ if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit
+ .getPluginManager().getPlugin("MultiWorld").isEnabled()) {
+ Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
+ "mw create " + world + " plugin:" + object.setupGenerator);
setGenerator(world, object.setupGenerator);
if (Bukkit.getWorld(world) != null) {
return world;
@@ -187,20 +190,24 @@ public class BukkitSetupUtils extends SetupUtils {
Bukkit.createWorld(wc);
setGenerator(world, object.setupGenerator);
} else {
- if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit.getPluginManager().getPlugin("Multiverse-Core")
- .isEnabled()) {
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mv create " + world + " normal");
+ if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null && Bukkit
+ .getPluginManager().getPlugin("Multiverse-Core").isEnabled()) {
+ Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(),
+ "mv create " + world + " normal");
if (Bukkit.getWorld(world) != null) {
return world;
}
}
- if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit.getPluginManager().getPlugin("MultiWorld").isEnabled()) {
- Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
+ if (Bukkit.getPluginManager().getPlugin("MultiWorld") != null && Bukkit
+ .getPluginManager().getPlugin("MultiWorld").isEnabled()) {
+ Bukkit.getServer()
+ .dispatchCommand(Bukkit.getServer().getConsoleSender(), "mw create " + world);
if (Bukkit.getWorld(world) != null) {
return world;
}
}
- World bw = Bukkit.createWorld(new WorldCreator(object.world).environment(Environment.NORMAL));
+ World bw =
+ Bukkit.createWorld(new WorldCreator(object.world).environment(Environment.NORMAL));
}
return object.world;
}
@@ -219,8 +226,7 @@ public class BukkitSetupUtils extends SetupUtils {
}
}
- @Override
- public String getGenerator(PlotArea plotArea) {
+ @Override public String getGenerator(PlotArea plotArea) {
if (SetupUtils.generators.isEmpty()) {
updateGenerators();
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java
index 7a6c89ded..13325772b 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java
@@ -12,39 +12,37 @@ public class BukkitTaskManager extends TaskManager {
this.bukkitMain = bukkitMain;
}
- @Override
- public int taskRepeat(Runnable runnable, int interval) {
- return this.bukkitMain.getServer().getScheduler().scheduleSyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
+ @Override public int taskRepeat(Runnable runnable, int interval) {
+ return this.bukkitMain.getServer().getScheduler()
+ .scheduleSyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
}
- @SuppressWarnings("deprecation")
- @Override
+ @SuppressWarnings("deprecation") @Override
public int taskRepeatAsync(Runnable runnable, int interval) {
- return this.bukkitMain.getServer().getScheduler().scheduleAsyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
+ return this.bukkitMain.getServer().getScheduler()
+ .scheduleAsyncRepeatingTask(this.bukkitMain, runnable, interval, interval);
}
- @Override
- public void taskAsync(Runnable runnable) {
- this.bukkitMain.getServer().getScheduler().runTaskAsynchronously(this.bukkitMain, runnable).getTaskId();
+ @Override public void taskAsync(Runnable runnable) {
+ this.bukkitMain.getServer().getScheduler().runTaskAsynchronously(this.bukkitMain, runnable)
+ .getTaskId();
}
- @Override
- public void task(Runnable runnable) {
+ @Override public void task(Runnable runnable) {
this.bukkitMain.getServer().getScheduler().runTask(this.bukkitMain, runnable).getTaskId();
}
- @Override
- public void taskLater(Runnable runnable, int delay) {
- this.bukkitMain.getServer().getScheduler().runTaskLater(this.bukkitMain, runnable, delay).getTaskId();
+ @Override public void taskLater(Runnable runnable, int delay) {
+ this.bukkitMain.getServer().getScheduler().runTaskLater(this.bukkitMain, runnable, delay)
+ .getTaskId();
}
- @Override
- public void taskLaterAsync(Runnable runnable, int delay) {
- this.bukkitMain.getServer().getScheduler().runTaskLaterAsynchronously(this.bukkitMain, runnable, delay);
+ @Override public void taskLaterAsync(Runnable runnable, int delay) {
+ this.bukkitMain.getServer().getScheduler()
+ .runTaskLaterAsynchronously(this.bukkitMain, runnable, delay);
}
- @Override
- public void cancelTask(int task) {
+ @Override public void cancelTask(int task) {
if (task != -1) {
Bukkit.getScheduler().cancelTask(task);
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
index 83511ac0a..e1abb1b08 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java
@@ -10,9 +10,6 @@ import com.intellectualcrafters.plot.util.StringComparison;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.bukkit.object.BukkitPlayer;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.OfflinePlayer;
@@ -26,12 +23,11 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.ItemStack;
-import org.bukkit.material.MaterialData;
-import org.bukkit.material.Sandstone;
-import org.bukkit.material.Step;
-import org.bukkit.material.Tree;
-import org.bukkit.material.WoodenStep;
-import org.bukkit.material.Wool;
+import org.bukkit.material.*;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
public class BukkitUtil extends WorldUtil {
@@ -71,12 +67,13 @@ public class BukkitUtil extends WorldUtil {
}
public static Location getLocation(org.bukkit.Location location) {
- return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()),
- MathMan.roundInt(location.getZ()));
+ return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
+ MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()));
}
public static org.bukkit.Location getLocation(Location location) {
- return new org.bukkit.Location(getWorld(location.getWorld()), location.getX(), location.getY(), location.getZ());
+ return new org.bukkit.Location(getWorld(location.getWorld()), location.getX(),
+ location.getY(), location.getZ());
}
public static World getWorld(String string) {
@@ -95,37 +92,40 @@ public class BukkitUtil extends WorldUtil {
public static Location getLocation(Entity entity) {
org.bukkit.Location location = entity.getLocation();
String world = location.getWorld().getName();
- return new Location(world, location.getBlockX(), location.getBlockY(), location.getBlockZ());
+ return new Location(world, location.getBlockX(), location.getBlockY(),
+ location.getBlockZ());
}
public static Location getLocationFull(Entity entity) {
org.bukkit.Location location = entity.getLocation();
- return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()), MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()),
- location.getYaw(), location.getPitch());
+ return new Location(location.getWorld().getName(), MathMan.roundInt(location.getX()),
+ MathMan.roundInt(location.getY()), MathMan.roundInt(location.getZ()), location.getYaw(),
+ location.getPitch());
}
- @Override
- public boolean isWorld(String worldName) {
+ @Override public boolean isWorld(String worldName) {
return getWorld(worldName) != null;
}
- @Override
- public String getBiome(String world, int x, int z) {
+ @Override public String getBiome(String world, int x, int z) {
return getWorld(world).getBiome(x, z).name();
}
- @Override
- public void setSign(String worldName, int x, int y, int z, String[] lines) {
+ @Override public void setSign(String worldName, int x, int y, int z, String[] lines) {
World world = getWorld(worldName);
Block block = world.getBlockAt(x, y, z);
// block.setType(Material.AIR);
Material type = block.getType();
if (type != Material.SIGN && type != Material.SIGN_POST) {
int data = 2;
- if (world.getBlockAt(x, y, z + 1).getType().isSolid()) data = 2;
- else if (world.getBlockAt(x + 1, y, z).getType().isSolid()) data = 4;
- else if (world.getBlockAt(x, y, z - 1).getType().isSolid()) data = 3;
- else if (world.getBlockAt(x - 1, y, z).getType().isSolid()) data = 5;
+ if (world.getBlockAt(x, y, z + 1).getType().isSolid())
+ data = 2;
+ else if (world.getBlockAt(x + 1, y, z).getType().isSolid())
+ data = 4;
+ else if (world.getBlockAt(x, y, z - 1).getType().isSolid())
+ data = 3;
+ else if (world.getBlockAt(x - 1, y, z).getType().isSolid())
+ data = 5;
block.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) data, false);
}
BlockState blockstate = block.getState();
@@ -138,9 +138,9 @@ public class BukkitUtil extends WorldUtil {
}
}
- @Override
- public String[] getSign(Location location) {
- Block block = getWorld(location.getWorld()).getBlockAt(location.getX(), location.getY(), location.getZ());
+ @Override public String[] getSign(Location location) {
+ Block block = getWorld(location.getWorld())
+ .getBlockAt(location.getX(), location.getY(), location.getZ());
if (block != null) {
if (block.getState() instanceof Sign) {
Sign sign = (Sign) block.getState();
@@ -150,35 +150,31 @@ public class BukkitUtil extends WorldUtil {
return null;
}
- @Override
- public Location getSpawn(PlotPlayer player) {
+ @Override public Location getSpawn(PlotPlayer player) {
return getLocation(((BukkitPlayer) player).player.getBedSpawnLocation());
}
- @Override
- public Location getSpawn(String world) {
+ @Override public Location getSpawn(String world) {
org.bukkit.Location temp = getWorld(world).getSpawnLocation();
- return new Location(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(), temp.getYaw(), temp.getPitch());
+ return new Location(world, temp.getBlockX(), temp.getBlockY(), temp.getBlockZ(),
+ temp.getYaw(), temp.getPitch());
}
- @Override
- public void setSpawn(Location location) {
+ @Override public void setSpawn(Location location) {
World world = getWorld(location.getWorld());
if (world != null) {
world.setSpawnLocation(location.getX(), location.getY(), location.getZ());
}
}
- @Override
- public void saveWorld(String worldName) {
+ @Override public void saveWorld(String worldName) {
World world = getWorld(worldName);
if (world != null) {
world.save();
}
}
- @Override
- public int getHighestBlock(String world, int x, int z) {
+ @Override public int getHighestBlock(String world, int x, int z) {
World bukkitWorld = getWorld(world);
// Skip top and bottom block
int air = 1;
@@ -187,7 +183,8 @@ public class BukkitUtil extends WorldUtil {
if (block != null) {
Material type = block.getType();
if (type.isSolid()) {
- if (air > 1) return y;
+ if (air > 1)
+ return y;
air = 0;
} else {
switch (type) {
@@ -204,8 +201,7 @@ public class BukkitUtil extends WorldUtil {
return bukkitWorld.getMaxHeight() - 1;
}
- @Override
- public int getBiomeFromString(String biomeString) {
+ @Override public int getBiomeFromString(String biomeString) {
try {
Biome biome = Biome.valueOf(biomeString.toUpperCase());
return Arrays.asList(Biome.values()).indexOf(biome);
@@ -214,8 +210,7 @@ public class BukkitUtil extends WorldUtil {
}
}
- @Override
- public String[] getBiomeList() {
+ @Override public String[] getBiomeList() {
Biome[] biomes = Biome.values();
String[] list = new String[biomes.length];
for (int i = 0; i < biomes.length; i++) {
@@ -224,8 +219,7 @@ public class BukkitUtil extends WorldUtil {
return list;
}
- @Override
- public boolean addItems(String worldName, PlotItem items) {
+ @Override public boolean addItems(String worldName, PlotItem items) {
World world = getWorld(worldName);
Block block = world.getBlockAt(items.x, items.y, items.z);
if (block == null) {
@@ -245,18 +239,15 @@ public class BukkitUtil extends WorldUtil {
return false;
}
- @Override
- public boolean isBlockSolid(PlotBlock block) {
+ @Override public boolean isBlockSolid(PlotBlock block) {
try {
Material material = Material.getMaterial(block.id);
if (material.isBlock() && material.isSolid() && !material.hasGravity()) {
Class extends MaterialData> data = material.getData();
- if (data.equals(MaterialData.class) && !material.isTransparent() && material.isOccluding()
- || data.equals(Tree.class)
- || data.equals(Sandstone.class)
- || data.equals(Wool.class)
- || data.equals(Step.class)
- || data.equals(WoodenStep.class)) {
+ if (data.equals(MaterialData.class) && !material.isTransparent() && material
+ .isOccluding() || data.equals(Tree.class) || data.equals(Sandstone.class)
+ || data.equals(Wool.class) || data.equals(Step.class) || data
+ .equals(WoodenStep.class)) {
switch (material) {
case NOTE_BLOCK:
case MOB_SPAWNER:
@@ -272,8 +263,7 @@ public class BukkitUtil extends WorldUtil {
}
}
- @Override
- public String getClosestMatchingName(PlotBlock block) {
+ @Override public String getClosestMatchingName(PlotBlock block) {
try {
return Material.getMaterial(block.id).name();
} catch (Exception ignored) {
@@ -281,12 +271,13 @@ public class BukkitUtil extends WorldUtil {
}
}
- @Override
- public StringComparison.ComparisonResult getClosestBlock(String name) {
+ @Override public StringComparison.ComparisonResult getClosestBlock(String name) {
try {
Material material = Material.valueOf(name.toUpperCase());
- return new StringComparison().new ComparisonResult(0, PlotBlock.get((short) material.getId(), (byte) 0));
- } catch (IllegalArgumentException ignored) {}
+ return new StringComparison().new ComparisonResult(0,
+ PlotBlock.get((short) material.getId(), (byte) 0));
+ } catch (IllegalArgumentException ignored) {
+ }
try {
byte data;
String[] split = name.split(":");
@@ -302,7 +293,8 @@ public class BukkitUtil extends WorldUtil {
id = Short.parseShort(split[0]);
match = 0;
} else {
- StringComparison.ComparisonResult comparison = new StringComparison<>(name, Material.values()).getBestMatchAdvanced();
+ StringComparison.ComparisonResult comparison =
+ new StringComparison<>(name, Material.values()).getBestMatchAdvanced();
match = comparison.match;
id = (short) comparison.best.getId();
}
@@ -310,12 +302,12 @@ public class BukkitUtil extends WorldUtil {
StringComparison outer = new StringComparison<>();
return outer.new ComparisonResult(match, block);
- } catch (NumberFormatException ignored) {}
+ } catch (NumberFormatException ignored) {
+ }
return null;
}
- @Override
- public void setBiomes(String worldName, RegionWrapper region, String biomeString) {
+ @Override public void setBiomes(String worldName, RegionWrapper region, String biomeString) {
World world = getWorld(worldName);
Biome biome = Biome.valueOf(biomeString.toUpperCase());
for (int x = region.minX; x <= region.maxX; x++) {
@@ -325,8 +317,7 @@ public class BukkitUtil extends WorldUtil {
}
}
- @Override
- public PlotBlock getBlock(Location location) {
+ @Override public PlotBlock getBlock(Location location) {
World world = getWorld(location.getWorld());
Block block = world.getBlockAt(location.getX(), location.getY(), location.getZ());
if (block == null) {
@@ -335,8 +326,7 @@ public class BukkitUtil extends WorldUtil {
return PlotBlock.get((short) block.getTypeId(), block.getData());
}
- @Override
- public String getMainWorld() {
+ @Override public String getMainWorld() {
return Bukkit.getWorlds().get(0).getName();
}
}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java
index d1b30c50c..276ee0c78 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/Metrics.java
@@ -6,12 +6,7 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask;
-import java.io.BufferedReader;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
+import java.io.*;
import java.lang.reflect.InvocationTargetException;
import java.net.URL;
import java.net.URLConnection;
@@ -22,19 +17,33 @@ import java.util.zip.GZIPOutputStream;
public class Metrics {
- /** The current revision number. */
+ /**
+ * The current revision number.
+ */
private static final int REVISION = 7;
- /** The base url of the metrics domain.*/
+ /**
+ * The base url of the metrics domain.
+ */
private static final String BASE_URL = "http://report.mcstats.org";
- /** The url used to report a server's status. */
+ /**
+ * The url used to report a server's status.
+ */
private static final String REPORT_URL = "/plugin/%s";
- /** Interval of time to ping (in minutes). */
+ /**
+ * Interval of time to ping (in minutes).
+ */
private static final int PING_INTERVAL = 15;
- /** The plugin this metrics submits for. */
+ /**
+ * The plugin this metrics submits for.
+ */
private final Plugin plugin;
- /** Unique server id. */
+ /**
+ * Unique server id.
+ */
private final String guid;
- /** The scheduled task. */
+ /**
+ * The scheduled task.
+ */
private volatile BukkitTask task = null;
public Metrics(Plugin plugin) {
@@ -46,7 +55,6 @@ public class Metrics {
* GZip compress a string of bytes.
*
* @param input
- *
* @return byte[] the file as a byte array
*/
public static byte[] gzip(String input) {
@@ -61,7 +69,8 @@ public class Metrics {
if (gzos != null) {
try {
gzos.close();
- } catch (IOException ignore) {}
+ } catch (IOException ignore) {
+ }
}
}
return baos.toByteArray();
@@ -73,7 +82,6 @@ public class Metrics {
* @param json
* @param key
* @param value
- *
*/
private static void appendJSONPair(StringBuilder json, String key, String value) {
boolean isValueNumeric = false;
@@ -101,7 +109,6 @@ public class Metrics {
* Escape a string to create a valid JSON string
*
* @param text
- *
* @return String
*/
private static String escapeJSON(String text) {
@@ -145,7 +152,6 @@ public class Metrics {
* Encode text as UTF-8
*
* @param text the text to encode
- *
* @return the encoded text, as UTF-8
*/
private static String urlEncode(String text) throws UnsupportedEncodingException {
@@ -165,22 +171,22 @@ public class Metrics {
return true;
}
// Begin hitting the server with glorious data
- this.task = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() {
- private boolean firstPost = true;
+ this.task = this.plugin.getServer().getScheduler()
+ .runTaskTimerAsynchronously(this.plugin, new Runnable() {
+ private boolean firstPost = true;
- @Override
- public void run() {
- try {
- postPlugin(!this.firstPost);
- // After the first post we set firstPost to
- // false
- // Each post thereafter will be a ping
- this.firstPost = false;
- } catch (IOException e) {
- e.printStackTrace();
+ @Override public void run() {
+ try {
+ postPlugin(!this.firstPost);
+ // After the first post we set firstPost to
+ // false
+ // Each post thereafter will be a ping
+ this.firstPost = false;
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
}
- }
- }, 0, PING_INTERVAL * 1200);
+ }, 0, PING_INTERVAL * 1200);
return true;
}
@@ -196,10 +202,15 @@ public class Metrics {
String serverVersion = Bukkit.getVersion();
int playersOnline = 0;
try {
- if (Bukkit.class.getMethod("getOnlinePlayers", new Class>[0]).getReturnType() == Collection.class) {
- playersOnline = ((Collection>) Bukkit.class.getMethod("getOnlinePlayers", new Class>[0]).invoke(null)).size();
+ if (Bukkit.class.getMethod("getOnlinePlayers", new Class>[0]).getReturnType()
+ == Collection.class) {
+ playersOnline =
+ ((Collection>) Bukkit.class.getMethod("getOnlinePlayers", new Class>[0])
+ .invoke(null)).size();
} else {
- playersOnline = ((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class>[0]).invoke(null)).length;
+ playersOnline =
+ ((Player[]) Bukkit.class.getMethod("getOnlinePlayers", new Class>[0])
+ .invoke(null)).length;
}
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) {
ex.printStackTrace();
@@ -256,7 +267,8 @@ public class Metrics {
os.flush();
}
String response;
- try (BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()))) {
+ try (BufferedReader reader = new BufferedReader(
+ new InputStreamReader(connection.getInputStream()))) {
response = reader.readLine();
}
if (response == null || response.startsWith("ERR") || response.startsWith("7")) {
@@ -267,6 +279,7 @@ public class Metrics {
}
throw new IOException(response);
}
- } catch (IOException ignored) {}
+ } catch (IOException ignored) {
+ }
}
-}
\ No newline at end of file
+}
diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java
index 69690cc8c..54cdfdf7a 100644
--- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java
+++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/NbtFactory.java
@@ -8,36 +8,18 @@ import com.google.common.collect.MapMaker;
import com.google.common.io.ByteSink;
import com.google.common.io.Closeables;
import com.google.common.primitives.Primitives;
-import java.io.BufferedInputStream;
-import java.io.DataInput;
-import java.io.DataInputStream;
-import java.io.DataOutput;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Field;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Modifier;
-import java.util.AbstractList;
-import java.util.AbstractMap;
-import java.util.AbstractSet;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentMap;
-import java.util.zip.GZIPInputStream;
-import java.util.zip.GZIPOutputStream;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.Server;
import org.bukkit.inventory.ItemStack;
+import java.io.*;
+import java.lang.reflect.*;
+import java.util.*;
+import java.util.concurrent.ConcurrentMap;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
+
public class NbtFactory {
// Convert between NBT type and the equivalent class in java
@@ -73,14 +55,16 @@ public class NbtFactory {
ClassLoader loader = NbtFactory.class.getClassLoader();
String packageName = getPackageName();
- String craftpackageName = getCraftPackageName();
+ String craftpackageName = getCraftPackageName();
Class> offlinePlayer = loader.loadClass(packageName + ".CraftOfflinePlayer");
// Prepare NBT
- this.COMPOUND_CLASS = getMethod(0, Modifier.STATIC, offlinePlayer, "getData").getReturnType();
+ this.COMPOUND_CLASS =
+ getMethod(0, Modifier.STATIC, offlinePlayer, "getData").getReturnType();
this.BASE_CLASS = loader.loadClass(craftpackageName + ".NBTBase");
this.NBT_GET_TYPE = getMethod(0, Modifier.STATIC, this.BASE_CLASS, "getTypeId");
- this.NBT_CREATE_TAG = getMethod(Modifier.STATIC, 0, this.BASE_CLASS, "createTag", byte.class);
+ this.NBT_CREATE_TAG =
+ getMethod(Modifier.STATIC, 0, this.BASE_CLASS, "createTag", byte.class);
// Prepare CraftItemStack
this.CRAFT_STACK = loader.loadClass(packageName + ".inventory.CraftItemStack");
@@ -92,11 +76,14 @@ public class NbtFactory {
initializeNMS(loader, nmsPackage);
if (this.READ_LIMITER_CLASS != null) {
- this.LOAD_COMPOUND = new LoadMethodSkinUpdate(this.STREAM_TOOLS, this.READ_LIMITER_CLASS);
+ this.LOAD_COMPOUND =
+ new LoadMethodSkinUpdate(this.STREAM_TOOLS, this.READ_LIMITER_CLASS);
} else {
this.LOAD_COMPOUND = new LoadMethodWorldUpdate(this.STREAM_TOOLS);
}
- this.SAVE_COMPOUND = getMethod(Modifier.STATIC, 0, this.STREAM_TOOLS, null, this.BASE_CLASS, DataOutput.class);
+ this.SAVE_COMPOUND =
+ getMethod(Modifier.STATIC, 0, this.STREAM_TOOLS, null, this.BASE_CLASS,
+ DataOutput.class);
} catch (ClassNotFoundException e) {
throw new IllegalStateException("Unable to find offline player.", e);
@@ -106,6 +93,7 @@ public class NbtFactory {
/**
* Retrieve or construct a shared NBT factory.
+ *
* @return The factory.
*/
private static NbtFactory get() {
@@ -117,6 +105,7 @@ public class NbtFactory {
/**
* Construct a new NBT list of an unspecified type.
+ *
* @return The NBT list.
*/
public static NbtList createList(Object... content) {
@@ -125,6 +114,7 @@ public class NbtFactory {
/**
* Construct a new NBT list of an unspecified type.
+ *
* @return The NBT list.
*/
public static NbtList createList(Iterable extends Object> iterable) {
@@ -148,6 +138,7 @@ public class NbtFactory {
/**
* Construct a new NBT wrapper from a list.
+ *
* @param nmsList - the NBT list.
* @return The wrapper.
*/
@@ -158,12 +149,13 @@ public class NbtFactory {
/**
* Load the content of a file from a stream.
*
- * @param input - the stream.
+ * @param input - the stream.
* @param option - whether or not to decompress the input stream.
* @return The decoded NBT compound.
* @throws IOException If anything went wrong.
*/
- public static NbtCompound fromStream(InputStream input, StreamOptions option) throws IOException {
+ public static NbtCompound fromStream(InputStream input, StreamOptions option)
+ throws IOException {
DataInputStream data = null;
boolean suppress = true;
@@ -195,14 +187,16 @@ public class NbtFactory {
* @param option - whether or not to compress the output.
* @throws IOException If anything went wrong.
*/
- public static void saveStream(NbtCompound source, ByteSink stream, StreamOptions option) throws IOException {
+ public static void saveStream(NbtCompound source, ByteSink stream, StreamOptions option)
+ throws IOException {
OutputStream output = null;
DataOutputStream data = null;
boolean suppress = true;
try {
output = stream.openStream();
- data = new DataOutputStream(option == StreamOptions.GZIP_COMPRESSION ? new GZIPOutputStream(output) : output);
+ data = new DataOutputStream(
+ option == StreamOptions.GZIP_COMPRESSION ? new GZIPOutputStream(output) : output);
invokeMethod(get().SAVE_COMPOUND, null, source.getHandle(), data);
suppress = false;
@@ -218,6 +212,7 @@ public class NbtFactory {
/**
* Construct a new NBT wrapper from a compound.
+ *
* @param nmsCompound - the NBT compound.
* @return The wrapper.
*/
@@ -228,7 +223,8 @@ public class NbtFactory {
/**
* Set the NBT compound tag of a given item stack.
*
- * @param stack - the item stack, cannot be air.
+ *
+ * @param stack - the item stack, cannot be air.
* @param compound - the new NBT compound, or NULL to remove it.
* @throws IllegalArgumentException If the stack is not a CraftItemStack, or it represents air.
*/
@@ -246,6 +242,7 @@ public class NbtFactory {
* material, damage value or count.
*
* The item stack must be a wrapper for a CraftItemStack.
+ *
* @param stack - the item stack.
* @return A wrapper for its NBT tag.
*/
@@ -265,6 +262,7 @@ public class NbtFactory {
/**
* Retrieve a CraftItemStack version of the stack.
+ *
* @param stack - the stack to convert.
* @return The CraftItemStack version.
*/
@@ -279,12 +277,14 @@ public class NbtFactory {
caller.setAccessible(true);
return (ItemStack) caller.newInstance(stack);
} catch (Exception ignored) {
- throw new IllegalStateException("Unable to convert " + stack + " + to a CraftItemStack.");
+ throw new IllegalStateException(
+ "Unable to convert " + stack + " + to a CraftItemStack.");
}
}
/**
* Ensure that the given stack can store arbitrary NBT information.
+ *
* @param stack - the stack to check.
*/
private static void checkItemStack(ItemStack stack) {
@@ -295,12 +295,14 @@ public class NbtFactory {
throw new IllegalArgumentException("Stack must be a CraftItemStack.");
}
if (stack.getType() == Material.AIR) {
- throw new IllegalArgumentException("ItemStacks representing air cannot store NMS information.");
+ throw new IllegalArgumentException(
+ "ItemStacks representing air cannot store NMS information.");
}
}
/**
* Invoke a method on the given target instance using the provided parameters.
+ *
* @param method - the method to invoke.
* @param target - the target.
* @param params - the parameters to supply.
@@ -332,22 +334,23 @@ public class NbtFactory {
/**
* Search for the first publicly and privately defined method of the given name and parameter count.
+ *
* @param requireMod - modifiers that are required.
- * @param bannedMod - modifiers that are banned.
- * @param clazz - a class to start with.
+ * @param bannedMod - modifiers that are banned.
+ * @param clazz - a class to start with.
* @param methodName - the method name, or NULL to skip.
- * @param params - the expected parameters.
+ * @param params - the expected parameters.
* @return The first method by this name.
* @throws IllegalStateException If we cannot find this method.
*/
- private static Method getMethod(int requireMod, int bannedMod, Class> clazz, String methodName,
- Class>... params) {
+ private static Method getMethod(int requireMod, int bannedMod, Class> clazz,
+ String methodName, Class>... params) {
for (Method method : clazz.getDeclaredMethods()) {
// Limitation: Doesn't handle overloads
- if (((method.getModifiers() & requireMod) == requireMod)
- && ((method.getModifiers() & bannedMod) == 0)
- && ((methodName == null) || method.getName().equals(methodName))
- && Arrays.equals(method.getParameterTypes(), params)) {
+ if (((method.getModifiers() & requireMod) == requireMod) && (
+ (method.getModifiers() & bannedMod) == 0) && ((methodName == null) || method
+ .getName().equals(methodName)) && Arrays
+ .equals(method.getParameterTypes(), params)) {
method.setAccessible(true);
return method;
@@ -357,13 +360,15 @@ public class NbtFactory {
if (clazz.getSuperclass() != null) {
return getMethod(requireMod, bannedMod, clazz.getSuperclass(), methodName, params);
}
- throw new IllegalStateException(String.format("Unable to find method %s (%s).", methodName, Arrays.asList(params)));
+ throw new IllegalStateException(
+ String.format("Unable to find method %s (%s).", methodName, Arrays.asList(params)));
}
/**
* Search for the first publicly and privately defined field of the given name.
- * @param instance - an instance of the class with the field.
- * @param clazz - an optional class to start with, or NULL to deduce it from instance.
+ *
+ * @param instance - an instance of the class with the field.
+ * @param clazz - an optional class to start with, or NULL to deduce it from instance.
* @param fieldName - the field name.
* @return The first field by this name.
* @throws IllegalStateException If we cannot find this field.
@@ -390,7 +395,8 @@ public class NbtFactory {
try {
this.STREAM_TOOLS = loader.loadClass(nmsPackage + ".NBTCompressedStreamTools");
this.READ_LIMITER_CLASS = loader.loadClass(nmsPackage + ".NBTReadLimiter");
- } catch (ClassNotFoundException ignored) {}
+ } catch (ClassNotFoundException ignored) {
+ }
}
private String getPackageName() {
@@ -404,24 +410,25 @@ public class NbtFactory {
return "org.bukkit.craftbukkit.v1_13_R1";
}
}
-
- private String getCraftPackageName() {
- String version = Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
- return "net.minecraft.server." + version;
+
+ private String getCraftPackageName() {
+ String version =
+ Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];
+ return "net.minecraft.server." + version;
}
- @SuppressWarnings("unchecked")
- private Map getDataMap(Object handle) {
- return (Map) getFieldValue(getDataField(NbtType.TAG_COMPOUND, handle), handle);
+ @SuppressWarnings("unchecked") private Map getDataMap(Object handle) {
+ return (Map) getFieldValue(getDataField(NbtType.TAG_COMPOUND, handle),
+ handle);
}
- @SuppressWarnings("unchecked")
- private List