Adding in offline explosion protection per default.
This commit is contained in:
parent
fa0a2fb90a
commit
549aaaf494
@ -32,6 +32,7 @@ public enum FFlag
|
|||||||
FRIENDLYFIRE("friendlyfire", "<i>Can friends hurt eachother here?", false),
|
FRIENDLYFIRE("friendlyfire", "<i>Can friends hurt eachother here?", false),
|
||||||
MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true),
|
MONSTERS("monsters", "<i>Can monsters spawn in this territory?", true),
|
||||||
EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true),
|
EXPLOSIONS("explosions", "<i>Can explosions occur in this territory?", true),
|
||||||
|
OFFLINE_EXPLOSIONS("offlineexplosions", "<i>Can explosions occur if faction is offline?", false),
|
||||||
FIRESPREAD("firespread", "<i>Can fire spread in territory?", true),
|
FIRESPREAD("firespread", "<i>Can fire spread in territory?", true),
|
||||||
ENDERGRIEF("endergrief", "<i>Can endermen grief in this territory?", false),
|
ENDERGRIEF("endergrief", "<i>Can endermen grief in this territory?", false),
|
||||||
|
|
||||||
@ -98,6 +99,7 @@ public enum FFlag
|
|||||||
if (str.startsWith("fr") || str.startsWith("ff")) return FRIENDLYFIRE;
|
if (str.startsWith("fr") || str.startsWith("ff")) return FRIENDLYFIRE;
|
||||||
if (str.startsWith("m")) return MONSTERS;
|
if (str.startsWith("m")) return MONSTERS;
|
||||||
if (str.startsWith("ex")) return EXPLOSIONS;
|
if (str.startsWith("ex")) return EXPLOSIONS;
|
||||||
|
if (str.startsWith("o")) return OFFLINE_EXPLOSIONS;
|
||||||
if (str.startsWith("fi")) return FIRESPREAD;
|
if (str.startsWith("fi")) return FIRESPREAD;
|
||||||
if (str.startsWith("en")) return ENDERGRIEF;
|
if (str.startsWith("en")) return ENDERGRIEF;
|
||||||
return null;
|
return null;
|
||||||
|
@ -1009,6 +1009,39 @@ public class Faction extends Entity<Faction> implements EconomyParticipator
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -------------------------------------------- //
|
||||||
|
// FACTION ONLINE STATE
|
||||||
|
// -------------------------------------------- //
|
||||||
|
|
||||||
|
public boolean isAllUPlayersOffline()
|
||||||
|
{
|
||||||
|
return this.getUPlayersWhereOnline(true).size() == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAnyUPlayersOnline()
|
||||||
|
{
|
||||||
|
return !this.isAllUPlayersOffline();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFactionConsideredOffline()
|
||||||
|
{
|
||||||
|
return this.isAllUPlayersOffline();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFactionConsideredOnline()
|
||||||
|
{
|
||||||
|
return !this.isFactionConsideredOffline();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExplosionsAllowed()
|
||||||
|
{
|
||||||
|
boolean explosions = this.getFlag(FFlag.EXPLOSIONS);
|
||||||
|
boolean offlineexplosions = this.getFlag(FFlag.OFFLINE_EXPLOSIONS);
|
||||||
|
boolean online = this.isFactionConsideredOnline();
|
||||||
|
|
||||||
|
return (online && explosions) || (!online && offlineexplosions);
|
||||||
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// MESSAGES
|
// MESSAGES
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -102,6 +102,7 @@ public class FactionColl extends Coll<Faction>
|
|||||||
faction.setFlag(FFlag.FRIENDLYFIRE, false);
|
faction.setFlag(FFlag.FRIENDLYFIRE, false);
|
||||||
faction.setFlag(FFlag.MONSTERS, true);
|
faction.setFlag(FFlag.MONSTERS, true);
|
||||||
faction.setFlag(FFlag.EXPLOSIONS, true);
|
faction.setFlag(FFlag.EXPLOSIONS, true);
|
||||||
|
faction.setFlag(FFlag.OFFLINE_EXPLOSIONS, true);
|
||||||
faction.setFlag(FFlag.FIRESPREAD, true);
|
faction.setFlag(FFlag.FIRESPREAD, true);
|
||||||
faction.setFlag(FFlag.ENDERGRIEF, true);
|
faction.setFlag(FFlag.ENDERGRIEF, true);
|
||||||
|
|
||||||
@ -134,6 +135,7 @@ public class FactionColl extends Coll<Faction>
|
|||||||
faction.setFlag(FFlag.FRIENDLYFIRE, false);
|
faction.setFlag(FFlag.FRIENDLYFIRE, false);
|
||||||
faction.setFlag(FFlag.MONSTERS, false);
|
faction.setFlag(FFlag.MONSTERS, false);
|
||||||
faction.setFlag(FFlag.EXPLOSIONS, false);
|
faction.setFlag(FFlag.EXPLOSIONS, false);
|
||||||
|
faction.setFlag(FFlag.OFFLINE_EXPLOSIONS, false);
|
||||||
faction.setFlag(FFlag.FIRESPREAD, false);
|
faction.setFlag(FFlag.FIRESPREAD, false);
|
||||||
faction.setFlag(FFlag.ENDERGRIEF, false);
|
faction.setFlag(FFlag.ENDERGRIEF, false);
|
||||||
|
|
||||||
@ -166,6 +168,7 @@ public class FactionColl extends Coll<Faction>
|
|||||||
faction.setFlag(FFlag.FRIENDLYFIRE, true);
|
faction.setFlag(FFlag.FRIENDLYFIRE, true);
|
||||||
faction.setFlag(FFlag.MONSTERS, true);
|
faction.setFlag(FFlag.MONSTERS, true);
|
||||||
faction.setFlag(FFlag.EXPLOSIONS, true);
|
faction.setFlag(FFlag.EXPLOSIONS, true);
|
||||||
|
faction.setFlag(FFlag.OFFLINE_EXPLOSIONS, true);
|
||||||
faction.setFlag(FFlag.FIRESPREAD, true);
|
faction.setFlag(FFlag.FIRESPREAD, true);
|
||||||
faction.setFlag(FFlag.ENDERGRIEF, true);
|
faction.setFlag(FFlag.ENDERGRIEF, true);
|
||||||
|
|
||||||
|
@ -573,7 +573,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
|
|
||||||
// ... and the faction there has explosions disabled ...
|
// ... and the faction there has explosions disabled ...
|
||||||
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(entity));
|
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(entity));
|
||||||
if (faction.getFlag(FFlag.EXPLOSIONS)) return;
|
if (faction.isExplosionsAllowed()) return;
|
||||||
|
|
||||||
// ... then cancel.
|
// ... then cancel.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
@ -589,7 +589,8 @@ public class FactionsListenerMain implements Listener
|
|||||||
if (UConf.isDisabled(location)) return;
|
if (UConf.isDisabled(location)) return;
|
||||||
|
|
||||||
// Check the entity. Are explosions disabled there?
|
// Check the entity. Are explosions disabled there?
|
||||||
if (BoardColls.get().getFactionAt(PS.valueOf(location)).getFlag(FFlag.EXPLOSIONS) == false)
|
|
||||||
|
if (BoardColls.get().getFactionAt(PS.valueOf(location)).isExplosionsAllowed() == false)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
@ -601,7 +602,7 @@ public class FactionsListenerMain implements Listener
|
|||||||
{
|
{
|
||||||
Block block = iter.next();
|
Block block = iter.next();
|
||||||
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(block));
|
Faction faction = BoardColls.get().getFactionAt(PS.valueOf(block));
|
||||||
if (faction.getFlag(FFlag.EXPLOSIONS) == false) iter.remove();
|
if (faction.isExplosionsAllowed() == false) iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -618,7 +619,8 @@ public class FactionsListenerMain implements Listener
|
|||||||
// ... and the faction there has explosions disabled ...
|
// ... and the faction there has explosions disabled ...
|
||||||
PS ps = PS.valueOf(event.getBlock());
|
PS ps = PS.valueOf(event.getBlock());
|
||||||
Faction faction = BoardColls.get().getFactionAt(ps);
|
Faction faction = BoardColls.get().getFactionAt(ps);
|
||||||
if (faction.getFlag(FFlag.EXPLOSIONS)) return;
|
|
||||||
|
if (faction.isExplosionsAllowed()) return;
|
||||||
|
|
||||||
// ... stop the block alteration.
|
// ... stop the block alteration.
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user