Fixes #1774 (backwards compatibility)

This commit is contained in:
Jesse Boyd 2018-01-10 17:06:35 +11:00
parent 03337fe080
commit bc8b2af164
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F
3 changed files with 30 additions and 31 deletions

View File

@ -99,7 +99,6 @@ import org.bukkit.command.PluginCommand;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.entity.Shulker;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.metadata.FixedMetadataValue; import org.bukkit.metadata.FixedMetadataValue;
@ -459,8 +458,7 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
case WITHER: case WITHER:
case WOLF: case WOLF:
case ZOMBIE: case ZOMBIE:
case SHULKER: default: {
default:
if (Settings.Enabled_Components.KILL_ROAD_MOBS) { if (Settings.Enabled_Components.KILL_ROAD_MOBS) {
Location location = entity.getLocation(); Location location = entity.getLocation();
if (BukkitUtil.getLocation(location).isPlotRoad()) { if (BukkitUtil.getLocation(location).isPlotRoad()) {
@ -484,29 +482,28 @@ public final class BukkitMain extends JavaPlugin implements Listener, IPlotMain
} }
} }
} }
}
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();
}
if (entity != null && BukkitUtil.getLocation(entity.getLocation()).isPlotArea()) { }
if (entity instanceof Shulker) { } else {
LivingEntity livingEntity = (LivingEntity) entity; if (!entity.hasMetadata("plot")) {
if (entity.hasMetadata("ownerplot")) { //This is to apply the metadata to already spawned shulkers (see EntitySpawnListener.java)
if(!livingEntity.isLeashed() || !entity.hasMetadata("keep")) { entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, BukkitUtil.getLocation(entity.getLocation()).getPlot().getId()));
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()));
}
}
}
}
} }
} }
} catch (Throwable e) { } catch (Throwable e) {

View File

@ -42,8 +42,8 @@ public class EntitySpawnListener implements Listener {
event.setCancelled(true); event.setCancelled(true);
} }
case SHULKER: case SHULKER:
if(!entity.hasMetadata("ownerplot")) { if(!entity.hasMetadata("plot")) {
entity.setMetadata("ownerplot", new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId())); entity.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot.getId()));
} }
} }
} }

View File

@ -1263,9 +1263,11 @@ public class PlayerEvents extends PlotListener implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onBlockDispense(BlockDispenseEvent event) { public void onBlockDispense(BlockDispenseEvent event) {
Material type = event.getItem().getType(); Material type = event.getItem().getType();
Material dispenserType = event.getBlock().getType(); switch (type) {
if (dispenserType == Material.DROPPER || (type != Material.WATER_BUCKET && type != Material.LAVA_BUCKET)) { case WATER_BUCKET:
return; case LAVA_BUCKET: {
if (event.getBlock().getType() == Material.DROPPER) return;
}
} }
Location location = BukkitUtil.getLocation(event.getVelocity().toLocation(event.getBlock().getWorld())); Location location = BukkitUtil.getLocation(event.getVelocity().toLocation(event.getBlock().getWorld()));
if (location.isPlotRoad()) { if (location.isPlotRoad()) {