diff --git a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index 2b1a53446..a19c9de7d 100644 --- a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -47,14 +47,6 @@ import java.util.UUID; */ public class PlotAPI { - /** - * Permission that allows for admin access, this permission node will allow - * the player to use any part of the plugin, without limitations. - * @deprecated Use C.PERMISSION_ADMIN instead - */ - @Deprecated - public static final String ADMIN_PERMISSION = C.PERMISSION_ADMIN.s(); - /** * Deprecated, does nothing. * @param plugin not needed @@ -64,24 +56,6 @@ public class PlotAPI { public PlotAPI(JavaPlugin plugin) { } - /** - * Default Constructor that does nothing. - * - * @deprecated Use this class if you just want to do a few simple things - * - * - */ - @Deprecated - public PlotAPI() { - } - /** * Get all plots. * diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index d31379000..755475b38 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -75,6 +75,7 @@ import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.sk89q.worldedit.bukkit.WorldEditPlugin; import org.bukkit.Bukkit; import org.bukkit.ChatColor; +import org.bukkit.Chunk; import org.bukkit.Location; import org.bukkit.OfflinePlayer; import org.bukkit.World; @@ -96,7 +97,6 @@ import java.util.UUID; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { - public static BukkitMain THIS; public static WorldEditPlugin worldEdit; private int[] version; @@ -124,7 +124,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public void onEnable() { - BukkitMain.THIS = this; new PS(this, "Bukkit"); } @@ -132,40 +131,35 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public void onDisable() { PS.get().disable(); Bukkit.getScheduler().cancelTasks(this); - BukkitMain.THIS = null; } @Override public void log(String message) { - if (BukkitMain.THIS != null) { - try { - message = C.color(message); - if (!Settings.CONSOLE_COLOR) { - message = ChatColor.stripColor(message); - } - this.getServer().getConsoleSender().sendMessage(message); - return; - } catch (Throwable ignored) { - //ignored + try { + message = C.color(message); + if (!Settings.CONSOLE_COLOR) { + message = ChatColor.stripColor(message); } + this.getServer().getConsoleSender().sendMessage(message); + return; + } catch (Throwable ignored) { + //ignored } System.out.println(ConsoleColors.fromString(message)); } @Override public void disable() { - if (BukkitMain.THIS != null) { - onDisable(); - } + onDisable(); } @Override public int[] getPluginVersion() { - String version = getDescription().getVersion(); - if (version.contains("-SNAPSHOT")) { - version = version.split("-SNAPSHOT")[0]; + String ver = getDescription().getVersion(); + if (ver.contains("-SNAPSHOT")) { + ver = ver.split("-SNAPSHOT")[0]; } - String[] split = version.split("\\."); + String[] split = ver.split("\\."); return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), Integer.parseInt(split[2])}; } @@ -190,7 +184,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { @Override public TaskManager getTaskManager() { - return new BukkitTaskManager(); + return new BukkitTaskManager(this); } @Override @@ -403,7 +397,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { } @Override - public PlotQueue initPlotQueue() { + public PlotQueue initPlotQueue() { try { new SendChunk(); MainUtil.canSendChunk = true; 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 0e48d6d45..540b88766 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -4,6 +4,7 @@ import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.generator.GeneratorWrapper; import com.intellectualcrafters.plot.generator.HybridGen; import com.intellectualcrafters.plot.generator.IndependentPlotGenerator; +import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; @@ -22,6 +23,7 @@ import org.bukkit.generator.BlockPopulator; import org.bukkit.generator.ChunkGenerator; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Random; import java.util.Set; @@ -34,6 +36,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap private final List populators = new ArrayList<>(); private final ChunkGenerator platformGenerator; private final boolean full; + private final HashMap dataMap = new HashMap<>(); private boolean loaded = false; public BukkitPlotGenerator(IndependentPlotGenerator generator) { @@ -42,10 +45,26 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap this.populators.add(new BlockPopulator() { @Override public void populate(World world, Random r, Chunk c) { - GenChunk result = (GenChunk) BukkitPlotGenerator.this.chunkSetter; - if (result.result_data != null) { - for (int i = 0; i < result.result_data.length; i++) { - byte[] section = result.result_data[i]; + ChunkLoc loc = new ChunkLoc(c.getX(), c.getZ()); + byte[][] resultData; + if (!BukkitPlotGenerator.this.dataMap.containsKey(loc)) { + GenChunk result = (GenChunk) BukkitPlotGenerator.this.chunkSetter; + // Set the chunk location + result.setChunkWrapper(SetQueue.IMP.new ChunkWrapper(world.getName(), loc.x, loc.z)); + // Set the result data + result.result = new short[16][]; + result.result_data = new byte[16][]; + result.grid = null; + result.cd = null; + // Catch any exceptions (as exceptions usually thrown) + generate(world, loc.x, loc.z, result); + resultData = result.result_data; + } else { + resultData = BukkitPlotGenerator.this.dataMap.remove(loc); + } + if (resultData != null) { + for (int i = 0; i < resultData.length; i++) { + byte[] section = resultData[i]; if (section == null) { continue; } @@ -247,8 +266,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap // Return the result data return result.cd; } - - public void generate(World world, int cx, int cz, GenChunk result) { + + public void generate(World world, int cx, int cz, PlotChunk result) { // Load if improperly loaded if (!this.loaded) { String name = world.getName(); @@ -283,6 +302,8 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap return this.platformGenerator.generateExtBlockSections(world, r, cx, cz, grid); } else { generate(world, cx, cz, result); + this.dataMap.put(new ChunkLoc(cx, cz), result.result_data); + } } catch (Throwable e) { e.printStackTrace(); @@ -306,7 +327,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap @Override public String toString() { if (this.platformGenerator == this) { - return "" + this.plotGenerator; + return this.plotGenerator.getName(); } if (this.platformGenerator == null) { return "null"; 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 c137ed548..6500620fd 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -110,16 +110,6 @@ import org.bukkit.plugin.Plugin; import org.bukkit.projectiles.BlockProjectileSource; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.regex.Pattern; import java.util.ArrayList; import java.util.Arrays; @@ -476,8 +466,8 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void playerRespawn(PlayerRespawnEvent event) { - final Player player = event.getPlayer(); - final PlotPlayer pp = BukkitUtil.getPlayer(player); + Player player = event.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(player); EventUtil.manager.doDeathTask(pp); } @@ -784,20 +774,16 @@ public class PlayerEvents extends PlotListener implements Listener { } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onBS(BlockSpreadEvent e) { - Block b = e.getBlock(); - Location loc = BukkitUtil.getLocation(b.getLocation()); - if (loc.isPlotRoad()) { - e.setCancelled(true); - } + public void onBlockSpread(BlockSpreadEvent event) { + onBlockForm(event); //send to super class. } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) - public void onBF(BlockFormEvent e) { - Block b = e.getBlock(); - Location loc = BukkitUtil.getLocation(b.getLocation()); + public void onBlockForm(BlockFormEvent event) { + Block block = event.getBlock(); + Location loc = BukkitUtil.getLocation(block.getLocation()); if (loc.isPlotRoad()) { - e.setCancelled(true); + event.setCancelled(true); } } 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 d0ab1b024..5e8c339bc 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitleManager.java @@ -1,83 +1,14 @@ package com.plotsquared.bukkit.titles; import com.plotsquared.bukkit.chat.Reflection; -import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.entity.Player; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -/** - * [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ] - * - * @author Maxim Van de Wynckel - * - */ -public class DefaultTitleManager { - - private static final Map, Class> CORRESPONDING_TYPES = new HashMap<>(); - /* Title packet */ - private Class packetTitle; - /* Title packet actions ENUM */ - private Class packetActions; - /* Chat serializer */ - private Class nmsChatSerializer; - private Class chatBaseComponent; - /* Title text and color */ - private String title = ""; - private ChatColor titleColor = ChatColor.WHITE; - /* Subtitle text and color */ - private String subtitle = ""; - private ChatColor subtitleColor = ChatColor.WHITE; - /* Title timings */ - private int fadeInTime = -1; - private int stayTime = -1; - private int fadeOutTime = -1; - private boolean ticks = false; - - /** - * Create a new 1.8 title. - * - * @param title Title - */ - public DefaultTitleManager(String title) { - this.title = title; - loadClasses(); - } - - /** - * Create a new 1.8 title. - * - * @param title Title text - * @param subtitle Subtitle text - */ - public DefaultTitleManager(String title, String subtitle) { - this.title = title; - this.subtitle = subtitle; - loadClasses(); - } - - /** - * Copy 1.8 title. - * - * @param title Title - */ - public DefaultTitleManager(DefaultTitleManager title) { - // Copy title - this.title = title.title; - this.subtitle = title.subtitle; - this.titleColor = title.titleColor; - this.subtitleColor = title.subtitleColor; - this.fadeInTime = title.fadeInTime; - this.fadeOutTime = title.fadeOutTime; - this.stayTime = title.stayTime; - this.ticks = title.ticks; - loadClasses(); - } +public class DefaultTitleManager extends TitleManager { /** * Create a new 1.8 title. @@ -89,12 +20,7 @@ public class DefaultTitleManager { * @param fadeOutTime Fade out time */ public DefaultTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) { - this.title = title; - this.subtitle = subtitle; - this.fadeInTime = fadeInTime; - this.stayTime = stayTime; - this.fadeOutTime = fadeOutTime; - loadClasses(); + super(title, subtitle, fadeInTime, stayTime, fadeOutTime); } private static boolean equalsTypeArray(Class[] a, Class[] o) { @@ -112,115 +38,20 @@ public class DefaultTitleManager { /** * Load spigot and NMS classes. */ - private void loadClasses() { + @Override void loadClasses() { this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle"); this.packetActions = Reflection.getNMSClass("EnumTitleAction"); this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent"); this.nmsChatSerializer = Reflection.getNMSClass("ChatSerializer"); } - /** - * Get title text. - * - * @return Title text - */ - public String getTitle() { - return this.title; - } - - /** - * Set title text. - * - * @param title Title - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * Get subtitle text. - * - * @return Subtitle text - */ - public String getSubtitle() { - return this.subtitle; - } - - /** - * Set subtitle text. - * - * @param subtitle Subtitle text - */ - public void setSubtitle(String subtitle) { - this.subtitle = subtitle; - } - - /** - * Set the title color. - * - * @param color Chat color - */ - 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; - } - - /** - * Set timings to ticks. - */ - public void setTimingsToTicks() { - this.ticks = true; - } - - /** - * Set timings to seconds. - */ - public void setTimingsToSeconds() { - this.ticks = false; - } - /** * Send the title to a player. * * @param player Player * @throws Exception */ - public void send(Player player) throws Exception { + @Override public void send(Player player) throws Exception { if (this.packetTitle != null) { // First reset previous settings resetTitle(player); @@ -238,13 +69,14 @@ public class DefaultTitleManager { } // Send title Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, - "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}"); + "{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.subtitle.isEmpty()) { + if (!this.getSubtitle().isEmpty()) { // Send subtitle if present serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, - "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name() + "{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); @@ -252,24 +84,13 @@ public class DefaultTitleManager { } } - /** - * Broadcast the title to all players. - * - * @throws Exception - */ - public void broadcast() throws Exception { - for (Player p : Bukkit.getOnlinePlayers()) { - send(p); - } - } - /** * Clear the title. * * @param player Player * @throws Exception */ - public void clearTitle(Player player) throws Exception { + @Override public void clearTitle(Player player) throws Exception { // Send timings first Object handle = getHandle(player); Object connection = getField(handle.getClass(), "playerConnection").get(handle); @@ -285,7 +106,7 @@ public class DefaultTitleManager { * @param player Player * @throws Exception */ - public void resetTitle(Player player) throws Exception { + @Override public void resetTitle(Player player) throws Exception { // Send timings first Object handle = getHandle(player); Object connection = getField(handle.getClass(), "playerConnection").get(handle); @@ -295,29 +116,10 @@ public class DefaultTitleManager { sendPacket.invoke(connection, packet); } - private Class getPrimitiveType(Class clazz) { - return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; - } - - private Class[] toPrimitiveTypeArray(Class[] classes) { - int a = classes != null ? classes.length : 0; - Class[] types = new Class[a]; - for (int i = 0; i < a; i++) { - types[i] = getPrimitiveType(classes[i]); - } - return types; - } - private Object getHandle(Object obj) { try { return getMethod("getHandle", obj.getClass()).invoke(obj); - } catch (IllegalAccessException e) { - e.printStackTrace(); - return null; - } catch (IllegalArgumentException e) { - e.printStackTrace(); - return null; - } catch (InvocationTargetException e) { + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException e) { e.printStackTrace(); return null; } @@ -339,10 +141,7 @@ public class DefaultTitleManager { Field field = clazz.getDeclaredField(name); field.setAccessible(true); return field; - } catch (NoSuchFieldException e) { - e.printStackTrace(); - return null; - } catch (SecurityException e) { + } catch (NoSuchFieldException | SecurityException e) { e.printStackTrace(); return null; } 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 5dd450858..609d10fd4 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 @@ -1,83 +1,13 @@ package com.plotsquared.bukkit.titles; import com.plotsquared.bukkit.chat.Reflection; -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; -/** - * [ PlotSquared DefaultTitleManager by Maxim Van de Wynckel ] - * - * @version 1.1.0 - * @author Maxim Van de Wynckel - * - */ -public class DefaultTitleManager_183 { - - private static final Map, Class> CORRESPONDING_TYPES = new HashMap<>(); - /* Title packet */ - private Class packetTitle; - /* Title packet actions ENUM */ - private Class packetActions; - /* Chat serializer */ - private Class nmsChatSerializer; - private Class chatBaseComponent; - /* Title text and color */ - private String title = ""; - private ChatColor titleColor = ChatColor.WHITE; - /* Subtitle text and color */ - private String subtitle = ""; - private ChatColor subtitleColor = ChatColor.WHITE; - /* Title timings */ - private int fadeInTime = -1; - private int stayTime = -1; - private int fadeOutTime = -1; - private boolean ticks = false; - - /** - * Create a new 1.8 title - * - * @param title Title - */ - public DefaultTitleManager_183(String title) { - this.title = title; - loadClasses(); - } - - /** - * Create a new 1.8 title. - * - * @param title Title text - * @param subtitle Subtitle text - */ - public DefaultTitleManager_183(String title, String subtitle) { - this.title = title; - this.subtitle = subtitle; - loadClasses(); - } - - /** - * Copy 1.8 title. - * - * @param title Title - */ - public DefaultTitleManager_183(DefaultTitleManager_183 title) { - // Copy title - this.title = title.title; - this.subtitle = title.subtitle; - this.titleColor = title.titleColor; - this.subtitleColor = title.subtitleColor; - this.fadeInTime = title.fadeInTime; - this.fadeOutTime = title.fadeOutTime; - this.stayTime = title.stayTime; - this.ticks = title.ticks; - loadClasses(); - } +public class DefaultTitleManager_183 extends TitleManager { /** * Create a new 1.8 title. @@ -89,12 +19,7 @@ public class DefaultTitleManager_183 { * @param fadeOutTime Fade out time */ public DefaultTitleManager_183(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) { - this.title = title; - this.subtitle = subtitle; - this.fadeInTime = fadeInTime; - this.stayTime = stayTime; - this.fadeOutTime = fadeOutTime; - loadClasses(); + super(title, subtitle, fadeInTime, stayTime, fadeOutTime); } private static boolean equalsTypeArray(Class[] a, Class[] o) { @@ -112,7 +37,8 @@ public class DefaultTitleManager_183 { /** * Load spigot and NMS classes. */ - private void loadClasses() { + @Override + void loadClasses() { this.packetTitle = Reflection.getNMSClass("PacketPlayOutTitle"); this.chatBaseComponent = Reflection.getNMSClass("IChatBaseComponent"); this.packetActions = Reflection.getNMSClass("PacketPlayOutTitle$EnumTitleAction"); @@ -120,108 +46,7 @@ public class DefaultTitleManager_183 { } - /** - * Get title text. - * - * @return Title text - */ - public String getTitle() { - return this.title; - } - - /** - * Set title text. - * - * @param title Title - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * Get subtitle text. - * - * @return Subtitle text - */ - public String getSubtitle() { - return this.subtitle; - } - - /** - * Set subtitle text. - * - * @param subtitle Subtitle text - */ - public void setSubtitle(String subtitle) { - this.subtitle = subtitle; - } - - /** - * Set the title color. - * - * @param color Chat color - */ - 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; - } - - /** - * Set timings to ticks. - */ - public void setTimingsToTicks() { - this.ticks = true; - } - - /** - * Set timings to seconds. - */ - public void setTimingsToSeconds() { - this.ticks = false; - } - - /** - * Send the title to a player. - * - * @param player Player - * @throws Exception - */ + @Override public void send(Player player) throws Exception { if (this.packetTitle != null) { // First reset previous settings @@ -242,13 +67,14 @@ public class DefaultTitleManager_183 { } // Send title Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, - "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}"); + "{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.subtitle.isEmpty()) { + if (!this.getSubtitle().isEmpty()) { // Send subtitle if present serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, - "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name() + "{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); @@ -256,22 +82,13 @@ public class DefaultTitleManager_183 { } } - /** - * Broadcast the title to all players. - * @throws Exception - */ - public void broadcast() throws Exception { - for (Player p : Bukkit.getOnlinePlayers()) { - send(p); - } - } - /** * Clear the title. * * @param player Player * @throws Exception */ + @Override public void clearTitle(Player player) throws Exception { // Send timings first Object handle = getHandle(player); @@ -288,6 +105,7 @@ public class DefaultTitleManager_183 { * @param player Player * @throws Exception */ + @Override public void resetTitle(Player player) throws Exception { // Send timings first Object handle = getHandle(player); @@ -298,19 +116,6 @@ public class DefaultTitleManager_183 { sendPacket.invoke(connection, packet); } - private Class getPrimitiveType(Class clazz) { - return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; - } - - private Class[] toPrimitiveTypeArray(Class[] classes) { - int a = classes != null ? classes.length : 0; - Class[] types = new Class[a]; - for (int i = 0; i < a; i++) { - types[i] = getPrimitiveType(classes[i]); - } - return types; - } - private Object getHandle(Object obj) { try { return getMethod("getHandle", obj.getClass()).invoke(obj); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_183.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_183.java index 8746cab58..386fdb3ba 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_183.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_183.java @@ -11,7 +11,7 @@ public class DefaultTitle_183 extends AbstractTitle { try { DefaultTitleManager_183 title = new DefaultTitleManager_183(head, sub, in, delay, out); title.send(((BukkitPlayer) player).player); - } catch (Throwable e) { + } catch (Exception e) { AbstractTitle.TITLE_CLASS = new HackTitle(); AbstractTitle.TITLE_CLASS.sendTitle(player, head, sub, in, delay, out); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitle.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitle.java index 15ecc2dc3..c0a42bf60 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitle.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitle.java @@ -13,7 +13,7 @@ public class HackTitle extends AbstractTitle { try { HackTitleManager title = new HackTitleManager(head, sub, in, delay, out); title.send(((BukkitPlayer) player).player); - } catch (Throwable e) { + } catch (Exception e) { PS.debug("&cYour server version does not support titles!"); Settings.TITLES = false; AbstractTitle.TITLE_CLASS = null; 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 9fba9c439..933af3229 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/HackTitleManager.java @@ -8,75 +8,8 @@ import org.bukkit.entity.Player; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; -/** - * Minecraft 1.8 Title. - * - * @version 1.0.4 - * @author Maxim Van de Wynckel - */ -public class HackTitleManager { - - private static final Map, Class> CORRESPONDING_TYPES = new HashMap<>(); - /* Title packet */ - private Class packetTitle; - /* Title packet actions ENUM */ - private Class packetActions; - /* Chat serializer */ - private Class nmsChatSerializer; - /* Title text and color */ - private String title = ""; - private ChatColor titleColor = ChatColor.WHITE; - /* Subtitle text and color */ - private String subtitle = ""; - private ChatColor subtitleColor = ChatColor.WHITE; - /* Title timings. */ - private int fadeInTime = -1; - private int stayTime = -1; - private int fadeOutTime = -1; - private boolean ticks = false; - - /** - * Create a new 1.8 title. - * - * @param title Title - */ - public HackTitleManager(String title) { - this.title = title; - loadClasses(); - } - - /** - * Create a new 1.8 title. - * - * @param title Title text - * @param subtitle Subtitle text - */ - public HackTitleManager(String title, String subtitle) { - this.title = title; - this.subtitle = subtitle; - loadClasses(); - } - - /** - * Copy 1.8 title. - * - * @param title Title - */ - public HackTitleManager(HackTitleManager title) { - // Copy title - this.title = title.title; - this.subtitle = title.subtitle; - this.titleColor = title.titleColor; - this.subtitleColor = title.subtitleColor; - this.fadeInTime = title.fadeInTime; - this.fadeOutTime = title.fadeOutTime; - this.stayTime = title.stayTime; - this.ticks = title.ticks; - loadClasses(); - } +public class HackTitleManager extends TitleManager { /** * Create a new 1.8 title. @@ -88,12 +21,7 @@ public class HackTitleManager { * @param fadeOutTime Fade out time */ public HackTitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) { - this.title = title; - this.subtitle = subtitle; - this.fadeInTime = fadeInTime; - this.stayTime = stayTime; - this.fadeOutTime = fadeOutTime; - loadClasses(); + super(title, subtitle, fadeInTime, stayTime, fadeOutTime); } private static boolean equalsTypeArray(Class[] a, Class[] o) { @@ -111,114 +39,20 @@ public class HackTitleManager { /** * Load spigot and NMS classes. */ - private 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"); } - /** - * Get title text. - * - * @return Title text - */ - public String getTitle() { - return this.title; - } - - /** - * Set title text. - * - * @param title Title - */ - public void setTitle(String title) { - this.title = title; - } - - /** - * Get subtitle text. - * - * @return Subtitle text - */ - public String getSubtitle() { - return this.subtitle; - } - - /** - * Set subtitle text. - * - * @param subtitle Subtitle text - */ - public void setSubtitle(String subtitle) { - this.subtitle = subtitle; - } - - /** - * Set the title color. - * - * @param color Chat color - */ - 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; - } - - /** - * Set timings to ticks. - */ - public void setTimingsToTicks() { - this.ticks = true; - } - - /** - * Set timings to seconds. - */ - public void setTimingsToSeconds() { - this.ticks = false; - } - /** * Send the title to a player. * * @param player Player * @throws Exception on NMS error */ - public void send(Player player) throws Exception { + @Override public void send(Player player) throws Exception { if ((getProtocolVersion(player) >= 47) && isSpigot() && (this.packetTitle != null)) { // First reset previous settings resetTitle(player); @@ -237,14 +71,15 @@ public class HackTitleManager { } // Send title Object serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, - "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.title) + "\",color:" + this.titleColor.name().toLowerCase() + "}"); + "{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.subtitle.isEmpty()) { + if (!this.getSubtitle().isEmpty()) { // Send subtitle if present serialized = getMethod(this.nmsChatSerializer, "a", String.class).invoke(null, - "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.subtitle) + "\",color:" + this.subtitleColor.name() + "{text:\"" + ChatColor.translateAlternateColorCodes('&', this.getSubtitle()) + "\",color:" + this.subtitleColor.name() .toLowerCase() + "}"); packet = this.packetTitle.getConstructor(this.packetActions, Reflection.getNMSClass("IChatBaseComponent")) .newInstance(actions[1], serialized); @@ -253,23 +88,13 @@ public class HackTitleManager { } } - /** - * Broadcast the title to all players. - * @throws Exception on NMS Error - */ - public void broadcast() throws Exception { - for (Player p : Bukkit.getOnlinePlayers()) { - send(p); - } - } - /** * Clear the title. * * @param player Player * @throws Exception on NMS Error */ - public void clearTitle(Player player) throws Exception { + @Override public void clearTitle(Player player) throws Exception { if ((getProtocolVersion(player) >= 47) && isSpigot()) { // Send timings first Object handle = getHandle(player); @@ -287,7 +112,7 @@ public class HackTitleManager { * @param player Player * @throws Exception on NMS error. */ - public void resetTitle(Player player) throws Exception { + @Override public void resetTitle(Player player) throws Exception { if ((getProtocolVersion(player) >= 47) && isSpigot()) { // Send timings first Object handle = getHandle(player); @@ -346,19 +171,6 @@ public class HackTitleManager { return f.get(obj); } - private Class getPrimitiveType(Class clazz) { - return CORRESPONDING_TYPES.containsKey(clazz) ? CORRESPONDING_TYPES.get(clazz) : clazz; - } - - private Class[] toPrimitiveTypeArray(Class[] classes) { - int a = classes != null ? classes.length : 0; - Class[] types = new Class[a]; - for (int i = 0; i < a; i++) { - types[i] = getPrimitiveType(classes[i]); - } - return types; - } - private Object getHandle(Object obj) { try { return getMethod("getHandle", obj.getClass()).invoke(obj); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java new file mode 100644 index 000000000..bd2e0ee84 --- /dev/null +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/TitleManager.java @@ -0,0 +1,204 @@ +package com.plotsquared.bukkit.titles; + +import org.bukkit.Bukkit; +import org.bukkit.ChatColor; +import org.bukkit.entity.Player; + +import java.util.HashMap; +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; + Class chatBaseComponent; + ChatColor titleColor = ChatColor.WHITE; + ChatColor subtitleColor = ChatColor.WHITE; + /* Title timings */ + int fadeInTime = -1; + int stayTime = -1; + int fadeOutTime = -1; + boolean ticks = false; + /* Title text and color */ + private String title = ""; + /* Subtitle text and color */ + private String subtitle = ""; + + /** + * 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 fadeOutTime Fade out time + */ + TitleManager(String title, String subtitle, int fadeInTime, int stayTime, int fadeOutTime) { + this.title = title; + this.subtitle = subtitle; + this.fadeInTime = fadeInTime; + this.stayTime = stayTime; + this.fadeOutTime = fadeOutTime; + loadClasses(); + } + + abstract void loadClasses(); + + /** + * Get title text. + * + * @return Title text + */ + public final String getTitle() { + return this.title; + } + + /** + * Set title text. + * + * @param title Title + */ + public final void setTitle(String title) { + this.title = title; + } + + /** + * Get subtitle text. + * + * @return Subtitle text + */ + public final String getSubtitle() { + return this.subtitle; + } + + /** + * Set subtitle text. + * + * @param subtitle Subtitle text + */ + public final void setSubtitle(String subtitle) { + this.subtitle = subtitle; + } + + /** + * Set the title color. + * + * @param color Chat color + */ + public final void setTitleColor(ChatColor color) { + this.titleColor = color; + } + + /** + * Set the subtitle color. + * + * @param color Chat color + */ + public final void setSubtitleColor(ChatColor color) { + this.subtitleColor = color; + } + + /** + * Set title fade in time. + * + * @param time Time + */ + public final void setFadeInTime(int time) { + this.fadeInTime = time; + } + + /** + * Set title fade out time. + * + * @param time Time + */ + public final void setFadeOutTime(int time) { + this.fadeOutTime = time; + } + + /** + * Set title stay time. + * + * @param time Time + */ + public final void setStayTime(int time) { + this.stayTime = time; + } + + /** + * Set timings to ticks. + */ + public final void setTimingsToTicks() { + this.ticks = true; + } + + /** + * Set timings to seconds. + */ + public final void setTimingsToSeconds() { + this.ticks = false; + } + + /** + * Send the title to a player. + * + * @param player Player + * @throws Exception + */ + public abstract void send(Player player) throws Exception; + + /** + * Broadcast the title to all players. + * + * @throws Exception + */ + public final void broadcast() throws Exception { + for (Player p : Bukkit.getOnlinePlayers()) { + send(p); + } + } + + /** + * Clear the title. + * + * @param player Player + * @throws Exception + */ + public abstract void clearTitle(Player player) throws Exception; + + /** + * Reset the title settings. + * + * @param player Player + * @throws Exception + */ + public abstract void resetTitle(Player player) throws Exception; + + private Class getPrimitiveType(Class clazz) { + if (CORRESPONDING_TYPES.containsKey(clazz)) { + return CORRESPONDING_TYPES.get(clazz); + } else { + return clazz; + } + } + + final Class[] toPrimitiveTypeArray(Class[] classes) { + int a; + if (classes != null) { + a = classes.length; + } else { + a = 0; + } + Class[] types = new Class[a]; + for (int i = 0; i < a; i++) { + types[i] = getPrimitiveType(classes[i]); + } + return types; + } + +} 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 0829e123f..30b8e3b25 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -20,14 +20,6 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.bukkit.object.entity.EntityWrapper; -import java.util.ArrayDeque; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map.Entry; -import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.Chunk; import org.bukkit.DyeColor; @@ -60,545 +52,17 @@ import org.bukkit.entity.Player; import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.ItemStack; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map.Entry; +import java.util.Set; + public class BukkitChunkManager extends ChunkManager { - public static class ContentMap { - public HashMap chestContents; - public HashMap furnaceContents; - public HashMap dispenserContents; - public HashMap dropperContents; - public HashMap brewingStandContents; - public HashMap beaconContents; - public HashMap hopperContents; - public HashMap furnaceTime; - public HashMap skullData; - public HashMap jukeboxDisc; - public HashMap brewTime; - public HashMap spawnerData; - public HashMap cmdData; - public HashMap signContents; - public HashMap noteBlockContents; - public HashMap> bannerPatterns; - public HashMap bannerBase; - public HashSet entities; - public HashMap allBlocks; - - public ContentMap() { - chestContents = new HashMap<>(); - furnaceContents = new HashMap<>(); - dispenserContents = new HashMap<>(); - dropperContents = new HashMap<>(); - brewingStandContents = new HashMap<>(); - beaconContents = new HashMap<>(); - hopperContents = new HashMap<>(); - furnaceTime = new HashMap<>(); - skullData = new HashMap<>(); - brewTime = new HashMap<>(); - jukeboxDisc = new HashMap<>(); - spawnerData = new HashMap<>(); - noteBlockContents = new HashMap<>(); - signContents = new HashMap<>(); - cmdData = new HashMap<>(); - bannerBase = new HashMap<>(); - bannerPatterns = new HashMap<>(); - entities = new HashSet<>(); - allBlocks = new HashMap<>(); - } - - public void saveRegion(World world, int x1, int x2, int z1, int z2) { - if (z1 > z2) { - int tmp = z1; - z1 = z2; - z2 = tmp; - } - if (x1 > x2) { - int tmp = x1; - x1 = x2; - x2 = tmp; - } - for (int x = x1; x <= x2; x++) { - for (int z = z1; z <= z2; z++) { - saveBlocks(world, 256, x, z, 0, 0, true); - } - } - } - - public void saveEntitiesIn(Chunk chunk, RegionWrapper region) { - saveEntitiesIn(chunk, region, 0, 0, false); - } - - public void saveEntitiesOut(Chunk chunk, RegionWrapper region) { - for (Entity entity : chunk.getEntities()) { - Location loc = BukkitUtil.getLocation(entity); - int x = loc.getX(); - int z = loc.getZ(); - if (isIn(region, x, z)) { - continue; - } - if (entity.getVehicle() != null) { - continue; - } - EntityWrapper wrap = new EntityWrapper(entity, (short) 2); - entities.add(wrap); - } - } - - 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(); - int z = loc.getZ(); - if (!isIn(region, x, z)) { - continue; - } - if (entity.getVehicle() != null) { - continue; - } - EntityWrapper wrap = new EntityWrapper(entity, (short) 2); - wrap.x += offsetX; - wrap.z += offsetZ; - entities.add(wrap); - if (delete) { - if (!(entity instanceof Player)) { - entity.remove(); - } - } - } - } - - public void restoreEntities(World world, int xOffset, int zOffset) { - for (EntityWrapper entity : entities) { - try { - entity.spawn(world, xOffset, zOffset); - } catch (Exception e) { - PS.debug("Failed to restore entity (e): " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.type); - e.printStackTrace(); - } - } - entities.clear(); - } - - public void restoreBlocks(World world, int xOffset, int zOffset) { - for (Entry blockLocEntry : chestContents.entrySet()) { - try { - 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)); - } - } catch (IllegalArgumentException e) { - 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 : signContents.entrySet()) { - try { - 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; - int i = 0; - for (String line : blockLocEntry.getValue()) { - sign.setLine(i, line); - i++; - } - 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)); - } - } catch (IndexOutOfBoundsException e) { - PS.debug("&c[WARN] Plot clear failed to regenerate sign: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry.getKey().y - + "," + ( - blockLocEntry.getKey().z + zOffset)); - } - } - for (Entry blockLocEntry : dispenserContents.entrySet()) { - try { - 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()); - 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)); - } - } catch (IllegalArgumentException e) { - 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 : dropperContents.entrySet()) { - try { - 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()); - 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)); - } - } catch (IllegalArgumentException e) { - 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 : beaconContents.entrySet()) { - try { - 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()); - 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)); - } - } catch (IllegalArgumentException e) { - 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 : jukeboxDisc.entrySet()) { - try { - 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)); - } - } catch (Exception e) { - 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 : skullData.entrySet()) { - try { - 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(); - if (data[0] != null) { - ((Skull) state).setOwner((String) data[0]); - } - if ((Integer) data[1] != 0) { - ((Skull) state).setRotation(BlockFace.values()[(int) data[1]]); - } - if ((Integer) data[2] != 0) { - ((Skull) state).setSkullType(SkullType.values()[(int) data[2]]); - } - 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)); - } - } 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)); - } - } - for (Entry blockLocEntry : hopperContents.entrySet()) { - try { - 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()); - 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)); - } - } catch (IllegalArgumentException e) { - 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 : noteBlockContents.entrySet()) { - try { - 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)); - } - } catch (Exception e) { - 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 : brewTime.entrySet()) { - try { - 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)); - } - } catch (Exception e) { - 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 : spawnerData.entrySet()) { - try { - 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()); - 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)); - } - } catch (Exception e) { - 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 : cmdData.entrySet()) { - try { - 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)); - } - } catch (Exception e) { - 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 : brewingStandContents.entrySet()) { - try { - 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()); - 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)); - } - } catch (IllegalArgumentException e) { - 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 : furnaceTime.entrySet()) { - try { - 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)); - } - } catch (Exception e) { - 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 : furnaceContents.entrySet()) { - try { - 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()); - 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)); - } - } catch (IllegalArgumentException e) { - 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 : bannerBase.entrySet()) { - try { - 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 = 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)); - } - } catch (Exception e) { - 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) { - maxY = Math.min(255, maxY); - PlotBlock[] ids; - if (storeNormal) { - ids = new PlotBlock[maxY + 1]; - } else { - ids = null; - } - for (short y = 0; y <= maxY; y++) { - Block block = world.getBlockAt(x, y, z); - Material id = block.getType(); - if (storeNormal) { - int typeId = id.getId(); - ids[y] = new PlotBlock((short) typeId, typeId == 0 ? 0 : block.getData()); - } - if (!id.equals(Material.AIR)) { - try { - 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(); - if (id == Material.CHEST) { - chestContents.put(bl, inventory); - } else if (id == Material.DISPENSER) { - dispenserContents.put(bl, inventory); - } else if (id == Material.BEACON) { - beaconContents.put(bl, inventory); - } else if (id == Material.DROPPER) { - dropperContents.put(bl, inventory); - } else if (id == Material.HOPPER) { - hopperContents.put(bl, inventory); - } else if (id == Material.BREWING_STAND) { - BrewingStand brewingStand = (BrewingStand) inventoryHolder; - short time = (short) brewingStand.getBrewingTime(); - if (time > 0) { - brewTime.put(bl, time); - } - ItemStack[] invBre = brewingStand.getInventory().getContents().clone(); - brewingStandContents.put(bl, invBre); - } else if (id == Material.FURNACE || id == Material.BURNING_FURNACE) { - Furnace furnace = (Furnace) inventoryHolder; - short burn = furnace.getBurnTime(); - short cook = furnace.getCookTime(); - ItemStack[] invFur = furnace.getInventory().getContents().clone(); - furnaceContents.put(bl, invFur); - if (cook != 0) { - furnaceTime.put(bl, new Short[]{burn, cook}); - } - } - } else if (block.getState() instanceof CreatureSpawner) { - CreatureSpawner spawner = (CreatureSpawner) block.getState(); - EntityType type = spawner.getSpawnedType(); - if (type != null) { - spawnerData.put(bl, type); - } - } else if (block.getState() instanceof CommandBlock) { - CommandBlock cmd = (CommandBlock) block.getState(); - String string = cmd.getCommand(); - if (string != null && !string.isEmpty()) { - cmdData.put(bl, string); - } - } else if (block.getState() instanceof NoteBlock) { - NoteBlock noteBlock = (NoteBlock) block.getState(); - Note note = noteBlock.getNote(); - noteBlockContents.put(bl, note); - } else if (block.getState() instanceof Jukebox) { - Jukebox jukebox = (Jukebox) block.getState(); - Material playing = jukebox.getPlaying(); - if (playing != null) { - jukeboxDisc.put(bl, playing); - } - } else if (block.getState() instanceof Skull) { - Skull skull = (Skull) block.getState(); - String o = skull.getOwner(); - byte skullType = getOrdinal(SkullType.values(), skull.getSkullType()); - skull.getRotation(); - short rot = getOrdinal(BlockFace.values(), skull.getRotation()); - skullData.put(bl, new Object[]{o, rot, skullType}); - } else if (block.getState() instanceof Banner) { - Banner banner = (Banner) block.getState(); - DyeColor base = banner.getBaseColor(); - bannerBase.put(bl, base); - bannerPatterns.put(bl, banner.getPatterns()); - - } - } catch (Exception e) { - PS.debug("------------ FAILED TO DO SOMETHING --------"); - e.printStackTrace(); - PS.debug("------------ but we caught it ^ --------"); - } - } - } - PlotLoc loc = new PlotLoc(x + offsetX, z + offsetZ); - allBlocks.put(loc, ids); - } - } - public static boolean isIn(RegionWrapper region, int x, int z) { return x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ; } @@ -673,6 +137,22 @@ public class BukkitChunkManager extends ChunkManager { return chunks; } + @Override + public void regenerateChunk(String world, ChunkLoc loc) { + World worldObj = Bukkit.getWorld(world); + worldObj.regenerateChunk(loc.x, loc.z); + SetQueue.IMP.queue.sendChunk(world, Collections.singletonList(loc)); + for (Entry entry : UUIDHandler.getPlayers().entrySet()) { + PlotPlayer pp = entry.getValue(); + Location pLoc = pp.getLocation(); + if (!StringMan.isEqual(world, pLoc.getWorld()) || !pLoc.getChunkLoc().equals(loc)) { + continue; + } + pLoc.setY(WorldUtil.IMP.getHighestBlock(world, pLoc.getX(), pLoc.getZ())); + pp.teleport(pLoc); + } + } + @Override public boolean copyRegion(Location pos1, Location pos2, Location newPos, final Runnable whenDone) { final int relX = newPos.getX() - pos1.getX(); @@ -927,7 +407,7 @@ public class BukkitChunkManager extends ChunkManager { 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()); - final World world2 = Bukkit.getWorld(bot2.getWorld()); + World world2 = Bukkit.getWorld(bot2.getWorld()); int relX = bot2.getX() - bot1.getX(); int relZ = bot2.getZ() - bot1.getZ(); @@ -1131,4 +611,550 @@ public class BukkitChunkManager extends ChunkManager { } count[0]++; } + + public static class ContentMap { + + public final HashMap chestContents; + public final HashMap furnaceContents; + public final HashMap dispenserContents; + public final HashMap dropperContents; + public final HashMap brewingStandContents; + public final HashMap beaconContents; + public final HashMap hopperContents; + public final HashMap furnaceTime; + public final HashMap skullData; + public final HashMap jukeboxDisc; + public final HashMap brewTime; + public final HashMap spawnerData; + public final HashMap cmdData; + public final HashMap signContents; + public final HashMap noteBlockContents; + public final HashMap> bannerPatterns; + public final HashMap bannerBase; + public final HashSet entities; + public final HashMap allBlocks; + + public ContentMap() { + this.chestContents = new HashMap<>(); + this.furnaceContents = new HashMap<>(); + this.dispenserContents = new HashMap<>(); + this.dropperContents = new HashMap<>(); + this.brewingStandContents = new HashMap<>(); + this.beaconContents = new HashMap<>(); + this.hopperContents = new HashMap<>(); + this.furnaceTime = new HashMap<>(); + this.skullData = new HashMap<>(); + this.brewTime = new HashMap<>(); + this.jukeboxDisc = new HashMap<>(); + this.spawnerData = new HashMap<>(); + this.noteBlockContents = new HashMap<>(); + this.signContents = new HashMap<>(); + this.cmdData = new HashMap<>(); + this.bannerBase = new HashMap<>(); + this.bannerPatterns = new HashMap<>(); + this.entities = new HashSet<>(); + this.allBlocks = new HashMap<>(); + } + + public void saveRegion(World world, int x1, int x2, int z1, int z2) { + if (z1 > z2) { + int tmp = z1; + z1 = z2; + z2 = tmp; + } + if (x1 > x2) { + int tmp = x1; + x1 = x2; + x2 = tmp; + } + for (int x = x1; x <= x2; x++) { + for (int z = z1; z <= z2; z++) { + saveBlocks(world, 256, x, z, 0, 0, true); + } + } + } + + public void saveEntitiesIn(Chunk chunk, RegionWrapper region) { + saveEntitiesIn(chunk, region, 0, 0, false); + } + + public void saveEntitiesOut(Chunk chunk, RegionWrapper region) { + for (Entity entity : chunk.getEntities()) { + Location loc = BukkitUtil.getLocation(entity); + int x = loc.getX(); + int z = loc.getZ(); + if (isIn(region, x, z)) { + continue; + } + if (entity.getVehicle() != null) { + continue; + } + EntityWrapper wrap = new EntityWrapper(entity, (short) 2); + this.entities.add(wrap); + } + } + + 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(); + int z = loc.getZ(); + if (!isIn(region, x, z)) { + continue; + } + if (entity.getVehicle() != null) { + continue; + } + EntityWrapper wrap = new EntityWrapper(entity, (short) 2); + wrap.x += offsetX; + wrap.z += offsetZ; + this.entities.add(wrap); + if (delete) { + if (!(entity instanceof Player)) { + entity.remove(); + } + } + } + } + + public void restoreEntities(World world, int xOffset, int zOffset) { + for (EntityWrapper entity : this.entities) { + try { + entity.spawn(world, xOffset, zOffset); + } catch (Exception e) { + PS.debug("Failed to restore entity (e): " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.type); + e.printStackTrace(); + } + } + this.entities.clear(); + } + + 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); + 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)); + } + } catch (IllegalArgumentException e) { + 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); + BlockState state = block.getState(); + if (state instanceof Sign) { + Sign sign = (Sign) state; + int i = 0; + for (String line : blockLocEntry.getValue()) { + sign.setLine(i, line); + i++; + } + 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)); + } + } catch (IndexOutOfBoundsException e) { + 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); + BlockState state = block.getState(); + if (state instanceof Dispenser) { + ((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)); + } + } catch (IllegalArgumentException e) { + 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); + BlockState state = block.getState(); + if (state instanceof Dropper) { + ((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)); + } + } catch (IllegalArgumentException e) { + 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); + BlockState state = block.getState(); + if (state instanceof Beacon) { + ((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)); + } + } catch (IllegalArgumentException e) { + 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); + 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)); + } + } catch (Exception e) { + 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); + BlockState state = block.getState(); + if (state instanceof Skull) { + Object[] data = blockLocEntry.getValue(); + if (data[0] != null) { + ((Skull) state).setOwner((String) data[0]); + } + if ((Integer) data[1] != 0) { + ((Skull) state).setRotation(BlockFace.values()[(int) data[1]]); + } + if ((Integer) data[2] != 0) { + ((Skull) state).setSkullType(SkullType.values()[(int) data[2]]); + } + 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)); + } + } 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)); + } + } + for (Entry blockLocEntry : this.hopperContents.entrySet()) { + try { + 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()); + 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)); + } + } catch (IllegalArgumentException e) { + 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); + 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)); + } + } catch (Exception e) { + 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); + 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)); + } + } catch (Exception e) { + 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()) { + try { + 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()); + 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)); + } + } catch (Exception e) { + 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); + 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)); + } + } catch (Exception e) { + 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()) { + try { + 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()); + 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)); + } + } catch (IllegalArgumentException e) { + 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); + 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)); + } + } catch (Exception e) { + 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); + BlockState state = block.getState(); + if (state instanceof Furnace) { + ((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)); + } + } catch (IllegalArgumentException e) { + 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); + BlockState state = block.getState(); + if (state instanceof Banner) { + Banner banner = (Banner) state; + DyeColor base = blockLocByteEntry.getValue(); + 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)); + } + } catch (Exception e) { + 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) { + maxY = Math.min(255, maxY); + PlotBlock[] ids; + if (storeNormal) { + ids = new PlotBlock[maxY + 1]; + } else { + ids = null; + } + for (short y = 0; y <= maxY; y++) { + Block block = world.getBlockAt(x, y, z); + Material id = block.getType(); + if (storeNormal) { + int typeId = id.getId(); + ids[y] = new PlotBlock((short) typeId, typeId == 0 ? 0 : block.getData()); + } + if (!id.equals(Material.AIR)) { + try { + 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(); + if (id == Material.CHEST) { + this.chestContents.put(bl, inventory); + } else if (id == Material.DISPENSER) { + this.dispenserContents.put(bl, inventory); + } else if (id == Material.BEACON) { + this.beaconContents.put(bl, inventory); + } else if (id == Material.DROPPER) { + this.dropperContents.put(bl, inventory); + } else if (id == Material.HOPPER) { + this.hopperContents.put(bl, inventory); + } else if (id == Material.BREWING_STAND) { + BrewingStand brewingStand = (BrewingStand) inventoryHolder; + short time = (short) brewingStand.getBrewingTime(); + if (time > 0) { + this.brewTime.put(bl, time); + } + ItemStack[] invBre = brewingStand.getInventory().getContents().clone(); + this.brewingStandContents.put(bl, invBre); + } else if (id == Material.FURNACE || id == Material.BURNING_FURNACE) { + Furnace furnace = (Furnace) inventoryHolder; + short burn = furnace.getBurnTime(); + short cook = furnace.getCookTime(); + ItemStack[] invFur = furnace.getInventory().getContents().clone(); + this.furnaceContents.put(bl, invFur); + if (cook != 0) { + this.furnaceTime.put(bl, new Short[]{burn, cook}); + } + } + } else if (block.getState() instanceof CreatureSpawner) { + CreatureSpawner spawner = (CreatureSpawner) block.getState(); + EntityType type = spawner.getSpawnedType(); + if (type != null) { + this.spawnerData.put(bl, type); + } + } else if (block.getState() instanceof CommandBlock) { + CommandBlock cmd = (CommandBlock) block.getState(); + String string = cmd.getCommand(); + if (string != null && !string.isEmpty()) { + this.cmdData.put(bl, string); + } + } else if (block.getState() instanceof NoteBlock) { + NoteBlock noteBlock = (NoteBlock) block.getState(); + Note note = noteBlock.getNote(); + this.noteBlockContents.put(bl, note); + } else if (block.getState() instanceof Jukebox) { + Jukebox jukebox = (Jukebox) block.getState(); + Material playing = jukebox.getPlaying(); + if (playing != null) { + this.jukeboxDisc.put(bl, playing); + } + } else if (block.getState() instanceof Skull) { + Skull skull = (Skull) block.getState(); + String o = skull.getOwner(); + byte skullType = getOrdinal(SkullType.values(), skull.getSkullType()); + skull.getRotation(); + short rot = getOrdinal(BlockFace.values(), skull.getRotation()); + this.skullData.put(bl, new Object[]{o, rot, skullType}); + } else if (block.getState() instanceof Banner) { + Banner banner = (Banner) block.getState(); + DyeColor base = banner.getBaseColor(); + this.bannerBase.put(bl, base); + this.bannerPatterns.put(bl, banner.getPatterns()); + + } + } catch (Exception e) { + PS.debug("------------ FAILED TO DO SOMETHING --------"); + e.printStackTrace(); + PS.debug("------------ but we caught it ^ --------"); + } + } + } + PlotLoc loc = new PlotLoc(x + offsetX, z + offsetZ); + this.allBlocks.put(loc, ids); + } + } } 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 5cdffb7a3..145c04842 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java @@ -15,16 +15,6 @@ public class BukkitEconHandler extends EconHandler { private Economy econ; private Permission perms; - public Economy getEconomy() { - init(); - return this.econ; - } - - public Permission getPermissions() { - init(); - return this.perms; - } - public boolean init() { if (this.econ == null || this.perms == null) { setupPermissions(); 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 61f72f0b9..7a6c89ded 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java @@ -6,35 +6,41 @@ import org.bukkit.Bukkit; public class BukkitTaskManager extends TaskManager { + private final BukkitMain bukkitMain; + + public BukkitTaskManager(BukkitMain bukkitMain) { + this.bukkitMain = bukkitMain; + } + @Override public int taskRepeat(Runnable runnable, int interval) { - return BukkitMain.THIS.getServer().getScheduler().scheduleSyncRepeatingTask(BukkitMain.THIS, runnable, interval, interval); + return this.bukkitMain.getServer().getScheduler().scheduleSyncRepeatingTask(this.bukkitMain, runnable, interval, interval); } @SuppressWarnings("deprecation") @Override public int taskRepeatAsync(Runnable runnable, int interval) { - return BukkitMain.THIS.getServer().getScheduler().scheduleAsyncRepeatingTask(BukkitMain.THIS, runnable, interval, interval); + return this.bukkitMain.getServer().getScheduler().scheduleAsyncRepeatingTask(this.bukkitMain, runnable, interval, interval); } @Override public void taskAsync(Runnable runnable) { - BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, runnable).getTaskId(); + this.bukkitMain.getServer().getScheduler().runTaskAsynchronously(this.bukkitMain, runnable).getTaskId(); } @Override public void task(Runnable runnable) { - BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, runnable).getTaskId(); + this.bukkitMain.getServer().getScheduler().runTask(this.bukkitMain, runnable).getTaskId(); } @Override public void taskLater(Runnable runnable, int delay) { - BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, runnable, delay).getTaskId(); + this.bukkitMain.getServer().getScheduler().runTaskLater(this.bukkitMain, runnable, delay).getTaskId(); } @Override public void taskLaterAsync(Runnable runnable, int delay) { - BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, runnable, delay); + this.bukkitMain.getServer().getScheduler().runTaskLaterAsynchronously(this.bukkitMain, runnable, delay); } @Override diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java index bd1c21f0e..b534ec3f4 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8.java @@ -12,7 +12,6 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod; import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.TaskManager; -import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.SendChunk; import org.bukkit.Chunk; import org.bukkit.World; @@ -370,7 +369,6 @@ public class FastQueue_1_8 extends SlowQueue { */ @Override public void sendChunk(String world, Collection locations) { - World worldObj = BukkitUtil.getWorld(world); for (ChunkLoc loc : locations) { ChunkWrapper wrapper = SetQueue.IMP.new ChunkWrapper(world, loc.x, loc.z); this.toUpdate.remove(wrapper); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java index 719819955..d1e015dab 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_8_3.java @@ -1,5 +1,7 @@ package com.plotsquared.bukkit.util.block; +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; + import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.util.ChunkManager; @@ -15,6 +17,12 @@ import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.bukkit.util.SendChunk; +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.block.Biome; + import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -24,14 +32,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; -import org.bukkit.Chunk; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.block.Biome; - - -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; public class FastQueue_1_8_3 extends SlowQueue { @@ -266,7 +266,7 @@ public class FastQueue_1_8_3 extends SlowQueue { World world = BukkitUtil.getWorld(worldname); Chunk chunk = world.getChunkAt(loc.x, loc.z); if (chunk.getTileEntities().length > 0) { - Object w = methodGetHandleWorld.of(world).call(); + Object w = this.methodGetHandleWorld.of(world).call(); ((Collection) this.tileEntityListTick.of(w).get()).clear(); } super.regenerateChunk(worldname, loc); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java index c0d7b8f06..f3d150562 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/FastQueue_1_9.java @@ -1,5 +1,7 @@ package com.plotsquared.bukkit.util.block; +import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; + import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.util.ChunkManager; @@ -13,6 +15,12 @@ import com.intellectualcrafters.plot.util.ReflectionUtils.RefMethod.RefExecutor; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.util.BukkitUtil; +import org.bukkit.Chunk; +import org.bukkit.Material; +import org.bukkit.World; +import org.bukkit.World.Environment; +import org.bukkit.block.Biome; + import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; @@ -22,14 +30,6 @@ import java.util.HashMap; import java.util.Iterator; import java.util.Map.Entry; import java.util.Set; -import org.bukkit.Chunk; -import org.bukkit.Material; -import org.bukkit.World; -import org.bukkit.World.Environment; -import org.bukkit.block.Biome; - - -import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; public class FastQueue_1_9 extends SlowQueue { @@ -85,8 +85,8 @@ public class FastQueue_1_9 extends SlowQueue { World world = BukkitUtil.getWorld(worldname); Chunk chunk = world.getChunkAt(loc.x, loc.z); if (chunk.getTileEntities().length > 0) { - Object c = methodGetHandleChunk.of(chunk).call(); - Object w = methodGetWorld.of(c).call(); + Object c = this.methodGetHandleChunk.of(chunk).call(); + Object w = this.methodGetWorld.of(c).call(); ((Collection) this.tileEntityListTick.of(w).get()).clear(); } super.regenerateChunk(worldname, loc); @@ -97,7 +97,7 @@ public class FastQueue_1_9 extends SlowQueue { * @param plotChunk */ @Override - public void execute(final PlotChunk plotChunk) { + public void execute(PlotChunk plotChunk) { final FastChunk_1_9 fs = (FastChunk_1_9) plotChunk; Chunk chunk = plotChunk.getChunk(); World world = chunk.getWorld(); @@ -425,7 +425,7 @@ public class FastQueue_1_9 extends SlowQueue { * @param locations */ @Override - public void sendChunk(final String world, final Collection locations) { + public void sendChunk(String world, Collection locations) { World worldObj = BukkitUtil.getWorld(world); for (ChunkLoc loc : locations) { worldObj.refreshChunk(loc.x, loc.z); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/GenChunk.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/GenChunk.java index 8b0f2af43..286f63aee 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/GenChunk.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/GenChunk.java @@ -41,7 +41,9 @@ public class GenChunk extends PlotChunk { @Override public void setBiome(int x, int z, int biome) { - this.grid.setBiome(x, z, this.biomes[biome]); + if (this.grid != null) { + this.grid.setBiome(x, z, this.biomes[biome]); + } } public void setBiome(int x, int z, Biome biome) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/SlowQueue.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/SlowQueue.java index 86821aae4..222269f75 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/SlowQueue.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/block/SlowQueue.java @@ -9,13 +9,14 @@ import com.intellectualcrafters.plot.util.PlotQueue; import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.plotsquared.bukkit.util.BukkitUtil; +import org.bukkit.Chunk; +import org.bukkit.block.Biome; +import org.bukkit.block.Block; + import java.util.Collection; import java.util.Iterator; import java.util.Map.Entry; import java.util.concurrent.ConcurrentHashMap; -import org.bukkit.Chunk; -import org.bukkit.block.Biome; -import org.bukkit.block.Block; public class SlowQueue implements PlotQueue { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/PS.java b/Core/src/main/java/com/intellectualcrafters/plot/PS.java index dccd9cf7d..20638a8c5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/PS.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/PS.java @@ -53,6 +53,7 @@ import com.intellectualcrafters.plot.util.WorldUtil; import com.intellectualcrafters.plot.util.area.QuadMap; import com.plotsquared.listener.WESubscriber; import com.sk89q.worldedit.WorldEdit; + import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; @@ -89,6 +90,7 @@ import java.util.zip.ZipInputStream; public class PS { private static PS instance; + public final IPlotMain IMP; private final HashSet plotAreaHashCheck = new HashSet<>(); /** * All plot areas mapped by world (quick world access). @@ -98,6 +100,9 @@ public class PS { * All plot areas mapped by location (quick location based access). */ private final HashMap> plotAreaGrid = new HashMap<>(); + private final int[] version; + private final String platform; + private final Thread thread; public HashMap> clusters_tmp; public HashMap> plots_tmp; public File styleFile; @@ -108,7 +113,6 @@ public class PS { public YamlConfiguration config; public YamlConfiguration storage; public YamlConfiguration commands; - public IPlotMain IMP = null; public TaskManager TASK; public WorldEdit worldedit; public URL update; @@ -117,25 +121,23 @@ public class PS { * All plot areas (quick global access). */ private PlotArea[] plotAreas = new PlotArea[0]; - private File storageFile; private File file = null; // This file - private int[] version; private int[] lastVersion; - private String platform = null; private Database database; - private Thread thread; /** * Initialize PlotSquared with the desired Implementation class. - * @param imp_class + * @param iPlotMain Implementation of {@link IPlotMain} used + * @param platform The platform being used */ - public PS(IPlotMain imp_class, String platform) { + public PS(IPlotMain iPlotMain, String platform) { + PS.instance = this; + this.thread = Thread.currentThread(); + this.IMP = iPlotMain; + this.platform = platform; + this.version = this.IMP.getPluginVersion(); try { - PS.instance = this; - this.thread = Thread.currentThread(); - SetupUtils.generators = new HashMap<>(); - this.IMP = imp_class; new ReflectionUtils(this.IMP.getNMSPackage()); try { URL url = PS.class.getProtectionDomain().getCodeSource().getLocation(); @@ -147,8 +149,6 @@ public class PS { this.file = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared-" + platform + ".jar"); } } - this.version = this.IMP.getPluginVersion(); - this.platform = platform; if (getJavaVersion() < 1.7) { PS.log(C.CONSOLE_JAVA_OUTDATED_1_7); this.IMP.disable(); @@ -194,50 +194,7 @@ public class PS { } // create UUIDWrapper UUIDHandler.implementation = this.IMP.initUUIDHandler(); - TaskManager.runTaskLater(new Runnable() { - @Override - public void run() { - debug("Starting UUID caching"); - UUIDHandler.startCaching(new Runnable() { - @Override - public void run() { - for (Plot plot : getPlots()) { - if (plot.hasOwner() && plot.temp != -1) { - if (UUIDHandler.getName(plot.owner) == null) { - UUIDHandler.implementation.unknown.add(plot.owner); - } - } - } - // Auto clearing - if (Settings.AUTO_CLEAR) { - ExpireManager.IMP = new ExpireManager(); - if (Settings.AUTO_CLEAR_CONFIRMATION) { - ExpireManager.IMP.runConfirmedTask(); - } else { - ExpireManager.IMP.runAutomatedTask(); - } - } - // PlotMe - if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) { - TaskManager.runTaskLater(new Runnable() { - - @Override - public void run() { - if (PS.this.IMP.initPlotMeConverter()) { - PS.log("&c=== IMPORTANT ==="); - PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); - PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); - PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); - PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the " - + "'settings.yml'"); - } - } - }, 20); - } - } - }); - } - }, 20); + startUuidCatching(); // create event util class EventUtil.manager = this.IMP.initEventUtil(); // create Hybrid utility class @@ -348,10 +305,6 @@ public class PS { PS.get().IMP.log(StringMan.getString(message)); } - public static void stacktrace() { - System.err.println(StringMan.join(new Exception().getStackTrace(), "\n\tat ")); - } - /** * Log a message to the IPlotMain logger. * @@ -364,6 +317,53 @@ public class PS { } } + private void startUuidCatching() { + TaskManager.runTaskLater(new Runnable() { + @Override + public void run() { + debug("Starting UUID caching"); + UUIDHandler.startCaching(new Runnable() { + @Override + public void run() { + for (Plot plot : getPlots()) { + if (plot.hasOwner() && plot.temp != -1) { + if (UUIDHandler.getName(plot.owner) == null) { + UUIDHandler.implementation.unknown.add(plot.owner); + } + } + } + // Auto clearing + if (Settings.AUTO_CLEAR) { + ExpireManager.IMP = new ExpireManager(); + if (Settings.AUTO_CLEAR_CONFIRMATION) { + ExpireManager.IMP.runConfirmedTask(); + } else { + ExpireManager.IMP.runAutomatedTask(); + } + } + // PlotMe + if (Settings.CONVERT_PLOTME || Settings.CACHE_PLOTME) { + TaskManager.runTaskLater(new Runnable() { + + @Override + public void run() { + if (PS.this.IMP.initPlotMeConverter()) { + PS.log("&c=== IMPORTANT ==="); + PS.log("&cTHIS MESSAGE MAY BE EXTREMELY HELPFUL IF YOU HAVE TROUBLE CONVERTING PLOTME!"); + PS.log("&c - Make sure 'UUID.read-from-disk' is disabled (false)!"); + PS.log("&c - Sometimes the database can be locked, deleting PlotMe.jar beforehand will fix the issue!"); + PS.log("&c - After the conversion is finished, please set 'plotme-convert.enabled' to false in the " + + "'settings.yml'"); + } + } + }, 20); + } + } + }); + } + }, 20); + } + public boolean isMainThread(Thread thread) { return this.thread == thread; } @@ -2398,10 +2398,6 @@ public class PS { return count; } - public int getPlotAreaCount(String world) { - return this.plotAreaMap.size(); - } - public Set getPlotAreas() { HashSet set = new HashSet<>(this.plotAreas.length); Collections.addAll(set, this.plotAreas); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index 29d078ff2..dbb964df5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -357,8 +357,7 @@ public class DebugExec extends SubCommand { @Override public void run(Integer i, File file, PlotMessage message) { - String name; - name = file.getName(); + String name = file.getName(); message.text("[").color("$3") .text(i + "").color("$1") diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java index 165e585ef..231276d33 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Done.java @@ -19,7 +19,7 @@ import com.plotsquared.general.commands.CommandDeclaration; description = "Mark a plot as done", permission = "plots.done", category = CommandCategory.SETTINGS, - requiredType = RequiredType.NONE) + requiredType = RequiredType.PLAYER) public class Done extends SubCommand { @Override diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java index 441ea13fe..b1b0bd1bd 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Download.java @@ -22,7 +22,7 @@ import java.net.URL; command = "download", aliases = {"dl"}, category = CommandCategory.SCHEMATIC, - requiredType = RequiredType.NONE, + requiredType = RequiredType.PLAYER, description = "Download your plot", permission = "plots.download") public class Download extends SubCommand { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index d1b3bad8b..de2109dab 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringMan; import com.plotsquared.general.commands.CommandDeclaration; + import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; @@ -24,7 +25,7 @@ import java.util.Map; usage = "/plot flag ", description = "Set plot flags", category = CommandCategory.SETTINGS, - requiredType = RequiredType.NONE, + requiredType = RequiredType.PLAYER, permission = "plots.flag") public class FlagCmd extends SubCommand { @@ -75,18 +76,18 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); return false; } - AbstractFlag af = FlagManager.getFlag(args[1]); - if (af == null) { + AbstractFlag flag = FlagManager.getFlag(args[1]); + if (flag == null) { MainUtil.sendMessage(player, C.NOT_VALID_FLAG); MainUtil.sendMessage(player, C.COMMAND_SYNTAX, "/plot flag info "); return false; } // flag key - MainUtil.sendMessage(player, C.FLAG_KEY, af.getKey()); + MainUtil.sendMessage(player, C.FLAG_KEY, flag.getKey()); // flag type - MainUtil.sendMessage(player, C.FLAG_TYPE, af.value.getClass().getSimpleName()); + MainUtil.sendMessage(player, C.FLAG_TYPE, flag.value.getClass().getSimpleName()); // Flag type description - MainUtil.sendMessage(player, C.FLAG_DESC, af.getValueDesc()); + MainUtil.sendMessage(player, C.FLAG_DESC, flag.getValueDesc()); return true; } case "set": { @@ -167,7 +168,7 @@ public class FlagCmd extends SubCommand { MainUtil.sendMessage(player, C.FLAG_REMOVED); return true; } - case "add": { + case "add": if (!Permissions.hasPermission(player, "plots.flag.add")) { MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.add"); return false; @@ -206,7 +207,6 @@ public class FlagCmd extends SubCommand { } MainUtil.sendMessage(player, C.FLAG_ADDED); return true; - } case "list": if (!Permissions.hasPermission(player, "plots.flag.list")) { MainUtil.sendMessage(player, C.NO_PERMISSION, "plots.flag.list"); @@ -217,12 +217,12 @@ public class FlagCmd extends SubCommand { return false; } HashMap> flags = new HashMap<>(); - for (AbstractFlag af : FlagManager.getFlags()) { - String type = af.value.getClass().getSimpleName().replaceAll("Value", ""); + for (AbstractFlag flag1 : FlagManager.getFlags()) { + String type = flag1.value.getClass().getSimpleName().replaceAll("Value", ""); if (!flags.containsKey(type)) { flags.put(type, new ArrayList()); } - flags.get(type).add(af.getKey()); + flags.get(type).add(flag1.getKey()); } String message = ""; String prefix = ""; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index fcfe79919..3dcb50e64 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -22,7 +22,7 @@ import java.util.UUID; description = "Merge the plot you are standing on, with another plot", permission = "plots.merge", usage = "/plot merge [removeroads]", category = CommandCategory.SETTINGS, - requiredType = RequiredType.NONE, + requiredType = RequiredType.PLAYER, confirmation = true) public class Merge extends SubCommand { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java index 17e4214f4..ff4f73840 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Target.java @@ -15,7 +15,7 @@ import com.plotsquared.general.commands.CommandDeclaration; usage = "/plot target <|nearest>", description = "Target a plot with your compass", permission = "plots.target", - requiredType = RequiredType.NONE, + requiredType = RequiredType.PLAYER, category = CommandCategory.INFO) public class Target extends SubCommand { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java index 43c9e244f..f120f9433 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -5,6 +5,7 @@ import com.intellectualcrafters.configuration.file.YamlConfiguration; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.util.StringMan; import com.plotsquared.general.commands.CommandCaller; + import java.io.File; import java.util.EnumSet; import java.util.HashMap; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java b/Core/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java index cd24cef08..59197c9a7 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/ConfigurationNode.java @@ -19,7 +19,7 @@ public class ConfigurationNode { private final SettingValue type; private Object value; - public ConfigurationNode(String constant, Object defaultValue, String description, SettingValue type, boolean required) { + public ConfigurationNode(String constant, Object defaultValue, String description, SettingValue type) { this.constant = constant; this.defaultValue = defaultValue; this.description = description; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java b/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java index d911f5748..87f873cce 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/config/Settings.java @@ -6,16 +6,11 @@ import java.util.List; /** * Updater and DB settings * - - */ public class Settings { public static boolean USE_SQLUUIDHANDLER = false; public static boolean AUTO_PURGE = false; - /** - * - */ public static boolean UPDATE_NOTIFICATIONS = true; public static boolean FAST_CLEAR = false; @@ -163,8 +158,6 @@ public class Settings { /** * Database settings - * - */ public static class DB { /** diff --git a/Core/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java b/Core/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java index 5521dff8c..9aaf2e693 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/database/AbstractDB.java @@ -139,8 +139,7 @@ public interface AbstractDB { /** * Set plot flags. - * - * @param plot Plot Object + * @param plot Plot Object * @param flags flags to set (flag[]) */ void setFlags(Plot plot, Collection flags); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java index 327cf8c00..3be530cc4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/FlagManager.java @@ -26,6 +26,10 @@ import java.util.Set; */ public class FlagManager { + //TODO Default Flags + public static final IntegerFlag MUSIC = new IntegerFlag("music"); + + private static final HashSet reserved = new HashSet<>(); private static final HashSet flags = new HashSet<>(); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/flag/IntegerFlag.java b/Core/src/main/java/com/intellectualcrafters/plot/flag/IntegerFlag.java new file mode 100644 index 000000000..85e1f1916 --- /dev/null +++ b/Core/src/main/java/com/intellectualcrafters/plot/flag/IntegerFlag.java @@ -0,0 +1,8 @@ +package com.intellectualcrafters.plot.flag; + +public class IntegerFlag extends Flag { + + public IntegerFlag(String name) { + super(name); + } +} diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java index 8fbfea171..4ac5d5ff5 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/ClassicPlotWorld.java @@ -34,18 +34,18 @@ public abstract class ClassicPlotWorld extends SquarePlotWorld { @Override public ConfigurationNode[] getSettingNodes() { return new ConfigurationNode[] { - new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height", Configuration.INTEGER, true), - new ConfigurationNode("plot.size", this.PLOT_WIDTH, "Plot width", Configuration.INTEGER, true), - new ConfigurationNode("plot.filling", this.MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST, true), - new ConfigurationNode("plot.floor", this.TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST, true), - new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", Configuration.BLOCK, true), - new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, "Wall block (claimed)", Configuration.BLOCK, true), - new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", Configuration.INTEGER, true), - new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", Configuration.INTEGER, true), - new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", Configuration.BLOCK, true), - new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", Configuration.BLOCK, true), - new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", Configuration.INTEGER, true), - new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, "Plot bedrock generation", Configuration.BOOLEAN, true)}; + new ConfigurationNode("plot.height", this.PLOT_HEIGHT, "Plot height", Configuration.INTEGER), + new ConfigurationNode("plot.size", this.PLOT_WIDTH, "Plot width", Configuration.INTEGER), + new ConfigurationNode("plot.filling", this.MAIN_BLOCK, "Plot block", Configuration.BLOCKLIST), + new ConfigurationNode("plot.floor", this.TOP_BLOCK, "Plot floor block", Configuration.BLOCKLIST), + new ConfigurationNode("wall.block", this.WALL_BLOCK, "Top wall block", Configuration.BLOCK), + new ConfigurationNode("wall.block_claimed", this.CLAIMED_WALL_BLOCK, "Wall block (claimed)", Configuration.BLOCK), + new ConfigurationNode("road.width", this.ROAD_WIDTH, "Road width", Configuration.INTEGER), + new ConfigurationNode("road.height", this.ROAD_HEIGHT, "Road height", Configuration.INTEGER), + new ConfigurationNode("road.block", this.ROAD_BLOCK, "Road block", Configuration.BLOCK), + new ConfigurationNode("wall.filling", this.WALL_FILLING, "Wall filling block", Configuration.BLOCK), + new ConfigurationNode("wall.height", this.WALL_HEIGHT, "Wall height", Configuration.INTEGER), + new ConfigurationNode("plot.bedrock", this.PLOT_BEDROCK, "Plot bedrock generation", Configuration.BOOLEAN)}; } /** diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/IndependentPlotGenerator.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/IndependentPlotGenerator.java index 7f67c2afa..84fe328de 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/IndependentPlotGenerator.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/IndependentPlotGenerator.java @@ -9,8 +9,8 @@ import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.PlotChunk; /** - * This class allows for implementation independent world generation
- * - Sponge/Bukkit API

+ * This class allows for implementation independent world generation. + * - Sponge/Bukkit API * Use the specify method to get the generator for that platform. */ public abstract class IndependentPlotGenerator { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/generator/PlotGenerator.java b/Core/src/main/java/com/intellectualcrafters/plot/generator/PlotGenerator.java index aa2319223..138b1316e 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/generator/PlotGenerator.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/generator/PlotGenerator.java @@ -7,7 +7,7 @@ import com.intellectualcrafters.plot.object.SetupObject; public abstract class PlotGenerator { - public T generator; + public final T generator; public PlotGenerator(T generator) { this.generator = generator; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 38f844210..bafbc6e67 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -1302,7 +1302,7 @@ public class Plot { PlotArea plotworld = getArea(); if (plotworld.SCHEMATIC_ON_CLAIM) { SchematicHandler.Schematic sch; - if (schematic.isEmpty()) { + if (schematic == null || schematic.isEmpty()) { sch = SchematicHandler.manager.getSchematic(plotworld.SCHEMATIC_FILE); } else { sch = SchematicHandler.manager.getSchematic(schematic); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java index 0bcd48bcd..d9f21d11c 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/object/PlotArea.java @@ -91,7 +91,7 @@ public abstract class PlotArea { } /** - * Create a new PlotArea object with no functionality/information
+ * Create a new PlotArea object with no functionality/information. * - Mainly used during startup before worlds are created as a temporary object * @param world * @return @@ -106,8 +106,9 @@ public abstract class PlotArea { } /** - * Returns the region for this PlotArea or a RegionWrapper encompassing the whole world if none exists - * @NotNull + * Returns the region for this PlotArea or a RegionWrapper encompassing + * the whole world if none exists. + * * @return RegionWrapper */ public RegionWrapper getRegion() { @@ -119,7 +120,7 @@ public abstract class PlotArea { } /** - * Returns the region for this PlotArea + * Returns the region for this PlotArea. * * @return RegionWrapper or null if no applicable region */ @@ -135,7 +136,7 @@ public abstract class PlotArea { } /** - * Returns the min PlotId + * Returns the min PlotId. * @return */ public PlotId getMin() { @@ -143,7 +144,7 @@ public abstract class PlotArea { } /** - * Returns the max PlotId + * Returns the max PlotId. * @return */ public PlotId getMax() { @@ -151,7 +152,7 @@ public abstract class PlotArea { } /** - * Get the implementation independent generator for this area + * Get the implementation independent generator for this area. * * @return */ @@ -179,7 +180,7 @@ public abstract class PlotArea { } /** - * Check if a PlotArea is compatible (move/copy etc) + * Check if a PlotArea is compatible (move/copy etc). * @param plotArea * @return */ @@ -198,7 +199,7 @@ public abstract class PlotArea { } /** - * When a world is created, the following method will be called for each + * When a world is created, the following method will be called for each. * * @param config Configuration Section */ diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/ChatManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/ChatManager.java index d41e2e712..335935177 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/ChatManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/ChatManager.java @@ -7,16 +7,16 @@ public abstract class ChatManager { public static ChatManager manager; public abstract T builder(); - - public abstract void color(final PlotMessage message, final String color); - - public abstract void tooltip(final PlotMessage message, final PlotMessage... tooltip); - - public abstract void command(final PlotMessage message, final String command); - - public abstract void text(final PlotMessage message, final String text); - - public abstract void send(final PlotMessage plotMessage, final PlotPlayer player); - - public abstract void suggest(final PlotMessage plotMessage, final String command); + + public abstract void color(PlotMessage message, String color); + + public abstract void tooltip(PlotMessage message, PlotMessage... tooltip); + + public abstract void command(PlotMessage message, String command); + + public abstract void text(PlotMessage message, String text); + + public abstract void send(PlotMessage plotMessage, PlotPlayer player); + + public abstract void suggest(PlotMessage plotMessage, String command); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java index c7adcbfb5..f14952214 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/EventUtil.java @@ -15,6 +15,7 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.Rating; import com.plotsquared.listener.PlayerBlockEventType; + import java.util.ArrayList; import java.util.HashSet; import java.util.UUID; diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java index 31c70b0cd..8ea5775b4 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SchematicHandler.java @@ -24,6 +24,7 @@ import com.intellectualcrafters.plot.object.PlotArea; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.RunnableVal; + import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; @@ -705,7 +706,7 @@ public abstract class SchematicHandler { * @return Map of block location to tag */ public HashMap getTiles() { - return this.tiles; + return this.tiles == null ? new HashMap() : this.tiles; } /** diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/SetQueue.java b/Core/src/main/java/com/intellectualcrafters/plot/util/SetQueue.java index 5c2b6619e..6b4e414f3 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/SetQueue.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/SetQueue.java @@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.util; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; + import java.util.ArrayDeque; import java.util.concurrent.atomic.AtomicInteger; @@ -150,7 +151,7 @@ public class SetQueue { } public void regenerateChunk(String world, ChunkLoc loc) { - queue.regenerateChunk(world, loc); + this.queue.regenerateChunk(world, loc); } public class ChunkWrapper { diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java b/Core/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java index 8dc970c51..69bd7299d 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/TaskManager.java @@ -11,10 +11,9 @@ import java.util.concurrent.atomic.AtomicInteger; public abstract class TaskManager { - public static HashSet TELEPORT_QUEUE = new HashSet<>(); - + public static final HashSet TELEPORT_QUEUE = new HashSet<>(); + public static final HashMap tasks = new HashMap<>(); public static AtomicInteger index = new AtomicInteger(0); - public static HashMap tasks = new HashMap<>(); public static int runTaskRepeat(Runnable runnable, int interval) { if (runnable != null) { diff --git a/Core/src/main/java/com/plotsquared/general/commands/Command.java b/Core/src/main/java/com/plotsquared/general/commands/Command.java index 12a45c976..2f69d4652 100644 --- a/Core/src/main/java/com/plotsquared/general/commands/Command.java +++ b/Core/src/main/java/com/plotsquared/general/commands/Command.java @@ -477,7 +477,7 @@ public abstract class Command { return getCommandString() + " " + args + "]"; } - public Collection tab(PlotPlayer player, String[] args, boolean space) { + public Collection tab(PlotPlayer player, String[] args, boolean space) { switch (args.length) { case 0: return this.allCommands; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java index 9b4479ccf..616a1c4da 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -64,6 +64,7 @@ import org.spongepowered.api.event.game.state.GamePreInitializationEvent; import org.spongepowered.api.plugin.Plugin; import org.spongepowered.api.plugin.PluginContainer; import org.spongepowered.api.profile.GameProfileManager; +import org.spongepowered.api.world.Chunk; import org.spongepowered.api.world.World; import org.spongepowered.api.world.gen.GenerationPopulator; import org.spongepowered.api.world.gen.WorldGenerator; @@ -217,7 +218,7 @@ public class SpongeMain implements IPlotMain { @Override public TaskManager getTaskManager() { - return new SpongeTaskManager(); + return new SpongeTaskManager(this); } @Override @@ -370,7 +371,7 @@ public class SpongeMain implements IPlotMain { } @Override - public PlotQueue initPlotQueue() { + public PlotQueue initPlotQueue() { if (PS.get().checkVersion(getServerVersion(), 1, 8, 0)) { try { MainUtil.canSendChunk = true; diff --git a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java index c08219e4d..6f964f15e 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -286,7 +286,7 @@ public class MainListener { public void onNotifyNeighborBlock(NotifyNeighborBlockEvent event) throws Exception { AtomicBoolean cancelled = new AtomicBoolean(false); -// SpongeUtil.printCause("physics", event.getCause()); + // SpongeUtil.printCause("physics", event.getCause()); // PlotArea area = plotloc.getPlotArea(); // event.filterDirections(new Predicate() { // diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java index 312910917..cc76508ac 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java @@ -5,9 +5,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.TaskManager; -import java.util.Optional; -import java.util.Set; -import java.util.function.Predicate; import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.living.Living; import org.spongepowered.api.entity.living.animal.Animal; @@ -15,6 +12,10 @@ import org.spongepowered.api.entity.living.monster.Monster; import org.spongepowered.api.world.Chunk; import org.spongepowered.api.world.World; +import java.util.Optional; +import java.util.Set; +import java.util.function.Predicate; + public class SpongeChunkManager extends ChunkManager { @Override diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java index a77c5820b..345125c6c 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeEventUtil.java @@ -36,25 +36,25 @@ public class SpongeEventUtil extends EventUtil { public EventManager events; public SpongeEventUtil() { - events = SpongeMain.THIS.getGame().getEventManager(); + this.events = SpongeMain.THIS.getGame().getEventManager(); } - - public boolean callEvent(final Event event) { - return !events.post(event); + + public boolean callEvent(Event event) { + return !this.events.post(event); } @Override - public boolean callClaim(final PlotPlayer player, final Plot plot, final boolean auto) { + public boolean callClaim(PlotPlayer player, Plot plot, boolean auto) { return callEvent(new PlayerClaimPlotEvent(SpongeUtil.getPlayer(player), plot, auto)); } @Override - public boolean callTeleport(final PlotPlayer player, final Location from, final Plot plot) { + public boolean callTeleport(PlotPlayer player, Location from, Plot plot) { return callEvent(new PlayerTeleportToPlotEvent(SpongeUtil.getPlayer(player), from, plot)); } @Override - public boolean callClear(final Plot plot) { + public boolean callClear(Plot plot) { return callEvent(new PlotClearEvent(plot)); } @@ -64,59 +64,59 @@ public class SpongeEventUtil extends EventUtil { } @Override - public boolean callFlagAdd(final Flag flag, final Plot plot) { + public boolean callFlagAdd(Flag flag, Plot plot) { return callEvent(new PlotFlagAddEvent(flag, plot)); } @Override - public boolean callFlagRemove(final Flag flag, final Plot plot) { + public boolean callFlagRemove(Flag flag, Plot plot) { return callEvent(new PlotFlagRemoveEvent(flag, plot)); } @Override - public boolean callMerge(final Plot plot, final ArrayList plots) { + public boolean callMerge(Plot plot, ArrayList plots) { return callEvent(new PlotMergeEvent(SpongeUtil.getWorld(plot.getArea().worldname), plot, plots)); } @Override - public boolean callUnlink(final PlotArea area, final ArrayList plots) { + public boolean callUnlink(PlotArea area, ArrayList plots) { return callEvent(new PlotUnlinkEvent(SpongeUtil.getWorld(area.worldname), plots)); } @Override - public void callEntry(final PlotPlayer player, final Plot plot) { + public void callEntry(PlotPlayer player, Plot plot) { callEvent(new PlayerEnterPlotEvent(SpongeUtil.getPlayer(player), plot)); } @Override - public void callLeave(final PlotPlayer player, final Plot plot) { + public void callLeave(PlotPlayer player, Plot plot) { callEvent(new PlayerLeavePlotEvent(SpongeUtil.getPlayer(player), plot)); } @Override - public void callDenied(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added) { + public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) { callEvent(new PlayerPlotDeniedEvent(SpongeUtil.getPlayer(initiator), plot, player, added)); } @Override - public void callTrusted(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added) { + public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) { callEvent(new PlayerPlotHelperEvent(SpongeUtil.getPlayer(initiator), plot, player, added)); } @Override - public void callMember(final PlotPlayer initiator, final Plot plot, final UUID player, final boolean added) { + public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) { callEvent(new PlayerPlotTrustedEvent(SpongeUtil.getPlayer(initiator), plot, player, added)); } @Override - public boolean callFlagRemove(final Flag flag, final PlotCluster cluster) { + public boolean callFlagRemove(Flag flag, PlotCluster cluster) { return callEvent(new ClusterFlagRemoveEvent(flag, cluster)); } @Override - public Rating callRating(final PlotPlayer player, final Plot plot, final Rating rating) { - final PlotRateEvent event = new PlotRateEvent(player, rating, plot); - events.post(event); + public Rating callRating(PlotPlayer player, Plot plot, Rating rating) { + PlotRateEvent event = new PlotRateEvent(player, rating, plot); + this.events.post(event); return event.getRating(); } diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeTaskManager.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeTaskManager.java index 1747c935a..6272c33f1 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeTaskManager.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeTaskManager.java @@ -12,13 +12,18 @@ public class SpongeTaskManager extends TaskManager { private final AtomicInteger i = new AtomicInteger(); private final HashMap tasks = new HashMap<>(); + private final SpongeMain spongeMain; + + public SpongeTaskManager(SpongeMain spongeMain) { + this.spongeMain = spongeMain; + } @Override public int taskRepeat(Runnable runnable, int interval) { int val = this.i.incrementAndGet(); - Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); + Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder(); Task.Builder built = builder.delayTicks(interval).intervalTicks(interval).execute(runnable); - Task task = built.submit(SpongeMain.THIS.getPlugin()); + Task task = built.submit(this.spongeMain.getPlugin()); this.tasks.put(val, task); return val; } @@ -26,35 +31,35 @@ public class SpongeTaskManager extends TaskManager { @Override public int taskRepeatAsync(Runnable runnable, int interval) { int val = this.i.incrementAndGet(); - Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); + Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder(); Task.Builder built = builder.delayTicks(interval).async().intervalTicks(interval).execute(runnable); - Task task = built.submit(SpongeMain.THIS.getPlugin()); + Task task = built.submit(this.spongeMain.getPlugin()); this.tasks.put(val, task); return val; } @Override public void taskAsync(Runnable runnable) { - Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); - builder.async().execute(runnable).submit(SpongeMain.THIS.getPlugin()); + Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder(); + builder.async().execute(runnable).submit(this.spongeMain.getPlugin()); } @Override public void task(Runnable runnable) { - Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); - builder.execute(runnable).submit(SpongeMain.THIS.getPlugin()); + Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder(); + builder.execute(runnable).submit(this.spongeMain.getPlugin()); } @Override public void taskLater(Runnable runnable, int delay) { - Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); - builder.delayTicks(delay).execute(runnable).submit(SpongeMain.THIS.getPlugin()); + Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder(); + builder.delayTicks(delay).execute(runnable).submit(this.spongeMain.getPlugin()); } @Override public void taskLaterAsync(Runnable runnable, int delay) { - Task.Builder builder = SpongeMain.THIS.getGame().getScheduler().createTaskBuilder(); - builder.async().delayTicks(delay).execute(runnable).submit(SpongeMain.THIS.getPlugin()); + Task.Builder builder = this.spongeMain.getGame().getScheduler().createTaskBuilder(); + builder.async().delayTicks(delay).execute(runnable).submit(this.spongeMain.getPlugin()); } @Override diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index 0a473f649..3f8b61a20 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -17,13 +17,6 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.WorldUtil; import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.object.SpongePlayer; -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Locale; -import java.util.Optional; import net.minecraft.block.Block; import net.minecraft.world.biome.BiomeGenBase; import org.apache.commons.lang3.NotImplementedException; @@ -49,6 +42,14 @@ import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeTypes; import org.spongepowered.api.world.extent.Extent; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Optional; + public class SpongeUtil extends WorldUtil { public static Cause CAUSE = Cause.of(NamedCause.source("PlotSquared")); diff --git a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowQueue.java b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowQueue.java index 8581b889c..bc7f804da 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowQueue.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/util/block/SlowQueue.java @@ -10,17 +10,17 @@ import com.intellectualcrafters.plot.util.PlotQueue; import com.intellectualcrafters.plot.util.SetQueue; import com.intellectualcrafters.plot.util.SetQueue.ChunkWrapper; import com.plotsquared.sponge.util.SpongeUtil; -import java.util.Optional; import net.minecraft.world.chunk.IChunkProvider; import net.minecraft.world.gen.ChunkProviderServer; import org.spongepowered.api.block.BlockState; import org.spongepowered.api.world.Chunk; +import org.spongepowered.api.world.World; import java.util.Collection; import java.util.Iterator; import java.util.Map.Entry; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; -import org.spongepowered.api.world.World; public class SlowQueue implements PlotQueue { @@ -148,7 +148,7 @@ public class SlowQueue implements PlotQueue { else { PS.debug("CHUNK IS NULL!?"); }*/ - } catch (Throwable e){ + } catch (Throwable e) { e.printStackTrace(); } } diff --git a/pom.xml b/pom.xml index 4d2e24e5e..ad8947cb5 100644 --- a/pom.xml +++ b/pom.xml @@ -1,5 +1,6 @@ - + 4.0.0 com.intellectualcrafters