From 670d8e4a5f7e003f805b2e81ad7ba6b6b1c755b0 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Thu, 2 Oct 2014 11:45:06 +0200 Subject: [PATCH] Better flag system. Permission to change faction flags of choice. Possibility for other plugins to add faction flags, and more. --- .../java/com/massivecraft/factions/Const.java | 2 + .../java/com/massivecraft/factions/FFlag.java | 122 ---------- .../java/com/massivecraft/factions/FPerm.java | 2 + .../com/massivecraft/factions/Factions.java | 4 +- .../java/com/massivecraft/factions/Perm.java | 1 - .../factions/adapter/FFlagAdapter.java | 29 --- .../factions/cmd/CmdFactions.java | 2 - .../factions/cmd/CmdFactionsAdmin.java | 25 +- .../factions/cmd/CmdFactionsDisband.java | 4 +- .../factions/cmd/CmdFactionsFaction.java | 17 +- .../factions/cmd/CmdFactionsFlag.java | 58 +++-- .../factions/cmd/CmdFactionsHome.java | 4 +- .../factions/cmd/CmdFactionsJoin.java | 3 +- .../factions/cmd/CmdFactionsOpen.java | 56 ----- .../cmd/CmdFactionsRelationAbstract.java | 6 +- .../factions/cmd/CmdFactionsSeeChunk.java | 1 - .../factions/cmd/arg/ARFFlag.java | 51 ----- .../factions/cmd/arg/ARMFlag.java | 88 +++++++ .../massivecraft/factions/entity/Faction.java | 83 ++++--- .../factions/entity/FactionColl.java | 75 +++--- .../massivecraft/factions/entity/MConf.java | 5 +- .../massivecraft/factions/entity/MFlag.java | 214 ++++++++++++++++++ .../factions/entity/MFlagColl.java | 51 +++++ .../massivecraft/factions/entity/MPlayer.java | 5 +- ...ange.java => EventFactionsFlagChange.java} | 17 +- .../integration/dynmap/EngineDynmap.java | 8 +- .../listeners/FactionsListenerEcon.java | 8 +- .../listeners/FactionsListenerMain.java | 22 +- .../massivecraft/factions/update/OldConf.java | 9 +- .../factions/util/RelationUtil.java | 8 +- src/main/resources/plugin.yml | 3 - 31 files changed, 565 insertions(+), 418 deletions(-) delete mode 100644 src/main/java/com/massivecraft/factions/FFlag.java delete mode 100644 src/main/java/com/massivecraft/factions/adapter/FFlagAdapter.java delete mode 100644 src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java delete mode 100644 src/main/java/com/massivecraft/factions/cmd/arg/ARFFlag.java create mode 100644 src/main/java/com/massivecraft/factions/cmd/arg/ARMFlag.java create mode 100644 src/main/java/com/massivecraft/factions/entity/MFlag.java create mode 100644 src/main/java/com/massivecraft/factions/entity/MFlagColl.java rename src/main/java/com/massivecraft/factions/event/{EventFactionsOpenChange.java => EventFactionsFlagChange.java} (62%) diff --git a/src/main/java/com/massivecraft/factions/Const.java b/src/main/java/com/massivecraft/factions/Const.java index b140900f..6eb3363d 100644 --- a/src/main/java/com/massivecraft/factions/Const.java +++ b/src/main/java/com/massivecraft/factions/Const.java @@ -8,6 +8,8 @@ public class Const public static final String COLLECTION_BOARD = BASENAME_+"board"; public static final String COLLECTION_FACTION = BASENAME_+"faction"; + public static final String COLLECTION_MFLAG = BASENAME_+"mflag"; + public static final String COLLECTION_MPERM = BASENAME_+"mperm"; public static final String COLLECTION_MPLAYER = BASENAME_+"mplayer"; public static final String COLLECTION_MCONF = BASENAME_+"mconf"; diff --git a/src/main/java/com/massivecraft/factions/FFlag.java b/src/main/java/com/massivecraft/factions/FFlag.java deleted file mode 100644 index ed1c90cd..00000000 --- a/src/main/java/com/massivecraft/factions/FFlag.java +++ /dev/null @@ -1,122 +0,0 @@ -package com.massivecraft.factions; - -import java.util.LinkedHashMap; -import java.util.Map; - -import com.massivecraft.factions.entity.MConf; - - -/** - * Flags that describe the nature of a faction and it's territory. - * Can monsters spawn there? May fire spread etc? Is the faction permanent? - * These flags have nothing to do with player-permission. - * - * The flags are either true or false. - */ -public enum FFlag -{ - // -------------------------------------------- // - // ENUM - // -------------------------------------------- // - - // Faction flags - PERMANENT("permanent", "A permanent faction will never be deleted.", false), - PEACEFUL("peaceful", "Allways in truce with other factions.", false), - INFPOWER("infpower", "This flag gives the faction infinite power.", false), - // This faction has infinite power: TODO: Add faction has enough method. Replace the permanentpower level - - // (Faction) Territory flags - // If a faction later could have many different territories this would probably be in another enum - POWERLOSS("powerloss", "Is power lost on death in this territory?", true), - PVP("pvp", "Can you PVP in territory?", true), - FRIENDLYFIRE("friendlyfire", "Can friends hurt eachother here?", false), - MONSTERS("monsters", "Can monsters spawn in this territory?", true), - EXPLOSIONS("explosions", "Can explosions occur in this territory?", true), - OFFLINE_EXPLOSIONS("offlineexplosions", "Can explosions occur if faction is offline?", false), - FIRESPREAD("firespread", "Can fire spread in territory?", true), - ENDERGRIEF("endergrief", "Can endermen grief in this territory?", false), - - // END OF LIST - ; - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private final String nicename; - public String getNicename() { return this.nicename; } - - private final String desc; - public String getDescription() { return this.desc; } - - public final boolean defaultDefault; - public boolean getDefaultDefault() { return this.defaultDefault; } - - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - private FFlag(String nicename, final String desc, boolean defaultDefault) - { - this.nicename = nicename; - this.desc = desc; - this.defaultDefault = defaultDefault; - } - - // -------------------------------------------- // - // DEFAULTS - // -------------------------------------------- // - - public boolean getDefault() - { - Boolean ret = MConf.get().defaultFactionFlags.get(this); - if (ret == null) return this.getDefaultDefault(); - return ret; - } - - public static Map getDefaultDefaults() - { - Map ret = new LinkedHashMap(); - for (FFlag flag : values()) - { - ret.put(flag, flag.getDefaultDefault()); - } - return ret; - } - - // -------------------------------------------- // - // PARSE - // -------------------------------------------- // - - public static FFlag parse(String str) - { - str = str.toLowerCase(); - if (str.startsWith("per")) return PERMANENT; - if (str.startsWith("pea")) return PEACEFUL; - if (str.startsWith("i")) return INFPOWER; - if (str.startsWith("pow")) return POWERLOSS; - if (str.startsWith("pvp")) return PVP; - if (str.startsWith("fr") || str.startsWith("ff")) return FRIENDLYFIRE; - if (str.startsWith("m")) return MONSTERS; - if (str.startsWith("ex")) return EXPLOSIONS; - if (str.startsWith("o")) return OFFLINE_EXPLOSIONS; - if (str.startsWith("fi")) return FIRESPREAD; - if (str.startsWith("en")) return ENDERGRIEF; - return null; - } - - // -------------------------------------------- // - // UTIL - // -------------------------------------------- // - - public String getStateInfo(boolean value, boolean withDesc) - { - String ret = (value ? "YES" : "NOO") + " " + this.getNicename(); - if (withDesc) - { - ret += " " + this.getDescription(); - } - return ret; - } - -} diff --git a/src/main/java/com/massivecraft/factions/FPerm.java b/src/main/java/com/massivecraft/factions/FPerm.java index a7d80c19..32e412f9 100644 --- a/src/main/java/com/massivecraft/factions/FPerm.java +++ b/src/main/java/com/massivecraft/factions/FPerm.java @@ -39,6 +39,7 @@ public enum FPerm ACCESS(false, "access", "grant territory", Rel.LEADER, Rel.OFFICER), DISBAND(false, "disband", "disband the faction", Rel.LEADER), PERMS(false, "perms", "manage permissions", Rel.LEADER), + FLAGS(false, "flags", "manage flags", Rel.LEADER), // END OF LIST ; @@ -118,6 +119,7 @@ public enum FPerm if (str.startsWith("t")) return TERRITORY; if (str.startsWith("di")) return DISBAND; if (str.startsWith("pe")) return PERMS; + if (str.startsWith("f")) return FLAGS; return null; } diff --git a/src/main/java/com/massivecraft/factions/Factions.java b/src/main/java/com/massivecraft/factions/Factions.java index fd43b801..9411e3b4 100644 --- a/src/main/java/com/massivecraft/factions/Factions.java +++ b/src/main/java/com/massivecraft/factions/Factions.java @@ -2,7 +2,6 @@ package com.massivecraft.factions; import com.massivecraft.factions.adapter.BoardAdapter; import com.massivecraft.factions.adapter.BoardMapAdapter; -import com.massivecraft.factions.adapter.FFlagAdapter; import com.massivecraft.factions.adapter.FPermAdapter; import com.massivecraft.factions.adapter.FactionPreprocessAdapter; import com.massivecraft.factions.adapter.RelAdapter; @@ -25,6 +24,7 @@ import com.massivecraft.factions.entity.Board; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.MFlagColl; import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.entity.MConfColl; import com.massivecraft.factions.integration.dynmap.IntegrationDynmap; @@ -119,6 +119,7 @@ public class Factions extends MassivePlugin // Initialize Database this.databaseInitialized = false; + MFlagColl.get().init(); MConfColl.get().init(); UpdateUtil.update(); MPlayerColl.get().init(); @@ -184,7 +185,6 @@ public class Factions extends MassivePlugin .registerTypeAdapter(Board.MAP_TYPE, BoardMapAdapter.get()) .registerTypeAdapter(Rel.class, RelAdapter.get()) .registerTypeAdapter(FPerm.class, FPermAdapter.get()) - .registerTypeAdapter(FFlag.class, FFlagAdapter.get()) ; } diff --git a/src/main/java/com/massivecraft/factions/Perm.java b/src/main/java/com/massivecraft/factions/Perm.java index 9eed2237..21055147 100644 --- a/src/main/java/com/massivecraft/factions/Perm.java +++ b/src/main/java/com/massivecraft/factions/Perm.java @@ -24,7 +24,6 @@ public enum Perm DISBAND("disband"), FACTION("faction"), FLAG("flag"), - FLAG_SET("flag.set"), HOME("home"), HOME_OTHER("home.other"), INVITE("invite"), diff --git a/src/main/java/com/massivecraft/factions/adapter/FFlagAdapter.java b/src/main/java/com/massivecraft/factions/adapter/FFlagAdapter.java deleted file mode 100644 index 55c7f9dc..00000000 --- a/src/main/java/com/massivecraft/factions/adapter/FFlagAdapter.java +++ /dev/null @@ -1,29 +0,0 @@ -package com.massivecraft.factions.adapter; - -import java.lang.reflect.Type; - -import com.massivecraft.factions.FFlag; -import com.massivecraft.massivecore.xlib.gson.JsonDeserializationContext; -import com.massivecraft.massivecore.xlib.gson.JsonDeserializer; -import com.massivecraft.massivecore.xlib.gson.JsonElement; -import com.massivecraft.massivecore.xlib.gson.JsonParseException; - -public class FFlagAdapter implements JsonDeserializer -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static FFlagAdapter i = new FFlagAdapter(); - public static FFlagAdapter get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public FFlag deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException - { - return FFlag.parse(json.getAsString()); - } -} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java index f958e7a1..ccfc835f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactions.java @@ -26,7 +26,6 @@ public class CmdFactions extends FactionsCommand public CmdFactionsDescription cmdFactionsDescription = new CmdFactionsDescription(); public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome(); public CmdFactionsUnsethome cmdFactionsUnsethome = new CmdFactionsUnsethome(); - public CmdFactionsOpen cmdFactionsOpen = new CmdFactionsOpen(); public CmdFactionsInvite cmdFactionsInvite = new CmdFactionsInvite(); public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick(); public CmdFactionsTitle cmdFactionsTitle = new CmdFactionsTitle(); @@ -72,7 +71,6 @@ public class CmdFactions extends FactionsCommand this.addSubCommand(this.cmdFactionsDescription); this.addSubCommand(this.cmdFactionsSethome); this.addSubCommand(this.cmdFactionsUnsethome); - this.addSubCommand(this.cmdFactionsOpen); this.addSubCommand(this.cmdFactionsInvite); this.addSubCommand(this.cmdFactionsKick); this.addSubCommand(this.cmdFactionsTitle); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java index 1b8adbc7..c62d6e1d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAdmin.java @@ -4,6 +4,8 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.Txt; public class CmdFactionsAdmin extends FactionsCommand { @@ -20,7 +22,6 @@ public class CmdFactionsAdmin extends FactionsCommand this.addOptionalArg("on/off", "flip"); // Requirements - // this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.ADMIN.node)); } @@ -30,22 +31,22 @@ public class CmdFactionsAdmin extends FactionsCommand @Override public void perform() - { + { + // Args Boolean target = this.arg(0, ARBoolean.get(), !msender.isUsingAdminMode()); if (target == null) return; + // Apply msender.setUsingAdminMode(target); - if (msender.isUsingAdminMode()) - { - msender.msg("You have enabled admin bypass mode."); - Factions.get().log(msender.getId() + " has ENABLED admin bypass mode."); - } - else - { - msender.msg("You have disabled admin bypass mode."); - Factions.get().log(msender.getId() + " DISABLED admin bypass mode."); - } + // Inform + String desc = Txt.parse(msender.isUsingAdminMode() ? "ENABLED" : "DISABLED"); + + String messageYou = Txt.parse("%s %s admin bypass mode.", msender.getDisplayName(msender), desc); + String messageLog = Txt.parse("%s %s admin bypass mode.", msender.getDisplayName(IdUtil.getConsole()), desc); + + msender.sendMessage(messageYou); + Factions.get().log(messageLog); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java index a21b24f7..874e0732 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -2,13 +2,13 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.EventFactionsDisband; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; @@ -49,7 +49,7 @@ public class CmdFactionsDisband extends FactionsCommand if ( ! FPerm.DISBAND.has(msender, faction, true)) return; // Verify - if (faction.getFlag(FFlag.PERMANENT)) + if (faction.getFlag(MFlag.getPermanent())) { msg("This faction is designated as permanent, so you cannot disband it."); return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java index 78c0a4bc..eede25ac 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java @@ -8,11 +8,11 @@ import java.util.Map; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Perm; import com.massivecraft.factions.PlayerRoleComparator; import com.massivecraft.factions.Rel; @@ -59,6 +59,12 @@ public class CmdFactionsFaction extends FactionsCommand // INFO: Title msg(Txt.titleize("Faction " + faction.getName(msender))); + // INFO: Id (admin mode output only) + if (msender.isUsingAdminMode()) + { + msg("ID: %s", faction.getId()); + } + // INFO: Description msg("Description: %s", faction.getDescription()); @@ -71,7 +77,8 @@ public class CmdFactionsFaction extends FactionsCommand msg("Age: %s", ageString); // INFO: Open - msg("Open: "+(faction.isOpen() ? "Yes, anyone can join" : "No, only invited people can join")); + // TODO: Why hardcode displaying the open flag only? We should rather display everything publicly editable. + msg("Open: "+(faction.getFlag(MFlag.getOpen()) ? "Yes, anyone can join" : "No, only invited people can join")); // INFO: Power double powerBoost = faction.getPowerBoost(); @@ -113,12 +120,12 @@ public class CmdFactionsFaction extends FactionsCommand // Display important flags // TODO: Find the non default flags, and display them instead. - if (faction.getFlag(FFlag.PERMANENT)) + if (faction.getFlag(MFlag.getPermanent())) { msg("This faction is permanent - remaining even with no followers."); } - if (faction.getFlag(FFlag.PEACEFUL)) + if (faction.getFlag(MFlag.getPeaceful())) { msg("This faction is peaceful - in truce with everyone."); } @@ -129,7 +136,7 @@ public class CmdFactionsFaction extends FactionsCommand // List the relations to other factions Map> relationNames = faction.getFactionNamesPerRelation(msender, true); - if (faction.getFlag(FFlag.PEACEFUL)) + if (faction.getFlag(MFlag.getPeaceful())) { sendMessage(Txt.parse("In Truce with: *everyone*")); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java index b31379e8..11da036d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java @@ -1,10 +1,12 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.FFlag; +import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Perm; -import com.massivecraft.factions.cmd.arg.ARFFlag; +import com.massivecraft.factions.cmd.arg.ARMFlag; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.MFlag; +import com.massivecraft.factions.event.EventFactionsFlagChange; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -36,39 +38,67 @@ public class CmdFactionsFlag extends FactionsCommand @Override public void perform() { + // Arg: Faction Faction faction = this.arg(0, ARFaction.get(), msenderFaction); if (faction == null) return; + // Case: Show All if ( ! this.argIsSet(1)) { msg(Txt.titleize("Flags for " + faction.describeTo(msender, true))); - for (FFlag flag : FFlag.values()) + for (MFlag mflag : MFlag.getAll()) { - msg(flag.getStateInfo(faction.getFlag(flag), true)); + if (!mflag.isVisible() && !msender.isUsingAdminMode()) continue; + msg(mflag.getStateInfo(faction.getFlag(mflag), true)); } return; } - FFlag flag = this.arg(1, ARFFlag.get()); - if (flag == null) return; + // Arg: MFlag + MFlag mflag = this.arg(1, ARMFlag.get()); + if (mflag == null) return; + // Case: Show One if ( ! this.argIsSet(2)) { msg(Txt.titleize("Flag for " + faction.describeTo(msender, true))); - msg(flag.getStateInfo(faction.getFlag(flag), true)); + msg(mflag.getStateInfo(faction.getFlag(mflag), true)); return; } + // Do the sender have the right to change flags for this faction? + if ( ! FPerm.PERMS.has(msender, faction, true)) return; + + // Is this flag editable? + if (!msender.isUsingAdminMode() && !mflag.isEditable()) + { + msg("The flag %s is not editable.", mflag.getName()); + return; + } + + // Arg: Target Value Boolean targetValue = this.arg(2, ARBoolean.get()); if (targetValue == null) return; - - // Do the sender have the right to change flags? - if ( ! Perm.FLAG_SET.has(sender, true)) return; - // Do the change - msg(Txt.titleize("Flag for " + faction.describeTo(msender, true))); - faction.setFlag(flag, targetValue); - msg(flag.getStateInfo(faction.getFlag(flag), true)); + // Event + EventFactionsFlagChange event = new EventFactionsFlagChange(sender, faction, mflag, targetValue); + event.run(); + if (event.isCancelled()) return; + targetValue = event.isNewValue(); + + // Apply + faction.setFlag(mflag, targetValue); + + // Inform + String stateInfo = mflag.getStateInfo(faction.getFlag(mflag), true); + if (msender.getFaction() != faction) + { + // Send message to sender + msg("%s set a flag for %s", msender.describeTo(msender, true), faction.describeTo(msender, true)); + msg(stateInfo); + } + faction.msg("%s set a flag for %s", msender.describeTo(faction, true), faction.describeTo(faction, true)); + faction.msg(stateInfo); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java index 4a1c276a..41557854 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -4,7 +4,6 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; @@ -12,6 +11,7 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.EventFactionsHomeTeleport; @@ -98,7 +98,7 @@ public class CmdFactionsHome extends FactionsCommandHome ( MConf.get().homesTeleportAllowedEnemyDistance > 0 && - factionHere.getFlag(FFlag.PVP) + factionHere.getFlag(MFlag.getPvp()) && ( ! msender.isInOwnTerritory() diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java index e2b18dd4..6bcf3e92 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java @@ -5,6 +5,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARMPlayer; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.EventFactionsMembershipChange; @@ -79,7 +80,7 @@ public class CmdFactionsJoin extends FactionsCommand return; } - if( ! (faction.isOpen() || faction.isInvited(mplayer) || msender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false))) + if( ! (faction.getFlag(MFlag.getOpen()) || faction.isInvited(mplayer) || msender.isUsingAdminMode() || Perm.JOIN_ANY.has(sender, false))) { msg("This faction requires invitation."); if (samePlayer) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java deleted file mode 100644 index 909ac0a5..00000000 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Perm; -import com.massivecraft.factions.Rel; -import com.massivecraft.factions.cmd.req.ReqHasFaction; -import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; -import com.massivecraft.factions.event.EventFactionsOpenChange; -import com.massivecraft.massivecore.cmd.arg.ARBoolean; -import com.massivecraft.massivecore.cmd.req.ReqHasPerm; - -public class CmdFactionsOpen extends FactionsCommand -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public CmdFactionsOpen() - { - // Aliases - this.addAliases("open"); - - // Args - this.addOptionalArg("yes/no", "toggle"); - - // Requirements - this.addRequirements(ReqHasPerm.get(Perm.OPEN.node)); - this.addRequirements(ReqHasFaction.get()); - this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public void perform() - { - // Args - Boolean newOpen = this.arg(0, ARBoolean.get(), !msenderFaction.isOpen()); - if (newOpen == null) return; - - // Event - EventFactionsOpenChange event = new EventFactionsOpenChange(sender, msenderFaction, newOpen); - event.run(); - if (event.isCancelled()) return; - newOpen = event.isNewOpen(); - - // Apply - msenderFaction.setOpen(newOpen); - - // Inform - String descTarget = msenderFaction.isOpen() ? "open" : "closed"; - msenderFaction.msg("%s changed the faction to %s.", msender.describeTo(msenderFaction, true), descTarget); - } - -} diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index bf07e27a..4925a5c9 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARFaction; @@ -8,6 +7,7 @@ import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.event.EventFactionsRelationChange; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -89,13 +89,13 @@ public abstract class CmdFactionsRelationAbstract extends FactionsCommand // TODO: The ally case should work!! // * this might have to be bumped up to make that happen, & allow ALLY,NEUTRAL only - if ( newRelation != Rel.TRUCE && otherFaction.getFlag(FFlag.PEACEFUL)) + if ( newRelation != Rel.TRUCE && otherFaction.getFlag(MFlag.getPeaceful())) { otherFaction.msg("This will have no effect while your faction is peaceful."); msenderFaction.msg("This will have no effect while their faction is peaceful."); } - if ( newRelation != Rel.TRUCE && msenderFaction.getFlag(FFlag.PEACEFUL)) + if ( newRelation != Rel.TRUCE && msenderFaction.getFlag(MFlag.getPeaceful())) { otherFaction.msg("This will have no effect while their faction is peaceful."); msenderFaction.msg("This will have no effect while your faction is peaceful."); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java index 04c42331..bf62935a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java @@ -24,7 +24,6 @@ public class CmdFactionsSeeChunk extends FactionsCommand this.addAliases("sc", "seechunk"); // Requirements - // this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.SEE_CHUNK.node)); this.addRequirements(ReqIsPlayer.get()); } diff --git a/src/main/java/com/massivecraft/factions/cmd/arg/ARFFlag.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARFFlag.java deleted file mode 100644 index 4545548c..00000000 --- a/src/main/java/com/massivecraft/factions/cmd/arg/ARFFlag.java +++ /dev/null @@ -1,51 +0,0 @@ -package com.massivecraft.factions.cmd.arg; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.bukkit.command.CommandSender; - -import com.massivecraft.factions.FFlag; -import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect; -import com.massivecraft.massivecore.util.Txt; - -public class ARFFlag extends ARAbstractSelect -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static ARFFlag i = new ARFFlag(); - public static ARFFlag get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public String typename() - { - return "faction flag"; - } - - @Override - public FFlag select(String str, CommandSender sender) - { - return FFlag.parse(str); - } - - @Override - public Collection altNames(CommandSender sender) - { - List ret = new ArrayList(); - - for (FFlag fflag : FFlag.values()) - { - ret.add(Txt.getNicedEnum(fflag)); - } - - return ret; - } - -} diff --git a/src/main/java/com/massivecraft/factions/cmd/arg/ARMFlag.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARMFlag.java new file mode 100644 index 00000000..6e362fb5 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/cmd/arg/ARMFlag.java @@ -0,0 +1,88 @@ +package com.massivecraft.factions.cmd.arg; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; + +import org.bukkit.command.CommandSender; + +import com.massivecraft.factions.entity.MFlag; +import com.massivecraft.massivecore.cmd.arg.ARAbstractSelect; +import com.massivecraft.massivecore.util.Txt; + +public class ARMFlag extends ARAbstractSelect +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static ARMFlag i = new ARMFlag(); + public static ARMFlag get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public String typename() + { + return "faction flag"; + } + + @Override + public MFlag select(String arg, CommandSender sender) + { + if (arg == null) return null; + arg = getComparable(arg); + + // Algorithmic General Detection + int startswithCount = 0; + MFlag startswith = null; + for (MFlag mflag : MFlag.getAll()) + { + String comparable = getComparable(mflag); + if (comparable.equals(arg)) return mflag; + if (comparable.startsWith(arg)) + { + startswith = mflag; + startswithCount++; + } + } + + if (startswithCount == 1) + { + return startswith; + } + + // Nothing found + return null; + } + + @Override + public Collection altNames(CommandSender sender) + { + List ret = new ArrayList(); + + for (MFlag mflag : MFlag.getAll()) + { + ret.add(Txt.upperCaseFirst(mflag.getName())); + } + + return ret; + } + + // -------------------------------------------- // + // UTIL + // -------------------------------------------- // + + public static String getComparable(String string) + { + return string.toLowerCase(); + } + + public static String getComparable(MFlag mflag) + { + return getComparable(mflag.getName()); + } + +} diff --git a/src/main/java/com/massivecraft/factions/entity/Faction.java b/src/main/java/com/massivecraft/factions/entity/Faction.java index 204aa310..274351f4 100644 --- a/src/main/java/com/massivecraft/factions/entity/Faction.java +++ b/src/main/java/com/massivecraft/factions/entity/Faction.java @@ -9,7 +9,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.massivecraft.factions.EconomyParticipator; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FactionEqualsPredictate; import com.massivecraft.factions.Factions; @@ -48,10 +47,9 @@ public class Faction extends Entity implements EconomyParticipator this.setCreatedAtMillis(that.createdAtMillis); this.setHome(that.home); this.setPowerBoost(that.powerBoost); - this.setOpen(that.open); this.setInvitedPlayerIds(that.invitedPlayerIds); this.setRelationWishes(that.relationWishes); - this.setFlags(that.flags); + this.setFlagIds(that.flags); this.setPerms(that.perms); return this; @@ -108,7 +106,7 @@ public class Faction extends Entity implements EconomyParticipator // If the faction is open they can. // If the faction is closed an invite is required. // Null means default. - private Boolean open = null; + // private Boolean open = null; // This is the ids of the invited players. // They are actually "senderIds" since you can invite "@console" to your faction. @@ -121,7 +119,7 @@ public class Faction extends Entity implements EconomyParticipator // The flag overrides are modifications to the default values. // Null means default. - private Map flags = null; + private Map flags = null; // The perm overrides are modifications to the default values. // Null means default. @@ -338,6 +336,7 @@ public class Faction extends Entity implements EconomyParticipator // FIELD: open // -------------------------------------------- // + /* public boolean isDefaultOpen() { return MConf.get().defaultFactionOpen; @@ -363,7 +362,7 @@ public class Faction extends Entity implements EconomyParticipator // Mark as changed this.changed(); - } + }*/ // -------------------------------------------- // // FIELD: invitedPlayerIds @@ -538,45 +537,53 @@ public class Faction extends Entity implements EconomyParticipator // RAW - public Map getFlags() + public Map getFlags() { - Map ret = new LinkedHashMap(); - - for (FFlag fflag : FFlag.values()) + // We start with default values ... + Map ret = new LinkedHashMap(); + for (MFlag mflag : MFlag.getAll()) { - ret.put(fflag, fflag.getDefault()); + ret.put(mflag, mflag.isStandard()); } + // ... and if anything is explicitly set ... if (this.flags != null) { - for (Entry entry : this.flags.entrySet()) + // ... we we use that info. + for (Entry entry : this.flags.entrySet()) { - ret.put(entry.getKey(), entry.getValue()); + String id = entry.getKey(); + if (id == null) continue; + + MFlag mflag = MFlag.get(id); + if (mflag == null) continue; + + ret.put(mflag, entry.getValue()); } } return ret; } - public void setFlags(Map flags) + public void setFlagIds(Map flags) { // Clean input - Map target; - if (flags == null) + Map target = null; + if (flags != null) { - target = null; - } - else - { - target = new LinkedHashMap(flags); + // We start out with what was suggested + target = new LinkedHashMap(flags); + // However if the context is fully live we try to throw some default values away. if (this.attached() && Factions.get().isDatabaseInitialized()) { - Iterator> iter = target.entrySet().iterator(); + Iterator> iter = target.entrySet().iterator(); while (iter.hasNext()) { - Entry entry = iter.next(); - if (entry.getKey().getDefault() == entry.getValue()) + Entry entry = iter.next(); + String id = entry.getKey(); + MFlag mflag = MFlag.get(id); + if (mflag != null && mflag.isStandard() == entry.getValue()) { iter.remove(); } @@ -596,15 +603,25 @@ public class Faction extends Entity implements EconomyParticipator this.changed(); } + public void setFlags(Map flags) + { + Map flagIds = new LinkedHashMap(); + for (Entry entry : flags.entrySet()) + { + flagIds.put(entry.getKey().getId(), entry.getValue()); + } + setFlagIds(flagIds); + } + // FINER - public boolean getFlag(FFlag flag) + public boolean getFlag(MFlag flag) { return this.getFlags().get(flag); } - public void setFlag(FFlag flag, boolean value) + public void setFlag(MFlag flag, boolean value) { - Map flags = this.getFlags(); + Map flags = this.getFlags(); flags.put(flag, value); this.setFlags(flags); } @@ -776,7 +793,7 @@ public class Faction extends Entity implements EconomyParticipator public double getPower() { - if (this.getFlag(FFlag.INFPOWER)) return 999999; + if (this.getFlag(MFlag.getInfpower())) return 999999; double ret = 0; for (MPlayer mplayer : this.getMPlayers()) @@ -797,7 +814,7 @@ public class Faction extends Entity implements EconomyParticipator public double getPowerMax() { - if (this.getFlag(FFlag.INFPOWER)) return 999999; + if (this.getFlag(MFlag.getInfpower())) return 999999; double ret = 0; for (MPlayer mplayer : this.getMPlayers()) @@ -956,7 +973,7 @@ public class Faction extends Entity implements EconomyParticipator public void promoteNewLeader() { if ( ! this.isNormal()) return; - if (this.getFlag(FFlag.PERMANENT) && MConf.get().permanentFactionsDisableLeaderPromotion) return; + if (this.getFlag(MFlag.getPermanent()) && MConf.get().permanentFactionsDisableLeaderPromotion) return; MPlayer oldLeader = this.getLeader(); @@ -970,7 +987,7 @@ public class Faction extends Entity implements EconomyParticipator if (replacements == null || replacements.isEmpty()) { // faction leader is the only member; one-man faction - if (this.getFlag(FFlag.PERMANENT)) + if (this.getFlag(MFlag.getPermanent())) { if (oldLeader != null) { @@ -1032,8 +1049,8 @@ public class Faction extends Entity implements EconomyParticipator public boolean isExplosionsAllowed() { - boolean explosions = this.getFlag(FFlag.EXPLOSIONS); - boolean offlineexplosions = this.getFlag(FFlag.OFFLINE_EXPLOSIONS); + boolean explosions = this.getFlag(MFlag.getExplosions()); + boolean offlineexplosions = this.getFlag(MFlag.getOfflineexplosions()); boolean online = this.isFactionConsideredOnline(); return (online && explosions) || (!online && offlineexplosions); diff --git a/src/main/java/com/massivecraft/factions/entity/FactionColl.java b/src/main/java/com/massivecraft/factions/entity/FactionColl.java index 9ac463d6..dc9ff4c4 100644 --- a/src/main/java/com/massivecraft/factions/entity/FactionColl.java +++ b/src/main/java/com/massivecraft/factions/entity/FactionColl.java @@ -8,7 +8,6 @@ import com.massivecraft.massivecore.store.Coll; import com.massivecraft.massivecore.store.MStore; import com.massivecraft.massivecore.util.Txt; import com.massivecraft.factions.Const; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Rel; @@ -93,19 +92,19 @@ public class FactionColl extends Coll faction.setName(ChatColor.DARK_GREEN+"Wilderness"); faction.setDescription(null); - faction.setOpen(false); - faction.setFlag(FFlag.PERMANENT, true); - faction.setFlag(FFlag.PEACEFUL, false); - 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.OFFLINE_EXPLOSIONS, true); - faction.setFlag(FFlag.FIRESPREAD, true); - faction.setFlag(FFlag.ENDERGRIEF, true); + faction.setFlag(MFlag.getOpen(), false); + faction.setFlag(MFlag.getPermanent(), true); + faction.setFlag(MFlag.getPeaceful(), false); + faction.setFlag(MFlag.getInfpower(), true); + faction.setFlag(MFlag.getPowerloss(), true); + faction.setFlag(MFlag.getPvp(), true); + faction.setFlag(MFlag.getFriendlyire(), false); + faction.setFlag(MFlag.getMonsters(), true); + faction.setFlag(MFlag.getExplosions(), true); + faction.setFlag(MFlag.getOfflineexplosions(), true); + faction.setFlag(MFlag.getFirespread(), true); + faction.setFlag(MFlag.getEndergrief(), true); faction.setPermittedRelations(FPerm.BUILD, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); @@ -126,19 +125,19 @@ public class FactionColl extends Coll faction.setName("SafeZone"); faction.setDescription("Free from PVP and monsters"); - faction.setOpen(false); - 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.OFFLINE_EXPLOSIONS, false); - faction.setFlag(FFlag.FIRESPREAD, false); - faction.setFlag(FFlag.ENDERGRIEF, false); + faction.setFlag(MFlag.getOpen(), false); + faction.setFlag(MFlag.getPermanent(), true); + faction.setFlag(MFlag.getPeaceful(), true); + faction.setFlag(MFlag.getInfpower(), true); + faction.setFlag(MFlag.getPowerloss(), false); + faction.setFlag(MFlag.getPvp(), false); + faction.setFlag(MFlag.getFriendlyire(), false); + faction.setFlag(MFlag.getMonsters(), false); + faction.setFlag(MFlag.getExplosions(), false); + faction.setFlag(MFlag.getOfflineexplosions(), false); + faction.setFlag(MFlag.getFirespread(), false); + faction.setFlag(MFlag.getEndergrief(), false); faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(FPerm.CONTAINER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); @@ -159,19 +158,19 @@ public class FactionColl extends Coll faction.setName("WarZone"); faction.setDescription("Not the safest place to be"); - faction.setOpen(false); - 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.OFFLINE_EXPLOSIONS, true); - faction.setFlag(FFlag.FIRESPREAD, true); - faction.setFlag(FFlag.ENDERGRIEF, true); + faction.setFlag(MFlag.getOpen(), false); + faction.setFlag(MFlag.getPermanent(), true); + faction.setFlag(MFlag.getPeaceful(), true); + faction.setFlag(MFlag.getInfpower(), true); + faction.setFlag(MFlag.getPowerloss(), true); + faction.setFlag(MFlag.getPvp(), true); + faction.setFlag(MFlag.getFriendlyire(), true); + faction.setFlag(MFlag.getMonsters(), true); + faction.setFlag(MFlag.getExplosions(), true); + faction.setFlag(MFlag.getOfflineexplosions(), true); + faction.setFlag(MFlag.getFirespread(), true); + faction.setFlag(MFlag.getEndergrief(), true); faction.setPermittedRelations(FPerm.DOOR, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); faction.setPermittedRelations(FPerm.CONTAINER, Rel.LEADER, Rel.OFFICER, Rel.MEMBER, Rel.RECRUIT, Rel.ALLY, Rel.TRUCE, Rel.NEUTRAL, Rel.ENEMY); @@ -197,7 +196,7 @@ public class FactionColl extends Coll for (Faction faction : this.getAll()) { int landCount = faction.getLandCount(); - if (!faction.getFlag(FFlag.PEACEFUL) && landCount > 0) + if (!faction.getFlag(MFlag.getPeaceful()) && landCount > 0) { List players = faction.getMPlayers(); int playerCount = players.size(); diff --git a/src/main/java/com/massivecraft/factions/entity/MConf.java b/src/main/java/com/massivecraft/factions/entity/MConf.java index cb180c53..5c2b45dd 100644 --- a/src/main/java/com/massivecraft/factions/entity/MConf.java +++ b/src/main/java/com/massivecraft/factions/entity/MConf.java @@ -12,7 +12,6 @@ import org.bukkit.Material; import org.bukkit.entity.EntityType; import org.bukkit.event.EventPriority; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Rel; @@ -105,8 +104,6 @@ public class MConf extends Entity public Rel defaultPlayerRole = Rel.RECRUIT; public double defaultPlayerPower = 0.0; - public boolean defaultFactionOpen = false; - public Map defaultFactionFlags = FFlag.getDefaultDefaults(); public Map> defaultFactionPerms = FPerm.getDefaultDefaults(); // -------------------------------------------- // @@ -429,7 +426,7 @@ public class MConf extends Entity public double econCostName = 0.0; public double econCostDescription = 0.0; public double econCostTitle = 0.0; - public double econCostOpen = 0.0; + public double econCostFlag = 0.0; public Map econRelCost = MUtil.map( Rel.ENEMY, 0.0, diff --git a/src/main/java/com/massivecraft/factions/entity/MFlag.java b/src/main/java/com/massivecraft/factions/entity/MFlag.java new file mode 100644 index 00000000..1f2a97ac --- /dev/null +++ b/src/main/java/com/massivecraft/factions/entity/MFlag.java @@ -0,0 +1,214 @@ +package com.massivecraft.factions.entity; + +import java.util.List; + +import com.massivecraft.massivecore.PredictateIsRegistered; +import com.massivecraft.massivecore.Prioritized; +import com.massivecraft.massivecore.Registerable; +import com.massivecraft.massivecore.store.Entity; +import com.massivecraft.massivecore.util.Txt; + +public class MFlag extends Entity implements Prioritized, Registerable +{ + // -------------------------------------------- // + // CONSTANTS + // -------------------------------------------- // + + public final static transient String ID_OPEN = "open"; + public final static transient String ID_MONSTERS = "monsters"; + public final static transient String ID_POWERLOSS = "powerloss"; + public final static transient String ID_PVP = "pvp"; + public final static transient String ID_FRIENDLYFIRE = "friendlyfire"; + public final static transient String ID_EXPLOSIONS = "explosions"; + public final static transient String ID_OFFLINEEXPLOSIONS = "offlineexplosions"; + public final static transient String ID_FIRESPREAD = "firespread"; + public final static transient String ID_ENDERGRIEF = "endergrief"; + public final static transient String ID_PERMANENT = "permanent"; + public final static transient String ID_PEACEFUL = "peaceful"; + public final static transient String ID_INFPOWER = "infpower"; + + public final static transient int PRIORITY_OPEN = 1000; + public final static transient int PRIORITY_MONSTERS = 2000; + public final static transient int PRIORITY_POWERLOSS = 3000; + public final static transient int PRIORITY_PVP = 4000; + public final static transient int PRIORITY_FRIENDLYFIRE = 5000; + public final static transient int PRIORITY_EXPLOSIONS = 6000; + public final static transient int PRIORITY_OFFLINEEXPLOSIONS = 7000; + public final static transient int PRIORITY_FIRESPREAD = 8000; + public final static transient int PRIORITY_ENDERGRIEF = 9000; + public final static transient int PRIORITY_PERMANENT = 10000; + public final static transient int PRIORITY_PEACEFUL = 11000; + public final static transient int PRIORITY_INFPOWER = 12000; + + // -------------------------------------------- // + // META: CORE + // -------------------------------------------- // + + public static MFlag get(Object oid) + { + return MFlagColl.get().get(oid); + } + + public static List getAll() + { + return MFlagColl.get().getAll(PredictateIsRegistered.get()); + } + + public static void setupStandardFlags() + { + getOpen(); + getMonsters(); + getPowerloss(); + getPvp(); + getFriendlyire(); + getExplosions(); + getOfflineexplosions(); + getFirespread(); + getEndergrief(); + getPermanent(); + getPeaceful(); + getInfpower(); + } + + public static MFlag getOpen() { return getCreative(PRIORITY_OPEN, ID_OPEN, ID_OPEN, "Open factions can be joined without invite.", false, true, true); } + public static MFlag getMonsters() { return getCreative(PRIORITY_MONSTERS, ID_MONSTERS, ID_MONSTERS, "Can monsters spawn in this territory?", false, true, true); } + public static MFlag getPowerloss() { return getCreative(PRIORITY_POWERLOSS, ID_POWERLOSS, ID_POWERLOSS, "Is power lost on death in this territory?", true, false, true); } + public static MFlag getPvp() { return getCreative(PRIORITY_PVP, ID_PVP, ID_PVP, "Can you PVP in territory?", true, false, true); } + public static MFlag getFriendlyire() { return getCreative(PRIORITY_FRIENDLYFIRE, ID_FRIENDLYFIRE, ID_FRIENDLYFIRE, "Can friends hurt eachother here?", false, false, true); } + public static MFlag getExplosions() { return getCreative(PRIORITY_EXPLOSIONS, ID_EXPLOSIONS, ID_EXPLOSIONS, "Can explosions occur in this territory?", true, false, true); } + public static MFlag getOfflineexplosions() { return getCreative(PRIORITY_OFFLINEEXPLOSIONS, ID_OFFLINEEXPLOSIONS, ID_OFFLINEEXPLOSIONS, "Can explosions occur if faction is offline?", false, false, true); } + public static MFlag getFirespread() { return getCreative(PRIORITY_FIRESPREAD, ID_FIRESPREAD, ID_FIRESPREAD, "Can fire spread in territory?", true, false, true); } + public static MFlag getEndergrief() { return getCreative(PRIORITY_ENDERGRIEF, ID_ENDERGRIEF, ID_ENDERGRIEF, "Can endermen grief in this territory?", false, false, true); } + public static MFlag getPermanent() { return getCreative(PRIORITY_PERMANENT, ID_PERMANENT, ID_PERMANENT, "A permanent faction will never be deleted.", false, false, true); } + public static MFlag getPeaceful() { return getCreative(PRIORITY_PEACEFUL, ID_PEACEFUL, ID_PEACEFUL, "Always in truce with other factions.", false, false, true); } + public static MFlag getInfpower() { return getCreative(PRIORITY_INFPOWER, ID_INFPOWER, ID_INFPOWER, "This flag gives the faction infinite power.", false, false, true); } + + public static MFlag getCreative(int priority, String id, String name, String desc, boolean standard, boolean editable, boolean visible) + { + MFlag ret = MFlagColl.get().get(id, false); + if (ret != null) + { + ret.setRegistered(true); + return ret; + } + + ret = new MFlag(priority, name, desc, standard, editable, visible); + MFlagColl.get().attach(ret, id); + ret.setRegistered(true); + ret.sync(); + + return ret; + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public MFlag load(MFlag that) + { + this.priority = that.priority; + this.name = that.name; + this.desc = that.desc; + this.standard = that.standard; + this.editable = that.editable; + this.visible = that.visible; + + return this; + } + + // -------------------------------------------- // + // TRANSIENT FIELDS (Registered) + // -------------------------------------------- // + + private transient boolean registered = false; + public boolean isRegistered() { return this.registered; } + public void setRegistered(boolean registered) { this.registered = registered; } + + // -------------------------------------------- // + // FIELDS + // -------------------------------------------- // + + // The sort order priority 1 is high up, 99999 is far down. + private int priority = 0; + @Override public int getPriority() { return this.priority; } + public MFlag setPriority(int priority) { this.priority = priority; this.changed(); return this; } + + // Nice name / Display name + // Example: "monsters" + private String name = "defaultName"; + public String getName() { return this.name; } + public MFlag setName(String name) { this.name = name; this.changed(); return this; } + + // Short description + // Example: "Can monsters spawn in this territory?" + private String desc = "defaultDesc"; + public String getDesc() { return this.desc; } + public MFlag setDesc(String desc) { this.desc = desc; this.changed(); return this; } + + // Standard value + // Example: false (per default monsters do not spawn in faction territory) + private boolean standard = true; + public boolean isStandard() { return this.standard; } + public MFlag setStandard(boolean standard) { this.standard = standard; this.changed(); return this; } + + // If the flag is editable by the faction leader (or however the flag permission is configured) + // Example: true (if players want to turn mob spawning on I guess they should be able to) + private boolean editable = false; + public boolean isEditable() { return this.editable; } + public MFlag setEditable(boolean editable) { this.editable = editable; this.changed(); return this; } + + // If the flag is visible or hidden. + // Example: true (yeah we need to see this flag) + // Explanation: Some flags are rendered meaningless by other plugins. Say we have a creative mode server without any mobs. The server owner might want to hide this flag. + private boolean visible = true; + public boolean isVisible() { return this.visible; } + public MFlag setVisible(boolean visible) { this.visible = visible; this.changed(); return this; } + + // -------------------------------------------- // + // CONSTRUCT + // -------------------------------------------- // + + public MFlag() + { + // No argument constructor for GSON + } + + public MFlag(int priority, String name, String desc, boolean standard, boolean editable, boolean visible) + { + this.priority = priority; + this.name = name; + this.desc = desc; + this.standard = standard; + this.editable = editable; + this.visible = visible; + } + + // -------------------------------------------- // + // EXTRAS + // -------------------------------------------- // + + public String getStateInfo(boolean value, boolean withDesc) + { + String valueDesc = value ? "YES" : "NOO"; + + String color = ""; + if (!this.isVisible()) + { + color = ""; + } + else if (this.isEditable()) + { + color = ""; + } + + String ret = valueDesc + " " + color + this.getName(); + + if (withDesc) ret += " " + this.getDesc(); + + ret = Txt.parse(ret); + + return ret; + } + +} diff --git a/src/main/java/com/massivecraft/factions/entity/MFlagColl.java b/src/main/java/com/massivecraft/factions/entity/MFlagColl.java new file mode 100644 index 00000000..63502be4 --- /dev/null +++ b/src/main/java/com/massivecraft/factions/entity/MFlagColl.java @@ -0,0 +1,51 @@ +package com.massivecraft.factions.entity; + +import java.util.ArrayList; +import java.util.List; + +import com.massivecraft.factions.Const; +import com.massivecraft.factions.Factions; +import com.massivecraft.massivecore.PriorityComparator; +import com.massivecraft.massivecore.store.Coll; +import com.massivecraft.massivecore.store.MStore; + +public class MFlagColl extends Coll +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static MFlagColl i = new MFlagColl(); + public static MFlagColl get() { return i; } + private MFlagColl() + { + super(Const.COLLECTION_MFLAG, MFlag.class, MStore.getDb(), Factions.get(), false, false, true, null, PriorityComparator.get()); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public void init() + { + super.init(); + MFlag.setupStandardFlags(); + } + + // -------------------------------------------- // + // EXTRAS + // -------------------------------------------- // + + public List getAll(boolean registered) + { + List ret = new ArrayList(); + for (MFlag mflag : this.getAll()) + { + if (mflag.isRegistered() != registered) continue; + ret.add(mflag); + } + return ret; + } + +} diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayer.java b/src/main/java/com/massivecraft/factions/entity/MPlayer.java index 1e082dd1..109ffca3 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayer.java @@ -7,7 +7,6 @@ import org.bukkit.ChatColor; import org.bukkit.entity.Player; import com.massivecraft.factions.EconomyParticipator; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Lang; @@ -635,7 +634,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato { Faction myFaction = this.getFaction(); - boolean permanent = myFaction.getFlag(FFlag.PERMANENT); + boolean permanent = myFaction.getFlag(MFlag.getPermanent()); if (myFaction.getMPlayers().size() > 1) { @@ -725,7 +724,7 @@ public class MPlayer extends SenderEntity implements EconomyParticipato int ownedLand = newFaction.getLandCount(); - if (mconf.claimedLandsMax != 0 && ownedLand >= mconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER)) + if (mconf.claimedLandsMax != 0 && ownedLand >= mconf.claimedLandsMax && ! newFaction.getFlag(MFlag.getInfpower())) { msg("Limit reached. You can't claim more land."); return false; diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsOpenChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsFlagChange.java similarity index 62% rename from src/main/java/com/massivecraft/factions/event/EventFactionsOpenChange.java rename to src/main/java/com/massivecraft/factions/event/EventFactionsFlagChange.java index b6758f4e..de70309d 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsOpenChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsFlagChange.java @@ -4,8 +4,9 @@ import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.MFlag; -public class EventFactionsOpenChange extends EventFactionsAbstractSender +public class EventFactionsFlagChange extends EventFactionsAbstractSender { // -------------------------------------------- // // REQUIRED EVENT CODE @@ -22,19 +23,23 @@ public class EventFactionsOpenChange extends EventFactionsAbstractSender private final Faction faction; public Faction getFaction() { return this.faction; } - private boolean newOpen; - public boolean isNewOpen() { return this.newOpen; } - public void setNewOpen(boolean newOpen) { this.newOpen = newOpen; } + private final MFlag flag; + public MFlag getFlag() { return this.flag; } + + private boolean newValue; + public boolean isNewValue() { return this.newValue; } + public void setNewValue(boolean newValue) { this.newValue = newValue; } // -------------------------------------------- // // CONSTRUCT // -------------------------------------------- // - public EventFactionsOpenChange(CommandSender sender, Faction faction, boolean newOpen) + public EventFactionsFlagChange(CommandSender sender, Faction faction, MFlag flag, boolean newValue) { super(sender); this.faction = faction; - this.newOpen = newOpen; + this.flag = flag; + this.newValue = newValue; } } diff --git a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java index 8e0c91df..bafeffd3 100644 --- a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java @@ -22,7 +22,6 @@ import org.dynmap.markers.MarkerSet; import org.dynmap.markers.PlayerSet; import org.dynmap.utils.TileFlags; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Rel; import com.massivecraft.factions.TerritoryAccess; @@ -31,6 +30,7 @@ import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.EngineAbstract; import com.massivecraft.massivecore.money.Money; @@ -759,10 +759,10 @@ public class EngineDynmap extends EngineAbstract // Flags and Open Map flags = new HashMap(); - flags.put("open", faction.isOpen()); - for (FFlag fflag : FFlag.values()) + for (MFlag mflag : MFlag.getAll()) { - flags.put(fflag.getNicename(), faction.getFlag(fflag)); + if (!mflag.isVisible()) continue; + flags.put(mflag.getName(), faction.getFlag(mflag)); } for (Entry entry : flags.entrySet()) { diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java index d51909f8..40b3a605 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java @@ -21,7 +21,7 @@ import com.massivecraft.factions.event.EventFactionsInvitedChange; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.event.EventFactionsNameChange; -import com.massivecraft.factions.event.EventFactionsOpenChange; +import com.massivecraft.factions.event.EventFactionsFlagChange; import com.massivecraft.factions.event.EventFactionsRelationChange; import com.massivecraft.factions.event.EventFactionsTitleChange; import com.massivecraft.factions.integration.Econ; @@ -209,10 +209,10 @@ public class FactionsListenerEcon implements Listener } @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) - public void payForCommand(EventFactionsOpenChange event) + public void payForCommand(EventFactionsFlagChange event) { - Double cost = MConf.get().econCostOpen; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsOpen.getDesc(); + Double cost = MConf.get().econCostFlag; + String desc = Factions.get().getOuterCmdFactions().cmdFactionsFlag.getDesc(); payForAction(event, cost, desc); } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java index fe128567..6b02add7 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -54,12 +54,12 @@ import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.projectiles.ProjectileSource; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Rel; import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; @@ -195,7 +195,7 @@ public class FactionsListenerMain implements Listener // ... and powerloss can happen here ... Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player)); - if (!faction.getFlag(FFlag.POWERLOSS)) + if (!faction.getFlag(MFlag.getPowerloss())) { mplayer.msg("You didn't lose any power since the territory you died in works that way."); return; @@ -298,7 +298,7 @@ public class FactionsListenerMain implements Listener Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs); // ... PVP flag may cause a damage block ... - if (defenderPsFaction.getFlag(FFlag.PVP) == false) + if (defenderPsFaction.getFlag(MFlag.getPvp()) == false) { if (eattacker == null) { @@ -316,7 +316,7 @@ public class FactionsListenerMain implements Listener } return ret; } - return defenderPsFaction.getFlag(FFlag.MONSTERS); + return defenderPsFaction.getFlag(MFlag.getMonsters()); } // ... and if the attacker is a player ... @@ -334,7 +334,7 @@ public class FactionsListenerMain implements Listener // ... PVP flag may cause a damage block ... // (just checking the defender as above isn't enough. What about the attacker? It could be in a no-pvp area) // NOTE: This check is probably not that important but we could keep it anyways. - if (attackerPsFaction.getFlag(FFlag.PVP) == false) + if (attackerPsFaction.getFlag(MFlag.getPvp()) == false) { ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); if (!ret && notify) uattacker.msg("PVP is disabled in %s.", attackerPsFaction.describeTo(uattacker)); @@ -371,7 +371,7 @@ public class FactionsListenerMain implements Listener Rel relation = defendFaction.getRelationTo(attackFaction); // Check the relation - if (udefender.hasFaction() && relation.isFriend() && defenderPsFaction.getFlag(FFlag.FRIENDLYFIRE) == false) + if (udefender.hasFaction() && relation.isFriend() && defenderPsFaction.getFlag(MFlag.getFriendlyire()) == false) { ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); if (!ret && notify) uattacker.msg("You can't hurt %s.", relation.getDescPlayerMany()); @@ -474,7 +474,7 @@ public class FactionsListenerMain implements Listener command = command.trim(); // ... the command may be denied for members of permanent factions ... - if (mplayer.hasFaction() && mplayer.getFaction().getFlag(FFlag.PERMANENT) && containsCommand(command, MConf.get().denyCommandsPermanentFactionMember)) + if (mplayer.hasFaction() && mplayer.getFaction().getFlag(MFlag.getPermanent()) && containsCommand(command, MConf.get().denyCommandsPermanentFactionMember)) { mplayer.msg("You can't use \"/%s\" as member of a permanent faction.", command); event.setCancelled(true); @@ -528,7 +528,7 @@ public class FactionsListenerMain implements Listener // ... at a place where monsters are forbidden ... PS ps = PS.valueOf(event.getLocation()); Faction faction = BoardColl.get().getFactionAt(ps); - if (faction.getFlag(FFlag.MONSTERS)) return; + if (faction.getFlag(MFlag.getMonsters())) return; // ... block the spawn. event.setCancelled(true); @@ -547,7 +547,7 @@ public class FactionsListenerMain implements Listener // ... at a place where monsters are forbidden ... PS ps = PS.valueOf(target); Faction faction = BoardColl.get().getFactionAt(ps); - if (faction.getFlag(FFlag.MONSTERS)) return; + if (faction.getFlag(MFlag.getMonsters())) return; // ... then if ghast target nothing ... if (event.getEntityType() == EntityType.GHAST) @@ -651,7 +651,7 @@ public class FactionsListenerMain implements Listener // ... and the faction there has endergrief disabled ... PS ps = PS.valueOf(event.getBlock()); Faction faction = BoardColl.get().getFactionAt(ps); - if (faction.getFlag(FFlag.ENDERGRIEF)) return; + if (faction.getFlag(MFlag.getEndergrief())) return; // ... stop the block alteration. event.setCancelled(true); @@ -667,7 +667,7 @@ public class FactionsListenerMain implements Listener PS ps = PS.valueOf(block); Faction faction = BoardColl.get().getFactionAt(ps); - if (faction.getFlag(FFlag.FIRESPREAD)) return; + if (faction.getFlag(MFlag.getFirespread())) return; // then cancel the event. cancellable.setCancelled(true); diff --git a/src/main/java/com/massivecraft/factions/update/OldConf.java b/src/main/java/com/massivecraft/factions/update/OldConf.java index 0853ea88..6732fb8d 100644 --- a/src/main/java/com/massivecraft/factions/update/OldConf.java +++ b/src/main/java/com/massivecraft/factions/update/OldConf.java @@ -6,7 +6,6 @@ import java.util.Set; import org.bukkit.event.EventPriority; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.entity.MConf; @@ -28,8 +27,8 @@ public class OldConf extends Entity mconf.defaultPlayerFactionId = this.defaultPlayerFactionId; mconf.defaultPlayerRole = this.defaultPlayerRole; mconf.defaultPlayerPower = this.defaultPlayerPower; - mconf.defaultFactionOpen = this.defaultFactionOpen; - mconf.defaultFactionFlags = this.defaultFactionFlags; + //mconf.defaultFactionOpen = this.defaultFactionOpen; + //mconf.defaultFactionFlags = this.defaultFactionFlags; mconf.defaultFactionPerms = this.defaultFactionPerms; mconf.powerMax = this.powerMax; mconf.powerMin = this.powerMin; @@ -78,7 +77,7 @@ public class OldConf extends Entity mconf.econCostName = this.econCostName; mconf.econCostDescription = this.econCostDescription; mconf.econCostTitle = this.econCostTitle; - mconf.econCostOpen = this.econCostOpen; + mconf.econCostFlag = this.econCostOpen; mconf.econRelCost = this.econRelCost; mconf.bankEnabled = this.bankEnabled; mconf.bankFactionPaysCosts = this.bankFactionPaysCosts; @@ -108,7 +107,7 @@ public class OldConf extends Entity public double defaultPlayerPower = 0.0; public boolean defaultFactionOpen = false; - public Map defaultFactionFlags = null; + //public Map defaultFactionFlags = null; public Map> defaultFactionPerms = null; // -------------------------------------------- // diff --git a/src/main/java/com/massivecraft/factions/util/RelationUtil.java b/src/main/java/com/massivecraft/factions/util/RelationUtil.java index 6c3b5212..13f10983 100644 --- a/src/main/java/com/massivecraft/factions/util/RelationUtil.java +++ b/src/main/java/com/massivecraft/factions/util/RelationUtil.java @@ -2,9 +2,9 @@ package com.massivecraft.factions.util; import org.bukkit.ChatColor; -import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Rel; import com.massivecraft.factions.RelationParticipator; +import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; @@ -108,7 +108,7 @@ public class RelationUtil //P.p.log("getRelationOfThatToMe it was a player and role is "+ret); } } - else if (!ignorePeaceful && (thatFaction.getFlag(FFlag.PEACEFUL) || myFaction.getFlag(FFlag.PEACEFUL))) + else if (!ignorePeaceful && (thatFaction.getFlag(MFlag.getPeaceful()) || myFaction.getFlag(MFlag.getPeaceful()))) { ret = Rel.TRUCE; } @@ -137,12 +137,12 @@ public class RelationUtil Faction thatFaction = getFaction(that); if (thatFaction != null && thatFaction != getFaction(me)) { - if (thatFaction.getFlag(FFlag.FRIENDLYFIRE) == true) + if (thatFaction.getFlag(MFlag.getFriendlyire()) == true) { return MConf.get().colorFriendlyFire; } - if (thatFaction.getFlag(FFlag.PVP) == false) + if (thatFaction.getFlag(MFlag.getPvp()) == false) { return MConf.get().colorNoPVP; } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index ecb2d553..a868487c 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -24,7 +24,6 @@ permissions: factions.disband: {description: disband faction, default: false} factions.faction: {description: show faction information, default: false} factions.flag: {description: manage faction flags, default: false} - factions.flag.set: {description: set faction flags, default: false} factions.home: {description: teleport to faction home, default: false} factions.home.other: {description: teleport to another faction home, default: false} factions.invite: {description: set if player is invited, default: false} @@ -82,7 +81,6 @@ permissions: factions.disband: true factions.faction: true factions.flag: true - factions.flag.set: true factions.home: true factions.home.other: true factions.invite: true @@ -136,7 +134,6 @@ permissions: default: false children: factions.kit.rank1: true - factions.flag.set: true factions.powerboost: true factions.join.any: true factions.join.others: true