mirror of
https://github.com/garbagemule/MobArena.git
synced 2025-02-19 22:12:09 +01:00
reworked block break logic a little, deny outsiders to break into the arena at all times
This commit is contained in:
parent
d856f32103
commit
806583f41a
@ -135,6 +135,18 @@ public class ArenaListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockBreak(BlockBreakEvent event) {
|
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))
|
if (onBlockDestroy(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -142,24 +154,29 @@ public class ArenaListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onBlockBurn(BlockBurnEvent event) {
|
public void onBlockBurn(BlockBurnEvent event) {
|
||||||
if (onBlockDestroy(event))
|
if (!arena.getRegion().contains(event.getBlock().getLocation()) || onBlockDestroy(event))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean onBlockDestroy(BlockEvent event) {
|
private boolean onBlockDestroy(BlockEvent event) {
|
||||||
if (!arena.getRegion().contains(event.getBlock().getLocation()) || arena.inEditMode() || (!arena.isProtected() && arena.isRunning()))
|
if (arena.inEditMode())
|
||||||
return true;
|
return true;
|
||||||
|
// Below this, arena is not in edit mode - ACStache
|
||||||
Block b = event.getBlock();
|
|
||||||
if (arena.removeBlock(b) || b.getType() == Material.TNT)
|
if (!arena.isRunning())
|
||||||
return true;
|
return false;
|
||||||
|
// Below this, arena is running - ACStache
|
||||||
if (softRestore && arena.isRunning()) {
|
|
||||||
|
if (softRestore) {
|
||||||
|
if (arena.isProtected())
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Block b = event.getBlock();
|
||||||
BlockState state = b.getState();
|
BlockState state = b.getState();
|
||||||
|
|
||||||
Repairable r = null;
|
Repairable r = null;
|
||||||
|
|
||||||
if (state instanceof InventoryHolder)
|
if (state instanceof InventoryHolder)
|
||||||
r = new RepairableContainer(state);
|
r = new RepairableContainer(state);
|
||||||
else if (state instanceof Sign)
|
else if (state instanceof Sign)
|
||||||
@ -170,10 +187,9 @@ public class ArenaListener
|
|||||||
r = new RepairableBlock(state);
|
r = new RepairableBlock(state);
|
||||||
|
|
||||||
arena.addRepairable(r);
|
arena.addRepairable(r);
|
||||||
|
|
||||||
if (!softRestoreDrops)
|
if(!softRestoreDrops)
|
||||||
b.setTypeId(0);
|
b.setTypeId(0);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -436,29 +436,19 @@ public class ArenaMasterImpl implements ArenaMaster
|
|||||||
// Get any previous nodes
|
// Get any previous nodes
|
||||||
List<String> nodes = section.getStringList("permissions", null);
|
List<String> nodes = section.getStringList("permissions", null);
|
||||||
|
|
||||||
if (nodes.contains(perm) && add)
|
if (nodes.contains(perm) && add) {
|
||||||
return false;
|
return false;
|
||||||
else if (nodes.contains(perm) && !add)
|
}
|
||||||
|
else if (nodes.contains(perm) && !add) {
|
||||||
nodes.remove(perm);
|
nodes.remove(perm);
|
||||||
else if (!nodes.contains(perm) && add)
|
}
|
||||||
nodes.add(perm);
|
else if (!nodes.contains(perm) && add) {
|
||||||
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) {
|
|
||||||
removeContradictions(nodes, perm);
|
removeContradictions(nodes, perm);
|
||||||
nodes.add(perm);
|
nodes.add(perm);
|
||||||
}
|
}
|
||||||
else {
|
else if (!nodes.contains(perm) && !add) {
|
||||||
nodes.remove(perm);
|
return false;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
// Replace the set.
|
// Replace the set.
|
||||||
section.set("permissions", nodes);
|
section.set("permissions", nodes);
|
||||||
|
Loading…
Reference in New Issue
Block a user