Started to implement special faction behavior
This commit is contained in:
parent
e3821a8d4e
commit
46161f61db
@ -1,5 +1,5 @@
|
||||
name: Factions
|
||||
version: 1.5.9 beta
|
||||
version: 1.7_dev
|
||||
main: com.massivecraft.factions.P
|
||||
authors: [Olof Larsson, Brett Flannigan]
|
||||
softdepend: [PermissionsEx, Permissions, Essentials, EssentialsChat, HeroChat, iChat, LocalAreaChat, nChat, ChatManager, CAPI, AuthMe, Register, Spout, WorldEdit, WorldGuard]
|
||||
|
@ -5,7 +5,7 @@ import java.util.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
@ -25,8 +25,8 @@ public class Conf
|
||||
//public static ChatColor colorWar = ChatColor.DARK_RED;
|
||||
//public static ChatColor colorWilderness = ChatColor.DARK_GREEN;
|
||||
|
||||
public static Map<FactionFlag, Boolean> factionFlagDefaults;
|
||||
public static Map<FactionFlag, Boolean> factionFlagIsChangeable;
|
||||
public static Map<FFlag, Boolean> factionFlagDefaults;
|
||||
public static Map<FFlag, Boolean> factionFlagIsChangeable;
|
||||
public static Map<FPerm, Set<Rel>> factionPermDefaults;
|
||||
|
||||
// Power
|
||||
@ -276,9 +276,9 @@ public class Conf
|
||||
{
|
||||
baseCommandAliases.add("f");
|
||||
|
||||
factionFlagDefaults = new LinkedHashMap<FactionFlag, Boolean>();
|
||||
factionFlagIsChangeable = new LinkedHashMap<FactionFlag, Boolean>();
|
||||
for (FactionFlag flag : FactionFlag.values())
|
||||
factionFlagDefaults = new LinkedHashMap<FFlag, Boolean>();
|
||||
factionFlagIsChangeable = new LinkedHashMap<FFlag, Boolean>();
|
||||
for (FFlag flag : FFlag.values())
|
||||
{
|
||||
factionFlagDefaults.put(flag, flag.defaultDefaultValue);
|
||||
factionFlagIsChangeable.put(flag, flag.defaultDefaultChangeable);
|
||||
|
@ -14,7 +14,7 @@ import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.integration.Worldguard;
|
||||
import com.massivecraft.factions.struct.ChatMode;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.RelationUtil;
|
||||
import com.massivecraft.factions.zcore.persist.PlayerEntity;
|
||||
@ -487,11 +487,11 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
return Board.getFactionAt(new FLocation(this)) == this.getFaction();
|
||||
}
|
||||
|
||||
public boolean isInOthersTerritory()
|
||||
/*public boolean isInOthersTerritory()
|
||||
{
|
||||
Faction factionHere = Board.getFactionAt(new FLocation(this));
|
||||
return factionHere != null && factionHere.isNormal() && factionHere != this.getFaction();
|
||||
}
|
||||
}*/
|
||||
|
||||
public boolean isInAllyTerritory()
|
||||
{
|
||||
@ -530,7 +530,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator
|
||||
public void leave(boolean makePay)
|
||||
{
|
||||
Faction myFaction = this.getFaction();
|
||||
boolean perm = myFaction.getFlag(FactionFlag.PERMANENT);
|
||||
boolean perm = myFaction.getFlag(FFlag.PERMANENT);
|
||||
|
||||
if (!perm && this.getRole() == Rel.LEADER && myFaction.getFPlayers().size() > 1)
|
||||
{
|
||||
|
@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
|
||||
import com.massivecraft.factions.iface.EconomyParticipator;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.*;
|
||||
@ -107,14 +107,14 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
|
||||
// FIELDS: Flag management
|
||||
// TODO: This will save... defaults if they where changed to...
|
||||
private Map<FactionFlag, Boolean> flagOverrides; // Contains the modifications to the default values
|
||||
public boolean getFlag(FactionFlag flag)
|
||||
private Map<FFlag, Boolean> flagOverrides; // Contains the modifications to the default values
|
||||
public boolean getFlag(FFlag flag)
|
||||
{
|
||||
Boolean ret = this.flagOverrides.get(flag);
|
||||
if (ret == null) ret = flag.getDefault();
|
||||
return ret;
|
||||
}
|
||||
public void setFlag(FactionFlag flag, boolean value)
|
||||
public void setFlag(FFlag flag, boolean value)
|
||||
{
|
||||
if (Conf.factionFlagDefaults.get(flag).equals(value))
|
||||
{
|
||||
@ -132,14 +132,21 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
if (ret == null) ret = perm.getDefault();
|
||||
return ret;
|
||||
}
|
||||
public void setPermittedRelations(FPerm perm, Set<Rel> value)
|
||||
public void setPermittedRelations(FPerm perm, Set<Rel> rels)
|
||||
{
|
||||
if (Conf.factionPermDefaults.get(perm).equals(value))
|
||||
if (Conf.factionPermDefaults.get(perm).equals(rels))
|
||||
{
|
||||
this.permOverrides.remove(perm);
|
||||
return;
|
||||
}
|
||||
this.permOverrides.put(perm, value);
|
||||
this.permOverrides.put(perm, rels);
|
||||
}
|
||||
|
||||
public void setPermittedRelations(FPerm perm, Rel... rels)
|
||||
{
|
||||
Set<Rel> temp = new HashSet<Rel>();
|
||||
temp.addAll(Arrays.asList(rels));
|
||||
this.setPermittedRelations(perm, temp);
|
||||
}
|
||||
|
||||
|
||||
@ -158,7 +165,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
//this.peaceful = false;
|
||||
//this.peacefulExplosionsEnabled = false;
|
||||
this.money = 0.0;
|
||||
this.flagOverrides = new LinkedHashMap<FactionFlag, Boolean>();
|
||||
this.flagOverrides = new LinkedHashMap<FFlag, Boolean>();
|
||||
this.permOverrides = new LinkedHashMap<FPerm, Set<Rel>>();
|
||||
}
|
||||
|
||||
@ -240,7 +247,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
//----------------------------------------------//
|
||||
public double getPower()
|
||||
{
|
||||
if (this.getFlag(FactionFlag.INFPOWER))
|
||||
if (this.getFlag(FFlag.INFPOWER))
|
||||
{
|
||||
return 999999;
|
||||
}
|
||||
@ -259,7 +266,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
|
||||
public double getPowerMax()
|
||||
{
|
||||
if (this.getFlag(FactionFlag.INFPOWER))
|
||||
if (this.getFlag(FFlag.INFPOWER))
|
||||
{
|
||||
return 999999;
|
||||
}
|
||||
@ -338,7 +345,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
|
||||
public FPlayer getFPlayerLeader()
|
||||
{
|
||||
if ( ! this.isNormal()) return null;
|
||||
//if ( ! this.isNormal()) return null;
|
||||
|
||||
for (FPlayer fplayer : FPlayers.i.get())
|
||||
{
|
||||
@ -353,7 +360,7 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
public ArrayList<FPlayer> getFPlayersWhereRole(Rel role)
|
||||
{
|
||||
ArrayList<FPlayer> ret = new ArrayList<FPlayer>();
|
||||
if ( ! this.isNormal()) return ret;
|
||||
//if ( ! this.isNormal()) return ret;
|
||||
|
||||
for (FPlayer fplayer : FPlayers.i.get())
|
||||
{
|
||||
@ -407,14 +414,9 @@ public class Faction extends Entity implements EconomyParticipator
|
||||
}
|
||||
|
||||
public void memberLoggedOff()
|
||||
{
|
||||
if (this.isNormal())
|
||||
{
|
||||
lastPlayerLoggedOffTime = System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//----------------------------------------------//
|
||||
// Messages
|
||||
|
@ -10,6 +10,9 @@ import java.util.logging.Level;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
import com.massivecraft.factions.zcore.persist.EntityCollection;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
@ -43,47 +46,122 @@ public class Factions extends EntityCollection<Faction>
|
||||
{
|
||||
if ( ! super.loadFromDisc()) return false;
|
||||
|
||||
// Make sure the default neutral faction exists
|
||||
//----------------------------------------------//
|
||||
// Create Default Special Factions
|
||||
//----------------------------------------------//
|
||||
if ( ! this.exists("0"))
|
||||
{
|
||||
Faction faction = this.create("0");
|
||||
faction.setTag(ChatColor.DARK_GREEN+"Wilderness");
|
||||
faction.setDescription("");
|
||||
this.setFlagsForWilderness(faction);
|
||||
}
|
||||
|
||||
// Make sure the safe zone faction exists
|
||||
if ( ! this.exists("-1"))
|
||||
{
|
||||
Faction faction = this.create("-1");
|
||||
faction.setTag("SafeZone");
|
||||
faction.setDescription("Free from PVP and monsters");
|
||||
}
|
||||
else
|
||||
{
|
||||
// if SafeZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
||||
Faction faction = this.getSafeZone();
|
||||
if (faction.getTag().contains(" "))
|
||||
faction.setTag("SafeZone");
|
||||
}
|
||||
|
||||
// Make sure the war zone faction exists
|
||||
this.setFlagsForSafeZone(faction);
|
||||
}
|
||||
if ( ! this.exists("-2"))
|
||||
{
|
||||
Faction faction = this.create("-2");
|
||||
faction.setTag("WarZone");
|
||||
faction.setDescription("Not the safest place to be");
|
||||
}
|
||||
else
|
||||
{
|
||||
// if WarZone has old pre-1.6.0 name, rename it to remove troublesome " "
|
||||
Faction faction = this.getWarZone();
|
||||
if (faction.getTag().contains(" "))
|
||||
faction.setTag("WarZone");
|
||||
this.setFlagsForWarZone(faction);
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// Fix From Old Formats
|
||||
//----------------------------------------------//
|
||||
Faction wild = this.get("0");
|
||||
Faction safeZone = this.get("-1");
|
||||
Faction warZone = this.get("-2");
|
||||
|
||||
// Remove troublesome " " from old pre-1.6.0 names
|
||||
if (safeZone != null && safeZone.getTag().contains(" "))
|
||||
safeZone.setTag("SafeZone");
|
||||
if (warZone != null && warZone.getTag().contains(" "))
|
||||
warZone.setTag("WarZone");
|
||||
|
||||
// Set Flags if they are not set already.
|
||||
if (wild != null && ! wild.getFlag(FFlag.PERMANENT))
|
||||
setFlagsForWilderness(wild);
|
||||
if (safeZone != null && ! safeZone.getFlag(FFlag.PERMANENT))
|
||||
setFlagsForSafeZone(safeZone);
|
||||
if (warZone != null && ! warZone.getFlag(FFlag.PERMANENT))
|
||||
setFlagsForWarZone(warZone);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------//
|
||||
// Flag Setters
|
||||
//----------------------------------------------//
|
||||
public void setFlagsForWilderness(Faction faction)
|
||||
{
|
||||
faction.setFlag(FFlag.PERMANENT, true);
|
||||
faction.setFlag(FFlag.PEACEFUL, true);
|
||||
faction.setFlag(FFlag.INFPOWER, true);
|
||||
faction.setFlag(FFlag.POWERLOSS, true);
|
||||
faction.setFlag(FFlag.PVP, true);
|
||||
faction.setFlag(FFlag.FRIENDLYFIRE, false);
|
||||
faction.setFlag(FFlag.MONSTERS, true);
|
||||
faction.setFlag(FFlag.EXPLOSIONS, true);
|
||||
faction.setFlag(FFlag.FIRESPREAD, true);
|
||||
faction.setFlag(FFlag.LIGHTNING, true);
|
||||
faction.setFlag(FFlag.ENDERGRIEF, true);
|
||||
|
||||
faction.setPermittedRelations(FPerm.BUILD, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
}
|
||||
|
||||
public void setFlagsForSafeZone(Faction faction)
|
||||
{
|
||||
faction.setFlag(FFlag.PERMANENT, true);
|
||||
faction.setFlag(FFlag.PEACEFUL, true);
|
||||
faction.setFlag(FFlag.INFPOWER, true);
|
||||
faction.setFlag(FFlag.POWERLOSS, false);
|
||||
faction.setFlag(FFlag.PVP, false);
|
||||
faction.setFlag(FFlag.FRIENDLYFIRE, false);
|
||||
faction.setFlag(FFlag.MONSTERS, false);
|
||||
faction.setFlag(FFlag.EXPLOSIONS, false);
|
||||
faction.setFlag(FFlag.FIRESPREAD, false);
|
||||
faction.setFlag(FFlag.LIGHTNING, false);
|
||||
faction.setFlag(FFlag.ENDERGRIEF, false);
|
||||
|
||||
faction.setPermittedRelations(FPerm.BUILD, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
}
|
||||
|
||||
public void setFlagsForWarZone(Faction faction)
|
||||
{
|
||||
faction.setFlag(FFlag.PERMANENT, true);
|
||||
faction.setFlag(FFlag.PEACEFUL, true);
|
||||
faction.setFlag(FFlag.INFPOWER, true);
|
||||
faction.setFlag(FFlag.POWERLOSS, true);
|
||||
faction.setFlag(FFlag.PVP, true);
|
||||
faction.setFlag(FFlag.FRIENDLYFIRE, true);
|
||||
faction.setFlag(FFlag.MONSTERS, true);
|
||||
faction.setFlag(FFlag.EXPLOSIONS, true);
|
||||
faction.setFlag(FFlag.FIRESPREAD, true);
|
||||
faction.setFlag(FFlag.LIGHTNING, true);
|
||||
faction.setFlag(FFlag.ENDERGRIEF, true);
|
||||
|
||||
faction.setPermittedRelations(FPerm.BUILD, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.DOOR, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.CONTAINER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.BUTTON, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
faction.setPermittedRelations(FPerm.LEVER, Rel.ENEMY, Rel.NEUTRAL, Rel.TRUCE, Rel.ALLY, Rel.MEMBER);
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------//
|
||||
// GET
|
||||
@ -107,17 +185,6 @@ public class Factions extends EntityCollection<Faction>
|
||||
return this.get("0");
|
||||
}
|
||||
|
||||
public Faction getSafeZone()
|
||||
{
|
||||
return this.get("-1");
|
||||
}
|
||||
|
||||
public Faction getWarZone()
|
||||
{
|
||||
return this.get("-2");
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------//
|
||||
// Faction tag
|
||||
//----------------------------------------------//
|
||||
|
@ -7,7 +7,7 @@ import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
@ -51,7 +51,7 @@ public class CmdDisband extends FCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (faction.getFlag(FactionFlag.PERMANENT))
|
||||
if (faction.getFlag(FFlag.PERMANENT))
|
||||
{
|
||||
msg("<i>This faction is designated as permanent, so you cannot disband it.");
|
||||
return;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package com.massivecraft.factions.cmd;
|
||||
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
@ -41,14 +41,14 @@ public class CmdFlag extends FCommand
|
||||
|
||||
if ( ! this.argIsSet(1))
|
||||
{
|
||||
for (FactionFlag flag : FactionFlag.values())
|
||||
for (FFlag flag : FFlag.values())
|
||||
{
|
||||
msg(flag.getStateInfo(faction.getFlag(flag), true));
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
FactionFlag flag = this.argAsFactionFlag(1);
|
||||
FFlag flag = this.argAsFactionFlag(1);
|
||||
if (flag == null) return;
|
||||
if ( ! this.argIsSet(2))
|
||||
{
|
||||
|
@ -13,7 +13,7 @@ import com.massivecraft.factions.FLocation;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.zcore.util.SmokeUtil;
|
||||
@ -80,7 +80,7 @@ public class CmdHome extends FCommand
|
||||
(
|
||||
Conf.homesTeleportAllowedEnemyDistance > 0
|
||||
&&
|
||||
faction.getFlag(FactionFlag.PVP)
|
||||
faction.getFlag(FFlag.PVP)
|
||||
&&
|
||||
(
|
||||
! fme.isInOwnTerritory()
|
||||
|
@ -30,11 +30,11 @@ public class CmdJoin extends FCommand
|
||||
Faction faction = this.argAsFaction(0);
|
||||
if (faction == null) return;
|
||||
|
||||
if ( ! faction.isNormal())
|
||||
/*if ( ! faction.isNormal())
|
||||
{
|
||||
msg("<b>You may only join normal factions. This is a system faction.");
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (faction == myFaction)
|
||||
{
|
||||
|
@ -5,7 +5,7 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
|
||||
public class CmdKick extends FCommand
|
||||
@ -82,7 +82,7 @@ public class CmdKick extends FCommand
|
||||
if (Conf.logFactionKick)
|
||||
P.p.log(fme.getName()+" kicked "+you.getName()+" from the faction: "+yourFaction.getTag());
|
||||
|
||||
if (yourFaction.getFPlayers().isEmpty() && !yourFaction.getFlag(FactionFlag.PERMANENT))
|
||||
if (yourFaction.getFPlayers().isEmpty() && !yourFaction.getFlag(FFlag.PERMANENT))
|
||||
{
|
||||
// Remove this faction
|
||||
for (FPlayer fplayer : FPlayers.i.getOnline())
|
||||
|
@ -38,9 +38,11 @@ public class CmdList extends FCommand
|
||||
if ( ! payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) return;
|
||||
|
||||
ArrayList<Faction> factionList = new ArrayList<Faction>(Factions.i.get());
|
||||
|
||||
factionList.remove(Factions.i.getNone());
|
||||
factionList.remove(Factions.i.getSafeZone());
|
||||
factionList.remove(Factions.i.getWarZone());
|
||||
// TODO: Add flag SECRET To factions instead.
|
||||
//factionList.remove(Factions.i.getSafeZone());
|
||||
//factionList.remove(Factions.i.getWarZone());
|
||||
|
||||
// Sort by total followers first
|
||||
Collections.sort(factionList, new Comparator<Faction>(){
|
||||
|
@ -61,7 +61,6 @@ public class CmdPerm extends FCommand
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: Awesomesause parser for deltas...
|
||||
Set<Rel> targetValue = FPerm.parseRelDeltas(TextUtil.implode(args.subList(2, args.size()), " "), faction.getPermittedRelations(perm));
|
||||
|
||||
// Do the sender have the right to change perms for this faction?
|
||||
|
@ -7,7 +7,7 @@ import com.massivecraft.factions.integration.Econ;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
@ -50,13 +50,13 @@ public class CmdShow extends FCommand
|
||||
|
||||
msg(p.txt.titleize(faction.getTag(fme)));
|
||||
msg("<a>Description: <i>%s", faction.getDescription());
|
||||
if ( ! faction.isNormal())
|
||||
/*if ( ! faction.isNormal())
|
||||
{
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
String peaceStatus = "";
|
||||
if (faction.getFlag(FactionFlag.PEACEFUL))
|
||||
if (faction.getFlag(FFlag.PEACEFUL))
|
||||
{
|
||||
peaceStatus = " "+Conf.colorTruce+"This faction is Peaceful";
|
||||
}
|
||||
@ -64,7 +64,7 @@ public class CmdShow extends FCommand
|
||||
msg("<a>Joining: <i>"+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus);
|
||||
msg("<a>Land / Power / Maxpower: <i> %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded());
|
||||
|
||||
if (faction.getFlag(FactionFlag.PERMANENT))
|
||||
if (faction.getFlag(FFlag.PERMANENT))
|
||||
{
|
||||
msg("<a>This faction is permanent, remaining even with no members.");
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.Factions;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.FPerm;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.zcore.MCommand;
|
||||
@ -276,13 +276,13 @@ public abstract class FCommand extends MCommand<P>
|
||||
}
|
||||
|
||||
// FACTION FLAG ======================
|
||||
public FactionFlag strAsFactionFlag(String name, FactionFlag def, boolean msg)
|
||||
public FFlag strAsFactionFlag(String name, FFlag def, boolean msg)
|
||||
{
|
||||
FactionFlag ret = def;
|
||||
FFlag ret = def;
|
||||
|
||||
if (name != null)
|
||||
{
|
||||
FactionFlag flag = FactionFlag.parse(name);
|
||||
FFlag flag = FFlag.parse(name);
|
||||
if (flag != null)
|
||||
{
|
||||
ret = flag;
|
||||
@ -296,15 +296,15 @@ public abstract class FCommand extends MCommand<P>
|
||||
|
||||
return ret;
|
||||
}
|
||||
public FactionFlag argAsFactionFlag(int idx, FactionFlag def, boolean msg)
|
||||
public FFlag argAsFactionFlag(int idx, FFlag def, boolean msg)
|
||||
{
|
||||
return this.strAsFactionFlag(this.argAsString(idx), def, msg);
|
||||
}
|
||||
public FactionFlag argAsFactionFlag(int idx, FactionFlag def)
|
||||
public FFlag argAsFactionFlag(int idx, FFlag def)
|
||||
{
|
||||
return this.argAsFactionFlag(idx, def, true);
|
||||
}
|
||||
public FactionFlag argAsFactionFlag(int idx)
|
||||
public FFlag argAsFactionFlag(int idx)
|
||||
{
|
||||
return this.argAsFactionFlag(idx, null);
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.ChatColor;
|
||||
import com.massivecraft.factions.Conf;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.integration.SpoutFeatures;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Permission;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
|
||||
@ -34,11 +34,11 @@ public abstract class FRelationCommand extends FCommand
|
||||
Faction them = this.argAsFaction(0);
|
||||
if (them == null) return;
|
||||
|
||||
if ( ! them.isNormal())
|
||||
/*if ( ! them.isNormal())
|
||||
{
|
||||
msg("<b>Nope! You can't.");
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (them == myFaction)
|
||||
{
|
||||
@ -64,13 +64,13 @@ public abstract class FRelationCommand extends FCommand
|
||||
myFaction.msg(currentRelationColor+them.getTag()+"<i> were informed that you wish to be "+targetRelation.getColor()+targetRelation);
|
||||
}
|
||||
|
||||
if ( targetRelation != Rel.NEUTRAL && them.getFlag(FactionFlag.PEACEFUL))
|
||||
if ( targetRelation != Rel.NEUTRAL && them.getFlag(FFlag.PEACEFUL))
|
||||
{
|
||||
them.msg("<i>This will have no effect while your faction is peaceful.");
|
||||
myFaction.msg("<i>This will have no effect while their faction is peaceful.");
|
||||
}
|
||||
|
||||
if ( targetRelation != Rel.NEUTRAL && myFaction.getFlag(FactionFlag.PEACEFUL))
|
||||
if ( targetRelation != Rel.NEUTRAL && myFaction.getFlag(FFlag.PEACEFUL))
|
||||
{
|
||||
them.msg("<i>This will have no effect while their faction is peaceful.");
|
||||
myFaction.msg("<i>This will have no effect while your faction is peaceful.");
|
||||
|
@ -124,13 +124,11 @@ public class FactionsBlockListener extends BlockListener
|
||||
FLocation loc = new FLocation(location);
|
||||
Faction factionHere = Board.getFactionAt(loc);
|
||||
|
||||
Faction myFaction = me.getFaction();
|
||||
|
||||
if (FPerm.PAINBUILD.has(me, location))
|
||||
{
|
||||
if (!justCheck)
|
||||
{
|
||||
me.msg("<b>It is painful to try to "+action+" in the territory of "+factionHere.getTag(myFaction));
|
||||
me.msg("<b>It is painful to %s in the territory of %s<b>.", action, factionHere.describeTo(me));
|
||||
player.damage(Conf.actionDeniedPainAmount);
|
||||
}
|
||||
return true;
|
||||
|
@ -26,7 +26,7 @@ import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.FPlayers;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.P;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.util.MiscUtil;
|
||||
|
||||
@ -49,7 +49,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
FPlayer fplayer = FPlayers.i.get(player);
|
||||
Faction faction = Board.getFactionAt(new FLocation(player.getLocation()));
|
||||
|
||||
if ( ! faction.getFlag(FactionFlag.POWERLOSS))
|
||||
if ( ! faction.getFlag(FFlag.POWERLOSS))
|
||||
{
|
||||
fplayer.msg("<i>You didn't lose any power since the territory you died in works that way.");
|
||||
return;
|
||||
@ -101,7 +101,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
|
||||
Faction faction = Board.getFactionAt(new FLocation(loc));
|
||||
|
||||
if (faction.getFlag(FactionFlag.EXPLOSIONS) == false)
|
||||
if (faction.getFlag(FFlag.EXPLOSIONS) == false)
|
||||
{
|
||||
// faction is peaceful and has explosions set to disabled
|
||||
event.setCancelled(true);
|
||||
@ -157,7 +157,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
|
||||
// Players can not take attack damage in a SafeZone, or possibly peaceful territory
|
||||
|
||||
if (defLocFaction.getFlag(FactionFlag.PVP) == false)
|
||||
if (defLocFaction.getFlag(FFlag.PVP) == false)
|
||||
{
|
||||
if (damager instanceof Player)
|
||||
{
|
||||
@ -165,7 +165,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
attacker.msg("<i>You can't hurt other players here.");
|
||||
return false;
|
||||
}
|
||||
return defLocFaction.getFlag(FactionFlag.MONSTERS);
|
||||
return defLocFaction.getFlag(FFlag.MONSTERS);
|
||||
}
|
||||
|
||||
if ( ! (damager instanceof Player))
|
||||
@ -189,7 +189,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
Faction locFaction = Board.getFactionAt(new FLocation(attacker));
|
||||
|
||||
// so we know from above that the defender isn't in a safezone... what about the attacker, sneaky dog that he might be?
|
||||
if (locFaction.getFlag(FactionFlag.PVP) == false)
|
||||
if (locFaction.getFlag(FFlag.PVP) == false)
|
||||
{
|
||||
attacker.msg("<i>You can't hurt other players here.");
|
||||
return false;
|
||||
@ -272,7 +272,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
FLocation floc = new FLocation(event.getLocation());
|
||||
Faction faction = Board.getFactionAt(floc);
|
||||
|
||||
if (faction.getFlag(FactionFlag.MONSTERS)) return;
|
||||
if (faction.getFlag(FFlag.MONSTERS)) return;
|
||||
if ( ! Conf.monsters.contains(event.getCreatureType())) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
@ -293,7 +293,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
FLocation floc = new FLocation(target.getLocation());
|
||||
Faction faction = Board.getFactionAt(floc);
|
||||
|
||||
if (faction.getFlag(FactionFlag.MONSTERS)) return;
|
||||
if (faction.getFlag(FFlag.MONSTERS)) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -339,7 +339,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
FLocation floc = new FLocation(event.getBlock());
|
||||
Faction faction = Board.getFactionAt(floc);
|
||||
|
||||
if (faction.getFlag(FactionFlag.ENDERGRIEF)) return;
|
||||
if (faction.getFlag(FFlag.ENDERGRIEF)) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
@ -352,7 +352,7 @@ public class FactionsEntityListener extends EntityListener
|
||||
FLocation floc = new FLocation(event.getLocation());
|
||||
Faction faction = Board.getFactionAt(floc);
|
||||
|
||||
if (faction.getFlag(FactionFlag.ENDERGRIEF)) return;
|
||||
if (faction.getFlag(FFlag.ENDERGRIEF)) return;
|
||||
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
@ -341,13 +341,8 @@ public class FactionsPlayerListener extends PlayerListener
|
||||
|
||||
FPlayer me = FPlayers.i.get(player);
|
||||
|
||||
if (!me.isInOthersTerritory())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Rel rel = me.getRelationToLocation();
|
||||
if (rel.isAtLeast(Rel.ALLY))
|
||||
if (rel.isAtLeast(Rel.TRUCE))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
@ -9,7 +9,7 @@ import com.massivecraft.factions.Conf;
|
||||
*
|
||||
* The flags are either true or false.
|
||||
*/
|
||||
public enum FactionFlag
|
||||
public enum FFlag
|
||||
{
|
||||
// Faction flags
|
||||
PERMANENT("permanent", "<i>A permanent faction will never be deleted.", false, false),
|
||||
@ -33,7 +33,7 @@ public enum FactionFlag
|
||||
public final boolean defaultDefaultValue;
|
||||
public final boolean defaultDefaultChangeable;
|
||||
|
||||
private FactionFlag(final String nicename, final String desc, final boolean defaultDefaultValue, final boolean defaultDefaultChangeable)
|
||||
private FFlag(final String nicename, final String desc, final boolean defaultDefaultValue, final boolean defaultDefaultChangeable)
|
||||
{
|
||||
this.nicename = nicename;
|
||||
this.desc = desc;
|
||||
@ -73,7 +73,7 @@ public enum FactionFlag
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static FactionFlag parse(String str)
|
||||
public static FFlag parse(String str)
|
||||
{
|
||||
str = str.toLowerCase();
|
||||
if (str.startsWith("per")) return PERMANENT;
|
@ -125,7 +125,7 @@ public enum FPerm
|
||||
return ret;
|
||||
}
|
||||
|
||||
private static final String errorpattern = "<b>%s can't <h>%s<b> in the territory of %s<b>.";
|
||||
private static final String errorpattern = "<b>%s<b> can't %s in the territory of %s<b>.";
|
||||
public boolean has(RelationParticipator testSubject, FLocation floc, boolean informIfNot)
|
||||
{
|
||||
Faction factionThere = Board.getFactionAt(floc);
|
||||
|
@ -5,7 +5,7 @@ import org.bukkit.ChatColor;
|
||||
import com.massivecraft.factions.FPlayer;
|
||||
import com.massivecraft.factions.Faction;
|
||||
import com.massivecraft.factions.iface.RelationParticipator;
|
||||
import com.massivecraft.factions.struct.FactionFlag;
|
||||
import com.massivecraft.factions.struct.FFlag;
|
||||
import com.massivecraft.factions.struct.Rel;
|
||||
import com.massivecraft.factions.zcore.util.TextUtil;
|
||||
|
||||
@ -90,7 +90,7 @@ public class RelationUtil
|
||||
return Rel.MEMBER;
|
||||
}
|
||||
|
||||
if (!ignorePeaceful && (fme.getFlag(FactionFlag.PEACEFUL) || fthat.getFlag(FactionFlag.PEACEFUL)))
|
||||
if (!ignorePeaceful && (fme.getFlag(FFlag.PEACEFUL) || fthat.getFlag(FFlag.PEACEFUL)))
|
||||
{
|
||||
return Rel.TRUCE;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user