diff --git a/Bukkit/build.gradle b/Bukkit/build.gradle index 83d6b2443..0ee1e63ab 100644 --- a/Bukkit/build.gradle +++ b/Bukkit/build.gradle @@ -2,12 +2,15 @@ repositories { maven {url "https://hub.spigotmc.org/nexus/content/groups/public/"} maven { url = "https://oss.sonatype.org/content/repositories/snapshots/"} maven {url "http://nexus.hc.to/content/repositories/pub_releases"} + mavenLocal() } dependencies { compile project(':Core') - compile 'org.spigotmc:spigot-api:1.10.2-R0.1-SNAPSHOT' - compile 'net.milkbowl.vault:VaultAPI:1.6' + compile 'org.spigotmc:spigot-api:1.11-R0.1-SNAPSHOT' + compile("net.milkbowl.vault:VaultAPI:1.6") { + exclude module: 'bukkit' + } } sourceCompatibility = 1.7 diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 67ef23682..446494c31 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -72,15 +72,6 @@ import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.sk89q.worldedit.WorldEdit; -import java.io.File; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Iterator; -import java.util.List; -import java.util.Map; -import java.util.UUID; -import java.util.concurrent.ConcurrentHashMap; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; @@ -97,54 +88,63 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; +import java.io.File; +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; + public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain { private static ConcurrentHashMap pluginMap; static { - { // Disable AWE as otherwise both fail to load - PluginManager manager = Bukkit.getPluginManager(); - try { - Settings.load(new File("plugins/PlotSquared/config/settings.yml")); - if (Settings.Enabled_Components.PLOTME_CONVERTER) { // Only disable PlotMe if conversion is enabled - Field pluginsField = manager.getClass().getDeclaredField("plugins"); - Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames"); - pluginsField.setAccessible(true); - lookupNamesField.setAccessible(true); - List plugins = (List) pluginsField.get(manager); - Iterator iter = plugins.iterator(); - while (iter.hasNext()) { - if (iter.next().getName().startsWith("PlotMe")) { - iter.remove(); - } + // Disable AWE as otherwise both fail to load + PluginManager manager = Bukkit.getPluginManager(); + try { + Settings.load(new File("plugins/PlotSquared/config/settings.yml")); + if (Settings.Enabled_Components.PLOTME_CONVERTER) { // Only disable PlotMe if conversion is enabled + Field pluginsField = manager.getClass().getDeclaredField("plugins"); + Field lookupNamesField = manager.getClass().getDeclaredField("lookupNames"); + pluginsField.setAccessible(true); + lookupNamesField.setAccessible(true); + List plugins = (List) pluginsField.get(manager); + Iterator iter = plugins.iterator(); + while (iter.hasNext()) { + if (iter.next().getName().startsWith("PlotMe")) { + iter.remove(); } - Map lookupNames = (Map) lookupNamesField.get(manager); - lookupNames.remove("PlotMe"); - lookupNames.remove("PlotMe-DefaultGenerator"); - pluginsField.set(manager, new ArrayList(plugins) { - @Override - public boolean add(Plugin plugin) { - if (plugin.getName().startsWith("PlotMe")) { - System.out.print("Disabling `" + plugin.getName() + "` for PlotMe conversion (configure in PlotSquared settings.yml)"); - } else { - return super.add(plugin); - } - return false; - } - }); - pluginMap = new ConcurrentHashMap(lookupNames) { - @Override - public Plugin put(String key, Plugin plugin) { - if (!plugin.getName().startsWith("PlotMe")) { - return super.put(key, plugin); - } - return null; - } - }; - lookupNamesField.set(manager, pluginMap); } - } catch (Throwable ignore) {} - } + Map lookupNames = (Map) lookupNamesField.get(manager); + lookupNames.remove("PlotMe"); + lookupNames.remove("PlotMe-DefaultGenerator"); + pluginsField.set(manager, new ArrayList(plugins) { + @Override + public boolean add(Plugin plugin) { + if (plugin.getName().startsWith("PlotMe")) { + System.out.print("Disabling `" + plugin.getName() + "` for PlotMe conversion (configure in PlotSquared settings.yml)"); + } else { + return super.add(plugin); + } + return false; + } + }); + pluginMap = new ConcurrentHashMap(lookupNames) { + @Override + public Plugin put(String key, Plugin plugin) { + if (!plugin.getName().startsWith("PlotMe")) { + return super.put(key, plugin); + } + return null; + } + }; + lookupNamesField.set(manager, pluginMap); + } + } catch (Throwable ignore) {} } public static WorldEdit worldEdit; @@ -299,6 +299,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain case TIPPED_ARROW: case ENDER_PEARL: case ARROW: + case LLAMA_SPIT: // managed elsewhere | projectile continue; case ITEM_FRAME: @@ -315,7 +316,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain case MINECART_MOB_SPAWNER: case ENDER_CRYSTAL: case MINECART_TNT: - case BOAT: { + case BOAT: if (Settings.Enabled_Components.KILL_ROAD_VEHICLES) { com.intellectualcrafters.plot.object.Location location = BukkitUtil.getLocation(entity.getLocation()); Plot plot = location.getPlot(); @@ -339,7 +340,6 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain } else { continue; } - } case SMALL_FIREBALL: case FIREBALL: case DRAGON_FIREBALL: @@ -350,6 +350,20 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain case FALLING_BLOCK: // managed elsewhere continue; + case LLAMA: + case DONKEY: + case MULE: + case ZOMBIE_HORSE: + case SKELETON_HORSE: + case HUSK: + case ELDER_GUARDIAN: + case WITHER_SKELETON: + case STRAY: + case ZOMBIE_VILLAGER: + case EVOKER: + case EVOKER_FANGS: + case VEX: + case VINDICATOR: case POLAR_BEAR: case BAT: case BLAZE: @@ -530,8 +544,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain public boolean initPlotMeConverter() { if (new LikePlotMeConverter("PlotMe").run(new ClassicPlotMeConnector())) { return true; - } - else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) { + } else if (new LikePlotMeConverter("PlotMe").run(new PlotMeConnector_017())) { return true; } return false; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java index 429248e6b..0dee64897 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/database/plotme/PlotMeConnector_017.java @@ -67,7 +67,7 @@ public class PlotMeConnector_017 extends APlotMeConnector { return null; } boolean checkUUID = DBFunc.hasColumn(resultSet, "ownerID"); - boolean merge = !this.plugin.equals("plotme") && Settings.Enabled_Components.PLOTME_CONVERTER; + boolean merge = !"plotme".equals(this.plugin) && Settings.Enabled_Components.PLOTME_CONVERTER; while (resultSet.next()) { int key = resultSet.getInt("plot_id"); PlotId id = new PlotId(resultSet.getInt("plotX"), resultSet.getInt("plotZ")); 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 7f78448a5..5bb9cb1d1 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -2,7 +2,6 @@ package com.plotsquared.bukkit.generator; 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.ChunkWrapper; @@ -245,8 +244,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap ArrayList toAdd = new ArrayList<>(); List existing = world.getPopulators(); if (populators == null && platformGenerator != null) { - populators = new ArrayList<>(); - this.populators.addAll(platformGenerator.getDefaultPopulators(world)); + populators = new ArrayList<>(platformGenerator.getDefaultPopulators(world)); } for (BlockPopulator populator : this.populators) { if (!existing.contains(populator)) { 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 eaf856d5f..d45b9dc01 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -25,17 +25,9 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.bukkit.object.BukkitLazyBlock; import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitVersion; import com.plotsquared.listener.PlayerBlockEventType; import com.plotsquared.listener.PlotListener; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Map.Entry; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -123,6 +115,18 @@ import org.bukkit.projectiles.BlockProjectileSource; import org.bukkit.projectiles.ProjectileSource; import org.bukkit.util.Vector; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map.Entry; +import java.util.Objects; +import java.util.Set; +import java.util.UUID; +import java.util.regex.Pattern; + /** * Player Events involving plots. * @@ -160,6 +164,7 @@ public class PlayerEvents extends PlotListener implements Listener { public void onRedstoneEvent(BlockRedstoneEvent event) { Block block = event.getBlock(); switch (block.getType()) { + case OBSERVER: case REDSTONE_LAMP_OFF: case REDSTONE_WIRE: case REDSTONE_LAMP_ON: @@ -604,7 +609,7 @@ public class PlayerEvents extends PlotListener implements Listener { PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); Location location = plotPlayer.getLocation(); PlotArea area = location.getPlotArea(); - if (area == null || (!area.PLOT_CHAT != plotPlayer.getAttribute("chat"))) { + if (area == null || (area.PLOT_CHAT == plotPlayer.getAttribute("chat"))) { return; } Plot plot = area.getPlot(location); @@ -1223,6 +1228,25 @@ public class PlayerEvents extends PlotListener implements Listener { case NOTE_BLOCK: case JUKEBOX: case WORKBENCH: + case SILVER_SHULKER_BOX: + case BLACK_SHULKER_BOX: + case BLUE_SHULKER_BOX: + case RED_SHULKER_BOX: + case PINK_SHULKER_BOX: + case ORANGE_SHULKER_BOX: + case WHITE_SHULKER_BOX: + case YELLOW_SHULKER_BOX: + case BROWN_SHULKER_BOX: + case CYAN_SHULKER_BOX: + case GREEN_SHULKER_BOX: + case PURPLE_SHULKER_BOX: + case GRAY_SHULKER_BOX: + case LIME_SHULKER_BOX: + case LIGHT_BLUE_SHULKER_BOX: + case MAGENTA_SHULKER_BOX: + case COMMAND_REPEATING: + case COMMAND_CHAIN: + eventType = PlayerBlockEventType.INTERACT_BLOCK; break; case DRAGON_EGG: @@ -1241,7 +1265,7 @@ public class PlayerEvents extends PlotListener implements Listener { } Material type = (hand == null) ? null : hand.getType(); int id = (type == null) ? 0 : type.getId(); - if (id == 0) { + if (type == Material.AIR) { eventType = PlayerBlockEventType.INTERACT_BLOCK; break; } @@ -1258,18 +1282,15 @@ public class PlayerEvents extends PlotListener implements Listener { case MONSTER_EGGS: eventType = PlayerBlockEventType.SPAWN_MOB; break; - case ARMOR_STAND: location = BukkitUtil.getLocation(block.getRelative(event.getBlockFace()).getLocation()); eventType = PlayerBlockEventType.PLACE_MISC; break; - case WRITTEN_BOOK: case BOOK_AND_QUILL: case BOOK: eventType = PlayerBlockEventType.READ; break; - case APPLE: case BAKED_POTATO: case MUSHROOM_SOUP: @@ -1510,6 +1531,7 @@ public class PlayerEvents extends PlotListener implements Listener { switch (entity.getType()) { case PLAYER: return false; + case LLAMA_SPIT: case SMALL_FIREBALL: case FIREBALL: case DROPPED_ITEM: @@ -1539,6 +1561,7 @@ public class PlayerEvents extends PlotListener implements Listener { case AREA_EFFECT_CLOUD: case LIGHTNING: case WITHER_SKULL: + case EVOKER_FANGS: case UNKNOWN: // non moving / unmovable return checkEntity(plot, Flags.ENTITY_CAP); @@ -1571,6 +1594,11 @@ public class PlayerEvents extends PlotListener implements Listener { case SNOWMAN: case BAT: case HORSE: + case DONKEY: + case LLAMA: + case MULE: + case ZOMBIE_HORSE: + case SKELETON_HORSE: // animal return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.ANIMAL_CAP); case BLAZE: @@ -1592,6 +1620,14 @@ public class PlayerEvents extends PlotListener implements Listener { case WITHER: case ZOMBIE: case SHULKER: + case HUSK: + case STRAY: + case ELDER_GUARDIAN: + case WITHER_SKELETON: + case VINDICATOR: + case EVOKER: + case VEX: + case ZOMBIE_VILLAGER: // monster return checkEntity(plot, Flags.ENTITY_CAP, Flags.MOB_CAP, Flags.HOSTILE_CAP); default: @@ -2055,7 +2091,23 @@ public class PlayerEvents extends PlotListener implements Listener { @SuppressWarnings("deprecation") @EventHandler(priority = EventPriority.HIGHEST) public void onEntityCombustByEntity(EntityCombustByEntityEvent event) { - EntityDamageByEntityEvent eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration()); + EntityDamageByEntityEvent eventChange = null; + if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), BukkitVersion.v1_11_0)) { + eventChange = new EntityDamageByEntityEvent(event.getCombuster(), event.getEntity(), + EntityDamageEvent.DamageCause.FIRE_TICK, (double)event.getDuration()); + } else { + try { + Constructor constructor = EntityDamageByEntityEvent.class.getConstructor(Entity.class, + Entity.class, EntityDamageEvent.DamageCause.class, Integer.TYPE); + eventChange = constructor.newInstance(event.getCombuster(), event.getEntity(), + EntityDamageEvent.DamageCause.FIRE_TICK, event.getDuration()); + } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { + e.printStackTrace(); + } + } + if (eventChange == null) { + return; + } onEntityDamageByEntityEvent(eventChange); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java index 313b6d97e..50a643382 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java @@ -11,9 +11,6 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.listener.PlotListener; -import java.util.HashSet; -import java.util.List; -import java.util.UUID; import org.bukkit.block.Block; import org.bukkit.block.BlockState; import org.bukkit.entity.ArmorStand; @@ -30,6 +27,10 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.PlayerInventory; import org.bukkit.inventory.meta.ItemMeta; +import java.util.HashSet; +import java.util.List; +import java.util.UUID; + public class PlayerEvents_1_8 extends PlotListener implements Listener { @SuppressWarnings("deprecation") @@ -66,7 +67,7 @@ public class PlayerEvents_1_8 extends PlotListener implements Listener { oldLore = lore.toString(); } } - if (!newLore.equals("[(+NBT)]") || (current.equals(newItem) && newLore.equals(oldLore))) { + if (!"[(+NBT)]".equals(newLore) || (current.equals(newItem) && newLore.equals(oldLore))) { return; } HashSet blocks = null; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java index d4e68b71f..a25b20779 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/titles/DefaultTitle_19.java @@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.object.BukkitPlayer; import org.bukkit.entity.Player; +@SuppressWarnings("deprecation") public class DefaultTitle_19 extends AbstractTitle { @Override 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 fcd195343..e39ab5f4e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -516,6 +516,7 @@ public class BukkitChunkManager extends ChunkManager { case SHULKER_BULLET: case SPECTRAL_ARROW: case DRAGON_FIREBALL: + case LLAMA_SPIT: // projectile case PRIMED_TNT: case FALLING_BLOCK: @@ -533,6 +534,7 @@ public class BukkitChunkManager extends ChunkManager { case UNKNOWN: case AREA_EFFECT_CLOUD: case LINGERING_POTION: + case EVOKER_FANGS: // non moving / unremovable break; case ITEM_FRAME: @@ -566,6 +568,11 @@ public class BukkitChunkManager extends ChunkManager { case COW: case SNOWMAN: case BAT: + case DONKEY: + case LLAMA: + case SKELETON_HORSE: + case ZOMBIE_HORSE: + case MULE: // animal count[3]++; count[1]++; @@ -589,6 +596,14 @@ public class BukkitChunkManager extends ChunkManager { case WITHER: case ZOMBIE: case SHULKER: + case ELDER_GUARDIAN: + case STRAY: + case HUSK: + case EVOKER: + case VEX: + case WITHER_SKELETON: + case ZOMBIE_VILLAGER: + case VINDICATOR: // monster count[3]++; count[2]++; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitVersion.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitVersion.java index bb40266d3..401d2aabe 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitVersion.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitVersion.java @@ -1,6 +1,7 @@ package com.plotsquared.bukkit.util; public class BukkitVersion { + public static int[] v1_11_0 = {1, 11, 0}; public static int[] v1_10_2 = {1, 10, 2}; public static int[] v1_10_0 = {1, 10, 0}; public static int[] v1_9_4 = {1, 9, 4}; diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 0b0c63832..f5f5350b3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Wed Oct 26 22:42:12 EDT 2016 +#Thu Nov 17 22:56:15 EST 2016 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.0-all.zip