reworked block break logic a little, deny outsiders to break into the arena at all times

This commit is contained in:
Brian 2012-05-16 22:30:12 -04:00
parent d856f32103
commit 806583f41a
2 changed files with 35 additions and 29 deletions

View File

@ -135,6 +135,18 @@ public class ArenaListener
}
public void onBlockBreak(BlockBreakEvent event) {
if (!arena.getRegion().contains(event.getBlock().getLocation()))
return;
// Below this, the block break is in the arena's region - ACStache
if (!arena.inArena(event.getPlayer())) {
if (arena.inEditMode())
return;
else
// Players not partaking in the arena while edit mode is off - ACStache
event.setCancelled(true);
}
if (onBlockDestroy(event))
return;
@ -142,24 +154,29 @@ public class ArenaListener
}
public void onBlockBurn(BlockBurnEvent event) {
if (onBlockDestroy(event))
if (!arena.getRegion().contains(event.getBlock().getLocation()) || onBlockDestroy(event))
return;
event.setCancelled(true);
}
private boolean onBlockDestroy(BlockEvent event) {
if (!arena.getRegion().contains(event.getBlock().getLocation()) || arena.inEditMode() || (!arena.isProtected() && arena.isRunning()))
if (arena.inEditMode())
return true;
Block b = event.getBlock();
if (arena.removeBlock(b) || b.getType() == Material.TNT)
return true;
if (softRestore && arena.isRunning()) {
// Below this, arena is not in edit mode - ACStache
if (!arena.isRunning())
return false;
// Below this, arena is running - ACStache
if (softRestore) {
if (arena.isProtected())
return false;
Block b = event.getBlock();
BlockState state = b.getState();
Repairable r = null;
if (state instanceof InventoryHolder)
r = new RepairableContainer(state);
else if (state instanceof Sign)
@ -170,10 +187,9 @@ public class ArenaListener
r = new RepairableBlock(state);
arena.addRepairable(r);
if (!softRestoreDrops)
if(!softRestoreDrops)
b.setTypeId(0);
return true;
}

View File

@ -436,29 +436,19 @@ public class ArenaMasterImpl implements ArenaMaster
// Get any previous nodes
List<String> nodes = section.getStringList("permissions", null);
if (nodes.contains(perm) && add)
if (nodes.contains(perm) && add) {
return false;
else if (nodes.contains(perm) && !add)
}
else if (nodes.contains(perm) && !add) {
nodes.remove(perm);
else if (!nodes.contains(perm) && add)
nodes.add(perm);
else if (!nodes.contains(perm) && !add)
return false;
/* erroneous logic - if it contains the perm when trying to remove, it won't remove it.
* it would return false early.
if (nodes.contains(perm))
return false;
// Add or remove.
if (add) {
}
else if (!nodes.contains(perm) && add) {
removeContradictions(nodes, perm);
nodes.add(perm);
}
else {
nodes.remove(perm);
else if (!nodes.contains(perm) && !add) {
return false;
}
*/
// Replace the set.
section.set("permissions", nodes);