From 46161f61dbb1180b75210eab6ad4183035e43cf0 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Mon, 24 Oct 2011 02:33:30 +0200 Subject: [PATCH] Started to implement special faction behavior --- plugin.yml | 2 +- src/com/massivecraft/factions/Conf.java | 12 +- src/com/massivecraft/factions/FPlayer.java | 8 +- src/com/massivecraft/factions/Faction.java | 38 +++--- src/com/massivecraft/factions/Factions.java | 127 +++++++++++++----- .../massivecraft/factions/cmd/CmdDisband.java | 4 +- .../massivecraft/factions/cmd/CmdFlag.java | 6 +- .../massivecraft/factions/cmd/CmdHome.java | 4 +- .../massivecraft/factions/cmd/CmdJoin.java | 4 +- .../massivecraft/factions/cmd/CmdKick.java | 4 +- .../massivecraft/factions/cmd/CmdList.java | 6 +- .../massivecraft/factions/cmd/CmdPerm.java | 1 - .../massivecraft/factions/cmd/CmdShow.java | 10 +- .../massivecraft/factions/cmd/FCommand.java | 14 +- .../factions/cmd/FRelationCommand.java | 10 +- .../listeners/FactionsBlockListener.java | 4 +- .../listeners/FactionsEntityListener.java | 20 +-- .../listeners/FactionsPlayerListener.java | 7 +- .../struct/{FactionFlag.java => FFlag.java} | 6 +- .../massivecraft/factions/struct/FPerm.java | 4 +- .../factions/util/RelationUtil.java | 4 +- 21 files changed, 179 insertions(+), 116 deletions(-) rename src/com/massivecraft/factions/struct/{FactionFlag.java => FFlag.java} (91%) diff --git a/plugin.yml b/plugin.yml index ff1c5f9d..afe9dbcf 100644 --- a/plugin.yml +++ b/plugin.yml @@ -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] diff --git a/src/com/massivecraft/factions/Conf.java b/src/com/massivecraft/factions/Conf.java index eccc2b86..c85d718f 100644 --- a/src/com/massivecraft/factions/Conf.java +++ b/src/com/massivecraft/factions/Conf.java @@ -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 factionFlagDefaults; - public static Map factionFlagIsChangeable; + public static Map factionFlagDefaults; + public static Map factionFlagIsChangeable; public static Map> factionPermDefaults; // Power @@ -276,9 +276,9 @@ public class Conf { baseCommandAliases.add("f"); - factionFlagDefaults = new LinkedHashMap(); - factionFlagIsChangeable = new LinkedHashMap(); - for (FactionFlag flag : FactionFlag.values()) + factionFlagDefaults = new LinkedHashMap(); + factionFlagIsChangeable = new LinkedHashMap(); + for (FFlag flag : FFlag.values()) { factionFlagDefaults.put(flag, flag.defaultDefaultValue); factionFlagIsChangeable.put(flag, flag.defaultDefaultChangeable); diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index b2b38f27..6c4c4759 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -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) { diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index 144f472a..f4e669a5 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -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 flagOverrides; // Contains the modifications to the default values - public boolean getFlag(FactionFlag flag) + private Map 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 value) + public void setPermittedRelations(FPerm perm, Set 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 temp = new HashSet(); + 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(); + this.flagOverrides = new LinkedHashMap(); this.permOverrides = new LinkedHashMap>(); } @@ -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 getFPlayersWhereRole(Rel role) { ArrayList ret = new ArrayList(); - if ( ! this.isNormal()) return ret; + //if ( ! this.isNormal()) return ret; for (FPlayer fplayer : FPlayers.i.get()) { @@ -408,14 +415,9 @@ public class Faction extends Entity implements EconomyParticipator public void memberLoggedOff() { - if (this.isNormal()) - { - lastPlayerLoggedOffTime = System.currentTimeMillis(); - } + lastPlayerLoggedOffTime = System.currentTimeMillis(); } - - //----------------------------------------------// // Messages //----------------------------------------------// diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 250de1c2..04accb9f 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -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 { 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"); + + this.setFlagsForSafeZone(faction); } - 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 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 return this.get("0"); } - public Faction getSafeZone() - { - return this.get("-1"); - } - - public Faction getWarZone() - { - return this.get("-2"); - } - - //----------------------------------------------// // Faction tag //----------------------------------------------// diff --git a/src/com/massivecraft/factions/cmd/CmdDisband.java b/src/com/massivecraft/factions/cmd/CmdDisband.java index 693851fe..e1e140a8 100644 --- a/src/com/massivecraft/factions/cmd/CmdDisband.java +++ b/src/com/massivecraft/factions/cmd/CmdDisband.java @@ -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("This faction is designated as permanent, so you cannot disband it."); return; diff --git a/src/com/massivecraft/factions/cmd/CmdFlag.java b/src/com/massivecraft/factions/cmd/CmdFlag.java index 6b7ee848..b8844d28 100644 --- a/src/com/massivecraft/factions/cmd/CmdFlag.java +++ b/src/com/massivecraft/factions/cmd/CmdFlag.java @@ -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)) { diff --git a/src/com/massivecraft/factions/cmd/CmdHome.java b/src/com/massivecraft/factions/cmd/CmdHome.java index 0db42cf7..ef8c5eab 100644 --- a/src/com/massivecraft/factions/cmd/CmdHome.java +++ b/src/com/massivecraft/factions/cmd/CmdHome.java @@ -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() diff --git a/src/com/massivecraft/factions/cmd/CmdJoin.java b/src/com/massivecraft/factions/cmd/CmdJoin.java index 3df0b4c2..14b870c4 100644 --- a/src/com/massivecraft/factions/cmd/CmdJoin.java +++ b/src/com/massivecraft/factions/cmd/CmdJoin.java @@ -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("You may only join normal factions. This is a system faction."); return; - } + }*/ if (faction == myFaction) { diff --git a/src/com/massivecraft/factions/cmd/CmdKick.java b/src/com/massivecraft/factions/cmd/CmdKick.java index 477732f6..52b4fb18 100644 --- a/src/com/massivecraft/factions/cmd/CmdKick.java +++ b/src/com/massivecraft/factions/cmd/CmdKick.java @@ -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()) diff --git a/src/com/massivecraft/factions/cmd/CmdList.java b/src/com/massivecraft/factions/cmd/CmdList.java index 12e68aa0..5d595614 100644 --- a/src/com/massivecraft/factions/cmd/CmdList.java +++ b/src/com/massivecraft/factions/cmd/CmdList.java @@ -38,9 +38,11 @@ public class CmdList extends FCommand if ( ! payForCommand(Conf.econCostList, "to list the factions", "for listing the factions")) return; ArrayList factionList = new ArrayList(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(){ diff --git a/src/com/massivecraft/factions/cmd/CmdPerm.java b/src/com/massivecraft/factions/cmd/CmdPerm.java index cf2d8cdd..bef2231d 100644 --- a/src/com/massivecraft/factions/cmd/CmdPerm.java +++ b/src/com/massivecraft/factions/cmd/CmdPerm.java @@ -61,7 +61,6 @@ public class CmdPerm extends FCommand return; } - // TODO: Awesomesause parser for deltas... Set 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? diff --git a/src/com/massivecraft/factions/cmd/CmdShow.java b/src/com/massivecraft/factions/cmd/CmdShow.java index 898abe9d..eb75ce51 100644 --- a/src/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/com/massivecraft/factions/cmd/CmdShow.java @@ -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("Description: %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("Joining: "+(faction.getOpen() ? "no invitation is needed" : "invitation is required")+peaceStatus); msg("Land / Power / Maxpower: %d/%d/%d", faction.getLandRounded(), faction.getPowerRounded(), faction.getPowerMaxRounded()); - if (faction.getFlag(FactionFlag.PERMANENT)) + if (faction.getFlag(FFlag.PERMANENT)) { msg("This faction is permanent, remaining even with no members."); } diff --git a/src/com/massivecraft/factions/cmd/FCommand.java b/src/com/massivecraft/factions/cmd/FCommand.java index 680fd342..b4007f38 100644 --- a/src/com/massivecraft/factions/cmd/FCommand.java +++ b/src/com/massivecraft/factions/cmd/FCommand.java @@ -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

} // 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

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); } diff --git a/src/com/massivecraft/factions/cmd/FRelationCommand.java b/src/com/massivecraft/factions/cmd/FRelationCommand.java index b08ac9b8..0d946c08 100644 --- a/src/com/massivecraft/factions/cmd/FRelationCommand.java +++ b/src/com/massivecraft/factions/cmd/FRelationCommand.java @@ -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("Nope! You can't."); return; - } + }*/ if (them == myFaction) { @@ -64,13 +64,13 @@ public abstract class FRelationCommand extends FCommand myFaction.msg(currentRelationColor+them.getTag()+" 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("This will have no effect while your faction is peaceful."); myFaction.msg("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("This will have no effect while their faction is peaceful."); myFaction.msg("This will have no effect while your faction is peaceful."); diff --git a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java index c8ed4974..65ba9d36 100644 --- a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -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("It is painful to try to "+action+" in the territory of "+factionHere.getTag(myFaction)); + me.msg("It is painful to %s in the territory of %s.", action, factionHere.describeTo(me)); player.damage(Conf.actionDeniedPainAmount); } return true; diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index e23f2bb3..6d6cfdba 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -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("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("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("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); } diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index a179a010..9383b26a 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -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; } diff --git a/src/com/massivecraft/factions/struct/FactionFlag.java b/src/com/massivecraft/factions/struct/FFlag.java similarity index 91% rename from src/com/massivecraft/factions/struct/FactionFlag.java rename to src/com/massivecraft/factions/struct/FFlag.java index 07181d49..19f7777a 100644 --- a/src/com/massivecraft/factions/struct/FactionFlag.java +++ b/src/com/massivecraft/factions/struct/FFlag.java @@ -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", "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; diff --git a/src/com/massivecraft/factions/struct/FPerm.java b/src/com/massivecraft/factions/struct/FPerm.java index 9ec6c076..ec2fbe24 100644 --- a/src/com/massivecraft/factions/struct/FPerm.java +++ b/src/com/massivecraft/factions/struct/FPerm.java @@ -81,7 +81,7 @@ public enum FPerm { rels.add("

"+rel.nicename); } - ret += TextUtil.implode(rels, " + "); + ret += TextUtil.implode(rels, "+"); if (withDesc) { @@ -125,7 +125,7 @@ public enum FPerm return ret; } - private static final String errorpattern = "%s can't %s in the territory of %s."; + private static final String errorpattern = "%s can't %s in the territory of %s."; public boolean has(RelationParticipator testSubject, FLocation floc, boolean informIfNot) { Faction factionThere = Board.getFactionAt(floc); diff --git a/src/com/massivecraft/factions/util/RelationUtil.java b/src/com/massivecraft/factions/util/RelationUtil.java index 7c0f9f49..f019f1d2 100644 --- a/src/com/massivecraft/factions/util/RelationUtil.java +++ b/src/com/massivecraft/factions/util/RelationUtil.java @@ -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; }