mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-29 16:46:45 +01:00
Potentially fixed BlockDamage in survival mode
This commit is contained in:
parent
d143296d5e
commit
a79f3d9e54
@ -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)
|
||||||
|
Loading…
Reference in New Issue
Block a user