From bc8b2af164533ac982b0a07731e3c752fa958064 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Wed, 10 Jan 2018 17:06:35 +1100 Subject: [PATCH] Fixes #1774 (backwards compatibility) --- .../com/plotsquared/bukkit/BukkitMain.java | 49 +++++++++---------- .../bukkit/listeners/EntitySpawnListener.java | 4 +- .../bukkit/listeners/PlayerEvents.java | 8 +-- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java index eac5e7bcc..ffa7a6ac7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -99,7 +99,6 @@ import org.bukkit.command.PluginCommand; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.entity.Shulker; import org.bukkit.event.Listener; import org.bukkit.generator.ChunkGenerator; import org.bukkit.metadata.FixedMetadataValue; @@ -459,8 +458,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain case WITHER: case WOLF: case ZOMBIE: - case SHULKER: - default: + default: { if (Settings.Enabled_Components.KILL_ROAD_MOBS) { Location location = entity.getLocation(); if (BukkitUtil.getLocation(location).isPlotRoad()) { @@ -484,29 +482,28 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain } } } - - if (entity != null && BukkitUtil.getLocation(entity.getLocation()).isPlotArea()) { - if (entity instanceof Shulker) { - LivingEntity livingEntity = (LivingEntity) entity; - if (entity.hasMetadata("ownerplot")) { - if(!livingEntity.isLeashed() || !entity.hasMetadata("keep")) { - PlotId originalPlotId = (PlotId) (!entity.getMetadata("ownerplot").isEmpty() ? entity.getMetadata("ownerplot").get(0).value() : null); - PlotId currentPlotId = BukkitUtil.getLocation(entity.getLocation()).getPlot().getId(); - if(!currentPlotId.equals(originalPlotId)) { - iterator.remove(); - entity.remove(); - } - - } - } - else { - if(!entity.hasMetadata("ownerplot")) { - //This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java) - entity.setMetadata("ownerplot", new FixedMetadataValue((Plugin) PS.get().IMP, BukkitUtil.getLocation(entity.getLocation()).getPlot().getId())); - } - } - } - } + } + case SHULKER: { + if (Settings.Enabled_Components.KILL_ROAD_MOBS) { + LivingEntity livingEntity = (LivingEntity) entity; + if (entity.hasMetadata("plot")) { + if (!livingEntity.isLeashed() || !entity.hasMetadata("keep")) { + PlotId originalPlotId = (PlotId) (!entity.getMetadata("plot").isEmpty() ? entity.getMetadata("plot").get(0).value() : null); + PlotId currentPlotId = BukkitUtil.getLocation(entity.getLocation()).getPlot().getId(); + if (!currentPlotId.equals(originalPlotId)) { + iterator.remove(); + entity.remove(); + } + + } + } else { + if (!entity.hasMetadata("plot")) { + //This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java) + entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, BukkitUtil.getLocation(entity.getLocation()).getPlot().getId())); + } + } + } + } } } } catch (Throwable e) { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java index 3b8c7b02d..1d609af3b 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/EntitySpawnListener.java @@ -42,8 +42,8 @@ public class EntitySpawnListener implements Listener { event.setCancelled(true); } case SHULKER: - if(!entity.hasMetadata("ownerplot")) { - entity.setMetadata("ownerplot", new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId())); + if(!entity.hasMetadata("plot")) { + entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId())); } } } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 88a35e6d0..27c1a5d20 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -1263,9 +1263,11 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onBlockDispense(BlockDispenseEvent event) { Material type = event.getItem().getType(); - Material dispenserType = event.getBlock().getType(); - if (dispenserType == Material.DROPPER || (type != Material.WATER_BUCKET && type != Material.LAVA_BUCKET)) { - return; + switch (type) { + case WATER_BUCKET: + case LAVA_BUCKET: { + if (event.getBlock().getType() == Material.DROPPER) return; + } } Location location = BukkitUtil.getLocation(event.getVelocity().toLocation(event.getBlock().getWorld())); if (location.isPlotRoad()) {