Potentially fixed BlockDamage in survival mode

This commit is contained in:
boy0001 2015-03-03 00:36:11 +11:00
parent d143296d5e
commit a79f3d9e54

View File

@ -412,16 +412,63 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onBD(final BlockDamageEvent e) { public static void onBD(final BlockDamageEvent event) {
final Block b = e.getBlock(); final Player player = event.getPlayer();
final Location loc = BukkitUtil.getLocation(b.getLocation()); if (player == null) {
if (isPlotWorld(loc)) { final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
if (!isInPlot(loc)) { if (isPlotWorld(loc)) {
if (isPlotArea(BukkitUtil.getLocation(e.getBlock().getLocation()))) { if (!isInPlot(loc)) {
e.setCancelled(true); if (isPlotArea(loc)) {
event.setCancelled(true);
}
} }
} }
} }
final String world = player.getWorld().getName();
if (!isPlotWorld(world)) {
return;
}
final Location loc = BukkitUtil.getLocation(event.getBlock().getLocation());
final Plot plot = getCurrentPlot(loc);
if (plot != null) {
if (event.getBlock().getY() == 0) {
event.setCancelled(true);
return;
}
if (!plot.hasOwner()) {
final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(pp, "plots.admin.destroy.unowned")) {
return;
}
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.unowned");
event.setCancelled(true);
return;
}
final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (!plot.isAdded(pp.getUUID())) {
final Flag destroy = FlagManager.getPlotFlag(plot, "break");
final Block block = event.getBlock();
if ((destroy != null) && ((HashSet<PlotBlock>) destroy.getValue()).contains(new PlotBlock((short) block.getTypeId(), block.getData()))) {
return;
}
if (Permissions.hasPermission(pp, "plots.admin.destroy.other")) {
return;
}
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.other");
event.setCancelled(true);
return;
}
return;
}
final PlotPlayer pp = BukkitUtil.getPlayer(player);
if (Permissions.hasPermission(pp, "plots.admin.destroy.road")) {
return;
}
if (isPlotArea(loc)) {
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.destroy.road");
event.setCancelled(true);
return;
}
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)