Fix for explosion

This commit is contained in:
Jesse Boyd 2016-03-03 12:25:57 +11:00
parent 0dc672bcd5
commit 2b3fb7b4d0

View File

@ -564,40 +564,40 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
iter.remove(); iter.remove();
} }
} }
} else { return;
Plot plot = area.getOwnedPlot(loc); }
if (plot != null) { Plot plot = area.getOwnedPlot(loc);
if (FlagManager.isPlotFlagTrue(plot, "explosion")) { if (plot != null) {
List<MetadataValue> meta = event.getEntity().getMetadata("plot"); if (FlagManager.isPlotFlagTrue(plot, "explosion")) {
Plot origin; List<MetadataValue> meta = event.getEntity().getMetadata("plot");
if (meta.isEmpty()) { Plot origin;
origin = plot; if (meta.isEmpty()) {
} else { origin = plot;
origin = (Plot) meta.get(0).value(); } else {
} origin = (Plot) meta.get(0).value();
if (lastRadius != 0) { }
final List<Entity> nearby = event.getEntity().getNearbyEntities(lastRadius, lastRadius, lastRadius); if (lastRadius != 0) {
for (final Entity near : nearby) { final List<Entity> nearby = event.getEntity().getNearbyEntities(lastRadius, lastRadius, lastRadius);
if (near instanceof TNTPrimed || near.getType() == EntityType.MINECART_TNT) { for (final Entity near : nearby) {
if (!near.hasMetadata("plot")) { if (near instanceof TNTPrimed || near.getType() == EntityType.MINECART_TNT) {
near.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot)); if (!near.hasMetadata("plot")) {
} near.setMetadata("plot", new FixedMetadataValue((Plugin) PS.get().IMP, plot));
} }
} }
lastRadius = 0;
} }
final Iterator<Block> iter = event.blockList().iterator(); lastRadius = 0;
while (iter.hasNext()) { }
final Block b = iter.next(); final Iterator<Block> iter = event.blockList().iterator();
loc = BukkitUtil.getLocation(b.getLocation()); while (iter.hasNext()) {
if (!area.contains(loc.getX(), loc.getZ()) || !origin.equals(area.getOwnedPlot(loc))) { final Block b = iter.next();
iter.remove(); loc = BukkitUtil.getLocation(b.getLocation());
} if (!area.contains(loc.getX(), loc.getZ()) || !origin.equals(area.getOwnedPlot(loc))) {
iter.remove();
} }
} }
} else { return;
event.setCancelled(true);
} }
event.setCancelled(true);
} }
} }