From 529ae45ede7c63264fda25b9d28e03ecd565b9ee Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Wed, 17 Sep 2014 13:17:33 +0200 Subject: [PATCH] Step 1 in many removing the universe system. Untested and lacking auto convert features. --- .../java/com/massivecraft/factions/Const.java | 4 +- .../massivecraft/factions/EngineIdUpdate.java | 125 --- .../java/com/massivecraft/factions/FFlag.java | 6 +- .../java/com/massivecraft/factions/FPerm.java | 18 +- .../factions/FactionEqualsPredictate.java | 4 +- .../com/massivecraft/factions/Factions.java | 15 +- .../factions/PlayerRoleComparator.java | 6 +- .../factions/TerritoryAccess.java | 19 +- .../factions/chat/tag/ChatTagName.java | 8 +- .../factions/chat/tag/ChatTagNameforce.java | 8 +- .../factions/chat/tag/ChatTagRelcolor.java | 10 +- .../factions/chat/tag/ChatTagRole.java | 8 +- .../factions/chat/tag/ChatTagRoleprefix.java | 8 +- .../chat/tag/ChatTagRoleprefixforce.java | 8 +- .../factions/chat/tag/ChatTagTitle.java | 8 +- .../factions/cmd/CmdFactionsAccess.java | 2 - .../cmd/CmdFactionsAccessAbstract.java | 6 +- .../cmd/CmdFactionsAccessFaction.java | 6 +- .../factions/cmd/CmdFactionsAccessPlayer.java | 8 +- .../factions/cmd/CmdFactionsAutoClaim.java | 10 +- .../factions/cmd/CmdFactionsClaim.java | 4 +- .../factions/cmd/CmdFactionsCreate.java | 19 +- .../factions/cmd/CmdFactionsDemote.java | 6 +- .../factions/cmd/CmdFactionsDescription.java | 6 +- .../factions/cmd/CmdFactionsDisband.java | 16 +- .../factions/cmd/CmdFactionsFaction.java | 19 +- .../factions/cmd/CmdFactionsFlag.java | 4 +- .../factions/cmd/CmdFactionsHome.java | 30 +- .../factions/cmd/CmdFactionsInvite.java | 6 +- .../factions/cmd/CmdFactionsJoin.java | 17 +- .../factions/cmd/CmdFactionsKick.java | 13 +- .../factions/cmd/CmdFactionsLeader.java | 14 +- .../factions/cmd/CmdFactionsLeave.java | 2 - .../factions/cmd/CmdFactionsList.java | 8 +- .../factions/cmd/CmdFactionsMap.java | 6 +- .../factions/cmd/CmdFactionsMoney.java | 2 - .../factions/cmd/CmdFactionsMoneyBalance.java | 4 +- .../factions/cmd/CmdFactionsMoneyDeposit.java | 4 +- .../cmd/CmdFactionsMoneyTransferFf.java | 6 +- .../cmd/CmdFactionsMoneyTransferFp.java | 8 +- .../cmd/CmdFactionsMoneyTransferPf.java | 8 +- .../cmd/CmdFactionsMoneyWithdraw.java | 8 +- .../factions/cmd/CmdFactionsName.java | 14 +- .../factions/cmd/CmdFactionsOfficer.java | 6 +- .../factions/cmd/CmdFactionsOpen.java | 2 - .../factions/cmd/CmdFactionsPerm.java | 6 +- .../factions/cmd/CmdFactionsPlayer.java | 6 +- .../factions/cmd/CmdFactionsPowerBoost.java | 8 +- .../factions/cmd/CmdFactionsPromote.java | 6 +- .../cmd/CmdFactionsRelationAbstract.java | 4 +- .../factions/cmd/CmdFactionsSethome.java | 8 +- .../factions/cmd/CmdFactionsTitle.java | 6 +- .../factions/cmd/CmdFactionsUnclaim.java | 6 +- .../factions/cmd/CmdFactionsUnclaimall.java | 12 +- .../massivecraft/factions/cmd/FCommand.java | 11 +- .../factions/cmd/arg/ARFaction.java | 24 +- .../factions/cmd/arg/ARUPlayer.java | 14 +- .../cmd/req/ReqBankCommandsEnabled.java | 11 +- .../factions/cmd/req/ReqFactionsEnabled.java | 36 - .../factions/cmd/req/ReqHasFaction.java | 4 +- .../factions/cmd/req/ReqHasntFaction.java | 4 +- .../factions/cmd/req/ReqRoleIsAtLeast.java | 4 +- .../massivecraft/factions/entity/Board.java | 11 +- .../factions/entity/BoardColl.java | 56 +- .../factions/entity/BoardColls.java | 215 ----- .../massivecraft/factions/entity/Faction.java | 101 +- .../factions/entity/FactionColl.java | 92 +- .../factions/entity/FactionColls.java | 103 -- .../massivecraft/factions/entity/MConf.java | 263 +++++- .../factions/entity/MConfColl.java | 1 - .../massivecraft/factions/entity/MPlayer.java | 887 ++++++++++++++++-- .../factions/entity/MPlayerColl.java | 102 ++ .../massivecraft/factions/entity/UConf.java | 273 ------ .../factions/entity/UConfColl.java | 30 - .../factions/entity/UConfColls.java | 48 - .../massivecraft/factions/entity/UPlayer.java | 796 ---------------- .../factions/entity/UPlayerColl.java | 77 -- .../factions/entity/UPlayerColls.java | 95 -- .../massivecraft/factions/entity/XColls.java | 42 - .../event/EventFactionsAbstractSender.java | 4 +- .../event/EventFactionsChunkChange.java | 8 +- .../factions/event/EventFactionsCreate.java | 6 +- .../event/EventFactionsInvitedChange.java | 8 +- .../event/EventFactionsMembershipChange.java | 8 +- .../event/EventFactionsPowerChange.java | 8 +- .../event/EventFactionsPvpDisallowed.java | 6 +- .../event/EventFactionsTitleChange.java | 8 +- .../factions/integration/Econ.java | 59 +- .../integration/dynmap/EngineDynmap.java | 138 ++- .../herochat/ChannelFactionsAbstract.java | 6 +- .../factions/integration/lwc/EngineLwc.java | 11 +- .../listeners/FactionsListenerEcon.java | 43 +- .../listeners/FactionsListenerMain.java | 169 ++-- .../factions/mixin/PowerMixin.java | 12 +- .../factions/mixin/PowerMixinDefault.java | 24 +- .../factions/task/TaskEconLandReward.java | 10 +- .../factions/task/TaskPlayerDataRemove.java | 12 +- .../factions/task/TaskPlayerPowerUpdate.java | 14 +- .../factions/util/RelationUtil.java | 16 +- 99 files changed, 1789 insertions(+), 2662 deletions(-) delete mode 100644 src/main/java/com/massivecraft/factions/EngineIdUpdate.java delete mode 100644 src/main/java/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/BoardColls.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/FactionColls.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/UConf.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/UConfColl.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/UConfColls.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/UPlayer.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/UPlayerColl.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/UPlayerColls.java delete mode 100644 src/main/java/com/massivecraft/factions/entity/XColls.java diff --git a/src/main/java/com/massivecraft/factions/Const.java b/src/main/java/com/massivecraft/factions/Const.java index 11e89366..fc2b6412 100644 --- a/src/main/java/com/massivecraft/factions/Const.java +++ b/src/main/java/com/massivecraft/factions/Const.java @@ -7,10 +7,8 @@ public class Const public static final String BASENAME_ = BASENAME+"_"; public static final String COLLECTION_BOARD = BASENAME_+"board"; - public static final String COLLECTION_FACTION = BASENAME_+"faction"; - public static final String COLLECTION_UPLAYER = BASENAME_+"uplayer"; + public static final String COLLECTION_FACTION = BASENAME_+"faction"; public static final String COLLECTION_MPLAYER = BASENAME_+"mplayer"; - public static final String COLLECTION_UCONF = BASENAME_+"uconf"; public static final String COLLECTION_MCONF = BASENAME_+"mconf"; public static final String ASPECT = BASENAME; diff --git a/src/main/java/com/massivecraft/factions/EngineIdUpdate.java b/src/main/java/com/massivecraft/factions/EngineIdUpdate.java deleted file mode 100644 index 96afe04d..00000000 --- a/src/main/java/com/massivecraft/factions/EngineIdUpdate.java +++ /dev/null @@ -1,125 +0,0 @@ -package com.massivecraft.factions; - -import java.util.Set; - -import org.bukkit.event.EventHandler; -import org.bukkit.event.EventPriority; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.entity.Board; -import com.massivecraft.factions.entity.BoardColl; -import com.massivecraft.factions.entity.BoardColls; -import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.FactionColls; -import com.massivecraft.factions.entity.MPlayerColl; -import com.massivecraft.factions.entity.UPlayerColl; -import com.massivecraft.factions.entity.UPlayerColls; -import com.massivecraft.massivecore.EngineAbstract; -import com.massivecraft.massivecore.event.EventMassiveCoreUuidUpdate; -import com.massivecraft.massivecore.util.IdUpdateUtil; -import com.massivecraft.massivecore.util.MUtil; - -public class EngineIdUpdate extends EngineAbstract -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static EngineIdUpdate i = new EngineIdUpdate(); - public static EngineIdUpdate get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Plugin getPlugin() - { - return Factions.get(); - } - - // -------------------------------------------- // - // LISTENER - // -------------------------------------------- // - - @EventHandler(priority = EventPriority.MONITOR) - public void update(EventMassiveCoreUuidUpdate event) - { - for (FactionColl coll : FactionColls.get().getColls()) - { - for (Faction entity : coll.getAll()) - { - update(coll, entity); - } - } - - IdUpdateUtil.update(MPlayerColl.get()); - - for (UPlayerColl coll : UPlayerColls.get().getColls()) - { - IdUpdateUtil.update(coll); - } - - for (BoardColl coll : BoardColls.get().getColls()) - { - update(coll); - } - } - - public static void update(FactionColl coll, Faction entity) - { - // Before and After - Set before = entity.getInvitedPlayerIds(); - if (before == null) return; - Set after = IdUpdateUtil.update(before, true); - if (after == null) return; - - // NoChange - if (MUtil.equals(before, after)) return; - - // Apply - entity.setInvitedPlayerIds(after); - entity.sync(); - } - - public static void update(BoardColl coll) - { - for (Board board : coll.getAll()) - { - update(board); - } - } - - public static void update(Board board) - { - boolean changed = false; - for (TerritoryAccess ta : board.getMap().values()) - { - changed |= update(ta); - } - if (changed) - { - board.changed(); - board.sync(); - } - } - - public static boolean update(TerritoryAccess entity) - { - // Before and After - Set before = entity.playerIds; - if (before == null) return false; - Set after = IdUpdateUtil.update(before, true); - if (after == null) return false; - - // NoChange - if (MUtil.equals(before, after)) return false; - - // Apply - entity.playerIds = after; - //entity.sync(); - return true; - } - -} diff --git a/src/main/java/com/massivecraft/factions/FFlag.java b/src/main/java/com/massivecraft/factions/FFlag.java index bce7fb26..ed1c90cd 100644 --- a/src/main/java/com/massivecraft/factions/FFlag.java +++ b/src/main/java/com/massivecraft/factions/FFlag.java @@ -3,7 +3,7 @@ package com.massivecraft.factions; import java.util.LinkedHashMap; import java.util.Map; -import com.massivecraft.factions.entity.UConf; +import com.massivecraft.factions.entity.MConf; /** @@ -67,9 +67,9 @@ public enum FFlag // DEFAULTS // -------------------------------------------- // - public boolean getDefault(Object o) + public boolean getDefault() { - Boolean ret = UConf.get(o).defaultFactionFlags.get(this); + Boolean ret = MConf.get().defaultFactionFlags.get(this); if (ret == null) return this.getDefaultDefault(); return ret; } diff --git a/src/main/java/com/massivecraft/factions/FPerm.java b/src/main/java/com/massivecraft/factions/FPerm.java index 13241cb7..e0250001 100644 --- a/src/main/java/com/massivecraft/factions/FPerm.java +++ b/src/main/java/com/massivecraft/factions/FPerm.java @@ -7,10 +7,10 @@ import java.util.LinkedHashSet; import java.util.Map; import java.util.Set; -import com.massivecraft.factions.entity.BoardColls; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UConf; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.Txt; @@ -79,9 +79,9 @@ public enum FPerm // DEFAULTS // -------------------------------------------- // - public Set getDefault(Object o) + public Set getDefault() { - Set ret = UConf.get(o).defaultFactionPerms.get(this); + Set ret = MConf.get().defaultFactionPerms.get(this); if (ret == null) return this.getDefaultDefault(); ret = new LinkedHashSet(ret); return ret; @@ -125,7 +125,7 @@ public enum FPerm // HAS? // -------------------------------------------- // - public String createDeniedMessage(UPlayer uplayer, Faction hostFaction) + public String createDeniedMessage(MPlayer uplayer, Faction hostFaction) { String ret = Txt.parse("%s does not allow you to %s.", hostFaction.describeTo(uplayer, true), this.getDescription()); if (Perm.ADMIN.has(uplayer.getPlayer())) @@ -141,7 +141,7 @@ public enum FPerm return hostFaction.getPermittedRelations(this).contains(rel); } - public boolean has(UPlayer uplayer, Faction hostFaction, boolean verboose) + public boolean has(MPlayer uplayer, Faction hostFaction, boolean verboose) { if (uplayer.isUsingAdminMode()) return true; @@ -153,11 +153,11 @@ public enum FPerm return false; } - public boolean has(UPlayer uplayer, PS ps, boolean verboose) + public boolean has(MPlayer uplayer, PS ps, boolean verboose) { if (uplayer.isUsingAdminMode()) return true; - TerritoryAccess ta = BoardColls.get().getTerritoryAccessAt(ps); + TerritoryAccess ta = BoardColl.get().getTerritoryAccessAt(ps); Faction hostFaction = ta.getHostFaction(ps); if (this.isTerritoryPerm()) diff --git a/src/main/java/com/massivecraft/factions/FactionEqualsPredictate.java b/src/main/java/com/massivecraft/factions/FactionEqualsPredictate.java index 9ec2c2c6..40e9e1d7 100644 --- a/src/main/java/com/massivecraft/factions/FactionEqualsPredictate.java +++ b/src/main/java/com/massivecraft/factions/FactionEqualsPredictate.java @@ -4,7 +4,7 @@ import java.io.Serializable; import org.bukkit.command.CommandSender; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.Predictate; @@ -35,7 +35,7 @@ public class FactionEqualsPredictate implements Predictate, Seria @Override public boolean apply(CommandSender sender) { - UPlayer uplayer = UPlayer.get(sender); + MPlayer uplayer = MPlayer.get(sender); return this.factionId.equals(uplayer.getFactionId()); } diff --git a/src/main/java/com/massivecraft/factions/Factions.java b/src/main/java/com/massivecraft/factions/Factions.java index 1220235c..d06406e4 100644 --- a/src/main/java/com/massivecraft/factions/Factions.java +++ b/src/main/java/com/massivecraft/factions/Factions.java @@ -22,12 +22,10 @@ import com.massivecraft.factions.chat.tag.ChatTagRoleprefixforce; import com.massivecraft.factions.chat.tag.ChatTagTitle; import com.massivecraft.factions.cmd.*; import com.massivecraft.factions.entity.Board; -import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MPlayerColl; -import com.massivecraft.factions.entity.UConfColls; -import com.massivecraft.factions.entity.UPlayerColls; -import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConfColl; import com.massivecraft.factions.integration.dynmap.IntegrationDynmap; import com.massivecraft.factions.integration.dynmap.IntegrationDynmapFactions; @@ -117,11 +115,9 @@ public class Factions extends MassivePlugin this.databaseInitialized = false; MConfColl.get().init(); MPlayerColl.get().init(); - UConfColls.get().init(); - UPlayerColls.get().init(); - FactionColls.get().init(); - BoardColls.get().init(); - FactionColls.get().reindexUPlayers(); + FactionColl.get().init(); + BoardColl.get().init(); + FactionColl.get().reindexUPlayers(); this.databaseInitialized = true; // Commands @@ -129,7 +125,6 @@ public class Factions extends MassivePlugin this.outerCmdFactions.register(); // Setup Listeners - EngineIdUpdate.get().activate(); FactionsListenerMain.get().setup(); FactionsListenerChat.get().setup(); FactionsListenerExploit.get().setup(); diff --git a/src/main/java/com/massivecraft/factions/PlayerRoleComparator.java b/src/main/java/com/massivecraft/factions/PlayerRoleComparator.java index 5a585708..9ae4165a 100644 --- a/src/main/java/com/massivecraft/factions/PlayerRoleComparator.java +++ b/src/main/java/com/massivecraft/factions/PlayerRoleComparator.java @@ -2,9 +2,9 @@ package com.massivecraft.factions; import java.util.Comparator; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; -public class PlayerRoleComparator implements Comparator +public class PlayerRoleComparator implements Comparator { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -18,7 +18,7 @@ public class PlayerRoleComparator implements Comparator // -------------------------------------------- // @Override - public int compare(UPlayer o1, UPlayer o2) + public int compare(MPlayer o1, MPlayer o2) { int ret = 0; diff --git a/src/main/java/com/massivecraft/factions/TerritoryAccess.java b/src/main/java/com/massivecraft/factions/TerritoryAccess.java index a359466c..5a32e998 100644 --- a/src/main/java/com/massivecraft/factions/TerritoryAccess.java +++ b/src/main/java/com/massivecraft/factions/TerritoryAccess.java @@ -8,11 +8,8 @@ import java.util.Set; import java.util.TreeSet; import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.FactionColls; -import com.massivecraft.factions.entity.UPlayerColl; -import com.massivecraft.factions.entity.UPlayerColls; public class TerritoryAccess { @@ -99,16 +96,15 @@ public class TerritoryAccess public Faction getHostFaction(Object universe) { - return FactionColls.get().get(universe).get(this.getHostFactionId()); + return FactionColl.get().get(this.getHostFactionId()); } - public LinkedHashSet getGrantedUPlayers(Object universe) + public LinkedHashSet getGrantedUPlayers(Object universe) { - LinkedHashSet ret = new LinkedHashSet(); - UPlayerColl coll = UPlayerColls.get().get(universe); + LinkedHashSet ret = new LinkedHashSet(); for (String playerId : this.getPlayerIds()) { - ret.add(coll.get(playerId)); + ret.add(MPlayer.get(playerId)); } return ret; } @@ -116,10 +112,9 @@ public class TerritoryAccess public LinkedHashSet getGrantedFactions(Object universe) { LinkedHashSet ret = new LinkedHashSet(); - FactionColl coll = FactionColls.get().get(universe); for (String factionId : this.getFactionIds()) { - ret.add(coll.get(factionId)); + ret.add(FactionColl.get().get(factionId)); } return ret; } @@ -205,7 +200,7 @@ public class TerritoryAccess // true means elevated access // false means decreased access // null means standard access - public Boolean hasTerritoryAccess(UPlayer uplayer) + public Boolean hasTerritoryAccess(MPlayer uplayer) { if (this.getPlayerIds().contains(uplayer.getId())) return true; diff --git a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagName.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagName.java index 74ba0214..97717004 100644 --- a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagName.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagName.java @@ -4,8 +4,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public class ChatTagName extends ChatTagAbstract { @@ -24,11 +23,8 @@ public class ChatTagName extends ChatTagAbstract @Override public String getReplacement(CommandSender sender, CommandSender recipient) { - // Check disabled - if (UConf.isDisabled(sender)) return ""; - // Get entities - UPlayer usender = UPlayer.get(sender); + MPlayer usender = MPlayer.get(sender); // No "force" Faction faction = usender.getFaction(); diff --git a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagNameforce.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagNameforce.java index 7c5b6864..c25c2156 100644 --- a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagNameforce.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagNameforce.java @@ -4,8 +4,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public class ChatTagNameforce extends ChatTagAbstract { @@ -24,11 +23,8 @@ public class ChatTagNameforce extends ChatTagAbstract @Override public String getReplacement(CommandSender sender, CommandSender recipient) { - // Check disabled - if (UConf.isDisabled(sender)) return ""; - // Get entities - UPlayer usender = UPlayer.get(sender); + MPlayer usender = MPlayer.get(sender); Faction faction = usender.getFaction(); return faction.getName(); diff --git a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java index 7c23c2ed..1b112ab5 100644 --- a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRelcolor.java @@ -3,8 +3,7 @@ package com.massivecraft.factions.chat.tag; import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatTagAbstract; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public class ChatTagRelcolor extends ChatTagAbstract { @@ -23,15 +22,12 @@ public class ChatTagRelcolor extends ChatTagAbstract @Override public String getReplacement(CommandSender sender, CommandSender recipient) { - // Check disabled - if (UConf.isDisabled(sender)) return ""; - // Opt out if no recipient if (recipient == null) return null; // Get entities - UPlayer usender = UPlayer.get(sender); - UPlayer urecipient = UPlayer.get(recipient); + MPlayer usender = MPlayer.get(sender); + MPlayer urecipient = MPlayer.get(recipient); return urecipient.getRelationTo(usender).getColor().toString(); } diff --git a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRole.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRole.java index 707d5d5f..09aa4dc2 100644 --- a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRole.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRole.java @@ -3,8 +3,7 @@ package com.massivecraft.factions.chat.tag; import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatTagAbstract; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.util.Txt; public class ChatTagRole extends ChatTagAbstract @@ -24,11 +23,8 @@ public class ChatTagRole extends ChatTagAbstract @Override public String getReplacement(CommandSender sender, CommandSender recipient) { - // Check disabled - if (UConf.isDisabled(sender)) return ""; - // Get entities - UPlayer usender = UPlayer.get(sender); + MPlayer usender = MPlayer.get(sender); return Txt.upperCaseFirst(usender.getRole().toString().toLowerCase()); } diff --git a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java index 37771450..e6bb5527 100644 --- a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefix.java @@ -4,8 +4,7 @@ import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatTagAbstract; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public class ChatTagRoleprefix extends ChatTagAbstract { @@ -24,11 +23,8 @@ public class ChatTagRoleprefix extends ChatTagAbstract @Override public String getReplacement(CommandSender sender, CommandSender recipient) { - // Check disabled - if (UConf.isDisabled(sender)) return ""; - // Get entities - UPlayer usender = UPlayer.get(sender); + MPlayer usender = MPlayer.get(sender); // No "force" Faction faction = usender.getFaction(); diff --git a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java index d408a999..6356a765 100644 --- a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagRoleprefixforce.java @@ -3,8 +3,7 @@ package com.massivecraft.factions.chat.tag; import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatTagAbstract; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public class ChatTagRoleprefixforce extends ChatTagAbstract { @@ -23,11 +22,8 @@ public class ChatTagRoleprefixforce extends ChatTagAbstract @Override public String getReplacement(CommandSender sender, CommandSender recipient) { - // Check disabled - if (UConf.isDisabled(sender)) return ""; - // Get entities - UPlayer usender = UPlayer.get(sender); + MPlayer usender = MPlayer.get(sender); return usender.getRole().getPrefix(); } diff --git a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagTitle.java b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagTitle.java index fe96a894..b68a58ef 100644 --- a/src/main/java/com/massivecraft/factions/chat/tag/ChatTagTitle.java +++ b/src/main/java/com/massivecraft/factions/chat/tag/ChatTagTitle.java @@ -3,8 +3,7 @@ package com.massivecraft.factions.chat.tag; import org.bukkit.command.CommandSender; import com.massivecraft.factions.chat.ChatTagAbstract; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public class ChatTagTitle extends ChatTagAbstract { @@ -23,11 +22,8 @@ public class ChatTagTitle extends ChatTagAbstract @Override public String getReplacement(CommandSender sender, CommandSender recipient) { - // Check disabled - if (UConf.isDisabled(sender)) return ""; - // Get entities - UPlayer usender = UPlayer.get(sender); + MPlayer usender = MPlayer.get(sender); if (!usender.hasTitle()) return ""; return usender.getTitle(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java index 84c07e89..7c2c4027 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccess.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.massivecore.cmd.HelpCommand; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; @@ -32,7 +31,6 @@ public class CmdFactionsAccess extends FCommand this.addAliases("access"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.ACCESS.node)); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java index 7b2140ab..90f2b140 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessAbstract.java @@ -6,8 +6,7 @@ import java.util.List; import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.TerritoryAccess; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -32,7 +31,6 @@ public abstract class CmdFactionsAccessAbstract extends FCommand public CmdFactionsAccessAbstract() { // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqIsPlayer.get()); } @@ -44,7 +42,7 @@ public abstract class CmdFactionsAccessAbstract extends FCommand public void perform() { chunk = PS.valueOf(me).getChunk(true); - ta = BoardColls.get().getTerritoryAccessAt(chunk); + ta = BoardColl.get().getTerritoryAccessAt(chunk); hostFaction = ta.getHostFaction(usender); this.innerPerform(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java index 8869abee..9d04ada7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessFaction.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -35,7 +35,7 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract public void innerPerform() { // Args - Faction faction = this.arg(0, ARFaction.get(usender)); + Faction faction = this.arg(0, ARFaction.get()); if (faction == null) return; Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isFactionIdGranted(faction.getId())); @@ -46,7 +46,7 @@ public class CmdFactionsAccessFaction extends CmdFactionsAccessAbstract // Apply ta = ta.withFactionId(faction.getId(), newValue); - BoardColls.get().setTerritoryAccessAt(chunk, ta); + BoardColl.get().setTerritoryAccessAt(chunk, ta); // Inform this.sendAccessInfo(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java index ec325bb1..f230865e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAccessPlayer.java @@ -3,8 +3,8 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; -import com.massivecraft.factions.entity.BoardColls; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -35,7 +35,7 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract public void innerPerform() { // Args - UPlayer uplayer = this.arg(0, ARUPlayer.getAny(usender)); + MPlayer uplayer = this.arg(0, ARUPlayer.getAny()); if (uplayer == null) return; Boolean newValue = this.arg(1, ARBoolean.get(), !ta.isPlayerIdGranted(uplayer.getId())); @@ -46,7 +46,7 @@ public class CmdFactionsAccessPlayer extends CmdFactionsAccessAbstract // Apply ta = ta.withPlayerId(uplayer.getId(), newValue); - BoardColls.get().setTerritoryAccessAt(chunk, ta); + BoardColl.get().setTerritoryAccessAt(chunk, ta); // Inform this.sendAccessInfo(); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java index 0d58ee43..f5260233 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java @@ -3,9 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UConf; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; import com.massivecraft.massivecore.ps.PS; @@ -25,7 +23,6 @@ public class CmdFactionsAutoClaim extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.AUTOCLAIM.node)); this.addRequirements(ReqIsPlayer.get()); } @@ -36,12 +33,9 @@ public class CmdFactionsAutoClaim extends FCommand @Override public void perform() - { - // Check disabled - if (UConf.isDisabled(sender, sender)) return; - + { // Args - Faction forFaction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction); + Faction forFaction = this.arg(0, ARFaction.get(), usenderFaction); if (forFaction == null || forFaction == usender.getAutoClaimFaction()) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java index cab93ae4..b2a044d2 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsClaim.java @@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.task.SpiralTask; @@ -29,7 +28,6 @@ public class CmdFactionsClaim extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.CLAIM.node)); } @@ -45,7 +43,7 @@ public class CmdFactionsClaim extends FCommand Integer radius = this.arg(0, ARInteger.get(), 1); if (radius == null) return; - final Faction forFaction = this.arg(1, ARFaction.get(me), usenderFaction); + final Faction forFaction = this.arg(1, ARFaction.get(), usenderFaction); if (forFaction == null) return; // FPerm diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java index 047bc553..c49c981a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsCreate.java @@ -5,14 +5,12 @@ import java.util.ArrayList; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasntFaction; -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.event.EventFactionsCreate; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; @@ -34,7 +32,6 @@ public class CmdFactionsCreate extends FCommand this.addRequiredArg("name"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasntFaction.get()); this.addRequirements(ReqHasPerm.get(Perm.CREATE.node)); } @@ -50,15 +47,13 @@ public class CmdFactionsCreate extends FCommand String newName = this.arg(0); // Verify - FactionColl coll = FactionColls.get().get(usender); - - if (coll.isNameTaken(newName)) + if (FactionColl.get().isNameTaken(newName)) { msg("That name is already in use."); return; } - ArrayList nameValidationErrors = coll.validateName(newName); + ArrayList nameValidationErrors = FactionColl.get().validateName(newName); if (nameValidationErrors.size() > 0) { sendMessage(nameValidationErrors); @@ -69,12 +64,12 @@ public class CmdFactionsCreate extends FCommand String factionId = MStore.createId(); // Event - EventFactionsCreate createEvent = new EventFactionsCreate(sender, coll.getUniverse(), factionId, newName); + EventFactionsCreate createEvent = new EventFactionsCreate(sender, factionId, newName); createEvent.run(); if (createEvent.isCancelled()) return; // Apply - Faction faction = coll.create(factionId); + Faction faction = FactionColl.get().create(factionId); faction.setName(newName); usender.setRole(Rel.LEADER); @@ -85,7 +80,7 @@ public class CmdFactionsCreate extends FCommand // NOTE: join event cannot be cancelled or you'll have an empty faction // Inform - for (UPlayer follower : UPlayerColls.get().get(usender).getAllOnline()) + for (MPlayer follower : MPlayerColl.get().getAllOnline()) { follower.msg("%s created a new faction %s", usender.describeTo(follower, true), faction.getName(follower)); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java index 099018f7..59c07d8e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDemote.java @@ -3,8 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsDemote extends FCommand @@ -22,7 +21,6 @@ public class CmdFactionsDemote extends FCommand this.addRequiredArg("player"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.DEMOTE.node)); //To demote someone from member -> recruit you must be an officer. @@ -37,7 +35,7 @@ public class CmdFactionsDemote extends FCommand @Override public void perform() { - UPlayer you = this.arg(0, ARUPlayer.getAny(usender)); + MPlayer you = this.arg(0, ARUPlayer.getAny()); if (you == null) return; if (you.getFaction() != usenderFaction) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java index 7b17d423..89d14fce 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDescription.java @@ -2,10 +2,9 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsDescriptionChange; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.mixin.Mixin; @@ -26,7 +25,6 @@ public class CmdFactionsDescription extends FCommand this.setErrorOnToManyArgs(false); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.DESCRIPTION.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); @@ -52,7 +50,7 @@ public class CmdFactionsDescription extends FCommand usenderFaction.setDescription(newDescription); // Inform - for (UPlayer follower : usenderFaction.getUPlayers()) + for (MPlayer follower : usenderFaction.getUPlayers()) { follower.msg("%s set your faction description to:\n%s", Mixin.getDisplayName(sender, follower), usenderFaction.getDescription()); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java index 801e5589..e039f99d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -1,12 +1,11 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.event.EventFactionsDisband; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; @@ -33,7 +32,6 @@ public class CmdFactionsDisband extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.DISBAND.node)); } @@ -45,7 +43,7 @@ public class CmdFactionsDisband extends FCommand public void perform() { // Args - Faction faction = this.arg(0, ARFaction.get(usender), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), usenderFaction); if (faction == null) return; // FPerm @@ -66,14 +64,14 @@ public class CmdFactionsDisband extends FCommand // Merged Apply and Inform // Run event for each player in the faction - for (UPlayer uplayer : faction.getUPlayers()) + for (MPlayer uplayer : faction.getUPlayers()) { - EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, uplayer, FactionColls.get().get(faction).getNone(), MembershipChangeReason.DISBAND); + EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(sender, uplayer, FactionColl.get().getNone(), MembershipChangeReason.DISBAND); membershipChangeEvent.run(); } // Inform all players - for (UPlayer uplayer : UPlayerColls.get().get(usender).getAllOnline()) + for (MPlayer uplayer : MPlayerColl.get().getAllOnline()) { String who = usender.describeTo(uplayer); if (uplayer.getFaction() == faction) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java index 52226508..2db23aca 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFaction.java @@ -7,9 +7,8 @@ import java.util.List; import java.util.Map; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.integration.Econ; @@ -39,7 +38,6 @@ public class CmdFactionsFaction extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.FACTION.node)); } @@ -51,11 +49,10 @@ public class CmdFactionsFaction extends FCommand public void perform() { // Args - Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), usenderFaction); if (faction == null) return; // Data precalculation - UConf uconf = UConf.get(faction); //boolean none = faction.isNone(); boolean normal = faction.isNormal(); @@ -82,13 +79,13 @@ public class CmdFactionsFaction extends FCommand msg("Land / Power / Maxpower: %d/%d/%d %s", faction.getLandCount(), faction.getPowerRounded(), faction.getPowerMaxRounded(), boost); // show the land value - if (Econ.isEnabled(faction)) + if (Econ.isEnabled()) { long landCount = faction.getLandCount(); for (EventFactionsChunkChangeType type : EventFactionsChunkChangeType.values()) { - Double money = uconf.econChunkCost.get(type); + Double money = MConf.get().econChunkCost.get(type); if (money == null) continue; if (money == 0D) continue; money *= landCount; @@ -108,7 +105,7 @@ public class CmdFactionsFaction extends FCommand } // Show bank contents - if (UConf.get(faction).bankEnabled) + if (MConf.get().bankEnabled) { msg("Bank contains: "+Money.format(Money.get(faction))); } @@ -148,10 +145,10 @@ public class CmdFactionsFaction extends FCommand List followerNamesOnline = new ArrayList(); List followerNamesOffline = new ArrayList(); - List followers = faction.getUPlayers(); + List followers = faction.getUPlayers(); Collections.sort(followers, PlayerRoleComparator.get()); - for (UPlayer follower : followers) + for (MPlayer follower : followers) { if (follower.isOnline() && Mixin.canSee(sender, follower.getId())) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java index 204dccf8..669be843 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsFlag.java @@ -4,7 +4,6 @@ import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFFlag; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -27,7 +26,6 @@ public class CmdFactionsFlag extends FCommand this.addOptionalArg("yes/no", "read"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.FLAG.node)); } @@ -38,7 +36,7 @@ public class CmdFactionsFlag extends FCommand @Override public void perform() { - Faction faction = this.arg(0, ARFaction.get(sender), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), usenderFaction); if (faction == null) return; if ( ! this.argIsSet(1)) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java index b262b613..0ebdbc3a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -8,11 +8,10 @@ import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; -import com.massivecraft.factions.entity.BoardColls; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.EventFactionsHomeTeleport; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -34,7 +33,6 @@ public class CmdFactionsHome extends FCommand this.addAliases("home"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.HOME.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); @@ -47,16 +45,14 @@ public class CmdFactionsHome extends FCommand @Override public void perform() { - UConf uconf = UConf.get(sender); - // TODO: Hide this command on help also. - if ( ! uconf.homesEnabled) + if ( ! MConf.get().homesEnabled) { usender.msg("Sorry, Faction homes are disabled on this server."); return; } - if ( ! uconf.homesTeleportCommandEnabled) + if ( ! MConf.get().homesTeleportCommandEnabled) { usender.msg("Sorry, the ability to teleport to Faction homes is disabled on this server."); return; @@ -69,26 +65,26 @@ public class CmdFactionsHome extends FCommand return; } - if ( ! uconf.homesTeleportAllowedFromEnemyTerritory && usender.isInEnemyTerritory()) + if ( ! MConf.get().homesTeleportAllowedFromEnemyTerritory && usender.isInEnemyTerritory()) { usender.msg("You cannot teleport to your faction home while in the territory of an enemy faction."); return; } - if (!uconf.homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(usenderFaction.getHome().getWorld())) + if ( ! MConf.get().homesTeleportAllowedFromDifferentWorld && !me.getWorld().getName().equalsIgnoreCase(usenderFaction.getHome().getWorld())) { usender.msg("You cannot teleport to your faction home while in a different world."); return; } - Faction faction = BoardColls.get().getFactionAt(PS.valueOf(me)); + Faction faction = BoardColl.get().getFactionAt(PS.valueOf(me)); Location loc = me.getLocation().clone(); // if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby if ( - uconf.homesTeleportAllowedEnemyDistance > 0 + MConf.get().homesTeleportAllowedEnemyDistance > 0 && faction.getFlag(FFlag.PVP) && @@ -98,7 +94,7 @@ public class CmdFactionsHome extends FCommand ( usender.isInOwnTerritory() && - ! uconf.homesTeleportIgnoreEnemiesIfInOwnTerritory + ! MConf.get().homesTeleportIgnoreEnemiesIfInOwnTerritory ) ) ) @@ -113,7 +109,7 @@ public class CmdFactionsHome extends FCommand if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) continue; - UPlayer fp = UPlayer.get(p); + MPlayer fp = MPlayer.get(p); if (usender.getRelationTo(fp) != Rel.ENEMY) continue; @@ -121,13 +117,13 @@ public class CmdFactionsHome extends FCommand double dx = Math.abs(x - l.getX()); double dy = Math.abs(y - l.getY()); double dz = Math.abs(z - l.getZ()); - double max = uconf.homesTeleportAllowedEnemyDistance; + double max = MConf.get().homesTeleportAllowedEnemyDistance; // box-shaped distance check if (dx > max || dy > max || dz > max) continue; - usender.msg("You cannot teleport to your faction home while an enemy is within " + uconf.homesTeleportAllowedEnemyDistance + " blocks of you."); + usender.msg("You cannot teleport to your faction home while an enemy is within " + MConf.get().homesTeleportAllowedEnemyDistance + " blocks of you."); return; } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java index 630c7bf8..42102d97 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsInvite.java @@ -4,9 +4,8 @@ import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsInvitedChange; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -28,7 +27,6 @@ public class CmdFactionsInvite extends FCommand this.addOptionalArg("yes/no", "toggle"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.INVITE.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); @@ -42,7 +40,7 @@ public class CmdFactionsInvite extends FCommand public void perform() { // Args - UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender)); + MPlayer uplayer = this.arg(0, ARUPlayer.getAny()); if (uplayer == null) return; Boolean newInvited = this.arg(1, ARBoolean.get(), !usenderFaction.isInvited(uplayer)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java index 0a3e46e5..d10fbc28 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsJoin.java @@ -4,11 +4,9 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.entity.UConf; +import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -30,7 +28,6 @@ public class CmdFactionsJoin extends FCommand this.addOptionalArg("player", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.JOIN.node)); } @@ -42,10 +39,10 @@ public class CmdFactionsJoin extends FCommand public void perform() { // Args - Faction faction = this.arg(0, ARFaction.get(sender)); + Faction faction = this.arg(0, ARFaction.get()); if (faction == null) return; - UPlayer uplayer = this.arg(1, ARUPlayer.getAny(sender), usender); + MPlayer uplayer = this.arg(1, ARUPlayer.getAny(), usender); if (uplayer == null) return; Faction uplayerFaction = uplayer.getFaction(); @@ -64,9 +61,9 @@ public class CmdFactionsJoin extends FCommand return; } - if (UConf.get(faction).factionMemberLimit > 0 && faction.getUPlayers().size() >= UConf.get(faction).factionMemberLimit) + if (MConf.get().factionMemberLimit > 0 && faction.getUPlayers().size() >= MConf.get().factionMemberLimit) { - msg(" ! The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(usender), UConf.get(faction).factionMemberLimit, uplayer.describeTo(usender, false)); + msg(" ! The faction %s is at the limit of %d members, so %s cannot currently join.", faction.getName(usender), MConf.get().factionMemberLimit, uplayer.describeTo(usender, false)); return; } @@ -76,7 +73,7 @@ public class CmdFactionsJoin extends FCommand return; } - if (!UConf.get(faction).canLeaveWithNegativePower && uplayer.getPower() < 0) + if (!MConf.get().canLeaveWithNegativePower && uplayer.getPower() < 0) { msg("%s cannot join a faction with a negative power level.", uplayer.describeTo(usender, true)); return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java index 0f33a605..897e180f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsKick.java @@ -5,12 +5,10 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.FactionColl; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.entity.UConf; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -31,7 +29,6 @@ public class CmdFactionsKick extends FCommand this.addRequiredArg("player"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.KICK.node)); } @@ -43,7 +40,7 @@ public class CmdFactionsKick extends FCommand public void perform() { // Arg - UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender)); + MPlayer uplayer = this.arg(0, ARUPlayer.getAny()); if (uplayer == null) return; // Validate @@ -60,7 +57,7 @@ public class CmdFactionsKick extends FCommand return; } - if ( ! UConf.get(uplayer).canLeaveWithNegativePower && uplayer.getPower() < 0) + if ( ! MConf.get().canLeaveWithNegativePower && uplayer.getPower() < 0) { msg("You cannot kick that member until their power is positive."); return; @@ -71,7 +68,7 @@ public class CmdFactionsKick extends FCommand if (!FPerm.KICK.has(usender, uplayerFaction, true)) return; // Event - EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, uplayer, FactionColls.get().get(uplayer).getNone(), MembershipChangeReason.KICK); + EventFactionsMembershipChange event = new EventFactionsMembershipChange(sender, uplayer, FactionColl.get().getNone(), MembershipChangeReason.KICK); event.run(); if (event.isCancelled()) return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java index 16ba5ccf..e6f78f65 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeader.java @@ -4,10 +4,9 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; +import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.event.EventFactionsMembershipChange; import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; import com.massivecraft.factions.util.RelationUtil; @@ -29,7 +28,6 @@ public class CmdFactionsLeader extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.LEADER.node)); } @@ -40,13 +38,13 @@ public class CmdFactionsLeader extends FCommand @Override public void perform() { - UPlayer newLeader = this.arg(0, ARUPlayer.getAny(sender)); + MPlayer newLeader = this.arg(0, ARUPlayer.getAny()); if (newLeader == null) return; - Faction targetFaction = this.arg(1, ARFaction.get(sender), usenderFaction); + Faction targetFaction = this.arg(1, ARFaction.get(), usenderFaction); if (targetFaction == null) return; - UPlayer targetFactionCurrentLeader = targetFaction.getLeader(); + MPlayer targetFactionCurrentLeader = targetFaction.getLeader(); // We now have uplayer and the target faction if (this.senderIsConsole || usender.isUsingAdminMode() || Perm.LEADER_ANY.has(sender, false)) @@ -102,7 +100,7 @@ public class CmdFactionsLeader extends FCommand msg("You have promoted %s to the position of faction leader.", newLeader.describeTo(usender, true)); // Inform all players - for (UPlayer uplayer : UPlayerColls.get().get(sender).getAllOnline()) + for (MPlayer uplayer : MPlayerColl.get().getAllOnline()) { uplayer.msg("%s gave %s the leadership of %s.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(usender, uplayer, true), newLeader.describeTo(uplayer), targetFaction.describeTo(uplayer)); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java index 5ab580a3..f19c9f8e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsLeave.java @@ -1,7 +1,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -17,7 +16,6 @@ public class CmdFactionsLeave extends FCommand this.addAliases("leave"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.LEAVE.node)); this.addRequirements(ReqHasFaction.get()); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java index 22cc037f..9050f99c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsList.java @@ -5,9 +5,8 @@ import java.util.List; import com.massivecraft.factions.FactionListComparator; import com.massivecraft.factions.Perm; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.FactionColls; +import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.massivecore.cmd.arg.ARInteger; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.Txt; @@ -28,7 +27,6 @@ public class CmdFactionsList extends FCommand this.addOptionalArg("page", "1"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.LIST.node)); } @@ -45,7 +43,7 @@ public class CmdFactionsList extends FCommand // Create Messages List lines = new ArrayList(); - ArrayList factionList = new ArrayList(FactionColls.get().get(sender).getAll(null, FactionListComparator.get())); + ArrayList factionList = new ArrayList(FactionColl.get().getAll(null, FactionListComparator.get())); final int pageheight = 9; @@ -65,7 +63,7 @@ public class CmdFactionsList extends FCommand { if (faction.isNone()) { - lines.add(Txt.parse("Factionless %d online", FactionColls.get().get(sender).getNone().getUPlayersWhereOnline(true).size())); + lines.add(Txt.parse("Factionless %d online", FactionColl.get().getNone().getUPlayersWhereOnline(true).size())); continue; } lines.add(Txt.parse("%s %d/%d online, %d/%d/%d", diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java index e296c061..187125d6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMap.java @@ -1,8 +1,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; @@ -23,7 +22,6 @@ public class CmdFactionsMap extends FCommand this.addOptionalArg("on/off", "once"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MAP.node)); this.addRequirements(ReqIsPlayer.get()); } @@ -60,7 +58,7 @@ public class CmdFactionsMap extends FCommand public void showMap() { - sendMessage(BoardColls.get().getMap(usenderFaction, PS.valueOf(me), me.getLocation().getYaw())); + sendMessage(BoardColl.get().getMap(usenderFaction, PS.valueOf(me), me.getLocation().getYaw())); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java index 4679b1bc..f1b54323 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoney.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsMoney extends FCommand @@ -36,7 +35,6 @@ public class CmdFactionsMoney extends FCommand this.addAliases("money"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqBankCommandsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY.node)); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java index d38f1c05..02e39d57 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyBalance.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.integration.Econ; import com.massivecraft.factions.Perm; @@ -23,7 +22,6 @@ public class CmdFactionsMoneyBalance extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_BALANCE.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } @@ -35,7 +33,7 @@ public class CmdFactionsMoneyBalance extends FCommand @Override public void perform() { - Faction faction = this.arg(0, ARFaction.get(sender), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), usenderFaction); if (faction == null) return; if (faction != usenderFaction && ! Perm.MONEY_BALANCE_ANY.has(sender, true)) return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java index 542ced07..fde40cf8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyDeposit.java @@ -4,7 +4,6 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.integration.Econ; @@ -31,7 +30,6 @@ public class CmdFactionsMoneyDeposit extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_DEPOSIT.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } @@ -46,7 +44,7 @@ public class CmdFactionsMoneyDeposit extends FCommand Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; - Faction faction = this.arg(1, ARFaction.get(sender), usenderFaction); + Faction faction = this.arg(1, ARFaction.get(), usenderFaction); if (faction == null) return; boolean success = Econ.transferMoney(usender, usender, faction, amount); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java index 4b4f25ea..d44bfee3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFf.java @@ -3,7 +3,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; @@ -33,7 +32,6 @@ public class CmdFactionsMoneyTransferFf extends FCommand this.addRequiredArg("faction"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2F.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } @@ -48,10 +46,10 @@ public class CmdFactionsMoneyTransferFf extends FCommand Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; - Faction from = this.arg(1, ARFaction.get(sender)); + Faction from = this.arg(1, ARFaction.get()); if (from == null) return; - Faction to = this.arg(2, ARFaction.get(sender)); + Faction to = this.arg(2, ARFaction.get()); if (to == null) return; boolean success = Econ.transferMoney(usender, from, to, amount); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java index 52c7d45a..380111b8 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferFp.java @@ -4,8 +4,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; @@ -35,7 +34,6 @@ public class CmdFactionsMoneyTransferFp extends FCommand this.addRequiredArg("player"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_F2P.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } @@ -50,10 +48,10 @@ public class CmdFactionsMoneyTransferFp extends FCommand Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; - Faction from = this.arg(1, ARFaction.get(sender)); + Faction from = this.arg(1, ARFaction.get()); if (from == null) return; - UPlayer to = this.arg(2, ARUPlayer.getAny(sender)); + MPlayer to = this.arg(2, ARUPlayer.getAny()); if (to == null) return; boolean success = Econ.transferMoney(usender, from, to, amount); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java index 3e146d7d..5c9f334d 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyTransferPf.java @@ -4,8 +4,7 @@ import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; @@ -35,7 +34,6 @@ public class CmdFactionsMoneyTransferPf extends FCommand this.addRequiredArg("faction"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_P2F.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } @@ -50,10 +48,10 @@ public class CmdFactionsMoneyTransferPf extends FCommand Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; - UPlayer from = this.arg(1, ARUPlayer.getAny(sender)); + MPlayer from = this.arg(1, ARUPlayer.getAny()); if (from == null) return; - Faction to = this.arg(2, ARFaction.get(sender)); + Faction to = this.arg(2, ARFaction.get()); if (to == null) return; boolean success = Econ.transferMoney(usender, from, to, amount); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java index d4750756..51a418bb 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsMoneyWithdraw.java @@ -3,8 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.req.ReqBankCommandsEnabled; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.Factions; @@ -33,7 +32,6 @@ public class CmdFactionsMoneyWithdraw extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.MONEY_WITHDRAW.node)); this.addRequirements(ReqBankCommandsEnabled.get()); } @@ -48,10 +46,10 @@ public class CmdFactionsMoneyWithdraw extends FCommand Double amount = this.arg(0, ARDouble.get()); if (amount == null) return; - Faction from = this.arg(1, ARFaction.get(sender), usenderFaction); + Faction from = this.arg(1, ARFaction.get(), usenderFaction); if (from == null) return; - UPlayer to = usender; + MPlayer to = usender; boolean success = Econ.transferMoney(usender, from, to, amount); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java index af4383d2..4f081835 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsName.java @@ -4,13 +4,11 @@ import java.util.ArrayList; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; 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.FactionColl; -import com.massivecraft.factions.entity.FactionColls; -import com.massivecraft.factions.entity.UConf; +import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.EventFactionsNameChange; import com.massivecraft.factions.util.MiscUtil; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -30,7 +28,6 @@ public class CmdFactionsName extends FCommand this.addRequiredArg("new name"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.NAME.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); @@ -48,15 +45,14 @@ public class CmdFactionsName extends FCommand // TODO does not first test cover selfcase? - FactionColl factionColl = FactionColls.get().get(usenderFaction); - if (factionColl.isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(usenderFaction.getComparisonName())) + if (FactionColl.get().isNameTaken(newName) && ! MiscUtil.getComparisonString(newName).equals(usenderFaction.getComparisonName())) { msg("That name is already taken"); return; } ArrayList errors = new ArrayList(); - errors.addAll(factionColl.validateName(newName)); + errors.addAll(FactionColl.get().validateName(newName)); if (errors.size() > 0) { sendMessage(errors); @@ -76,8 +72,8 @@ public class CmdFactionsName extends FCommand // Inform usenderFaction.msg("%s changed your faction name to %s", usender.describeTo(usenderFaction, true), usenderFaction.getName(usenderFaction)); - if (!UConf.get(usender).broadcastNameChange) return; - for (Faction faction : FactionColls.get().get(usenderFaction).getAll()) + if (!MConf.get().broadcastNameChange) return; + for (Faction faction : FactionColl.get().getAll()) { if (faction == usenderFaction) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java index 393aac15..ac0714f3 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOfficer.java @@ -3,8 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -23,7 +22,6 @@ public class CmdFactionsOfficer extends FCommand this.addRequiredArg("player"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.OFFICER.node)); } @@ -34,7 +32,7 @@ public class CmdFactionsOfficer extends FCommand @Override public void perform() { - UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); + MPlayer you = this.arg(0, ARUPlayer.getAny()); if (you == null) return; boolean permAny = Perm.OFFICER_ANY.has(sender, false); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java index 03686a3b..a429839f 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsOpen.java @@ -2,7 +2,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.event.EventFactionsOpenChange; @@ -24,7 +23,6 @@ public class CmdFactionsOpen extends FCommand this.addOptionalArg("yes/no", "toggle"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.OPEN.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java index a75875da..2ac3ecb7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPerm.java @@ -6,7 +6,6 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARFPerm; import com.massivecraft.factions.cmd.arg.ARFaction; import com.massivecraft.factions.cmd.arg.ARRel; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.arg.ARBoolean; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -31,7 +30,6 @@ public class CmdFactionsPerm extends FCommand this.setErrorOnToManyArgs(false); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.PERM.node)); } @@ -42,7 +40,7 @@ public class CmdFactionsPerm extends FCommand @Override public void perform() { - Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), usenderFaction); if (faction == null) return; if ( ! this.argIsSet(1)) @@ -88,7 +86,7 @@ public class CmdFactionsPerm extends FCommand faction.setRelationPermitted(perm, rel, val); // The following is to make sure the leader always has the right to change perms if that is our goal. - if (perm == FPerm.PERMS && FPerm.PERMS.getDefault(faction).contains(Rel.LEADER)) + if (perm == FPerm.PERMS && FPerm.PERMS.getDefault().contains(Rel.LEADER)) { faction.setRelationPermitted(FPerm.PERMS, Rel.LEADER, true); } diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java index d039b11b..9c2134cf 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPlayer.java @@ -4,8 +4,7 @@ import java.util.LinkedHashMap; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.Progressbar; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.util.TimeDiffUtil; @@ -27,7 +26,6 @@ public class CmdFactionsPlayer extends FCommand this.addOptionalArg("player", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.PLAYER.node)); } @@ -39,7 +37,7 @@ public class CmdFactionsPlayer extends FCommand public void perform() { // Args - UPlayer uplayer = this.arg(0, ARUPlayer.getAny(sender), usender); + MPlayer uplayer = this.arg(0, ARUPlayer.getAny(), usender); if (uplayer == null) return; // INFO: Title diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java index 26b4e2a3..286ea451 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java @@ -4,8 +4,7 @@ import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARUPlayer; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.arg.ARDouble; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -27,7 +26,6 @@ public class CmdFactionsPowerBoost extends FCommand this.addRequiredArg("#"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.POWERBOOST.node)); } @@ -58,7 +56,7 @@ public class CmdFactionsPowerBoost extends FCommand if (doPlayer) { - UPlayer targetPlayer = this.arg(1, ARUPlayer.getAny(sender)); + MPlayer targetPlayer = this.arg(1, ARUPlayer.getAny()); if (targetPlayer == null) return; targetPlayer.setPowerBoost(targetPower); @@ -66,7 +64,7 @@ public class CmdFactionsPowerBoost extends FCommand } else { - Faction targetFaction = this.arg(1, ARFaction.get(sender)); + Faction targetFaction = this.arg(1, ARFaction.get()); if (targetFaction == null) return; targetFaction.setPowerBoost(targetPower); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java index 04df2da7..1be18a96 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsPromote.java @@ -3,8 +3,7 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; public class CmdFactionsPromote extends FCommand @@ -22,7 +21,6 @@ public class CmdFactionsPromote extends FCommand this.addRequiredArg("player"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.PROMOTE.node)); //To promote someone from recruit -> member you must be an officer. @@ -37,7 +35,7 @@ public class CmdFactionsPromote extends FCommand @Override public void perform() { - UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); + MPlayer you = this.arg(0, ARUPlayer.getAny()); if (you == null) return; if (you.getFaction() != usenderFaction) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index ae731545..c96713e0 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -4,7 +4,6 @@ import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.Faction; @@ -26,7 +25,6 @@ public abstract class CmdFactionsRelationAbstract extends FCommand this.addRequiredArg("faction"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.RELATION.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); @@ -40,7 +38,7 @@ public abstract class CmdFactionsRelationAbstract extends FCommand public void perform() { // Args - Faction otherFaction = this.arg(0, ARFaction.get(sender)); + Faction otherFaction = this.arg(0, ARFaction.get()); if (otherFaction == null) return; Rel newRelation = targetRelation; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java index 55b8724b..f134baf7 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -4,9 +4,8 @@ import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.arg.ARFaction; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UConf; +import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.EventFactionsHomeChange; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; @@ -27,7 +26,6 @@ public class CmdFactionsSethome extends FCommand this.addOptionalArg("faction", "you"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqIsPlayer.get()); this.addRequirements(ReqHasPerm.get(Perm.SETHOME.node)); } @@ -40,13 +38,13 @@ public class CmdFactionsSethome extends FCommand public void perform() { // Args - Faction faction = this.arg(0, ARFaction.get(usenderFaction), usenderFaction); + Faction faction = this.arg(0, ARFaction.get(), usenderFaction); if (faction == null) return; PS newHome = PS.valueOf(me.getLocation()); // Validate - if ( ! UConf.get(faction).homesEnabled) + if ( ! MConf.get().homesEnabled) { usender.msg("Sorry, Faction homes are disabled on this server."); return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java index b209c682..c781f716 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsTitle.java @@ -5,9 +5,8 @@ import org.bukkit.ChatColor; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.arg.ARUPlayer; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsTitleChange; import com.massivecraft.massivecore.cmd.arg.ARString; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -29,7 +28,6 @@ public class CmdFactionsTitle extends FCommand this.addOptionalArg("title", ""); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.TITLE.node)); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); } @@ -42,7 +40,7 @@ public class CmdFactionsTitle extends FCommand public void perform() { // Args - UPlayer you = this.arg(0, ARUPlayer.getAny(sender)); + MPlayer you = this.arg(0, ARUPlayer.getAny()); if (you == null) return; String newTitle = this.argConcatFrom(1, ARString.get(), ""); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index bb610523..6b44c7f6 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -1,9 +1,8 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.FactionColls; +import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.Perm; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; import com.massivecraft.massivecore.cmd.req.ReqIsPlayer; @@ -21,7 +20,6 @@ public class CmdFactionsUnclaim extends FCommand this.addAliases("unclaim"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqIsPlayer.get()); @@ -36,7 +34,7 @@ public class CmdFactionsUnclaim extends FCommand { // Args PS chunk = PS.valueOf(me).getChunk(true); - Faction newFaction = FactionColls.get().get(me).getNone(); + Faction newFaction = FactionColl.get().getNone(); // Apply if (usender.tryClaim(newFaction, chunk, true, true)) return; diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java index ec71a181..3ce2deae 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java @@ -6,13 +6,11 @@ import com.massivecraft.factions.FPerm; import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.cmd.req.ReqFactionsEnabled; import com.massivecraft.factions.cmd.req.ReqHasFaction; import com.massivecraft.factions.cmd.req.ReqRoleIsAtLeast; import com.massivecraft.factions.entity.BoardColl; -import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.FactionColls; +import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.event.EventFactionsChunkChange; import com.massivecraft.massivecore.cmd.req.ReqHasPerm; @@ -30,7 +28,6 @@ public class CmdFactionsUnclaimall extends FCommand this.addAliases("unclaimall"); // Requirements - this.addRequirements(ReqFactionsEnabled.get()); this.addRequirements(ReqHasPerm.get(Perm.UNCLAIM_ALL.node)); this.addRequirements(ReqHasFaction.get()); this.addRequirements(ReqRoleIsAtLeast.get(Rel.OFFICER)); @@ -45,14 +42,13 @@ public class CmdFactionsUnclaimall extends FCommand { // Args Faction faction = usenderFaction; - Faction newFaction = FactionColls.get().get(faction).getNone(); + Faction newFaction = FactionColl.get().getNone(); // FPerm if (!FPerm.TERRITORY.has(usender, faction, true)) return; // Apply - BoardColl boardColl = BoardColls.get().get(faction); - Set chunks = boardColl.getChunks(faction); + Set chunks = BoardColl.get().getChunks(faction); int countTotal = chunks.size(); int countSuccess = 0; int countFail = 0; @@ -67,7 +63,7 @@ public class CmdFactionsUnclaimall extends FCommand else { countSuccess++; - boardColl.setFactionAt(chunk, newFaction); + BoardColl.get().setFactionAt(chunk, newFaction); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/FCommand.java b/src/main/java/com/massivecraft/factions/cmd/FCommand.java index 9ccd4212..0e4b1410 100644 --- a/src/main/java/com/massivecraft/factions/cmd/FCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/FCommand.java @@ -2,8 +2,6 @@ package com.massivecraft.factions.cmd; import com.massivecraft.factions.Rel; import com.massivecraft.factions.entity.MPlayer; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.util.Txt; @@ -15,7 +13,7 @@ public abstract class FCommand extends MassiveCommand // -------------------------------------------- // public MPlayer msender; - public UPlayer usender; + public MPlayer usender; public Faction usenderFaction; // -------------------------------------------- // @@ -30,10 +28,7 @@ public abstract class FCommand extends MassiveCommand this.usender = null; this.usenderFaction = null; - // Check disabled - if (UConf.isDisabled(sender)) return; - - this.usender = UPlayer.get(this.sender); + this.usender = MPlayer.get(this.sender); this.usenderFaction = this.usender.getFaction(); } @@ -50,7 +45,7 @@ public abstract class FCommand extends MassiveCommand // COMMONLY USED LOGIC // -------------------------------------------- // - public boolean canIAdministerYou(UPlayer i, UPlayer you) + public boolean canIAdministerYou(MPlayer i, MPlayer you) { if ( ! i.getFaction().equals(you.getFaction())) { diff --git a/src/main/java/com/massivecraft/factions/cmd/arg/ARFaction.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARFaction.java index 28ca3a98..7980c588 100644 --- a/src/main/java/com/massivecraft/factions/cmd/arg/ARFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/arg/ARFaction.java @@ -2,11 +2,9 @@ package com.massivecraft.factions.cmd.arg; import org.bukkit.command.CommandSender; -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.massivecore.cmd.arg.ArgReaderAbstract; import com.massivecraft.massivecore.cmd.arg.ArgResult; import com.massivecraft.massivecore.util.IdUtil; @@ -18,18 +16,8 @@ public class ARFaction extends ArgReaderAbstract // INSTANCE & CONSTRUCT // -------------------------------------------- // - public static ARFaction get(Object universe) { return new ARFaction(FactionColls.get().get(universe)); } - private ARFaction(FactionColl coll) - { - this.coll = coll; - } - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private final FactionColl coll; - public FactionColl getColl() { return this.coll;} + private static ARFaction i = new ARFaction(); + public static ARFaction get() { return i; } // -------------------------------------------- // // OVERRIDE @@ -41,16 +29,16 @@ public class ARFaction extends ArgReaderAbstract ArgResult result = new ArgResult(); // Faction Name Exact - result.setResult(this.getColl().getByName(str)); + result.setResult(FactionColl.get().getByName(str)); if (result.hasResult()) return result; // Faction Name Match - result.setResult(this.getColl().getBestNameMatch(str)); + result.setResult(FactionColl.get().getBestNameMatch(str)); if (result.hasResult()) return result; // UPlayer Name Exact String id = IdUtil.getId(str); - UPlayer uplayer = UPlayerColls.get().get(this.getColl()).get(id); + MPlayer uplayer = MPlayer.get(id); if (uplayer != null) { result.setResult(uplayer.getFaction()); diff --git a/src/main/java/com/massivecraft/factions/cmd/arg/ARUPlayer.java b/src/main/java/com/massivecraft/factions/cmd/arg/ARUPlayer.java index 1b67ba0c..36685cae 100644 --- a/src/main/java/com/massivecraft/factions/cmd/arg/ARUPlayer.java +++ b/src/main/java/com/massivecraft/factions/cmd/arg/ARUPlayer.java @@ -1,7 +1,7 @@ package com.massivecraft.factions.cmd.arg; -import com.massivecraft.factions.entity.UPlayer; -import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.factions.entity.MPlayer; +import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.massivecore.cmd.arg.ArgReader; public class ARUPlayer @@ -10,8 +10,14 @@ public class ARUPlayer // INSTANCE // -------------------------------------------- // - public static ArgReader getAny(Object o) { return UPlayerColls.get().get(o).getAREntity(); } + public static ArgReader getAny() + { + return MPlayerColl.get().getAREntity(); + } - public static ArgReader getOnline(Object o) { return UPlayerColls.get().get(o).getAREntity(true); } + public static ArgReader getOnline() + { + return MPlayerColl.get().getAREntity(true); + } } diff --git a/src/main/java/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java index a77c88d3..73b9bb87 100644 --- a/src/main/java/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqBankCommandsEnabled.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; -import com.massivecraft.factions.entity.UConf; +import com.massivecraft.factions.entity.MConf; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.req.ReqAbstract; import com.massivecraft.massivecore.util.Txt; @@ -25,18 +25,17 @@ public class ReqBankCommandsEnabled extends ReqAbstract @Override public boolean apply(CommandSender sender, MassiveCommand command) { - return UConf.get(sender).econEnabled && UConf.get(sender).bankEnabled; + return MConf.get().econEnabled && MConf.get().bankEnabled; } @Override public String createErrorMessage(CommandSender sender, MassiveCommand command) { - UConf uconf = UConf.get(sender); - if (!uconf.bankEnabled) + if (!MConf.get().bankEnabled) { - return Txt.parse("Faction banks are disabled in the %s universe.", uconf.getUniverse()); + return Txt.parse("Faction banks are disabled."); } - return Txt.parse("Faction economy features are disabled in the %s universe.", uconf.getUniverse()); + return Txt.parse("Faction economy features are disabled."); } } diff --git a/src/main/java/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java deleted file mode 100644 index f04b7cf3..00000000 --- a/src/main/java/com/massivecraft/factions/cmd/req/ReqFactionsEnabled.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.massivecraft.factions.cmd.req; - -import org.bukkit.command.CommandSender; - -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.massivecore.cmd.MassiveCommand; -import com.massivecraft.massivecore.cmd.req.ReqAbstract; - -public class ReqFactionsEnabled extends ReqAbstract -{ - private static final long serialVersionUID = 1L; - - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static ReqFactionsEnabled i = new ReqFactionsEnabled(); - public static ReqFactionsEnabled get() { return i; } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public boolean apply(CommandSender sender, MassiveCommand command) - { - return !UConf.isDisabled(sender); - } - - @Override - public String createErrorMessage(CommandSender sender, MassiveCommand command) - { - return UConf.getDisabledMessage(sender); - } - -} diff --git a/src/main/java/com/massivecraft/factions/cmd/req/ReqHasFaction.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqHasFaction.java index d8b29f61..29587137 100644 --- a/src/main/java/com/massivecraft/factions/cmd/req/ReqHasFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqHasFaction.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.req.ReqAbstract; import com.massivecraft.massivecore.util.Txt; @@ -25,7 +25,7 @@ public class ReqHasFaction extends ReqAbstract @Override public boolean apply(CommandSender sender, MassiveCommand command) { - return UPlayer.get(sender).hasFaction(); + return MPlayer.get(sender).hasFaction(); } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/req/ReqHasntFaction.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqHasntFaction.java index a375a275..d802234c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/req/ReqHasntFaction.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqHasntFaction.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.req.ReqAbstract; import com.massivecraft.massivecore.util.Txt; @@ -25,7 +25,7 @@ public class ReqHasntFaction extends ReqAbstract @Override public boolean apply(CommandSender sender, MassiveCommand command) { - return !UPlayer.get(sender).hasFaction(); + return !MPlayer.get(sender).hasFaction(); } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java b/src/main/java/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java index b708e85b..3d04116c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java +++ b/src/main/java/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.cmd.MassiveCommand; import com.massivecraft.massivecore.cmd.req.ReqAbstract; import com.massivecraft.massivecore.util.Txt; @@ -33,7 +33,7 @@ public class ReqRoleIsAtLeast extends ReqAbstract @Override public boolean apply(CommandSender sender, MassiveCommand command) { - UPlayer uplayer = UPlayer.get(sender); + MPlayer uplayer = MPlayer.get(sender); return uplayer.getRole().isAtLeast(this.rel); } diff --git a/src/main/java/com/massivecraft/factions/entity/Board.java b/src/main/java/com/massivecraft/factions/entity/Board.java index 2cb85214..cc78077c 100644 --- a/src/main/java/com/massivecraft/factions/entity/Board.java +++ b/src/main/java/com/massivecraft/factions/entity/Board.java @@ -32,7 +32,7 @@ public class Board extends Entity implements BoardInterface public static Board get(Object oid) { - return BoardColls.get().get2(oid); + return BoardColl.get().get(oid); } // -------------------------------------------- // @@ -90,7 +90,7 @@ public class Board extends Entity implements BoardInterface if (ps == null) return null; ps = ps.getChunkCoords(true); TerritoryAccess ret = this.map.get(ps); - if (ret == null) ret = TerritoryAccess.valueOf(UConf.get(this).factionIdNone); + if (ret == null) ret = TerritoryAccess.valueOf(MConf.get().factionIdNone); return ret; } @@ -109,7 +109,7 @@ public class Board extends Entity implements BoardInterface { ps = ps.getChunkCoords(true); - if (territoryAccess == null || (territoryAccess.getHostFactionId().equals(UConf.get(this).factionIdNone) && territoryAccess.isDefault())) + if (territoryAccess == null || (territoryAccess.getHostFactionId().equals(MConf.get().factionIdNone) && territoryAccess.isDefault())) { this.map.remove(ps); } @@ -159,13 +159,12 @@ public class Board extends Entity implements BoardInterface @Override public void clean() { - FactionColl factionColl = FactionColls.get().get(this); - for (Entry entry : this.map.entrySet()) { TerritoryAccess territoryAccess = entry.getValue(); String factionId = territoryAccess.getHostFactionId(); - if (factionColl.containsId(factionId)) continue; + + if (FactionColl.get().containsId(factionId)) continue; PS ps = entry.getKey(); this.removeAt(ps); diff --git a/src/main/java/com/massivecraft/factions/entity/BoardColl.java b/src/main/java/com/massivecraft/factions/entity/BoardColl.java index 1a7987f7..1e4938e0 100644 --- a/src/main/java/com/massivecraft/factions/entity/BoardColl.java +++ b/src/main/java/com/massivecraft/factions/entity/BoardColl.java @@ -4,6 +4,7 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.Set; +import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; import com.massivecraft.factions.RelationParticipator; import com.massivecraft.factions.TerritoryAccess; @@ -15,12 +16,14 @@ import com.massivecraft.massivecore.util.MUtil; public class BoardColl extends Coll implements BoardInterface { // -------------------------------------------- // - // CONSTRUCT + // INSTANCE & CONSTRUCT // -------------------------------------------- // - public BoardColl(String name) + private static BoardColl i = new BoardColl(); + public static BoardColl get() { return i; } + private BoardColl() { - super(name, Board.class, MStore.getDb(), Factions.get(), false, true, true); + super(Const.COLLECTION_BOARD, Board.class, MStore.getDb(), Factions.get(), false, true, true); } // -------------------------------------------- // @@ -165,4 +168,51 @@ public class BoardColl extends Coll implements BoardInterface return board.getMap(observer, centerPs, inDegrees); } + /* + @Override + public void init() + { + super.init(); + + this.migrate(); + } + + // This method is for the 1.8.X --> 2.0.0 migration + public void migrate() + { + // Create file objects + File oldFile = new File(Factions.get().getDataFolder(), "board.json"); + File newFile = new File(Factions.get().getDataFolder(), "board.json.migrated"); + + // Already migrated? + if ( ! oldFile.exists()) return; + + // Read the file content through GSON. + Type type = new TypeToken>>(){}.getType(); + Map> worldCoordIds = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); + + // Set the data + for (Entry> entry : worldCoordIds.entrySet()) + { + String worldName = entry.getKey(); + BoardColl boardColl = this.getForWorld(worldName); + Board board = boardColl.get(worldName); + for (Entry entry2 : entry.getValue().entrySet()) + { + String[] ChunkCoordParts = entry2.getKey().trim().split("[,\\s]+"); + int chunkX = Integer.parseInt(ChunkCoordParts[0]); + int chunkZ = Integer.parseInt(ChunkCoordParts[1]); + PS ps = new PSBuilder().chunkX(chunkX).chunkZ(chunkZ).build(); + + TerritoryAccess territoryAccess = entry2.getValue(); + + board.setTerritoryAccessAt(ps, territoryAccess); + } + } + + // Mark as migrated + oldFile.renameTo(newFile); + } + */ + } diff --git a/src/main/java/com/massivecraft/factions/entity/BoardColls.java b/src/main/java/com/massivecraft/factions/entity/BoardColls.java deleted file mode 100644 index 8bdaed73..00000000 --- a/src/main/java/com/massivecraft/factions/entity/BoardColls.java +++ /dev/null @@ -1,215 +0,0 @@ -package com.massivecraft.factions.entity; - -import java.io.File; -import java.lang.reflect.Type; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.Map.Entry; - -import com.massivecraft.factions.Const; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.RelationParticipator; -import com.massivecraft.factions.TerritoryAccess; -import com.massivecraft.massivecore.Aspect; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.ps.PSBuilder; -import com.massivecraft.massivecore.util.DiscUtil; -import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken; - -public class BoardColls extends XColls implements BoardInterface -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static BoardColls i = new BoardColls(); - public static BoardColls get() { return i; } - - // -------------------------------------------- // - // OVERRIDE: COLLS - // -------------------------------------------- // - - @Override - public BoardColl createColl(String collName) - { - return new BoardColl(collName); - } - - @Override - public Aspect getAspect() - { - return Factions.get().getAspect(); - } - - @Override - public String getBasename() - { - return Const.COLLECTION_BOARD; - } - - @Override - public void init() - { - super.init(); - - this.migrate(); - } - - // This method is for the 1.8.X --> 2.0.0 migration - public void migrate() - { - // Create file objects - File oldFile = new File(Factions.get().getDataFolder(), "board.json"); - File newFile = new File(Factions.get().getDataFolder(), "board.json.migrated"); - - // Already migrated? - if ( ! oldFile.exists()) return; - - // Read the file content through GSON. - Type type = new TypeToken>>(){}.getType(); - Map> worldCoordIds = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); - - // Set the data - for (Entry> entry : worldCoordIds.entrySet()) - { - String worldName = entry.getKey(); - BoardColl boardColl = this.getForWorld(worldName); - Board board = boardColl.get(worldName); - for (Entry entry2 : entry.getValue().entrySet()) - { - String[] ChunkCoordParts = entry2.getKey().trim().split("[,\\s]+"); - int chunkX = Integer.parseInt(ChunkCoordParts[0]); - int chunkZ = Integer.parseInt(ChunkCoordParts[1]); - PS ps = new PSBuilder().chunkX(chunkX).chunkZ(chunkZ).build(); - - TerritoryAccess territoryAccess = entry2.getValue(); - - board.setTerritoryAccessAt(ps, territoryAccess); - } - } - - // Mark as migrated - oldFile.renameTo(newFile); - } - - // -------------------------------------------- // - // OVERRIDE: BOARD - // -------------------------------------------- // - - @Override - public TerritoryAccess getTerritoryAccessAt(PS ps) - { - BoardColl coll = this.getForWorld(ps.getWorld()); - if (coll == null) return null; - return coll.getTerritoryAccessAt(ps); - } - - @Override - public Faction getFactionAt(PS ps) - { - BoardColl coll = this.getForWorld(ps.getWorld()); - if (coll == null) return null; - return coll.getFactionAt(ps); - } - - // SET - - @Override - public void setTerritoryAccessAt(PS ps, TerritoryAccess territoryAccess) - { - BoardColl coll = this.getForWorld(ps.getWorld()); - if (coll == null) return; - coll.setTerritoryAccessAt(ps, territoryAccess); - } - - @Override - public void setFactionAt(PS ps, Faction faction) - { - BoardColl coll = this.getForWorld(ps.getWorld()); - if (coll == null) return; - coll.setFactionAt(ps, faction); - } - - // REMOVE - - @Override - public void removeAt(PS ps) - { - BoardColl coll = this.getForWorld(ps.getWorld()); - if (coll == null) return; - coll.removeAt(ps); - } - - @Override - public void removeAll(Faction faction) - { - for (BoardColl coll : this.getColls()) - { - coll.removeAll(faction); - } - } - - @Override - public void clean() - { - for (BoardColl coll : this.getColls()) - { - coll.clean(); - } - } - - // CHUNKS - @Override - public Set getChunks(Faction faction) - { - Set ret = new HashSet(); - for (BoardColl coll : this.getColls()) - { - ret.addAll(coll.getChunks(faction)); - } - return ret; - } - - // COUNT - @Override - public int getCount(Faction faction) - { - int ret = 0; - for (BoardColl coll : this.getColls()) - { - ret += coll.getCount(faction); - } - return ret; - } - - // NEARBY DETECTION - - @Override - public boolean isBorderPs(PS ps) - { - BoardColl coll = this.getForWorld(ps.getWorld()); - if (coll == null) return false; - return coll.isBorderPs(ps); - } - - @Override - public boolean isConnectedPs(PS ps, Faction faction) - { - BoardColl coll = this.getForWorld(ps.getWorld()); - if (coll == null) return false; - return coll.isConnectedPs(ps, faction); - } - - // MAP GENERATION - - @Override - public ArrayList getMap(RelationParticipator observer, PS centerPs, double inDegrees) - { - BoardColl coll = this.getForWorld(centerPs.getWorld()); - if (coll == null) return null; - return coll.getMap(observer, centerPs, inDegrees); - } - -} diff --git a/src/main/java/com/massivecraft/factions/entity/Faction.java b/src/main/java/com/massivecraft/factions/entity/Faction.java index fec97b86..520d4954 100644 --- a/src/main/java/com/massivecraft/factions/entity/Faction.java +++ b/src/main/java/com/massivecraft/factions/entity/Faction.java @@ -33,7 +33,7 @@ public class Faction extends Entity implements EconomyParticipator public static Faction get(Object oid) { - return FactionColls.get().get2(oid); + return FactionColl.get().get(oid); } // -------------------------------------------- // @@ -62,13 +62,11 @@ public class Faction extends Entity implements EconomyParticipator { Money.set(this, null, 0); - String universe = this.getUniverse(); - // Clean the board - BoardColls.get().getForUniverse(universe).clean(); + BoardColl.get().clean(); - // Clean the uplayers - UPlayerColls.get().getForUniverse(universe).clean(); + // Clean the mplayers + MPlayerColl.get().clean(); } // -------------------------------------------- // @@ -132,7 +130,7 @@ public class Faction extends Entity implements EconomyParticipator public boolean isNone() { - return this.getId().equals(UConf.get(this).factionIdNone); + return this.getId().equals(MConf.get().factionIdNone); } public boolean isNormal() @@ -150,8 +148,7 @@ public class Faction extends Entity implements EconomyParticipator { String ret = this.name; - UConf uconf = UConf.get(this); - if (uconf != null && UConf.get(this).factionNameForceUpperCase) + if (MConf.get().factionNameForceUpperCase) { ret = ret.toUpperCase(); } @@ -277,8 +274,8 @@ public class Faction extends Entity implements EconomyParticipator public boolean isValidHome(PS ps) { if (ps == null) return true; - if (!UConf.get(this).homesMustBeInClaimedTerritory) return true; - if (BoardColls.get().getFactionAt(ps) == this) return true; + if (!MConf.get().homesMustBeInClaimedTerritory) return true; + if (BoardColl.get().getFactionAt(ps) == this) return true; return false; } @@ -338,9 +335,7 @@ public class Faction extends Entity implements EconomyParticipator public boolean isDefaultOpen() { - UConf uconf = UConf.get(this); - if (uconf == null) return false; - return uconf.defaultFactionOpen; + return MConf.get().defaultFactionOpen; } public boolean isOpen() @@ -412,7 +407,7 @@ public class Faction extends Entity implements EconomyParticipator return this.getInvitedPlayerIds().contains(playerId); } - public boolean isInvited(UPlayer uplayer) + public boolean isInvited(MPlayer uplayer) { return this.isInvited(uplayer.getId()); } @@ -434,7 +429,7 @@ public class Faction extends Entity implements EconomyParticipator } - public void setInvited(UPlayer uplayer, boolean invited) + public void setInvited(MPlayer uplayer, boolean invited) { this.setInvited(uplayer.getId(), invited); } @@ -523,7 +518,7 @@ public class Faction extends Entity implements EconomyParticipator { ret.put(rel, new ArrayList()); } - for (Faction faction : FactionColls.get().get(this).getAll()) + for (Faction faction : FactionColl.get().getAll()) { Rel relation = faction.getRelationTo(this); if (onlyNonNeutral && relation == Rel.NEUTRAL) continue; @@ -544,7 +539,7 @@ public class Faction extends Entity implements EconomyParticipator for (FFlag fflag : FFlag.values()) { - ret.put(fflag, fflag.getDefault(this)); + ret.put(fflag, fflag.getDefault()); } if (this.flags != null) @@ -576,7 +571,7 @@ public class Faction extends Entity implements EconomyParticipator while (iter.hasNext()) { Entry entry = iter.next(); - if (entry.getKey().getDefault(this) == entry.getValue()) + if (entry.getKey().getDefault() == entry.getValue()) { iter.remove(); } @@ -621,7 +616,7 @@ public class Faction extends Entity implements EconomyParticipator for (FPerm fperm : FPerm.values()) { - ret.put(fperm, fperm.getDefault(this)); + ret.put(fperm, fperm.getDefault()); } if (this.perms != null) @@ -667,7 +662,7 @@ public class Faction extends Entity implements EconomyParticipator continue; } - Set keyDefault = key.getDefault(this); + Set keyDefault = key.getDefault(); Set value = entry.getValue(); if (keyDefault.equals(value)) @@ -779,12 +774,12 @@ public class Faction extends Entity implements EconomyParticipator if (this.getFlag(FFlag.INFPOWER)) return 999999; double ret = 0; - for (UPlayer uplayer : this.getUPlayers()) + for (MPlayer uplayer : this.getUPlayers()) { ret += uplayer.getPower(); } - double factionPowerMax = UConf.get(this).factionPowerMax; + double factionPowerMax = MConf.get().factionPowerMax; if (factionPowerMax > 0 && ret > factionPowerMax) { ret = factionPowerMax; @@ -800,12 +795,12 @@ public class Faction extends Entity implements EconomyParticipator if (this.getFlag(FFlag.INFPOWER)) return 999999; double ret = 0; - for (UPlayer uplayer : this.getUPlayers()) + for (MPlayer uplayer : this.getUPlayers()) { ret += uplayer.getPowerMax(); } - double factionPowerMax = UConf.get(this).factionPowerMax; + double factionPowerMax = MConf.get().factionPowerMax; if (factionPowerMax > 0 && ret > factionPowerMax) { ret = factionPowerMax; @@ -828,7 +823,7 @@ public class Faction extends Entity implements EconomyParticipator public int getLandCount() { - return BoardColls.get().get(this).getCount(this); + return BoardColl.get().getCount(this); } public int getLandCountInWorld(String worldName) { @@ -844,7 +839,7 @@ public class Faction extends Entity implements EconomyParticipator // FOREIGN KEY: UPLAYER // -------------------------------------------- // - protected transient List uplayers = new ArrayList(); + protected transient List uplayers = new ArrayList(); public void reindexUPlayers() { this.uplayers.clear(); @@ -852,10 +847,10 @@ public class Faction extends Entity implements EconomyParticipator String factionId = this.getId(); if (factionId == null) return; - for (UPlayer uplayer : UPlayerColls.get().get(this).getAll()) + for (MPlayer mplayer : MPlayerColl.get().getAll()) { - if (!MUtil.equals(factionId, uplayer.getFactionId())) continue; - this.uplayers.add(uplayer); + if (!MUtil.equals(factionId, mplayer.getFactionId())) continue; + this.uplayers.add(mplayer); } } @@ -863,10 +858,10 @@ public class Faction extends Entity implements EconomyParticipator // TODO: Find the bug causing non-attached UPlayers to be present in the index. private void checkUPlayerIndex() { - Iterator iter = this.uplayers.iterator(); + Iterator iter = this.uplayers.iterator(); while (iter.hasNext()) { - UPlayer uplayer = iter.next(); + MPlayer uplayer = iter.next(); if (!uplayer.attached()) { String msg = Txt.parse("WARN: Faction %s aka %s had unattached uplayer in index:", this.getName(), this.getId()); @@ -877,19 +872,19 @@ public class Faction extends Entity implements EconomyParticipator } } - public List getUPlayers() + public List getUPlayers() { this.checkUPlayerIndex(); - return new ArrayList(this.uplayers); + return new ArrayList(this.uplayers); } - public List getUPlayersWhereOnline(boolean online) + public List getUPlayersWhereOnline(boolean online) { - List ret = this.getUPlayers(); - Iterator iter = ret.iterator(); + List ret = this.getUPlayers(); + Iterator iter = ret.iterator(); while (iter.hasNext()) { - UPlayer uplayer = iter.next(); + MPlayer uplayer = iter.next(); if (uplayer.isOnline() != online) { iter.remove(); @@ -898,13 +893,13 @@ public class Faction extends Entity implements EconomyParticipator return ret; } - public List getUPlayersWhereRole(Rel role) + public List getUPlayersWhereRole(Rel role) { - List ret = this.getUPlayers(); - Iterator iter = ret.iterator(); + List ret = this.getUPlayers(); + Iterator iter = ret.iterator(); while (iter.hasNext()) { - UPlayer uplayer = iter.next(); + MPlayer uplayer = iter.next(); if (uplayer.getRole() != role) { iter.remove(); @@ -913,13 +908,13 @@ public class Faction extends Entity implements EconomyParticipator return ret; } - public UPlayer getLeader() + public MPlayer getLeader() { - List ret = this.getUPlayers(); - Iterator iter = ret.iterator(); + List ret = this.getUPlayers(); + Iterator iter = ret.iterator(); while (iter.hasNext()) { - UPlayer uplayer = iter.next(); + MPlayer uplayer = iter.next(); if (uplayer.getRole() == Rel.LEADER) { return uplayer; @@ -933,7 +928,7 @@ public class Faction extends Entity implements EconomyParticipator List ret = new ArrayList(); for (CommandSender player : IdUtil.getOnlineSenders()) { - UPlayer uplayer = UPlayer.get(player); + MPlayer uplayer = MPlayer.get(player); if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue; if (uplayer.getFaction() != this) continue; ret.add(player); @@ -946,7 +941,7 @@ public class Faction extends Entity implements EconomyParticipator List ret = new ArrayList(); for (Player player : Bukkit.getOnlinePlayers()) { - UPlayer uplayer = UPlayer.get(player); + MPlayer uplayer = MPlayer.get(player); if (!MUtil.equals(uplayer.getUniverse(), this.getUniverse())) continue; if (uplayer.getFaction() != this) continue; ret.add(player); @@ -958,12 +953,12 @@ public class Faction extends Entity implements EconomyParticipator public void promoteNewLeader() { if ( ! this.isNormal()) return; - if (this.getFlag(FFlag.PERMANENT) && UConf.get(this).permanentFactionsDisableLeaderPromotion) return; + if (this.getFlag(FFlag.PERMANENT) && MConf.get().permanentFactionsDisableLeaderPromotion) return; - UPlayer oldLeader = this.getLeader(); + MPlayer oldLeader = this.getLeader(); // get list of officers, or list of normal members if there are no officers - List replacements = this.getUPlayersWhereRole(Rel.OFFICER); + List replacements = this.getUPlayersWhereRole(Rel.OFFICER); if (replacements == null || replacements.isEmpty()) { replacements = this.getUPlayersWhereRole(Rel.MEMBER); @@ -988,9 +983,9 @@ public class Faction extends Entity implements EconomyParticipator Factions.get().log("The faction "+this.getName()+" ("+this.getId()+") has been disbanded since it has no members left."); } - for (UPlayer uplayer : UPlayerColls.get().get(this).getAllOnline()) + for (MPlayer mplayer : MPlayerColl.get().getAllOnline()) { - uplayer.msg("The faction %s was disbanded.", this.getName(uplayer)); + mplayer.msg("The faction %s was disbanded.", this.getName(mplayer)); } this.detach(); diff --git a/src/main/java/com/massivecraft/factions/entity/FactionColl.java b/src/main/java/com/massivecraft/factions/entity/FactionColl.java index 5ab6ed8d..65e6946d 100644 --- a/src/main/java/com/massivecraft/factions/entity/FactionColl.java +++ b/src/main/java/com/massivecraft/factions/entity/FactionColl.java @@ -7,6 +7,7 @@ import org.bukkit.ChatColor; 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; @@ -17,12 +18,14 @@ import com.massivecraft.factions.util.MiscUtil; public class FactionColl extends Coll { // -------------------------------------------- // - // CONSTRUCT + // INSTANCE & CONSTRUCT // -------------------------------------------- // - public FactionColl(String name) + private static FactionColl i = new FactionColl(); + public static FactionColl get() { return i; } + private FactionColl() { - super(name, Faction.class, MStore.getDb(), Factions.get()); + super(Const.COLLECTION_FACTION, Faction.class, MStore.getDb(), Factions.get()); } // -------------------------------------------- // @@ -50,8 +53,8 @@ public class FactionColl extends Coll String message = Txt.parse("Non existing factionId %s requested. Cleaning all boards and uplayers.", this.fixId(oid)); Factions.get().log(message); - BoardColls.get().clean(); - UPlayerColls.get().clean(); + BoardColl.get().clean(); + MPlayerColl.get().clean(); } return ret; @@ -82,7 +85,7 @@ public class FactionColl extends Coll public Faction getNone() { - String id = UConf.get(this).factionIdNone; + String id = MConf.get().factionIdNone; Faction faction = this.get(id); if (faction != null) return faction; @@ -115,7 +118,7 @@ public class FactionColl extends Coll public Faction getSafezone() { - String id = UConf.get(this).factionIdSafezone; + String id = MConf.get().factionIdSafezone; Faction faction = this.get(id); if (faction != null) return faction; @@ -148,7 +151,7 @@ public class FactionColl extends Coll public Faction getWarzone() { - String id = UConf.get(this).factionIdWarzone; + String id = MConf.get().factionIdWarzone; Faction faction = this.get(id); if (faction != null) return faction; @@ -185,9 +188,9 @@ public class FactionColl extends Coll public void econLandRewardRoutine() { - if (!Econ.isEnabled(this.getUniverse())) return; + if (!Econ.isEnabled()) return; - double econLandReward = UConf.get(this).econLandReward; + double econLandReward = MConf.get().econLandReward; if (econLandReward == 0.0) return; Factions.get().log("Running econLandRewardRoutine..."); @@ -196,10 +199,10 @@ public class FactionColl extends Coll int landCount = faction.getLandCount(); if (!faction.getFlag(FFlag.PEACEFUL) && landCount > 0) { - List players = faction.getUPlayers(); + List players = faction.getUPlayers(); int playerCount = players.size(); double reward = econLandReward * landCount / playerCount; - for (UPlayer player : players) + for (MPlayer player : players) { Econ.modifyMoney(player, reward, "own " + landCount + " faction land divided among " + playerCount + " members"); } @@ -215,14 +218,14 @@ public class FactionColl extends Coll { ArrayList errors = new ArrayList(); - if (MiscUtil.getComparisonString(str).length() < UConf.get(this).factionNameLengthMin) + if (MiscUtil.getComparisonString(str).length() < MConf.get().factionNameLengthMin) { - errors.add(Txt.parse("The faction name can't be shorter than %s chars.", UConf.get(this).factionNameLengthMin)); + errors.add(Txt.parse("The faction name can't be shorter than %s chars.", MConf.get().factionNameLengthMin)); } - if (str.length() > UConf.get(this).factionNameLengthMax) + if (str.length() > MConf.get().factionNameLengthMax) { - errors.add(Txt.parse("The faction name can't be longer than %s chars.", UConf.get(this).factionNameLengthMax)); + errors.add(Txt.parse("The faction name can't be longer than %s chars.", MConf.get().factionNameLengthMax)); } for (char c : str.toCharArray()) @@ -268,5 +271,62 @@ public class FactionColl extends Coll { return this.getByName(str) != null; } + + /* +@Override + public void init() + { + super.init(); + + this.migrate(); + } + + // This method is for the 1.8.X --> 2.0.0 migration + public void migrate() + { + // Create file objects + File oldFile = new File(Factions.get().getDataFolder(), "factions.json"); + File newFile = new File(Factions.get().getDataFolder(), "factions.json.migrated"); + + // Already migrated? + if ( ! oldFile.exists()) return; + + // Faction ids /delete + // For simplicity we just drop the old special factions. + // They will be replaced with new autogenerated ones per universe. + Set factionIdsToDelete = MUtil.set("0", "-1", "-2"); + + // Read the file content through GSON. + Type type = new TypeToken>(){}.getType(); + Map id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); + + // The Coll + FactionColl coll = this.getForUniverse(MassiveCore.DEFAULT); + + // Set the data + for (Entry entry : id2faction.entrySet()) + { + String factionId = entry.getKey(); + if (factionIdsToDelete.contains(factionId)) continue; + Faction faction = entry.getValue(); + coll.attach(faction, factionId); + } + + // Mark as migrated + oldFile.renameTo(newFile); + } + + // -------------------------------------------- // + // INDEX + // -------------------------------------------- // + + public void reindexUPlayers() + { + for (FactionColl coll : this.getColls()) + { + coll.reindexUPlayers(); + } + } + */ } diff --git a/src/main/java/com/massivecraft/factions/entity/FactionColls.java b/src/main/java/com/massivecraft/factions/entity/FactionColls.java deleted file mode 100644 index a9fcc152..00000000 --- a/src/main/java/com/massivecraft/factions/entity/FactionColls.java +++ /dev/null @@ -1,103 +0,0 @@ -package com.massivecraft.factions.entity; - -import java.io.File; -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Set; - -import com.massivecraft.factions.Const; -import com.massivecraft.factions.Factions; -import com.massivecraft.massivecore.Aspect; -import com.massivecraft.massivecore.MassiveCore; -import com.massivecraft.massivecore.util.DiscUtil; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken; - -public class FactionColls extends XColls -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static FactionColls i = new FactionColls(); - public static FactionColls get() { return i; } - - // -------------------------------------------- // - // OVERRIDE: COLLS - // -------------------------------------------- // - - @Override - public FactionColl createColl(String collName) - { - return new FactionColl(collName); - } - - @Override - public Aspect getAspect() - { - return Factions.get().getAspect(); - } - - @Override - public String getBasename() - { - return Const.COLLECTION_FACTION; - } - - @Override - public void init() - { - super.init(); - - this.migrate(); - } - - // This method is for the 1.8.X --> 2.0.0 migration - public void migrate() - { - // Create file objects - File oldFile = new File(Factions.get().getDataFolder(), "factions.json"); - File newFile = new File(Factions.get().getDataFolder(), "factions.json.migrated"); - - // Already migrated? - if ( ! oldFile.exists()) return; - - // Faction ids /delete - // For simplicity we just drop the old special factions. - // They will be replaced with new autogenerated ones per universe. - Set factionIdsToDelete = MUtil.set("0", "-1", "-2"); - - // Read the file content through GSON. - Type type = new TypeToken>(){}.getType(); - Map id2faction = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); - - // The Coll - FactionColl coll = this.getForUniverse(MassiveCore.DEFAULT); - - // Set the data - for (Entry entry : id2faction.entrySet()) - { - String factionId = entry.getKey(); - if (factionIdsToDelete.contains(factionId)) continue; - Faction faction = entry.getValue(); - coll.attach(faction, factionId); - } - - // Mark as migrated - oldFile.renameTo(newFile); - } - - // -------------------------------------------- // - // INDEX - // -------------------------------------------- // - - public void reindexUPlayers() - { - for (FactionColl coll : this.getColls()) - { - coll.reindexUPlayers(); - } - } - -} diff --git a/src/main/java/com/massivecraft/factions/entity/MConf.java b/src/main/java/com/massivecraft/factions/entity/MConf.java index ffc54262..a0735457 100644 --- a/src/main/java/com/massivecraft/factions/entity/MConf.java +++ b/src/main/java/com/massivecraft/factions/entity/MConf.java @@ -1,18 +1,24 @@ package com.massivecraft.factions.entity; +import java.util.ArrayList; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Set; import java.util.TreeSet; +import java.util.UUID; import org.bukkit.ChatColor; 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; +import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.factions.integration.dynmap.DynmapStyle; import com.massivecraft.factions.listeners.FactionsListenerChat; import com.massivecraft.massivecore.store.Entity; @@ -64,6 +70,54 @@ public class MConf extends Entity public boolean removePlayerDataWhenBanned = true; public double removePlayerDataAfterInactiveDays = 20.0; + // -------------------------------------------- // + // SPECIAL FACTION IDS + // -------------------------------------------- // + + public String factionIdNone = UUID.randomUUID().toString(); + public String factionIdSafezone = UUID.randomUUID().toString(); + public String factionIdWarzone = UUID.randomUUID().toString(); + + // -------------------------------------------- // + // DEFAULTS + // -------------------------------------------- // + + public String defaultPlayerFactionId = this.factionIdNone; + public Rel defaultPlayerRole = Rel.RECRUIT; + public double defaultPlayerPower = 0.0; + + public boolean defaultFactionOpen = false; + public Map defaultFactionFlags = FFlag.getDefaultDefaults(); + public Map> defaultFactionPerms = FPerm.getDefaultDefaults(); + + // -------------------------------------------- // + // POWER + // -------------------------------------------- // + + public double powerMax = 10.0; + public double powerMin = 0.0; + public double powerPerHour = 2.0; + public double powerPerDeath = -2.0; + + public boolean canLeaveWithNegativePower = true; + + // -------------------------------------------- // + // CORE + // -------------------------------------------- // + + public int factionMemberLimit = 0; + public double factionPowerMax = 0.0; + + public int factionNameLengthMin = 3; + public int factionNameLengthMax = 16; + public boolean factionNameForceUpperCase = false; + + // -------------------------------------------- // + // MESSAGES + // -------------------------------------------- // + + public boolean broadcastNameChange = false; + // -------------------------------------------- // // CLAIM LIMITS // -------------------------------------------- // @@ -74,6 +128,110 @@ public class MConf extends Entity // the maximum radius allowed when using the claim command. public int radiusClaimRadiusLimit = 5; + // -------------------------------------------- // + // CLAIMS + // -------------------------------------------- // + + public boolean claimsMustBeConnected = true; + public boolean claimingFromOthersAllowed = true; + public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false; + public int claimsRequireMinFactionMembers = 1; + public int claimedLandsMax = 0; + + // -------------------------------------------- // + // HOMES + // -------------------------------------------- // + + public boolean homesEnabled = true; + public boolean homesMustBeInClaimedTerritory = true; + public boolean homesTeleportCommandEnabled = true; + public boolean homesTeleportAllowedFromEnemyTerritory = true; + public boolean homesTeleportAllowedFromDifferentWorld = true; + public double homesTeleportAllowedEnemyDistance = 32.0; + public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; + + public boolean homesTeleportToOnDeathActive = false; + public EventPriority homesTeleportToOnDeathPriority = EventPriority.NORMAL; + + // -------------------------------------------- // + // ASSORTED + // -------------------------------------------- // + + public boolean permanentFactionsDisableLeaderPromotion = false; + public double actionDeniedPainAmount = 2.0D; + public boolean disablePVPForFactionlessPlayers = false; + public boolean enablePVPAgainstFactionlessInAttackersLand = false; + public double territoryShieldFactor = 0.3D; + + // -------------------------------------------- // + // DENY COMMANDS + // -------------------------------------------- // + + // commands which will be prevented if the player is a member of a permanent faction + public List denyCommandsPermanentFactionMember = new ArrayList(); + + // commands which will be prevented when in claimed territory of another faction + public Map> denyCommandsTerritoryRelation = MUtil.map( + Rel.ENEMY, MUtil.list( + // Essentials commands + "home", + "homes", + "sethome", + "createhome", + "tpahere", + "tpaccept", + "tpyes", + "tpa", + "call", + "tpask", + "warp", + "warps", + "spawn", + // Essentials e-alliases + "ehome", + "ehomes", + "esethome", + "ecreatehome", + "etpahere", + "etpaccept", + "etpyes", + "etpa", + "ecall", + "etpask", + "ewarp", + "ewarps", + "espawn", + // Essentials fallback alliases + "essentials:home", + "essentials:homes", + "essentials:sethome", + "essentials:createhome", + "essentials:tpahere", + "essentials:tpaccept", + "essentials:tpyes", + "essentials:tpa", + "essentials:call", + "essentials:tpask", + "essentials:warp", + "essentials:warps", + "essentials:spawn", + // Other plugins + "wtp", + "uspawn", + "utp", + "mspawn", + "mtp", + "fspawn", + "ftp", + "jspawn", + "jtp" + ), + Rel.NEUTRAL, new ArrayList(), + Rel.TRUCE, new ArrayList(), + Rel.ALLY, new ArrayList(), + Rel.MEMBER, new ArrayList() + ); + // -------------------------------------------- // // CHAT // -------------------------------------------- // @@ -87,28 +245,6 @@ public class MConf extends Entity public boolean chatParseTags = true; public EventPriority chatParseTagsAt = EventPriority.LOW; - // HeroChat: The Faction Channel - public String herochatFactionName = "Faction"; - public String herochatFactionNick = "F"; - public String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}"; - public ChatColor herochatFactionColor = ChatColor.GREEN; - public int herochatFactionDistance = 0; - public boolean herochatFactionIsShortcutAllowed = false; - public boolean herochatFactionCrossWorld = true; - public boolean herochatFactionMuted = false; - public Set herochatFactionWorlds = new HashSet(); - - // HeroChat: The Allies Channel - public String herochatAlliesName = "Allies"; - public String herochatAlliesNick = "A"; - public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_name|rp}{sender}{color}] &f{msg}"; - public ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE; - public int herochatAlliesDistance = 0; - public boolean herochatAlliesIsShortcutAllowed = false; - public boolean herochatAlliesCrossWorld = true; - public boolean herochatAlliesMuted = false; - public Set herochatAlliesWorlds = new HashSet(); - // -------------------------------------------- // // COLORS // -------------------------------------------- // @@ -250,7 +386,88 @@ public class MConf extends Entity ); // -------------------------------------------- // - // DYNMAP + // INTEGRATION: HeroChat + // -------------------------------------------- // + + // HeroChat: The Faction Channel + public String herochatFactionName = "Faction"; + public String herochatFactionNick = "F"; + public String herochatFactionFormat = "{color}[&l{nick}&r{color} &l{factions_roleprefix}&r{color}{factions_title|rp}{sender}{color}] &f{msg}"; + public ChatColor herochatFactionColor = ChatColor.GREEN; + public int herochatFactionDistance = 0; + public boolean herochatFactionIsShortcutAllowed = false; + public boolean herochatFactionCrossWorld = true; + public boolean herochatFactionMuted = false; + public Set herochatFactionWorlds = new HashSet(); + + // HeroChat: The Allies Channel + public String herochatAlliesName = "Allies"; + public String herochatAlliesNick = "A"; + public String herochatAlliesFormat = "{color}[&l{nick}&r&f {factions_relcolor}&l{factions_roleprefix}&r{factions_relcolor}{factions_name|rp}{sender}{color}] &f{msg}"; + public ChatColor herochatAlliesColor = ChatColor.DARK_PURPLE; + public int herochatAlliesDistance = 0; + public boolean herochatAlliesIsShortcutAllowed = false; + public boolean herochatAlliesCrossWorld = true; + public boolean herochatAlliesMuted = false; + public Set herochatAlliesWorlds = new HashSet(); + + // -------------------------------------------- // + // INTEGRATION: LWC + // -------------------------------------------- // + + public Map lwcRemoveOnChange = MUtil.map( + EventFactionsChunkChangeType.BUY, false, + EventFactionsChunkChangeType.SELL, false, + EventFactionsChunkChangeType.CONQUER, false, + EventFactionsChunkChangeType.PILLAGE, false + ); + + // -------------------------------------------- // + // INTEGRATION: ECONOMY + // -------------------------------------------- // + + public boolean econEnabled = false; + + // TODO: Rename to include unit. + public double econLandReward = 0.00; + + public String econUniverseAccount = ""; + + public Map econChunkCost = MUtil.map( + EventFactionsChunkChangeType.BUY, 30.0, + EventFactionsChunkChangeType.SELL, -20.0, + EventFactionsChunkChangeType.CONQUER, -10.0, + EventFactionsChunkChangeType.PILLAGE, -10.0 + ); + + public double econCostCreate = 200.0; + public double econCostSethome = 0.0; + public double econCostJoin = 0.0; + public double econCostLeave = 0.0; + public double econCostKick = 0.0; + public double econCostInvite = 0.0; + public double econCostDeinvite = 0.0; + public double econCostHome = 0.0; + public double econCostName = 0.0; + public double econCostDescription = 0.0; + public double econCostTitle = 0.0; + public double econCostOpen = 0.0; + + public Map econRelCost = MUtil.map( + Rel.ENEMY, 0.0, + Rel.ALLY, 0.0, + Rel.TRUCE, 0.0, + Rel.NEUTRAL, 0.0 + ); + + //Faction banks, to pay for land claiming and other costs instead of individuals paying for them + public boolean bankEnabled = true; + //public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction + public boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome + public boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs. + + // -------------------------------------------- // + // INTEGRATION: DYNMAP // -------------------------------------------- // // Should the dynmap intagration be used? diff --git a/src/main/java/com/massivecraft/factions/entity/MConfColl.java b/src/main/java/com/massivecraft/factions/entity/MConfColl.java index 4fed8089..a1201abe 100644 --- a/src/main/java/com/massivecraft/factions/entity/MConfColl.java +++ b/src/main/java/com/massivecraft/factions/entity/MConfColl.java @@ -27,7 +27,6 @@ public class MConfColl extends Coll public void init() { super.init(); - MConf.i = this.get(MassiveCore.INSTANCE, true); } diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayer.java b/src/main/java/com/massivecraft/factions/entity/MPlayer.java index d22f614f..440972a1 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayer.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayer.java @@ -1,59 +1,828 @@ -package com.massivecraft.factions.entity; - -import com.massivecraft.factions.Perm; -import com.massivecraft.massivecore.store.SenderEntity; - -public class MPlayer extends SenderEntity -{ - // -------------------------------------------- // - // META - // -------------------------------------------- // - - public static MPlayer get(Object oid) - { - return MPlayerColl.get().get(oid); - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public MPlayer load(MPlayer that) - { - this.mapAutoUpdating = that.mapAutoUpdating; - this.usingAdminMode = that.usingAdminMode; - - return this; - } - - @Override - public boolean isDefault() - { - if (this.isMapAutoUpdating()) return false; - if (this.isUsingAdminMode()) return false; - - return true; - } - - // -------------------------------------------- // - // FIELDS - // -------------------------------------------- // - - private boolean mapAutoUpdating = false; - public boolean isMapAutoUpdating() { return this.mapAutoUpdating; } - public void setMapAutoUpdating(boolean mapAutoUpdating) { this.mapAutoUpdating = mapAutoUpdating; this.changed(); } - - private boolean usingAdminMode = false; - public boolean isUsingAdminMode() - { - if (this.usingAdminMode && this.getSender() != null && !Perm.ADMIN.has(this.getSender(), false)) - { - // If we are using admin mode but don't have permissions for it we deactivate it. - this.setUsingAdminMode(false); - } - return this.usingAdminMode; - } - public void setUsingAdminMode(boolean usingAdminMode) { this.usingAdminMode = usingAdminMode; this.changed(); } - -} +package com.massivecraft.factions.entity; + +import java.util.HashSet; +import java.util.Set; + +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; +import com.massivecraft.factions.Perm; +import com.massivecraft.factions.Rel; +import com.massivecraft.factions.RelationParticipator; +import com.massivecraft.factions.event.EventFactionsChunkChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange; +import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; +import com.massivecraft.factions.util.RelationUtil; +import com.massivecraft.massivecore.mixin.Mixin; +import com.massivecraft.massivecore.ps.PS; +import com.massivecraft.massivecore.ps.PSFormatHumanSpace; +import com.massivecraft.massivecore.store.SenderEntity; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.MUtil; +import com.massivecraft.massivecore.util.Txt; + + +public class MPlayer extends SenderEntity implements EconomyParticipator +{ + // -------------------------------------------- // + // META + // -------------------------------------------- // + + public static MPlayer get(Object oid) + { + return MPlayerColl.get().get(oid); + } + + // -------------------------------------------- // + // OVERRIDE: ENTITY + // -------------------------------------------- // + + @Override + public MPlayer load(MPlayer that) + { + this.setFactionId(that.factionId); + this.setRole(that.role); + this.setTitle(that.title); + this.setPowerBoost(that.powerBoost); + this.setPower(that.power); + this.setMapAutoUpdating(that.mapAutoUpdating); + this.setUsingAdminMode(that.usingAdminMode); + + return this; + } + + @Override + public boolean isDefault() + { + if (this.hasFaction()) return false; + // Role means nothing without a faction. + // Title means nothing without a faction. + if (this.getPowerRounded() != (int) Math.round(MConf.get().defaultPlayerPower)) return false; + if (this.isMapAutoUpdating()) return false; + if (this.isUsingAdminMode()) return false; + + return true; + } + + @Override + public void postAttach(String id) + { + // If inited ... + if (!Factions.get().isDatabaseInitialized()) return; + + // ... update the index. + Faction faction = this.getFaction(); + faction.uplayers.add(this); + + //Factions.get().log(Txt.parse("postAttach added %s aka %s to %s aka %s.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); + } + + @Override + public void preDetach(String id) + { + // If inited ... + if (!Factions.get().isDatabaseInitialized()) return; + + // ... update the index. + Faction faction = this.getFaction(); + faction.uplayers.remove(this); + + //Factions.get().log(Txt.parse("preDetach removed %s aka %s to %s aka %s.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); + } + + // -------------------------------------------- // + // FIELDS: RAW + // -------------------------------------------- // + // In this section of the source code we place the field declarations only. + // Each field has it's own section further down since just the getter and setter logic takes up quite some place. + + // This is a foreign key. + // Each player belong to a faction. + // Null means default for the universe. + private String factionId = null; + + // What role does the player have in the faction? + // Null means default for the universe. + private Rel role = null; + + // What title does the player have in the faction? + // The title is just for fun. It's not connected to any game mechanic. + // The player title is similar to the faction description. + // + // Question: Can the title contain chat colors? + // Answer: Yes but in such case the policy is that they already must be parsed using Txt.parse. + // If the title contains raw markup, such as "" instead of "§f" it will not be parsed and "" will be displayed. + // + // Null means the player has no title. + private String title = null; + + // Player usually do not have a powerboost. It defaults to 0. + // The powerBoost is a custom increase/decrease to default and maximum power. + // Note that player powerBoost and faction powerBoost are very similar. + private Double powerBoost = null; + + // Each player has an individual power level. + // The power level for online players is occasionally updated by a recurring task and the power should stay the same for offline players. + // For that reason the value is to be considered correct when you pick it. Do not call the power update method. + // Null means default for the universe. + private Double power = null; + + // Has this player requested an auto-updating ascii art map? + // Null means false + private Boolean mapAutoUpdating = null; + + // Is this player using admin mode? + // Null means false + private Boolean usingAdminMode = null; + + // The id for the faction this uplayer is currently autoclaiming for. + // NOTE: This field will not be saved to the database ever. + // Null means the player isn't auto claiming. + private transient Faction autoClaimFaction = null; + public Faction getAutoClaimFaction() { return this.autoClaimFaction; } + public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; } + + // -------------------------------------------- // + // CORE UTILITIES + // -------------------------------------------- // + + public void resetFactionData() + { + // The default neutral faction + this.setFactionId(null); + this.setRole(null); + this.setTitle(null); + this.setAutoClaimFaction(null); + } + + // -------------------------------------------- // + // FIELD: factionId + // -------------------------------------------- // + + public String getDefaultFactionId() + { + return MConf.get().defaultPlayerFactionId; + } + + // This method never returns null + public String getFactionId() + { + if (this.factionId == null) return this.getDefaultFactionId(); + return this.factionId; + } + + // This method never returns null + public Faction getFaction() + { + Faction ret = Faction.get(this.getFactionId()); + if (ret == null) ret = Faction.get(MConf.get().defaultPlayerFactionId); + return ret; + } + + public boolean hasFaction() + { + return !this.getFactionId().equals(MConf.get().factionIdNone); + } + + // This setter is so long because it search for default/null case and takes care of updating the faction member index + public void setFactionId(String factionId) + { + // Clean input + String target = factionId; + + // Detect Nochange + if (MUtil.equals(this.factionId, target)) return; + + // Get the raw old value + String oldFactionId = this.factionId; + + // Apply + this.factionId = target; + + // Must be attached and initialized + if (!this.attached()) return; + if (!Factions.get().isDatabaseInitialized()) return; + + if (oldFactionId == null) oldFactionId = this.getDefaultFactionId(); + + // Update index + Faction oldFaction = Faction.get(oldFactionId); + Faction faction = this.getFaction(); + + if (oldFaction != null) oldFaction.uplayers.remove(this); + if (faction != null) faction.uplayers.add(this); + + String oldFactionIdDesc = "NULL"; + String oldFactionNameDesc = "NULL"; + if (oldFaction != null) + { + oldFactionIdDesc = oldFaction.getId(); + oldFactionNameDesc = oldFaction.getName(); + } + String factionIdDesc = "NULL"; + String factionNameDesc = "NULL"; + if (faction != null) + { + factionIdDesc = faction.getId(); + factionNameDesc = faction.getName(); + } + + Factions.get().log(Txt.parse("setFactionId moved %s aka %s from %s aka %s to %s aka %s.", this.getId(), this.getDisplayName(IdUtil.getConsole()), oldFactionIdDesc, oldFactionNameDesc, factionIdDesc, factionNameDesc)); + + // Mark as changed + this.changed(); + } + + public void setFaction(Faction faction) + { + this.setFactionId(faction.getId()); + } + + // -------------------------------------------- // + // FIELD: role + // -------------------------------------------- // + + public Rel getDefaultRole() + { + return MConf.get().defaultPlayerRole; + } + + public Rel getRole() + { + if (this.role == null) return this.getDefaultRole(); + return this.role; + } + + public void setRole(Rel role) + { + // Clean input + Rel target = role; + + // Detect Nochange + if (MUtil.equals(this.role, target)) return; + + // Apply + this.role = target; + + // Mark as changed + this.changed(); + } + + // -------------------------------------------- // + // FIELD: title + // -------------------------------------------- // + + public boolean hasTitle() + { + return this.title != null; + } + + public String getTitle() + { + if (this.hasTitle()) return this.title; + return Lang.PLAYER_NOTITLE; + } + + public void setTitle(String title) + { + // Clean input + String target = title; + if (target != null) + { + target = target.trim(); + if (target.length() == 0) + { + target = null; + } + } + + // NOTE: That we parse the title here is considered part of the 1.8 --> 2.0 migration. + // This should be removed once the migration phase is considered to be over. + if (target != null) + { + target = Txt.parse(target); + } + + // Detect Nochange + if (MUtil.equals(this.title, target)) return; + + // Apply + this.title = target; + + // Mark as changed + this.changed(); + } + + // -------------------------------------------- // + // FIELD: powerBoost + // -------------------------------------------- // + + public double getPowerBoost() + { + Double ret = this.powerBoost; + if (ret == null) ret = 0D; + return ret; + } + + public void setPowerBoost(Double powerBoost) + { + // Clean input + Double target = powerBoost; + if (target == null || target == 0) target = null; + + // Detect Nochange + if (MUtil.equals(this.powerBoost, target)) return; + + // Apply + this.powerBoost = target; + + // Mark as changed + this.changed(); + } + + public boolean hasPowerBoost() + { + return this.getPowerBoost() != 0D; + } + + // -------------------------------------------- // + // FIELD: power + // -------------------------------------------- // + + // MIXIN: RAW + + public double getPowerMaxUniversal() + { + return Factions.get().getPowerMixin().getMaxUniversal(this); + } + + public double getPowerMax() + { + return Factions.get().getPowerMixin().getMax(this); + } + + public double getPowerMin() + { + return Factions.get().getPowerMixin().getMin(this); + } + + public double getPowerPerHour() + { + return Factions.get().getPowerMixin().getPerHour(this); + } + + public double getPowerPerDeath() + { + return Factions.get().getPowerMixin().getPerDeath(this); + } + + // MIXIN: FINER + + public double getLimitedPower(double power) + { + power = Math.max(power, this.getPowerMin()); + power = Math.min(power, this.getPowerMax()); + + return power; + } + + public int getPowerMaxRounded() + { + return (int) Math.round(this.getPowerMax()); + } + + public int getPowerMinRounded() + { + return (int) Math.round(this.getPowerMin()); + } + + public int getPowerMaxUniversalRounded() + { + return (int) Math.round(this.getPowerMaxUniversal()); + } + + // RAW + + public double getDefaultPower() + { + return MConf.get().defaultPlayerPower; + } + + public double getPower() + { + Double ret = this.power; + if (ret == null) ret = this.getDefaultPower(); + ret = this.getLimitedPower(ret); + return ret; + } + + public void setPower(Double power) + { + // Clean input + Double target = power; + + // Detect Nochange + if (MUtil.equals(this.power, target)) return; + + // Apply + this.power = target; + + // Mark as changed + this.changed(); + } + + // FINER + + public int getPowerRounded() + { + return (int) Math.round(this.getPower()); + } + + // -------------------------------------------- // + // FIELD: mapAutoUpdating + // -------------------------------------------- // + + public boolean isMapAutoUpdating() + { + if (this.mapAutoUpdating == null) return false; + if (this.mapAutoUpdating == false) return false; + return true; + } + + public void setMapAutoUpdating(Boolean mapAutoUpdating) + { + // Clean input + Boolean target = mapAutoUpdating; + if (target == false) target = null; + + // Detect Nochange + if (MUtil.equals(this.mapAutoUpdating, target)) return; + + // Apply + this.mapAutoUpdating = target; + + // Mark as changed + this.changed(); + } + + // -------------------------------------------- // + // FIELD: usingAdminMode + // -------------------------------------------- // + + public boolean isUsingAdminMode() + { + if (this.usingAdminMode == null) return false; + if (this.usingAdminMode == false) return false; + + // Deactivate admin mode if we don't have permissions for it. + if (this.getSender() != null && !Perm.ADMIN.has(this.getSender(), false)) + { + this.setUsingAdminMode(false); + } + + return true; + } + + public void setUsingAdminMode(Boolean usingAdminMode) + { + // Clean input + Boolean target = usingAdminMode; + if (target == false) target = null; + + // Detect Nochange + if (MUtil.equals(this.usingAdminMode, target)) return; + + // Apply + this.usingAdminMode = target; + + // Mark as changed + this.changed(); + } + + // -------------------------------------------- // + // TITLE, NAME, FACTION NAME AND CHAT + // -------------------------------------------- // + + public String getFactionName() + { + Faction faction = this.getFaction(); + if (faction.isNone()) return ""; + return faction.getName(); + } + + // Base concatenations: + + public String getNameAndSomething(String color, String something) + { + String ret = ""; + ret += color; + ret += this.getRole().getPrefix(); + if (something != null && something.length() > 0) + { + ret += something; + ret += " "; + ret += color; + } + ret += this.getName(); + return ret; + } + + public String getNameAndFactionName() + { + return this.getNameAndSomething("", this.getFactionName()); + } + + public String getNameAndTitle(String color) + { + if (this.hasTitle()) + { + return this.getNameAndSomething(color, this.getTitle()); + } + else + { + return this.getNameAndSomething(color, null); + } + } + + // Colored concatenations: + // These are used in information messages + + public String getNameAndTitle(Faction faction) + { + return this.getNameAndTitle(this.getColorTo(faction).toString()); + } + public String getNameAndTitle(MPlayer uplayer) + { + return this.getNameAndTitle(this.getColorTo(uplayer).toString()); + } + + // -------------------------------------------- // + // RELATION AND RELATION COLORS + // -------------------------------------------- // + + @Override + public String describeTo(RelationParticipator observer, boolean ucfirst) + { + return RelationUtil.describeThatToMe(this, observer, ucfirst); + } + + @Override + public String describeTo(RelationParticipator observer) + { + return RelationUtil.describeThatToMe(this, observer); + } + + @Override + public Rel getRelationTo(RelationParticipator observer) + { + return RelationUtil.getRelationOfThatToMe(this, observer); + } + + @Override + public Rel getRelationTo(RelationParticipator observer, boolean ignorePeaceful) + { + return RelationUtil.getRelationOfThatToMe(this, observer, ignorePeaceful); + } + + @Override + public ChatColor getColorTo(RelationParticipator observer) + { + return RelationUtil.getColorOfThatToMe(this, observer); + } + + // -------------------------------------------- // + // HEALTH + // -------------------------------------------- // + + public void heal(int amnt) + { + Player player = this.getPlayer(); + if (player == null) + { + return; + } + player.setHealth(player.getHealth() + amnt); + } + + // -------------------------------------------- // + // TERRITORY + // -------------------------------------------- // + + public boolean isInOwnTerritory() + { + PS ps = Mixin.getSenderPs(this.getId()); + if (ps == null) return false; + return BoardColl.get().getFactionAt(ps) == this.getFaction(); + } + + public boolean isInEnemyTerritory() + { + PS ps = Mixin.getSenderPs(this.getId()); + if (ps == null) return false; + return BoardColl.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY; + } + + // -------------------------------------------- // + // ACTIONS + // -------------------------------------------- // + + public void leave() + { + Faction myFaction = this.getFaction(); + + boolean permanent = myFaction.getFlag(FFlag.PERMANENT); + + if (myFaction.getUPlayers().size() > 1) + { + if (!permanent && this.getRole() == Rel.LEADER) + { + msg("You must give the leader role to someone else first."); + return; + } + + if (!MConf.get().canLeaveWithNegativePower && this.getPower() < 0) + { + msg("You cannot leave until your power is positive."); + return; + } + } + + // Event + EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE); + membershipChangeEvent.run(); + if (membershipChangeEvent.isCancelled()) return; + + if (myFaction.isNormal()) + { + for (MPlayer uplayer : myFaction.getUPlayersWhereOnline(true)) + { + uplayer.msg("%s left %s.", this.describeTo(uplayer, true), myFaction.describeTo(uplayer)); + } + + if (MConf.get().logFactionLeave) + { + Factions.get().log(this.getName()+" left the faction: "+myFaction.getName()); + } + } + + this.resetFactionData(); + + if (myFaction.isNormal() && !permanent && myFaction.getUPlayers().isEmpty()) + { + // Remove this faction + for (MPlayer mplayer : MPlayerColl.get().getAllOnline()) + { + mplayer.msg("%s was disbanded.", myFaction.describeTo(mplayer, true)); + } + + if (MConf.get().logFactionDisband) + { + Factions.get().log("The faction "+myFaction.getName()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving."); + } + myFaction.detach(); + } + } + + public boolean tryClaim(Faction newFaction, PS ps, boolean verbooseChange, boolean verbooseSame) + { + PS chunk = ps.getChunk(true); + Faction oldFaction = BoardColl.get().getFactionAt(chunk); + + MConf mconf = MConf.get(); + + // Validate + if (newFaction == oldFaction) + { + msg("%s already owns this land.", newFaction.describeTo(this, true)); + return true; + } + + if (!this.isUsingAdminMode()) + { + if (newFaction.isNormal()) + { + if (mconf.getWorldsNoClaiming().contains(ps.getWorld())) + { + msg("Sorry, this world has land claiming disabled."); + return false; + } + + if (!FPerm.TERRITORY.has(this, newFaction, true)) + { + return false; + } + + if (newFaction.getUPlayers().size() < mconf.claimsRequireMinFactionMembers) + { + msg("Factions must have at least %s members to claim land.", mconf.claimsRequireMinFactionMembers); + return false; + } + + int ownedLand = newFaction.getLandCount(); + + if (mconf.claimedLandsMax != 0 && ownedLand >= mconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER)) + { + msg("Limit reached. You can't claim more land."); + return false; + } + + if (ownedLand >= newFaction.getPowerRounded()) + { + msg("You can't claim more land. You need more power."); + return false; + } + + if + ( + mconf.claimsMustBeConnected + && + newFaction.getLandCountInWorld(ps.getWorld()) > 0 + && + !BoardColl.get().isConnectedPs(chunk, newFaction) + && + (!mconf.claimsCanBeUnconnectedIfOwnedByOtherFaction || oldFaction.isNone()) + ) + { + if (mconf.claimsCanBeUnconnectedIfOwnedByOtherFaction) + { + msg("You can only claim additional land which is connected to your first claim or controlled by another faction!"); + } + else + { + msg("You can only claim additional land which is connected to your first claim!"); + } + return false; + } + } + + if (oldFaction.isNormal()) + { + if (!FPerm.TERRITORY.has(this, oldFaction, false)) + { + if (!mconf.claimingFromOthersAllowed) + { + msg("You may not claim land from others."); + return false; + } + + if (oldFaction.getRelationTo(newFaction).isAtLeast(Rel.TRUCE)) + { + msg("You can't claim this land due to your relation with the current owner."); + return false; + } + + if (!oldFaction.hasLandInflation()) + { + msg("%s owns this land and is strong enough to keep it.", oldFaction.getName(this)); + return false; + } + + if ( ! BoardColl.get().isBorderPs(chunk)) + { + msg("You must start claiming land at the border of the territory."); + return false; + } + } + } + } + + // Event + EventFactionsChunkChange event = new EventFactionsChunkChange(this.getSender(), chunk, newFaction); + event.run(); + if (event.isCancelled()) return false; + + // Apply + BoardColl.get().setFactionAt(chunk, newFaction); + + // Inform + Set informees = new HashSet(); + informees.add(this); + if (newFaction.isNormal()) + { + informees.addAll(newFaction.getUPlayers()); + } + if (oldFaction.isNormal()) + { + informees.addAll(oldFaction.getUPlayers()); + } + if (MConf.get().logLandClaims) + { + informees.add(MPlayer.get(IdUtil.getConsole())); + } + + String chunkString = chunk.toString(PSFormatHumanSpace.get()); + String typeString = event.getType().toString().toLowerCase(); + for (MPlayer informee : informees) + { + informee.msg("%s did %s %s for %s from %s.", this.describeTo(informee, true), typeString, chunkString, newFaction.describeTo(informee), oldFaction.describeTo(informee)); + } + + return true; + } + +} diff --git a/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java b/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java index 7afd223d..b72b9109 100644 --- a/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java +++ b/src/main/java/com/massivecraft/factions/entity/MPlayerColl.java @@ -2,8 +2,13 @@ package com.massivecraft.factions.entity; import com.massivecraft.factions.Const; import com.massivecraft.factions.Factions; +import com.massivecraft.factions.Rel; +import com.massivecraft.massivecore.mixin.Mixin; import com.massivecraft.massivecore.store.MStore; import com.massivecraft.massivecore.store.SenderColl; +import com.massivecraft.massivecore.util.IdUtil; +import com.massivecraft.massivecore.util.TimeUnit; +import com.massivecraft.massivecore.util.Txt; public class MPlayerColl extends SenderColl { @@ -18,4 +23,101 @@ public class MPlayerColl extends SenderColl super(Const.COLLECTION_MPLAYER, MPlayer.class, MStore.getDb(), Factions.get()); } + // -------------------------------------------- // + // EXTRAS + // -------------------------------------------- // + + public void clean() + { + String universe = this.getUniverse(); + for (MPlayer uplayer : this.getAll()) + { + String factionId = uplayer.getFactionId(); + if (FactionColl.get().containsId(factionId)) continue; + + uplayer.resetFactionData(); + + String message = Txt.parse("Reset data for %s in %s universe. Unknown factionId %s", uplayer.getDisplayName(IdUtil.getConsole()), universe, factionId); + Factions.get().log(message); + } + } + + public void removePlayerDataAfterInactiveDaysRoutine() + { + if (MConf.get().removePlayerDataAfterInactiveDays <= 0.0) return; + + long now = System.currentTimeMillis(); + double toleranceMillis = MConf.get().removePlayerDataAfterInactiveDays * TimeUnit.MILLIS_PER_DAY; + + for (MPlayer uplayer : this.getAll()) + { + Long lastPlayed = Mixin.getLastPlayed(uplayer.getId()); + if (lastPlayed == null) continue; + + if (uplayer.isOnline()) continue; + if (now - lastPlayed <= toleranceMillis) continue; + + if (MConf.get().logFactionLeave || MConf.get().logFactionKick) + { + Factions.get().log("Player "+uplayer.getName()+" was auto-removed due to inactivity."); + } + + // if player is faction leader, sort out the faction since he's going away + if (uplayer.getRole() == Rel.LEADER) + { + Faction faction = uplayer.getFaction(); + if (faction != null) + { + uplayer.getFaction().promoteNewLeader(); + } + } + + uplayer.leave(); + uplayer.detach(); + } + } + + /* +// This method is for the 1.8.X --> 2.0.0 migration + public void migrate() + { + // Create file objects + File oldFile = new File(Factions.get().getDataFolder(), "players.json"); + File newFile = new File(Factions.get().getDataFolder(), "players.json.migrated"); + + // Already migrated? + if ( ! oldFile.exists()) return; + + // Read the file content through GSON. + Type type = new TypeToken>(){}.getType(); + Map id2uplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); + + // The Coll + UPlayerColl coll = this.getForUniverse(MassiveCore.DEFAULT); + + // Set the data + for (Entry entry : id2uplayer.entrySet()) + { + String playerId = entry.getKey(); + UPlayer uplayer = entry.getValue(); + coll.attach(uplayer, playerId); + } + + // Mark as migrated + oldFile.renameTo(newFile); + } + + // -------------------------------------------- // + // EXTRAS + // -------------------------------------------- // + + public void clean() + { + for (UPlayerColl coll : this.getColls()) + { + coll.clean(); + } + } + */ + } diff --git a/src/main/java/com/massivecraft/factions/entity/UConf.java b/src/main/java/com/massivecraft/factions/entity/UConf.java deleted file mode 100644 index 2d9502b6..00000000 --- a/src/main/java/com/massivecraft/factions/entity/UConf.java +++ /dev/null @@ -1,273 +0,0 @@ -package com.massivecraft.factions.entity; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Set; -import java.util.UUID; - -import org.bukkit.command.CommandSender; -import org.bukkit.event.EventPriority; - -import com.massivecraft.factions.FFlag; -import com.massivecraft.factions.FPerm; -import com.massivecraft.factions.Rel; -import com.massivecraft.factions.event.EventFactionsChunkChangeType; -import com.massivecraft.massivecore.store.Entity; -import com.massivecraft.massivecore.store.SenderEntity; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.Txt; - -public class UConf extends Entity -{ - // -------------------------------------------- // - // META - // -------------------------------------------- // - - public static UConf get(Object oid) - { - return UConfColls.get().get2(oid); - } - - // -------------------------------------------- // - // UNIVERSE ENABLE SWITCH - // -------------------------------------------- // - - public boolean enabled = true; - - public static boolean isDisabled(Object universe) - { - return isDisabled(universe, null); - } - - public static String getDisabledMessage(Object universe) - { - UConf uconf = UConf.get(universe); - return Txt.parse("Factions are disabled in the %s universe.", uconf.getUniverse()); - } - - public static boolean isDisabled(Object universe, Object inform) - { - UConf uconf = UConf.get(universe); - if (uconf.enabled) return false; - - if (inform instanceof CommandSender) - { - ((CommandSender)inform).sendMessage(getDisabledMessage(universe)); - } - else if (inform instanceof SenderEntity) - { - ((SenderEntity)inform).sendMessage(getDisabledMessage(universe)); - } - - return true; - } - - // -------------------------------------------- // - // SPECIAL FACTION IDS - // -------------------------------------------- // - - public String factionIdNone = UUID.randomUUID().toString(); - public String factionIdSafezone = UUID.randomUUID().toString(); - public String factionIdWarzone = UUID.randomUUID().toString(); - - // -------------------------------------------- // - // DEFAULTS - // -------------------------------------------- // - - public String defaultPlayerFactionId = this.factionIdNone; - public Rel defaultPlayerRole = Rel.RECRUIT; - public double defaultPlayerPower = 0.0; - - public boolean defaultFactionOpen = false; - public Map defaultFactionFlags = FFlag.getDefaultDefaults(); - public Map> defaultFactionPerms = FPerm.getDefaultDefaults(); - - // -------------------------------------------- // - // MESSAGES - // -------------------------------------------- // - - public boolean broadcastNameChange = false; - - // -------------------------------------------- // - // POWER - // -------------------------------------------- // - - public double powerMax = 10.0; - public double powerMin = 0.0; - public double powerPerHour = 2.0; - public double powerPerDeath = -2.0; - - public boolean canLeaveWithNegativePower = true; - - // -------------------------------------------- // - // CORE - // -------------------------------------------- // - - public int factionMemberLimit = 0; - public double factionPowerMax = 0.0; - - public int factionNameLengthMin = 3; - public int factionNameLengthMax = 16; - public boolean factionNameForceUpperCase = false; - - // -------------------------------------------- // - // CLAIMS - // -------------------------------------------- // - - public boolean claimsMustBeConnected = true; - public boolean claimingFromOthersAllowed = true; - public boolean claimsCanBeUnconnectedIfOwnedByOtherFaction = false; - public int claimsRequireMinFactionMembers = 1; - public int claimedLandsMax = 0; - - // -------------------------------------------- // - // HOMES - // -------------------------------------------- // - - public boolean homesEnabled = true; - public boolean homesMustBeInClaimedTerritory = true; - public boolean homesTeleportCommandEnabled = true; - public boolean homesTeleportAllowedFromEnemyTerritory = true; - public boolean homesTeleportAllowedFromDifferentWorld = true; - public double homesTeleportAllowedEnemyDistance = 32.0; - public boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true; - - public boolean homesTeleportToOnDeathActive = false; - public EventPriority homesTeleportToOnDeathPriority = EventPriority.NORMAL; - - // -------------------------------------------- // - // ASSORTED - // -------------------------------------------- // - - public boolean permanentFactionsDisableLeaderPromotion = false; - public double actionDeniedPainAmount = 2.0D; - public boolean disablePVPForFactionlessPlayers = false; - public boolean enablePVPAgainstFactionlessInAttackersLand = false; - public double territoryShieldFactor = 0.3D; - - // -------------------------------------------- // - // DENY COMMANDS - // -------------------------------------------- // - - // commands which will be prevented if the player is a member of a permanent faction - public List denyCommandsPermanentFactionMember = new ArrayList(); - - // commands which will be prevented when in claimed territory of another faction - public Map> denyCommandsTerritoryRelation = MUtil.map( - Rel.ENEMY, MUtil.list( - // Essentials commands - "home", - "homes", - "sethome", - "createhome", - "tpahere", - "tpaccept", - "tpyes", - "tpa", - "call", - "tpask", - "warp", - "warps", - "spawn", - // Essentials e-alliases - "ehome", - "ehomes", - "esethome", - "ecreatehome", - "etpahere", - "etpaccept", - "etpyes", - "etpa", - "ecall", - "etpask", - "ewarp", - "ewarps", - "espawn", - // Essentials fallback alliases - "essentials:home", - "essentials:homes", - "essentials:sethome", - "essentials:createhome", - "essentials:tpahere", - "essentials:tpaccept", - "essentials:tpyes", - "essentials:tpa", - "essentials:call", - "essentials:tpask", - "essentials:warp", - "essentials:warps", - "essentials:spawn", - // Other plugins - "wtp", - "uspawn", - "utp", - "mspawn", - "mtp", - "fspawn", - "ftp", - "jspawn", - "jtp" - ), - Rel.NEUTRAL, new ArrayList(), - Rel.TRUCE, new ArrayList(), - Rel.ALLY, new ArrayList(), - Rel.MEMBER, new ArrayList() - ); - - // -------------------------------------------- // - // INTEGRATION: LWC - // -------------------------------------------- // - - public Map lwcRemoveOnChange = MUtil.map( - EventFactionsChunkChangeType.BUY, false, - EventFactionsChunkChangeType.SELL, false, - EventFactionsChunkChangeType.CONQUER, false, - EventFactionsChunkChangeType.PILLAGE, false - ); - - // -------------------------------------------- // - // INTEGRATION: ECONOMY - // -------------------------------------------- // - - public boolean econEnabled = false; - - // TODO: Rename to include unit. - public double econLandReward = 0.00; - - public String econUniverseAccount = ""; - - public Map econChunkCost = MUtil.map( - EventFactionsChunkChangeType.BUY, 30.0, - EventFactionsChunkChangeType.SELL, -20.0, - EventFactionsChunkChangeType.CONQUER, -10.0, - EventFactionsChunkChangeType.PILLAGE, -10.0 - ); - - public double econCostCreate = 200.0; - public double econCostSethome = 0.0; - public double econCostJoin = 0.0; - public double econCostLeave = 0.0; - public double econCostKick = 0.0; - public double econCostInvite = 0.0; - public double econCostDeinvite = 0.0; - public double econCostHome = 0.0; - public double econCostName = 0.0; - public double econCostDescription = 0.0; - public double econCostTitle = 0.0; - public double econCostOpen = 0.0; - - public Map econRelCost = MUtil.map( - Rel.ENEMY, 0.0, - Rel.ALLY, 0.0, - Rel.TRUCE, 0.0, - Rel.NEUTRAL, 0.0 - ); - - //Faction banks, to pay for land claiming and other costs instead of individuals paying for them - public boolean bankEnabled = true; - //public static boolean bankMembersCanWithdraw = false; //Have to be at least moderator to withdraw or pay money to another faction - public boolean bankFactionPaysCosts = true; //The faction pays for faction command costs, such as sethome - public boolean bankFactionPaysLandCosts = true; //The faction pays for land claiming costs. - -} diff --git a/src/main/java/com/massivecraft/factions/entity/UConfColl.java b/src/main/java/com/massivecraft/factions/entity/UConfColl.java deleted file mode 100644 index 76683eaf..00000000 --- a/src/main/java/com/massivecraft/factions/entity/UConfColl.java +++ /dev/null @@ -1,30 +0,0 @@ -package com.massivecraft.factions.entity; - -import com.massivecraft.factions.Factions; -import com.massivecraft.massivecore.MassiveCore; -import com.massivecraft.massivecore.store.Coll; -import com.massivecraft.massivecore.store.MStore; - -public class UConfColl extends Coll -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public UConfColl(String name) - { - super(name, UConf.class, MStore.getDb(), Factions.get()); - } - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public void init() - { - super.init(); - this.get(MassiveCore.INSTANCE, true); - } - -} diff --git a/src/main/java/com/massivecraft/factions/entity/UConfColls.java b/src/main/java/com/massivecraft/factions/entity/UConfColls.java deleted file mode 100644 index 85e416e3..00000000 --- a/src/main/java/com/massivecraft/factions/entity/UConfColls.java +++ /dev/null @@ -1,48 +0,0 @@ -package com.massivecraft.factions.entity; - -import com.massivecraft.factions.Const; -import com.massivecraft.factions.Factions; -import com.massivecraft.massivecore.Aspect; -import com.massivecraft.massivecore.MassiveCore; - -public class UConfColls extends XColls -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static UConfColls i = new UConfColls(); - public static UConfColls get() { return i; } - - // -------------------------------------------- // - // OVERRIDE: COLLS - // -------------------------------------------- // - - @Override - public UConfColl createColl(String collName) - { - return new UConfColl(collName); - } - - @Override - public Aspect getAspect() - { - return Factions.get().getAspect(); - } - - @Override - public String getBasename() - { - return Const.COLLECTION_UCONF; - } - - @Override - public UConf get2(Object worldNameExtractable) - { - UConfColl coll = this.get(worldNameExtractable); - if (coll == null) return null; - return coll.get(MassiveCore.INSTANCE); - } - -} - diff --git a/src/main/java/com/massivecraft/factions/entity/UPlayer.java b/src/main/java/com/massivecraft/factions/entity/UPlayer.java deleted file mode 100644 index 9c810aa0..00000000 --- a/src/main/java/com/massivecraft/factions/entity/UPlayer.java +++ /dev/null @@ -1,796 +0,0 @@ -package com.massivecraft.factions.entity; - -import java.util.HashSet; -import java.util.Set; - -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; -import com.massivecraft.factions.Rel; -import com.massivecraft.factions.RelationParticipator; -import com.massivecraft.factions.event.EventFactionsChunkChange; -import com.massivecraft.factions.event.EventFactionsMembershipChange; -import com.massivecraft.factions.event.EventFactionsMembershipChange.MembershipChangeReason; -import com.massivecraft.factions.util.RelationUtil; -import com.massivecraft.massivecore.mixin.Mixin; -import com.massivecraft.massivecore.ps.PS; -import com.massivecraft.massivecore.ps.PSFormatHumanSpace; -import com.massivecraft.massivecore.store.SenderEntity; -import com.massivecraft.massivecore.util.IdUtil; -import com.massivecraft.massivecore.util.MUtil; -import com.massivecraft.massivecore.util.Txt; - - -public class UPlayer extends SenderEntity implements EconomyParticipator -{ - // -------------------------------------------- // - // META - // -------------------------------------------- // - - public static UPlayer get(Object oid) - { - return UPlayerColls.get().get2(oid); - } - - // -------------------------------------------- // - // OVERRIDE: ENTITY - // -------------------------------------------- // - - @Override - public UPlayer load(UPlayer that) - { - this.setFactionId(that.factionId); - this.setRole(that.role); - this.setTitle(that.title); - this.setPowerBoost(that.powerBoost); - this.setPower(that.power); - - return this; - } - - @Override - public boolean isDefault() - { - if (this.hasFaction()) return false; - // Role means nothing without a faction. - // Title means nothing without a faction. - if (this.getPowerRounded() != (int) Math.round(UConf.get(this).defaultPlayerPower)) return false; - - return true; - } - - @Override - public void postAttach(String id) - { - // If inited ... - if (!Factions.get().isDatabaseInitialized()) return; - - // ... update the index. - Faction faction = this.getFaction(); - faction.uplayers.add(this); - - //Factions.get().log(Txt.parse("postAttach added %s aka %s to %s aka %s.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); - } - - @Override - public void preDetach(String id) - { - // If inited ... - if (!Factions.get().isDatabaseInitialized()) return; - - // ... update the index. - Faction faction = this.getFaction(); - faction.uplayers.remove(this); - - //Factions.get().log(Txt.parse("preDetach removed %s aka %s to %s aka %s.", id, Mixin.getDisplayName(id), faction.getId(), faction.getName())); - } - - // -------------------------------------------- // - // FIELDS: RAW - // -------------------------------------------- // - // In this section of the source code we place the field declarations only. - // Each field has it's own section further down since just the getter and setter logic takes up quite some place. - - // This is a foreign key. - // Each player belong to a faction. - // Null means default for the universe. - private String factionId = null; - - // What role does the player have in the faction? - // Null means default for the universe. - private Rel role = null; - - // What title does the player have in the faction? - // The title is just for fun. It's not connected to any game mechanic. - // The player title is similar to the faction description. - // - // Question: Can the title contain chat colors? - // Answer: Yes but in such case the policy is that they already must be parsed using Txt.parse. - // If the title contains raw markup, such as "" instead of "§f" it will not be parsed and "" will be displayed. - // - // Null means the player has no title. - private String title = null; - - // Player usually do not have a powerboost. It defaults to 0. - // The powerBoost is a custom increase/decrease to default and maximum power. - // Note that player powerBoost and faction powerBoost are very similar. - private Double powerBoost = null; - - // Each player has an individual power level. - // The power level for online players is occasionally updated by a recurring task and the power should stay the same for offline players. - // For that reason the value is to be considered correct when you pick it. Do not call the power update method. - // Null means default for the universe. - private Double power = null; - - // The id for the faction this uplayer is currently autoclaiming for. - // NOTE: This field will not be saved to the database ever. - // Null means the player isn't auto claiming. - private transient Faction autoClaimFaction = null; - public Faction getAutoClaimFaction() { return this.autoClaimFaction; } - public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; } - - // -------------------------------------------- // - // FIELDS: MULTIVERSE PROXY - // -------------------------------------------- // - - public boolean isMapAutoUpdating() { return MPlayer.get(this).isMapAutoUpdating(); } - public void setMapAutoUpdating(boolean mapAutoUpdating) { MPlayer.get(this).setMapAutoUpdating(mapAutoUpdating); } - - public boolean isUsingAdminMode() { return MPlayer.get(this).isUsingAdminMode(); } - public void setUsingAdminMode(boolean usingAdminMode) { MPlayer.get(this).setUsingAdminMode(usingAdminMode); } - - // -------------------------------------------- // - // CORE UTILITIES - // -------------------------------------------- // - - public void resetFactionData() - { - // The default neutral faction - this.setFactionId(null); - this.setRole(null); - this.setTitle(null); - this.setAutoClaimFaction(null); - } - - /* - public boolean isPresent(boolean requireFetchable) - { - if (!this.isOnline()) return false; - - if (requireFetchable) - { - - } - else - { - - } - - PS ps = Mixin.getSenderPs(this.getId()); - if (ps == null) return false; - - String psUniverse = Factions.get().getMultiverse().getUniverseForWorldName(ps.getWorld()); - if (!psUniverse.equals(this.getUniverse())) return false; - - if (!requireFetchable) return true; - - Player player = this.getPlayer(); - if (player == null) return false; - - if (player.isDead()) return false; - - return true; - } - */ - - // -------------------------------------------- // - // FIELD: factionId - // -------------------------------------------- // - - public String getDefaultFactionId() - { - return UConf.get(this).defaultPlayerFactionId; - } - - // This method never returns null - public String getFactionId() - { - if (this.factionId == null) return this.getDefaultFactionId(); - return this.factionId; - } - - // This method never returns null - public Faction getFaction() - { - Faction ret = FactionColls.get().get(this).get(this.getFactionId()); - if (ret == null) ret = FactionColls.get().get(this).get(UConf.get(this).defaultPlayerFactionId); - return ret; - } - - public boolean hasFaction() - { - return !this.getFactionId().equals(UConf.get(this).factionIdNone); - } - - // This setter is so long because it search for default/null case and takes care of updating the faction member index - public void setFactionId(String factionId) - { - // Clean input - String target = factionId; - - // Detect Nochange - if (MUtil.equals(this.factionId, target)) return; - - // Get the raw old value - String oldFactionId = this.factionId; - - // Apply - this.factionId = target; - - // Must be attached and initialized - if (!this.attached()) return; - if (!Factions.get().isDatabaseInitialized()) return; - - if (oldFactionId == null) oldFactionId = this.getDefaultFactionId(); - - // Update index - Faction oldFaction = FactionColls.get().get(this).get(oldFactionId); - Faction faction = this.getFaction(); - - if (oldFaction != null) oldFaction.uplayers.remove(this); - if (faction != null) faction.uplayers.add(this); - - String oldFactionIdDesc = "NULL"; - String oldFactionNameDesc = "NULL"; - if (oldFaction != null) - { - oldFactionIdDesc = oldFaction.getId(); - oldFactionNameDesc = oldFaction.getName(); - } - String factionIdDesc = "NULL"; - String factionNameDesc = "NULL"; - if (faction != null) - { - factionIdDesc = faction.getId(); - factionNameDesc = faction.getName(); - } - - Factions.get().log(Txt.parse("setFactionId moved %s aka %s from %s aka %s to %s aka %s.", this.getId(), this.getDisplayName(IdUtil.getConsole()), oldFactionIdDesc, oldFactionNameDesc, factionIdDesc, factionNameDesc)); - - // Mark as changed - this.changed(); - } - - public void setFaction(Faction faction) - { - this.setFactionId(faction.getId()); - } - - // -------------------------------------------- // - // FIELD: role - // -------------------------------------------- // - - public Rel getDefaultRole() - { - return UConf.get(this).defaultPlayerRole; - } - - public Rel getRole() - { - if (this.role == null) return this.getDefaultRole(); - return this.role; - } - - public void setRole(Rel role) - { - // Clean input - Rel target = role; - - // Detect Nochange - if (MUtil.equals(this.role, target)) return; - - // Apply - this.role = target; - - // Mark as changed - this.changed(); - } - - // -------------------------------------------- // - // FIELD: title - // -------------------------------------------- // - - public boolean hasTitle() - { - return this.title != null; - } - - public String getTitle() - { - if (this.hasTitle()) return this.title; - return Lang.PLAYER_NOTITLE; - } - - public void setTitle(String title) - { - // Clean input - String target = title; - if (target != null) - { - target = target.trim(); - if (target.length() == 0) - { - target = null; - } - } - - // NOTE: That we parse the title here is considered part of the 1.8 --> 2.0 migration. - // This should be removed once the migration phase is considered to be over. - if (target != null) - { - target = Txt.parse(target); - } - - // Detect Nochange - if (MUtil.equals(this.title, target)) return; - - // Apply - this.title = target; - - // Mark as changed - this.changed(); - } - - // -------------------------------------------- // - // FIELD: powerBoost - // -------------------------------------------- // - - public double getPowerBoost() - { - Double ret = this.powerBoost; - if (ret == null) ret = 0D; - return ret; - } - - public void setPowerBoost(Double powerBoost) - { - // Clean input - Double target = powerBoost; - if (target == null || target == 0) target = null; - - // Detect Nochange - if (MUtil.equals(this.powerBoost, target)) return; - - // Apply - this.powerBoost = target; - - // Mark as changed - this.changed(); - } - - public boolean hasPowerBoost() - { - return this.getPowerBoost() != 0D; - } - - // -------------------------------------------- // - // FIELD: power - // -------------------------------------------- // - - // MIXIN: RAW - - public double getPowerMaxUniversal() - { - return Factions.get().getPowerMixin().getMaxUniversal(this); - } - - public double getPowerMax() - { - return Factions.get().getPowerMixin().getMax(this); - } - - public double getPowerMin() - { - return Factions.get().getPowerMixin().getMin(this); - } - - public double getPowerPerHour() - { - return Factions.get().getPowerMixin().getPerHour(this); - } - - public double getPowerPerDeath() - { - return Factions.get().getPowerMixin().getPerDeath(this); - } - - // MIXIN: FINER - - public double getLimitedPower(double power) - { - power = Math.max(power, this.getPowerMin()); - power = Math.min(power, this.getPowerMax()); - - return power; - } - - public int getPowerMaxRounded() - { - return (int) Math.round(this.getPowerMax()); - } - - public int getPowerMinRounded() - { - return (int) Math.round(this.getPowerMin()); - } - - public int getPowerMaxUniversalRounded() - { - return (int) Math.round(this.getPowerMaxUniversal()); - } - - // RAW - - public double getDefaultPower() - { - return UConf.get(this).defaultPlayerPower; - } - - public double getPower() - { - Double ret = this.power; - if (ret == null) ret = this.getDefaultPower(); - ret = this.getLimitedPower(ret); - return ret; - } - - public void setPower(Double power) - { - // Clean input - Double target = power; - - // Detect Nochange - if (MUtil.equals(this.power, target)) return; - - // Apply - this.power = target; - - // Mark as changed - this.changed(); - } - - // FINER - - public int getPowerRounded() - { - return (int) Math.round(this.getPower()); - } - - // -------------------------------------------- // - // TITLE, NAME, FACTION NAME AND CHAT - // -------------------------------------------- // - - public String getFactionName() - { - Faction faction = this.getFaction(); - if (faction.isNone()) return ""; - return faction.getName(); - } - - // Base concatenations: - - public String getNameAndSomething(String color, String something) - { - String ret = ""; - ret += color; - ret += this.getRole().getPrefix(); - if (something != null && something.length() > 0) - { - ret += something; - ret += " "; - ret += color; - } - ret += this.getName(); - return ret; - } - - public String getNameAndFactionName() - { - return this.getNameAndSomething("", this.getFactionName()); - } - - public String getNameAndTitle(String color) - { - if (this.hasTitle()) - { - return this.getNameAndSomething(color, this.getTitle()); - } - else - { - return this.getNameAndSomething(color, null); - } - } - - // Colored concatenations: - // These are used in information messages - - public String getNameAndTitle(Faction faction) - { - return this.getNameAndTitle(this.getColorTo(faction).toString()); - } - public String getNameAndTitle(UPlayer uplayer) - { - return this.getNameAndTitle(this.getColorTo(uplayer).toString()); - } - - // -------------------------------------------- // - // RELATION AND RELATION COLORS - // -------------------------------------------- // - - @Override - public String describeTo(RelationParticipator observer, boolean ucfirst) - { - return RelationUtil.describeThatToMe(this, observer, ucfirst); - } - - @Override - public String describeTo(RelationParticipator observer) - { - return RelationUtil.describeThatToMe(this, observer); - } - - @Override - public Rel getRelationTo(RelationParticipator observer) - { - return RelationUtil.getRelationOfThatToMe(this, observer); - } - - @Override - public Rel getRelationTo(RelationParticipator observer, boolean ignorePeaceful) - { - return RelationUtil.getRelationOfThatToMe(this, observer, ignorePeaceful); - } - - @Override - public ChatColor getColorTo(RelationParticipator observer) - { - return RelationUtil.getColorOfThatToMe(this, observer); - } - - // -------------------------------------------- // - // HEALTH - // -------------------------------------------- // - - public void heal(int amnt) - { - Player player = this.getPlayer(); - if (player == null) - { - return; - } - player.setHealth(player.getHealth() + amnt); - } - - // -------------------------------------------- // - // TERRITORY - // -------------------------------------------- // - - public boolean isInOwnTerritory() - { - PS ps = Mixin.getSenderPs(this.getId()); - if (ps == null) return false; - return BoardColls.get().getFactionAt(ps) == this.getFaction(); - } - - public boolean isInEnemyTerritory() - { - PS ps = Mixin.getSenderPs(this.getId()); - if (ps == null) return false; - return BoardColls.get().getFactionAt(ps).getRelationTo(this) == Rel.ENEMY; - } - - // -------------------------------------------- // - // ACTIONS - // -------------------------------------------- // - - public void leave() - { - Faction myFaction = this.getFaction(); - - boolean permanent = myFaction.getFlag(FFlag.PERMANENT); - - if (myFaction.getUPlayers().size() > 1) - { - if (!permanent && this.getRole() == Rel.LEADER) - { - msg("You must give the leader role to someone else first."); - return; - } - - if (!UConf.get(myFaction).canLeaveWithNegativePower && this.getPower() < 0) - { - msg("You cannot leave until your power is positive."); - return; - } - } - - // Event - EventFactionsMembershipChange membershipChangeEvent = new EventFactionsMembershipChange(this.getSender(), this, myFaction, MembershipChangeReason.LEAVE); - membershipChangeEvent.run(); - if (membershipChangeEvent.isCancelled()) return; - - if (myFaction.isNormal()) - { - for (UPlayer uplayer : myFaction.getUPlayersWhereOnline(true)) - { - uplayer.msg("%s left %s.", this.describeTo(uplayer, true), myFaction.describeTo(uplayer)); - } - - if (MConf.get().logFactionLeave) - { - Factions.get().log(this.getName()+" left the faction: "+myFaction.getName()); - } - } - - this.resetFactionData(); - - if (myFaction.isNormal() && !permanent && myFaction.getUPlayers().isEmpty()) - { - // Remove this faction - for (UPlayer uplayer : UPlayerColls.get().get(this).getAllOnline()) - { - uplayer.msg("%s was disbanded.", myFaction.describeTo(uplayer, true)); - } - - if (MConf.get().logFactionDisband) - { - Factions.get().log("The faction "+myFaction.getName()+" ("+myFaction.getId()+") was disbanded due to the last player ("+this.getName()+") leaving."); - } - myFaction.detach(); - } - } - - public boolean tryClaim(Faction newFaction, PS ps, boolean verbooseChange, boolean verbooseSame) - { - PS chunk = ps.getChunk(true); - Faction oldFaction = BoardColls.get().getFactionAt(chunk); - - UConf uconf = UConf.get(newFaction); - MConf mconf = MConf.get(); - - // Validate - if (newFaction == oldFaction) - { - msg("%s already owns this land.", newFaction.describeTo(this, true)); - return true; - } - - if (!this.isUsingAdminMode()) - { - if (newFaction.isNormal()) - { - if (mconf.getWorldsNoClaiming().contains(ps.getWorld())) - { - msg("Sorry, this world has land claiming disabled."); - return false; - } - - if (!FPerm.TERRITORY.has(this, newFaction, true)) - { - return false; - } - - if (newFaction.getUPlayers().size() < uconf.claimsRequireMinFactionMembers) - { - msg("Factions must have at least %s members to claim land.", uconf.claimsRequireMinFactionMembers); - return false; - } - - int ownedLand = newFaction.getLandCount(); - - if (uconf.claimedLandsMax != 0 && ownedLand >= uconf.claimedLandsMax && ! newFaction.getFlag(FFlag.INFPOWER)) - { - msg("Limit reached. You can't claim more land."); - return false; - } - - if (ownedLand >= newFaction.getPowerRounded()) - { - msg("You can't claim more land. You need more power."); - return false; - } - - if - ( - uconf.claimsMustBeConnected - && - newFaction.getLandCountInWorld(ps.getWorld()) > 0 - && - !BoardColls.get().isConnectedPs(chunk, newFaction) - && - (!uconf.claimsCanBeUnconnectedIfOwnedByOtherFaction || oldFaction.isNone()) - ) - { - if (uconf.claimsCanBeUnconnectedIfOwnedByOtherFaction) - { - msg("You can only claim additional land which is connected to your first claim or controlled by another faction!"); - } - else - { - msg("You can only claim additional land which is connected to your first claim!"); - } - return false; - } - } - - if (oldFaction.isNormal()) - { - if (!FPerm.TERRITORY.has(this, oldFaction, false)) - { - if (!uconf.claimingFromOthersAllowed) - { - msg("You may not claim land from others."); - return false; - } - - if (oldFaction.getRelationTo(newFaction).isAtLeast(Rel.TRUCE)) - { - msg("You can't claim this land due to your relation with the current owner."); - return false; - } - - if (!oldFaction.hasLandInflation()) - { - msg("%s owns this land and is strong enough to keep it.", oldFaction.getName(this)); - return false; - } - - if ( ! BoardColls.get().isBorderPs(chunk)) - { - msg("You must start claiming land at the border of the territory."); - return false; - } - } - } - } - - // Event - EventFactionsChunkChange event = new EventFactionsChunkChange(this.getSender(), chunk, newFaction); - event.run(); - if (event.isCancelled()) return false; - - // Apply - BoardColls.get().setFactionAt(chunk, newFaction); - - // Inform - Set informees = new HashSet(); - informees.add(this); - if (newFaction.isNormal()) - { - informees.addAll(newFaction.getUPlayers()); - } - if (oldFaction.isNormal()) - { - informees.addAll(oldFaction.getUPlayers()); - } - if (MConf.get().logLandClaims) - { - informees.add(UPlayer.get(IdUtil.getConsole())); - } - - String chunkString = chunk.toString(PSFormatHumanSpace.get()); - String typeString = event.getType().toString().toLowerCase(); - for (UPlayer informee : informees) - { - informee.msg("%s did %s %s for %s from %s.", this.describeTo(informee, true), typeString, chunkString, newFaction.describeTo(informee), oldFaction.describeTo(informee)); - } - - return true; - } - -} diff --git a/src/main/java/com/massivecraft/factions/entity/UPlayerColl.java b/src/main/java/com/massivecraft/factions/entity/UPlayerColl.java deleted file mode 100644 index 5f94fe8f..00000000 --- a/src/main/java/com/massivecraft/factions/entity/UPlayerColl.java +++ /dev/null @@ -1,77 +0,0 @@ -package com.massivecraft.factions.entity; - -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.Rel; -import com.massivecraft.massivecore.mixin.Mixin; -import com.massivecraft.massivecore.store.MStore; -import com.massivecraft.massivecore.store.SenderColl; -import com.massivecraft.massivecore.util.IdUtil; -import com.massivecraft.massivecore.util.TimeUnit; -import com.massivecraft.massivecore.util.Txt; - -public class UPlayerColl extends SenderColl -{ - // -------------------------------------------- // - // CONSTRUCT - // -------------------------------------------- // - - public UPlayerColl(String name) - { - super(name, UPlayer.class, MStore.getDb(), Factions.get()); - } - - // -------------------------------------------- // - // EXTRAS - // -------------------------------------------- // - - public void clean() - { - FactionColl factionColl = FactionColls.get().get(this); - String universe = this.getUniverse(); - for (UPlayer uplayer : this.getAll()) - { - String factionId = uplayer.getFactionId(); - if (factionColl.containsId(factionId)) continue; - - uplayer.resetFactionData(); - - String message = Txt.parse("Reset data for %s in %s universe. Unknown factionId %s", uplayer.getDisplayName(IdUtil.getConsole()), universe, factionId); - Factions.get().log(message); - } - } - - public void removePlayerDataAfterInactiveDaysRoutine() - { - if (MConf.get().removePlayerDataAfterInactiveDays <= 0.0) return; - - long now = System.currentTimeMillis(); - double toleranceMillis = MConf.get().removePlayerDataAfterInactiveDays * TimeUnit.MILLIS_PER_DAY; - - for (UPlayer uplayer : this.getAll()) - { - Long lastPlayed = Mixin.getLastPlayed(uplayer.getId()); - if (lastPlayed == null) continue; - - if (uplayer.isOnline()) continue; - if (now - lastPlayed <= toleranceMillis) continue; - - if (MConf.get().logFactionLeave || MConf.get().logFactionKick) - { - Factions.get().log("Player "+uplayer.getName()+" was auto-removed due to inactivity."); - } - - // if player is faction leader, sort out the faction since he's going away - if (uplayer.getRole() == Rel.LEADER) - { - Faction faction = uplayer.getFaction(); - if (faction != null) - { - uplayer.getFaction().promoteNewLeader(); - } - } - - uplayer.leave(); - uplayer.detach(); - } - } -} diff --git a/src/main/java/com/massivecraft/factions/entity/UPlayerColls.java b/src/main/java/com/massivecraft/factions/entity/UPlayerColls.java deleted file mode 100644 index 1726dfd2..00000000 --- a/src/main/java/com/massivecraft/factions/entity/UPlayerColls.java +++ /dev/null @@ -1,95 +0,0 @@ -package com.massivecraft.factions.entity; - -import java.io.File; -import java.lang.reflect.Type; -import java.util.Map; -import java.util.Map.Entry; - -import com.massivecraft.factions.Const; -import com.massivecraft.factions.Factions; -import com.massivecraft.massivecore.Aspect; -import com.massivecraft.massivecore.MassiveCore; -import com.massivecraft.massivecore.util.DiscUtil; -import com.massivecraft.massivecore.xlib.gson.reflect.TypeToken; - -public class UPlayerColls extends XColls -{ - // -------------------------------------------- // - // INSTANCE & CONSTRUCT - // -------------------------------------------- // - - private static UPlayerColls i = new UPlayerColls(); - public static UPlayerColls get() { return i; } - - // -------------------------------------------- // - // OVERRIDE: COLLS - // -------------------------------------------- // - - @Override - public UPlayerColl createColl(String collName) - { - return new UPlayerColl(collName); - } - - @Override - public Aspect getAspect() - { - return Factions.get().getAspect(); - } - - @Override - public String getBasename() - { - return Const.COLLECTION_UPLAYER; - } - - @Override - public void init() - { - super.init(); - - this.migrate(); - } - - // This method is for the 1.8.X --> 2.0.0 migration - public void migrate() - { - // Create file objects - File oldFile = new File(Factions.get().getDataFolder(), "players.json"); - File newFile = new File(Factions.get().getDataFolder(), "players.json.migrated"); - - // Already migrated? - if ( ! oldFile.exists()) return; - - // Read the file content through GSON. - Type type = new TypeToken>(){}.getType(); - Map id2uplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); - - // The Coll - UPlayerColl coll = this.getForUniverse(MassiveCore.DEFAULT); - - // Set the data - for (Entry entry : id2uplayer.entrySet()) - { - String playerId = entry.getKey(); - UPlayer uplayer = entry.getValue(); - coll.attach(uplayer, playerId); - } - - // Mark as migrated - oldFile.renameTo(newFile); - } - - // -------------------------------------------- // - // EXTRAS - // -------------------------------------------- // - - public void clean() - { - for (UPlayerColl coll : this.getColls()) - { - coll.clean(); - } - } - -} diff --git a/src/main/java/com/massivecraft/factions/entity/XColls.java b/src/main/java/com/massivecraft/factions/entity/XColls.java deleted file mode 100644 index 45a59a1a..00000000 --- a/src/main/java/com/massivecraft/factions/entity/XColls.java +++ /dev/null @@ -1,42 +0,0 @@ -package com.massivecraft.factions.entity; - -import org.bukkit.Bukkit; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.massivecraft.massivecore.store.Coll; -import com.massivecraft.massivecore.store.Colls; -import com.massivecraft.massivecore.store.Entity; -import com.massivecraft.massivecore.util.MUtil; - -public abstract class XColls, E> extends Colls -{ - @Override - public C get(Object o) - { - if (o == null) return null; - - if (o instanceof Entity) - { - String universe = ((Entity)o).getUniverse(); - if (universe == null) return null; - return this.getForUniverse(universe); - } - - if (o instanceof Coll) - { - String universe = ((Coll)o).getUniverse(); - if (universe == null) return null; - return this.getForUniverse(universe); - } - - if ((o instanceof CommandSender) && !(o instanceof Player)) - { - return this.getForWorld(Bukkit.getWorlds().get(0).getName()); - } - - String worldName = MUtil.extract(String.class, "worldName", o); - if (worldName == null) return null; - return this.getForWorld(worldName); - } -} diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsAbstractSender.java b/src/main/java/com/massivecraft/factions/event/EventFactionsAbstractSender.java index e4907a3f..1535ff05 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsAbstractSender.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsAbstractSender.java @@ -2,7 +2,7 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.event.EventMassiveCore; public abstract class EventFactionsAbstractSender extends EventMassiveCore @@ -13,7 +13,7 @@ public abstract class EventFactionsAbstractSender extends EventMassiveCore private final CommandSender sender; public CommandSender getSender() { return this.sender; } - public UPlayer getUSender() { return this.sender == null ? null : UPlayer.get(this.sender); } + public MPlayer getUSender() { return this.sender == null ? null : MPlayer.get(this.sender); } // -------------------------------------------- // // CONSTRUCT diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsChunkChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsChunkChange.java index bc2f7e46..52293735 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsChunkChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsChunkChange.java @@ -3,9 +3,9 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; -import com.massivecraft.factions.entity.BoardColls; +import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.ps.PS; public class EventFactionsChunkChange extends EventFactionsAbstractSender @@ -37,7 +37,7 @@ public class EventFactionsChunkChange extends EventFactionsAbstractSender { super(sender); this.chunk = chunk.getChunk(true); - this.currentFaction = BoardColls.get().getFactionAt(chunk); + this.currentFaction = BoardColl.get().getFactionAt(chunk); this.newFaction = newFaction; } @@ -50,7 +50,7 @@ public class EventFactionsChunkChange extends EventFactionsAbstractSender if (currentFaction.isNone()) return EventFactionsChunkChangeType.BUY; if (newFaction.isNormal()) return EventFactionsChunkChangeType.CONQUER; - UPlayer usender = this.getUSender(); + MPlayer usender = this.getUSender(); if (usender != null && usender.getFaction() == currentFaction) return EventFactionsChunkChangeType.SELL; return EventFactionsChunkChangeType.PILLAGE; diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsCreate.java b/src/main/java/com/massivecraft/factions/event/EventFactionsCreate.java index f6d5ba1c..08de29b3 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsCreate.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsCreate.java @@ -17,9 +17,6 @@ public class EventFactionsCreate extends EventFactionsAbstractSender // FIELDS // -------------------------------------------- // - private final String universe; - public final String getUniverse() { return this.universe; } - private final String factionId; public final String getFactionId() { return this.factionId; } @@ -30,10 +27,9 @@ public class EventFactionsCreate extends EventFactionsAbstractSender // CONSTRUCT // -------------------------------------------- // - public EventFactionsCreate(CommandSender sender, String universe, String factionId, String factionName) + public EventFactionsCreate(CommandSender sender, String factionId, String factionName) { super(sender); - this.universe = universe; this.factionId = factionId; this.factionName = factionName; } diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsInvitedChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsInvitedChange.java index 93bcf62b..64c0f9d3 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsInvitedChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsInvitedChange.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; public class EventFactionsInvitedChange extends EventFactionsAbstractSender @@ -20,8 +20,8 @@ public class EventFactionsInvitedChange extends EventFactionsAbstractSender // FIELDS // -------------------------------------------- // - private final UPlayer uplayer; - public UPlayer getUPlayer() { return this.uplayer; } + private final MPlayer uplayer; + public MPlayer getUPlayer() { return this.uplayer; } private final Faction faction; public Faction getFaction() { return this.faction; } @@ -34,7 +34,7 @@ public class EventFactionsInvitedChange extends EventFactionsAbstractSender // CONSTRUCT // -------------------------------------------- // - public EventFactionsInvitedChange(CommandSender sender, UPlayer uplayer, Faction faction, boolean newInvited) + public EventFactionsInvitedChange(CommandSender sender, MPlayer uplayer, Faction faction, boolean newInvited) { super(sender); this.uplayer = uplayer; diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsMembershipChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsMembershipChange.java index 402f2f8b..5c545ac1 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsMembershipChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsMembershipChange.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; public class EventFactionsMembershipChange extends EventFactionsAbstractSender @@ -27,8 +27,8 @@ public class EventFactionsMembershipChange extends EventFactionsAbstractSender super.setCancelled(cancelled); } - private final UPlayer uplayer; - public UPlayer getUPlayer() { return this.uplayer; } + private final MPlayer uplayer; + public MPlayer getUPlayer() { return this.uplayer; } private final Faction newFaction; public Faction getNewFaction() { return this.newFaction; } @@ -40,7 +40,7 @@ public class EventFactionsMembershipChange extends EventFactionsAbstractSender // CONSTRUCT // -------------------------------------------- // - public EventFactionsMembershipChange(CommandSender sender, UPlayer uplayer, Faction newFaction, MembershipChangeReason reason) + public EventFactionsMembershipChange(CommandSender sender, MPlayer uplayer, Faction newFaction, MembershipChangeReason reason) { super(sender); this.uplayer = uplayer; diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsPowerChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsPowerChange.java index 0361086c..be8efa5f 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsPowerChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsPowerChange.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public class EventFactionsPowerChange extends EventFactionsAbstractSender { @@ -19,8 +19,8 @@ public class EventFactionsPowerChange extends EventFactionsAbstractSender // FIELDS // -------------------------------------------- // - private final UPlayer uplayer; - public UPlayer getUPlayer() { return this.uplayer; } + private final MPlayer uplayer; + public MPlayer getUPlayer() { return this.uplayer; } private final PowerChangeReason reason; public PowerChangeReason getReason() { return this.reason; } @@ -33,7 +33,7 @@ public class EventFactionsPowerChange extends EventFactionsAbstractSender // CONSTRUCT // -------------------------------------------- // - public EventFactionsPowerChange(CommandSender sender, UPlayer uplayer, PowerChangeReason reason, double newPower) + public EventFactionsPowerChange(CommandSender sender, MPlayer uplayer, PowerChangeReason reason, double newPower) { super(sender); this.uplayer = uplayer; diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsPvpDisallowed.java b/src/main/java/com/massivecraft/factions/event/EventFactionsPvpDisallowed.java index 23ab32f6..926f2f25 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsPvpDisallowed.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsPvpDisallowed.java @@ -4,7 +4,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.HandlerList; import org.bukkit.event.entity.EntityDamageByEntityEvent; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; /** * This event is fired when PVP is disallowed between players due to any rules in Factions. @@ -29,11 +29,11 @@ public class EventFactionsPvpDisallowed extends EventFactionsAbstract private final Player attacker; public Player getAttacker() { return this.attacker; } - public UPlayer getUAttacker() { return this.attacker == null ? null : UPlayer.get(this.attacker); } + public MPlayer getUAttacker() { return this.attacker == null ? null : MPlayer.get(this.attacker); } private final Player defender; public Player getDefender() { return this.defender; } - public UPlayer getUDefender() { return this.defender == null ? null : UPlayer.get(this.defender); } + public MPlayer getUDefender() { return this.defender == null ? null : MPlayer.get(this.defender); } private final EntityDamageByEntityEvent event; public EntityDamageByEntityEvent getEvent() { return this.event; } diff --git a/src/main/java/com/massivecraft/factions/event/EventFactionsTitleChange.java b/src/main/java/com/massivecraft/factions/event/EventFactionsTitleChange.java index edcf7043..4fa64ca8 100644 --- a/src/main/java/com/massivecraft/factions/event/EventFactionsTitleChange.java +++ b/src/main/java/com/massivecraft/factions/event/EventFactionsTitleChange.java @@ -3,7 +3,7 @@ package com.massivecraft.factions.event; import org.bukkit.command.CommandSender; import org.bukkit.event.HandlerList; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public class EventFactionsTitleChange extends EventFactionsAbstractSender { @@ -19,8 +19,8 @@ public class EventFactionsTitleChange extends EventFactionsAbstractSender // FIELDS // -------------------------------------------- // - private final UPlayer uplayer; - public UPlayer getUPlayer() { return this.uplayer; } + private final MPlayer uplayer; + public MPlayer getUPlayer() { return this.uplayer; } private String newTitle; public String getNewTitle() { return this.newTitle; } @@ -30,7 +30,7 @@ public class EventFactionsTitleChange extends EventFactionsAbstractSender // CONSTRUCT // -------------------------------------------- // - public EventFactionsTitleChange(CommandSender sender, UPlayer uplayer, String newTitle) + public EventFactionsTitleChange(CommandSender sender, MPlayer uplayer, String newTitle) { super(sender); this.uplayer = uplayer; diff --git a/src/main/java/com/massivecraft/factions/integration/Econ.java b/src/main/java/com/massivecraft/factions/integration/Econ.java index e6539c15..1524fb6c 100644 --- a/src/main/java/com/massivecraft/factions/integration/Econ.java +++ b/src/main/java/com/massivecraft/factions/integration/Econ.java @@ -5,8 +5,8 @@ import java.util.Set; import com.massivecraft.factions.EconomyParticipator; import com.massivecraft.factions.FPerm; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.util.RelationUtil; import com.massivecraft.massivecore.money.Money; @@ -17,27 +17,25 @@ public class Econ // STATE // -------------------------------------------- // - // TODO: Do we really need that config option? - // TODO: Could we not have it enabled as long as Money.enabled is true? - public static boolean isEnabled(Object universe) + public static boolean isEnabled() { - return UConf.get(universe).econEnabled && Money.enabled(); + return MConf.get().econEnabled && Money.enabled(); } // -------------------------------------------- // // UTIL // -------------------------------------------- // - public static boolean payForAction(double cost, UPlayer usender, String actionDescription) + public static boolean payForAction(double cost, MPlayer usender, String actionDescription) { - if (!isEnabled(usender)) return true; + if (!isEnabled()) return true; if (cost == 0D) return true; if (usender.isUsingAdminMode()) return true; - UConf uconf = UConf.get(usender); + Faction usenderFaction = usender.getFaction(); - if (uconf.bankEnabled && uconf.bankFactionPaysCosts && usenderFaction.isNormal()) + if (MConf.get().bankEnabled && MConf.get().bankFactionPaysCosts && usenderFaction.isNormal()) { return modifyMoney(usenderFaction, -cost, actionDescription); } @@ -53,18 +51,17 @@ public class Econ public static void modifyUniverseMoney(Object universe, double delta) { - if (!isEnabled(universe)) return; - UConf uconf = UConf.get(universe); + if (!isEnabled()) return; - if (uconf.econUniverseAccount == null) return; - if (uconf.econUniverseAccount.length() == 0) return; + if (MConf.get().econUniverseAccount == null) return; + if (MConf.get().econUniverseAccount.length() == 0) return; - if (!Money.exists(uconf.econUniverseAccount)) return; + if (!Money.exists(MConf.get().econUniverseAccount)) return; - Money.spawn(uconf.econUniverseAccount, null, delta); + Money.spawn(MConf.get().econUniverseAccount, null, delta); } - public static void sendBalanceInfo(UPlayer to, EconomyParticipator about) + public static void sendBalanceInfo(MPlayer to, EconomyParticipator about) { to.msg("%s's balance is %s.", about.describeTo(to, true), Money.format(Money.get(about))); } @@ -78,7 +75,7 @@ public class Econ if (fI == null) return true; // Bypassing players can do any kind of transaction - if (i instanceof UPlayer && ((UPlayer)i).isUsingAdminMode()) return true; + if (i instanceof MPlayer && ((MPlayer)i).isUsingAdminMode()) return true; // You can deposit to anywhere you feel like. It's your loss if you can't withdraw it again. if (i == you) return true; @@ -92,7 +89,7 @@ public class Econ if (you instanceof Faction) { if (i instanceof Faction && FPerm.WITHDRAW.has((Faction)i, fYou)) return true; - if (i instanceof UPlayer && FPerm.WITHDRAW.has((UPlayer)i, fYou, false)) return true; + if (i instanceof MPlayer && FPerm.WITHDRAW.has((MPlayer)i, fYou, false)) return true; } // Otherwise you may not! ;,,; @@ -105,7 +102,7 @@ public class Econ } public static boolean transferMoney(EconomyParticipator from, EconomyParticipator to, EconomyParticipator by, double amount, boolean notify) { - if (!isEnabled(from)) return false; + if (!isEnabled()) return false; // The amount must be positive. // If the amount is negative we must flip and multiply amount with -1. @@ -155,17 +152,17 @@ public class Econ } } - public static Set getUPlayers(EconomyParticipator ep) + public static Set getUPlayers(EconomyParticipator ep) { - Set uplayers = new HashSet(); + Set uplayers = new HashSet(); if (ep == null) { // Add nothing } - else if (ep instanceof UPlayer) + else if (ep instanceof MPlayer) { - uplayers.add((UPlayer)ep); + uplayers.add((MPlayer)ep); } else if (ep instanceof Faction) { @@ -177,35 +174,35 @@ public class Econ public static void sendTransferInfo(EconomyParticipator invoker, EconomyParticipator from, EconomyParticipator to, double amount) { - Set recipients = new HashSet(); + Set recipients = new HashSet(); recipients.addAll(getUPlayers(invoker)); recipients.addAll(getUPlayers(from)); recipients.addAll(getUPlayers(to)); if (invoker == null) { - for (UPlayer recipient : recipients) + for (MPlayer recipient : recipients) { recipient.msg("%s was transfered from %s to %s.", Money.format(amount), from.describeTo(recipient), to.describeTo(recipient)); } } else if (invoker == from) { - for (UPlayer recipient : recipients) + for (MPlayer recipient : recipients) { recipient.msg("%s gave %s to %s.", from.describeTo(recipient, true), Money.format(amount), to.describeTo(recipient)); } } else if (invoker == to) { - for (UPlayer recipient : recipients) + for (MPlayer recipient : recipients) { recipient.msg("%s took %s from %s.", to.describeTo(recipient, true), Money.format(amount), from.describeTo(recipient)); } } else { - for (UPlayer recipient : recipients) + for (MPlayer recipient : recipients) { recipient.msg("%s transfered %s from %s to %s.", invoker.describeTo(recipient, true), Money.format(amount), from.describeTo(recipient), to.describeTo(recipient)); } @@ -214,7 +211,7 @@ public class Econ public static boolean hasAtLeast(EconomyParticipator ep, double delta, String toDoThis) { - if (!isEnabled(ep)) return true; + if (!isEnabled()) return true; if (Money.get(ep) < delta) { @@ -229,7 +226,7 @@ public class Econ public static boolean modifyMoney(EconomyParticipator ep, double delta, String actionDescription) { - if (!isEnabled(ep)) return false; + if (!isEnabled()) return false; if (delta == 0) return true; String You = ep.describeTo(ep, true); 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 6da14517..d7dcbb4d 100644 --- a/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java +++ b/src/main/java/com/massivecraft/factions/integration/dynmap/EngineDynmap.java @@ -28,13 +28,10 @@ import com.massivecraft.factions.Rel; import com.massivecraft.factions.TerritoryAccess; import com.massivecraft.factions.entity.Board; import com.massivecraft.factions.entity.BoardColl; -import com.massivecraft.factions.entity.BoardColls; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.massivecore.EngineAbstract; import com.massivecraft.massivecore.money.Money; import com.massivecraft.massivecore.ps.PS; @@ -241,28 +238,25 @@ public class EngineDynmap extends EngineAbstract Map ret = new HashMap(); // Loop current factions - for (FactionColl coll : FactionColls.get().getColls()) + for (Faction faction : FactionColl.get().getAll()) { - for (Faction faction : coll.getAll()) - { - PS ps = faction.getHome(); - if (ps == null) continue; - - DynmapStyle style = getStyle(faction); - - String markerId = FACTIONS_HOME_ + faction.getId(); - - TempMarker temp = new TempMarker(); - temp.label = ChatColor.stripColor(faction.getName()); - temp.world = ps.getWorld(); - temp.x = ps.getLocationX(); - temp.y = ps.getLocationY(); - temp.z = ps.getLocationZ(); - temp.iconName = style.getHomeMarker(); - temp.description = getDescription(faction); - - ret.put(markerId, temp); - } + PS ps = faction.getHome(); + if (ps == null) continue; + + DynmapStyle style = getStyle(faction); + + String markerId = FACTIONS_HOME_ + faction.getId(); + + TempMarker temp = new TempMarker(); + temp.label = ChatColor.stripColor(faction.getName()); + temp.world = ps.getWorld(); + temp.x = ps.getLocationX(); + temp.y = ps.getLocationY(); + temp.z = ps.getLocationZ(); + temp.iconName = style.getHomeMarker(); + temp.description = getDescription(faction); + + ret.put(markerId, temp); } return ret; @@ -327,42 +321,41 @@ public class EngineDynmap extends EngineAbstract { // Create map "world name --> faction --> set of chunk coords" Map>> worldFactionChunks = new HashMap>>(); - for (BoardColl coll : BoardColls.get().getColls()) + + // Note: The board is the world. The board id is the world name. + for (Board board : BoardColl.get().getAll()) { - // Note: The board is the world. The board id is the world name. - for (Board board : coll.getAll()) + String world = board.getId(); + + // Get the factionChunks creatively. + Map> factionChunks = worldFactionChunks.get(world); + if (factionChunks == null) { - String world = board.getId(); + factionChunks = new HashMap>(); + worldFactionChunks.put(world, factionChunks); + } + + // Populate the factionChunks + for (Entry entry : board.getMap().entrySet()) + { + PS chunk = entry.getKey(); + TerritoryAccess territoryAccess = entry.getValue(); + String factionId = territoryAccess.getHostFactionId(); + Faction faction = Faction.get(factionId); + if (faction == null) continue; - // Get the factionChunks creatively. - Map> factionChunks = worldFactionChunks.get(world); - if (factionChunks == null) + // Get the chunks creatively. + Set chunks = factionChunks.get(faction); + if (chunks == null) { - factionChunks = new HashMap>(); - worldFactionChunks.put(world, factionChunks); - } - - // Populate the factionChunks - for (Entry entry : board.getMap().entrySet()) - { - PS chunk = entry.getKey(); - TerritoryAccess territoryAccess = entry.getValue(); - String factionId = territoryAccess.getHostFactionId(); - Faction faction = FactionColls.get().getForWorld(world).get(factionId); - if (faction == null) continue; - - // Get the chunks creatively. - Set chunks = factionChunks.get(faction); - if (chunks == null) - { - chunks = new HashSet(); - factionChunks.put(faction, chunks); - } - - chunks.add(chunk); + chunks = new HashSet(); + factionChunks.put(faction, chunks); } + + chunks.add(chunk); } } + return worldFactionChunks; } @@ -659,7 +652,7 @@ public class EngineDynmap extends EngineAbstract Set ret = new HashSet(); - for (UPlayer uplayer : faction.getUPlayers()) + for (MPlayer uplayer : faction.getUPlayers()) { // NOTE: We add both UUID and name. This might be a good idea for future proofing. ret.add(uplayer.getId()); @@ -675,17 +668,14 @@ public class EngineDynmap extends EngineAbstract if (!MConf.get().dynmapVisibilityByFaction) return null; Map> ret = new HashMap>(); - - for (FactionColl coll : FactionColls.get().getColls()) + + for (Faction faction : FactionColl.get().getAll()) { - for (Faction faction : coll.getAll()) - { - String playersetId = createPlayersetId(faction); - if (playersetId == null) continue; - Set playerIds = createPlayerset(faction); - if (playerIds == null) continue; - ret.put(playersetId, playerIds); - } + String playersetId = createPlayersetId(faction); + if (playersetId == null) continue; + Set playerIds = createPlayerset(faction); + if (playerIds == null) continue; + ret.put(playersetId, playerIds); } return ret; @@ -761,7 +751,7 @@ public class EngineDynmap extends EngineAbstract // Money String money = "unavailable"; - if (UConf.get(faction).bankEnabled && MConf.get().dynmapDescriptionMoney) + if (MConf.get().bankEnabled && MConf.get().dynmapDescriptionMoney) { money = Money.format(Money.get(faction)); } @@ -789,22 +779,22 @@ public class EngineDynmap extends EngineAbstract } // Players - List playersList = faction.getUPlayers(); + List playersList = faction.getUPlayers(); String playersCount = String.valueOf(playersList.size()); String players = getPlayerString(playersList); - UPlayer playersLeaderObject = faction.getLeader(); + MPlayer playersLeaderObject = faction.getLeader(); String playersLeader = getPlayerName(playersLeaderObject); - List playersOfficersList = faction.getUPlayersWhereRole(Rel.OFFICER); + List playersOfficersList = faction.getUPlayersWhereRole(Rel.OFFICER); String playersOfficersCount = String.valueOf(playersOfficersList.size()); String playersOfficers = getPlayerString(playersOfficersList); - List playersMembersList = faction.getUPlayersWhereRole(Rel.MEMBER); + List playersMembersList = faction.getUPlayersWhereRole(Rel.MEMBER); String playersMembersCount = String.valueOf(playersMembersList.size()); String playersMembers = getPlayerString(playersMembersList); - List playersRecruitsList = faction.getUPlayersWhereRole(Rel.RECRUIT); + List playersRecruitsList = faction.getUPlayersWhereRole(Rel.RECRUIT); String playersRecruitsCount = String.valueOf(playersRecruitsList.size()); String playersRecruits = getPlayerString(playersRecruitsList); @@ -822,10 +812,10 @@ public class EngineDynmap extends EngineAbstract return ret; } - public static String getPlayerString(List uplayers) + public static String getPlayerString(List uplayers) { String ret = ""; - for (UPlayer uplayer : uplayers) + for (MPlayer uplayer : uplayers) { if (ret.length() > 0) ret += ", "; ret += getPlayerName(uplayer); @@ -833,7 +823,7 @@ public class EngineDynmap extends EngineAbstract return ret; } - public static String getPlayerName(UPlayer uplayer) + public static String getPlayerName(MPlayer uplayer) { if (uplayer == null) return "none"; return escapeHtml(uplayer.getName()); diff --git a/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAbstract.java b/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAbstract.java index 1412d33b..c866e835 100644 --- a/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAbstract.java +++ b/src/main/java/com/massivecraft/factions/integration/herochat/ChannelFactionsAbstract.java @@ -23,7 +23,7 @@ import com.dthielke.herochat.Herochat; import com.dthielke.herochat.MessageFormatSupplier; import com.dthielke.herochat.MessageNotFoundException; import com.massivecraft.factions.Rel; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; public abstract class ChannelFactionsAbstract implements Channel @@ -228,13 +228,13 @@ public abstract class ChannelFactionsAbstract implements Channel { Set ret = new HashSet(); - UPlayer fpsender = UPlayer.get(sender); + MPlayer fpsender = MPlayer.get(sender); Faction faction = fpsender.getFaction(); String universe = fpsender.getUniverse(); for (Player player : Bukkit.getOnlinePlayers()) { - UPlayer frecipient = UPlayer.get(player); + MPlayer frecipient = MPlayer.get(player); if (!frecipient.getUniverse().equals(universe)) continue; if (!this.getTargetRelations().contains(faction.getRelationTo(frecipient))) continue; ret.add(player); diff --git a/src/main/java/com/massivecraft/factions/integration/lwc/EngineLwc.java b/src/main/java/com/massivecraft/factions/integration/lwc/EngineLwc.java index c484cf5a..b59eb2c8 100644 --- a/src/main/java/com/massivecraft/factions/integration/lwc/EngineLwc.java +++ b/src/main/java/com/massivecraft/factions/integration/lwc/EngineLwc.java @@ -17,8 +17,8 @@ import com.griefcraft.lwc.LWC; import com.griefcraft.model.Protection; import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsChunkChange; import com.massivecraft.factions.event.EventFactionsChunkChangeType; import com.massivecraft.massivecore.ps.PS; @@ -57,9 +57,8 @@ public class EngineLwc implements Listener { // If we are supposed to clear at this chunk change type ... Faction newFaction = event.getNewFaction(); - UConf uconf = UConf.get(newFaction); EventFactionsChunkChangeType type = event.getType(); - Boolean remove = uconf.lwcRemoveOnChange.get(type); + Boolean remove = MConf.get().lwcRemoveOnChange.get(type); if (remove == null) return; if (remove == false) return; @@ -73,10 +72,10 @@ public class EngineLwc implements Listener public static void removeAlienProtections(PS chunkPs, Faction faction) { - List nonAliens = faction.getUPlayers(); + List nonAliens = faction.getUPlayers(); for (Protection protection : getProtectionsInChunk(chunkPs)) { - UPlayer owner = UPlayer.get(protection.getOwner()); + MPlayer owner = MPlayer.get(protection.getOwner()); if (nonAliens.contains(owner)) continue; protection.remove(); } diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java index 9ba35a97..a74df86a 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerEcon.java @@ -7,8 +7,8 @@ import org.bukkit.event.Listener; import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.Faction; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsAbstractSender; import com.massivecraft.factions.event.EventFactionsChunkChange; import com.massivecraft.factions.event.EventFactionsChunkChangeType; @@ -57,7 +57,7 @@ public class FactionsListenerEcon implements Listener if (event.getReason() != MembershipChangeReason.LEAVE) return; // ... and that player was the last one in the faction ... - UPlayer uplayer = event.getUPlayer(); + MPlayer uplayer = event.getUPlayer(); Faction oldFaction = uplayer.getFaction(); if (oldFaction.getUPlayers().size() > 1) return; @@ -73,11 +73,11 @@ public class FactionsListenerEcon implements Listener public void takeOnDisband(EventFactionsDisband event) { // If there is a usender ... - UPlayer usender = event.getUSender(); + MPlayer usender = event.getUSender(); if (usender == null) return; // ... and economy is enabled ... - if (!Econ.isEnabled(usender)) return; + if (!Econ.isEnabled()) return; // ... then transfer all the faction money to the sender. Faction faction = event.getFaction(); @@ -98,7 +98,7 @@ public class FactionsListenerEcon implements Listener public static void payForAction(EventFactionsAbstractSender event, Double cost, String desc) { // If there is a sender ... - UPlayer usender = event.getUSender(); + MPlayer usender = event.getUSender(); if (usender == null) return; // ... and there is a cost ... @@ -115,10 +115,8 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForAction(EventFactionsChunkChange event) { - Faction newFaction = event.getNewFaction(); - UConf uconf = UConf.get(newFaction); EventFactionsChunkChangeType type = event.getType(); - Double cost = uconf.econChunkCost.get(type); + Double cost = MConf.get().econChunkCost.get(type); String desc = type.toString().toLowerCase() + " this land"; @@ -131,22 +129,19 @@ public class FactionsListenerEcon implements Listener Double cost = null; String desc = null; - UConf uconf = UConf.get(event.getSender()); - if (uconf == null) return; - if (event.getReason() == MembershipChangeReason.JOIN) { - cost = uconf.econCostJoin; + cost = MConf.get().econCostJoin; desc = "join a faction"; } else if (event.getReason() == MembershipChangeReason.LEAVE) { - cost = uconf.econCostLeave; + cost = MConf.get().econCostLeave; desc = "leave a faction"; } else if (event.getReason() == MembershipChangeReason.KICK) { - cost = uconf.econCostKick; + cost = MConf.get().econCostKick; desc = "kick someone from a faction"; } else @@ -160,7 +155,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsRelationChange event) { - Double cost = UConf.get(event.getSender()).econRelCost.get(event.getNewRelation()); + Double cost = MConf.get().econRelCost.get(event.getNewRelation()); String desc = Factions.get().getOuterCmdFactions().cmdFactionsRelationNeutral.getDesc(); payForAction(event, cost, desc); @@ -169,7 +164,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsHomeChange event) { - Double cost = UConf.get(event.getSender()).econCostSethome; + Double cost = MConf.get().econCostSethome; String desc = Factions.get().getOuterCmdFactions().cmdFactionsSethome.getDesc(); payForAction(event, cost, desc); @@ -178,7 +173,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsCreate event) { - Double cost = UConf.get(event.getSender()).econCostCreate; + Double cost = MConf.get().econCostCreate; String desc = Factions.get().getOuterCmdFactions().cmdFactionsCreate.getDesc(); payForAction(event, cost, desc); @@ -187,7 +182,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsDescriptionChange event) { - Double cost = UConf.get(event.getSender()).econCostDescription; + Double cost = MConf.get().econCostDescription; String desc = Factions.get().getOuterCmdFactions().cmdFactionsDescription.getDesc(); payForAction(event, cost, desc); @@ -196,7 +191,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsNameChange event) { - Double cost = UConf.get(event.getSender()).econCostName; + Double cost = MConf.get().econCostName; String desc = Factions.get().getOuterCmdFactions().cmdFactionsName.getDesc(); payForAction(event, cost, desc); @@ -205,7 +200,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsTitleChange event) { - Double cost = UConf.get(event.getSender()).econCostTitle; + Double cost = MConf.get().econCostTitle; String desc = Factions.get().getOuterCmdFactions().cmdFactionsTitle.getDesc(); payForAction(event, cost, desc); @@ -214,7 +209,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsOpenChange event) { - Double cost = UConf.get(event.getSender()).econCostOpen; + Double cost = MConf.get().econCostOpen; String desc = Factions.get().getOuterCmdFactions().cmdFactionsOpen.getDesc(); payForAction(event, cost, desc); @@ -223,7 +218,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsInvitedChange event) { - Double cost = event.isNewInvited() ? UConf.get(event.getSender()).econCostInvite : UConf.get(event.getSender()).econCostDeinvite; + Double cost = event.isNewInvited() ? MConf.get().econCostInvite : MConf.get().econCostDeinvite; String desc = Factions.get().getOuterCmdFactions().cmdFactionsInvite.getDesc(); payForAction(event, cost, desc); @@ -232,7 +227,7 @@ public class FactionsListenerEcon implements Listener @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void payForCommand(EventFactionsHomeTeleport event) { - Double cost = UConf.get(event.getSender()).econCostHome; + Double cost = MConf.get().econCostHome; String desc = Factions.get().getOuterCmdFactions().cmdFactionsHome.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 7225d903..882ece0c 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsListenerMain.java @@ -59,13 +59,11 @@ 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.BoardColls; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.BoardColl; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayerColl; -import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.event.EventFactionsPvpDisallowed; import com.massivecraft.factions.event.EventFactionsPowerChange; import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; @@ -105,33 +103,30 @@ public class FactionsListenerMain implements Listener if (MUtil.isSameChunk(event)) return; Player player = event.getPlayer(); - // Check Disabled - if (UConf.isDisabled(player)) return; - // ... gather info on the player and the move ... - UPlayer uplayer = UPlayerColls.get().get(event.getTo()).get(player); + MPlayer mplayer = MPlayer.get(player); PS chunkFrom = PS.valueOf(event.getFrom()).getChunk(true); PS chunkTo = PS.valueOf(event.getTo()).getChunk(true); - Faction factionFrom = BoardColls.get().getFactionAt(chunkFrom); - Faction factionTo = BoardColls.get().getFactionAt(chunkTo); + Faction factionFrom = BoardColl.get().getFactionAt(chunkFrom); + Faction factionTo = BoardColl.get().getFactionAt(chunkTo); // ... and send info onwards. - this.chunkChangeTerritoryInfo(uplayer, player, chunkFrom, chunkTo, factionFrom, factionTo); - this.chunkChangeAutoClaim(uplayer, chunkTo); + this.chunkChangeTerritoryInfo(mplayer, player, chunkFrom, chunkTo, factionFrom, factionTo); + this.chunkChangeAutoClaim(mplayer, chunkTo); } // -------------------------------------------- // // CHUNK CHANGE: TERRITORY INFO // -------------------------------------------- // - public void chunkChangeTerritoryInfo(UPlayer uplayer, Player player, PS chunkFrom, PS chunkTo, Faction factionFrom, Faction factionTo) + public void chunkChangeTerritoryInfo(MPlayer uplayer, Player player, PS chunkFrom, PS chunkTo, Faction factionFrom, Faction factionTo) { // send host faction info updates if (uplayer.isMapAutoUpdating()) { - uplayer.sendMessage(BoardColls.get().getMap(uplayer, chunkTo, player.getLocation().getYaw())); + uplayer.sendMessage(BoardColl.get().getMap(uplayer, chunkTo, player.getLocation().getYaw())); } else if (factionFrom != factionTo) { @@ -144,10 +139,10 @@ public class FactionsListenerMain implements Listener } // Show access level message if it changed. - TerritoryAccess accessFrom = BoardColls.get().getTerritoryAccessAt(chunkFrom); + TerritoryAccess accessFrom = BoardColl.get().getTerritoryAccessAt(chunkFrom); Boolean hasTerritoryAccessFrom = accessFrom.hasTerritoryAccess(uplayer); - TerritoryAccess accessTo = BoardColls.get().getTerritoryAccessAt(chunkTo); + TerritoryAccess accessTo = BoardColl.get().getTerritoryAccessAt(chunkTo); Boolean hasTerritoryAccessTo = accessTo.hasTerritoryAccess(uplayer); if (!MUtil.equals(hasTerritoryAccessFrom, hasTerritoryAccessTo)) @@ -171,7 +166,7 @@ public class FactionsListenerMain implements Listener // CHUNK CHANGE: AUTO CLAIM // -------------------------------------------- // - public void chunkChangeAutoClaim(UPlayer uplayer, PS chunkTo) + public void chunkChangeAutoClaim(MPlayer uplayer, PS chunkTo) { // If the player is auto claiming ... Faction autoClaimFaction = uplayer.getAutoClaimFaction(); @@ -195,39 +190,36 @@ public class FactionsListenerMain implements Listener // (yeah other plugins can case death event to fire twice the same tick) if (PlayerUtil.isDuplicateDeathEvent(event)) return; - // Check Disabled - if (UConf.isDisabled(player)) return; - - UPlayer uplayer = UPlayer.get(player); + MPlayer mplayer = MPlayer.get(player); // ... and powerloss can happen here ... - Faction faction = BoardColls.get().getFactionAt(PS.valueOf(player)); + Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player)); if (!faction.getFlag(FFlag.POWERLOSS)) { - uplayer.msg("You didn't lose any power since the territory you died in works that way."); + mplayer.msg("You didn't lose any power since the territory you died in works that way."); return; } if (MConf.get().getWorldsNoPowerLoss().contains(player.getWorld().getName())) { - uplayer.msg("You didn't lose any power due to the world you died in."); + mplayer.msg("You didn't lose any power due to the world you died in."); return; } // ... alter the power ... - double newPower = uplayer.getPower() + uplayer.getPowerPerDeath(); + double newPower = mplayer.getPower() + mplayer.getPowerPerDeath(); - EventFactionsPowerChange powerChangeEvent = new EventFactionsPowerChange(null, uplayer, PowerChangeReason.DEATH, newPower); + EventFactionsPowerChange powerChangeEvent = new EventFactionsPowerChange(null, mplayer, PowerChangeReason.DEATH, newPower); powerChangeEvent.run(); if (powerChangeEvent.isCancelled()) return; newPower = powerChangeEvent.getNewPower(); - uplayer.setPower(newPower); + mplayer.setPower(newPower); // ... and inform the player. // TODO: A progress bar here would be epic :) - uplayer.msg("Your power is now %.2f / %.2f", newPower, uplayer.getPowerMax()); + mplayer.msg("Your power is now %.2f / %.2f", newPower, mplayer.getPowerMax()); } // -------------------------------------------- // @@ -292,10 +284,7 @@ public class FactionsListenerMain implements Listener Entity edefender = event.getEntity(); if (!(edefender instanceof Player)) return true; Player defender = (Player)edefender; - UPlayer udefender = UPlayer.get(edefender); - - // Check Disabled - if (UConf.isDisabled(defender)) return true; + MPlayer udefender = MPlayer.get(edefender); // ... and the attacker is someone else ... Entity eattacker = MUtil.getLiableDamager(event); @@ -306,7 +295,7 @@ public class FactionsListenerMain implements Listener // ... gather defender PS and faction information ... PS defenderPs = PS.valueOf(defender); - Faction defenderPsFaction = BoardColls.get().getFactionAt(defenderPs); + Faction defenderPsFaction = BoardColl.get().getFactionAt(defenderPs); // ... PVP flag may cause a damage block ... if (defenderPsFaction.getFlag(FFlag.PVP) == false) @@ -322,7 +311,7 @@ public class FactionsListenerMain implements Listener ret = falseUnlessDisallowedPvpEventCancelled((Player)eattacker, defender, event); if (!ret && notify) { - UPlayer attacker = UPlayer.get(eattacker); + MPlayer attacker = MPlayer.get(eattacker); attacker.msg("PVP is disabled in %s.", defenderPsFaction.describeTo(attacker)); } return ret; @@ -333,14 +322,14 @@ public class FactionsListenerMain implements Listener // ... and if the attacker is a player ... if (!(eattacker instanceof Player)) return true; Player attacker = (Player)eattacker; - UPlayer uattacker = UPlayer.get(attacker); + MPlayer uattacker = MPlayer.get(attacker); // ... does this player bypass all protection? ... if (MConf.get().playersWhoBypassAllProtection.contains(attacker.getName())) return true; // ... gather attacker PS and faction information ... PS attackerPs = PS.valueOf(attacker); - Faction attackerPsFaction = BoardColls.get().getFactionAt(attackerPs); + Faction attackerPsFaction = BoardColl.get().getFactionAt(attackerPs); // ... 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) @@ -357,9 +346,8 @@ public class FactionsListenerMain implements Listener Faction defendFaction = udefender.getFaction(); Faction attackFaction = uattacker.getFaction(); - UConf uconf = UConf.get(attackFaction); - if (attackFaction.isNone() && uconf.disablePVPForFactionlessPlayers) + if (attackFaction.isNone() && MConf.get().disablePVPForFactionlessPlayers) { ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); if (!ret && notify) uattacker.msg("You can't hurt other players until you join a faction."); @@ -367,12 +355,12 @@ public class FactionsListenerMain implements Listener } else if (defendFaction.isNone()) { - if (defenderPsFaction == attackFaction && uconf.enablePVPAgainstFactionlessInAttackersLand) + if (defenderPsFaction == attackFaction && MConf.get().enablePVPAgainstFactionlessInAttackersLand) { // Allow PVP vs. Factionless in attacker's faction territory return true; } - else if (uconf.disablePVPForFactionlessPlayers) + else if (MConf.get().disablePVPForFactionlessPlayers) { ret = falseUnlessDisallowedPvpEventCancelled(attacker, defender, event); if (!ret && notify) uattacker.msg("You can't hurt players who are not currently in a faction."); @@ -406,15 +394,15 @@ public class FactionsListenerMain implements Listener // Damage will be dealt. However check if the damage should be reduced. double damage = event.getDamage(); - if (damage > 0.0 && udefender.hasFaction() && ownTerritory && uconf.territoryShieldFactor > 0) + if (damage > 0.0 && udefender.hasFaction() && ownTerritory && MConf.get().territoryShieldFactor > 0) { - double newDamage = damage * (1D - uconf.territoryShieldFactor); + double newDamage = damage * (1D - MConf.get().territoryShieldFactor); event.setDamage(newDamage); // Send message if (notify) { - String perc = MessageFormat.format("{0,number,#%}", (uconf.territoryShieldFactor)); // TODO does this display correctly?? + String perc = MessageFormat.format("{0,number,#%}", (MConf.get().territoryShieldFactor)); // TODO does this display correctly?? udefender.msg("Enemy damage reduced by %s.", perc); } } @@ -440,18 +428,16 @@ public class FactionsListenerMain implements Listener if (!MConf.get().removePlayerDataWhenBanned) return; // ... get rid of their stored info. - for (UPlayerColl coll : UPlayerColls.get().getColls()) + MPlayer mplayer = MPlayerColl.get().get(player, false); + if (mplayer == null) return; + + if (mplayer.getRole() == Rel.LEADER) { - UPlayer uplayer = coll.get(player, false); - if (uplayer == null) continue; - - if (uplayer.getRole() == Rel.LEADER) - { - uplayer.getFaction().promoteNewLeader(); - } - uplayer.leave(); - uplayer.detach(); + mplayer.getFaction().promoteNewLeader(); } + + mplayer.leave(); + mplayer.detach(); } // -------------------------------------------- // @@ -476,10 +462,7 @@ public class FactionsListenerMain implements Listener // If a player is trying to run a command ... Player player = event.getPlayer(); - // Check Disabled - if (UConf.isDisabled(player)) return; - - UPlayer uplayer = UPlayer.get(player); + MPlayer uplayer = MPlayer.get(player); // ... and the player does not have adminmode ... if (uplayer.isUsingAdminMode()) return; @@ -491,7 +474,7 @@ public class FactionsListenerMain implements Listener command = command.trim(); // ... the command may be denied for members of permanent factions ... - if (uplayer.hasFaction() && uplayer.getFaction().getFlag(FFlag.PERMANENT) && containsCommand(command, UConf.get(player).denyCommandsPermanentFactionMember)) + if (uplayer.hasFaction() && uplayer.getFaction().getFlag(FFlag.PERMANENT) && containsCommand(command, MConf.get().denyCommandsPermanentFactionMember)) { uplayer.msg("You can't use \"/%s\" as member of a permanent faction.", command); event.setCancelled(true); @@ -500,13 +483,13 @@ public class FactionsListenerMain implements Listener // ... if there is a faction at the players location ... PS ps = PS.valueOf(player).getChunk(true); - Faction factionAtPs = BoardColls.get().getFactionAt(ps); + Faction factionAtPs = BoardColl.get().getFactionAt(ps); if (factionAtPs.isNone()) return; // TODO: An NPE can arise here? Why? // ... the command may be denied in the territory of this relation type ... Rel rel = factionAtPs.getRelationTo(uplayer); - List deniedCommands = UConf.get(player).denyCommandsTerritoryRelation.get(rel); + List deniedCommands = MConf.get().denyCommandsTerritoryRelation.get(rel); if (deniedCommands == null) return; if (!containsCommand(command, deniedCommands)) return; @@ -542,12 +525,9 @@ public class FactionsListenerMain implements Listener // If a monster is spawning ... if ( ! MConf.get().entityTypesMonsters.contains(event.getEntityType())) return; - // Check Disabled - if (UConf.isDisabled(event.getLocation())) return; - // ... at a place where monsters are forbidden ... PS ps = PS.valueOf(event.getLocation()); - Faction faction = BoardColls.get().getFactionAt(ps); + Faction faction = BoardColl.get().getFactionAt(ps); if (faction.getFlag(FFlag.MONSTERS)) return; // ... block the spawn. @@ -564,12 +544,9 @@ public class FactionsListenerMain implements Listener Entity target = event.getTarget(); if (target == null) return; - // Check Disabled - if (UConf.isDisabled(target)) return; - // ... at a place where monsters are forbidden ... PS ps = PS.valueOf(target); - Faction faction = BoardColls.get().getFactionAt(ps); + Faction faction = BoardColl.get().getFactionAt(ps); if (faction.getFlag(FFlag.MONSTERS)) return; // ... then if ghast target nothing ... @@ -593,12 +570,9 @@ public class FactionsListenerMain implements Listener // If a hanging entity was broken by an explosion ... if (event.getCause() != RemoveCause.EXPLOSION) return; Entity entity = event.getEntity(); - - // Check Disabled - if (UConf.isDisabled(entity)) return; // ... and the faction there has explosions disabled ... - Faction faction = BoardColls.get().getFactionAt(PS.valueOf(entity)); + Faction faction = BoardColl.get().getFactionAt(PS.valueOf(entity)); if (faction.isExplosionsAllowed()) return; // ... then cancel. @@ -619,11 +593,8 @@ public class FactionsListenerMain implements Listener // If an explosion occurs at a location ... Location location = event.getLocation(); - // Check Disabled - if (UConf.isDisabled(location)) return; - // Check the entity. Are explosions disabled there? - faction = BoardColls.get().getFactionAt(PS.valueOf(location)); + faction = BoardColl.get().getFactionAt(PS.valueOf(location)); allowed = faction.isExplosionsAllowed(); if (allowed == false) { @@ -637,7 +608,7 @@ public class FactionsListenerMain implements Listener while (iter.hasNext()) { Block block = iter.next(); - faction = BoardColls.get().getFactionAt(PS.valueOf(block)); + faction = BoardColl.get().getFactionAt(PS.valueOf(block)); allowed = faction2allowed.get(faction); if (allowed == null) { @@ -655,13 +626,10 @@ public class FactionsListenerMain implements Listener // If a wither is changing a block ... Entity entity = event.getEntity(); if (!(entity instanceof Wither)) return; - - // Check Disabled - if (UConf.isDisabled(entity)) return; // ... and the faction there has explosions disabled ... PS ps = PS.valueOf(event.getBlock()); - Faction faction = BoardColls.get().getFactionAt(ps); + Faction faction = BoardColl.get().getFactionAt(ps); if (faction.isExplosionsAllowed()) return; @@ -680,12 +648,9 @@ public class FactionsListenerMain implements Listener Entity entity = event.getEntity(); if (!(entity instanceof Enderman)) return; - // Check Disabled - if (UConf.isDisabled(entity)) return; - // ... and the faction there has endergrief disabled ... PS ps = PS.valueOf(event.getBlock()); - Faction faction = BoardColls.get().getFactionAt(ps); + Faction faction = BoardColl.get().getFactionAt(ps); if (faction.getFlag(FFlag.ENDERGRIEF)) return; // ... stop the block alteration. @@ -698,12 +663,9 @@ public class FactionsListenerMain implements Listener public void blockFireSpread(Block block, Cancellable cancellable) { - // Check Disabled - if (UConf.isDisabled(block)) return; - // If the faction at the block has firespread disabled ... PS ps = PS.valueOf(block); - Faction faction = BoardColls.get().getFactionAt(ps); + Faction faction = BoardColl.get().getFactionAt(ps); if (faction.getFlag(FFlag.FIRESPREAD)) return; @@ -750,16 +712,16 @@ public class FactionsListenerMain implements Listener String name = player.getName(); if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; - UPlayer uplayer = UPlayer.get(player); + MPlayer uplayer = MPlayer.get(player); if (uplayer.isUsingAdminMode()) return true; if (!FPerm.BUILD.has(uplayer, ps, false) && FPerm.PAINBUILD.has(uplayer, ps, false)) { if (verboose) { - Faction hostFaction = BoardColls.get().getFactionAt(ps); + Faction hostFaction = BoardColl.get().getFactionAt(ps); uplayer.msg("It is painful to build in the territory of %s.", hostFaction.describeTo(uplayer)); - player.damage(UConf.get(player).actionDeniedPainAmount); + player.damage(MConf.get().actionDeniedPainAmount); } return true; } @@ -844,13 +806,13 @@ public class FactionsListenerMain implements Listener { Block block = event.getBlock(); - Faction pistonFaction = BoardColls.get().getFactionAt(PS.valueOf(block)); + Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(block)); // target end-of-the-line empty (air) block which is being pushed into, including if piston itself would extend into air Block targetBlock = block.getRelative(event.getDirection(), event.getLength() + 1); // members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case - Faction targetFaction = BoardColls.get().getFactionAt(PS.valueOf(targetBlock)); + Faction targetFaction = BoardColl.get().getFactionAt(PS.valueOf(targetBlock)); if (targetFaction == pistonFaction) return; // if potentially pushing into air/water/lava in another territory, we need to check it out @@ -878,10 +840,10 @@ public class FactionsListenerMain implements Listener // if potentially retracted block is just air/water/lava, no worries if (retractBlock.isEmpty() || retractBlock.isLiquid()) return; - Faction pistonFaction = BoardColls.get().getFactionAt(PS.valueOf(event.getBlock())); + Faction pistonFaction = BoardColl.get().getFactionAt(PS.valueOf(event.getBlock())); // members of faction might not have build rights in their own territory, but pistons should still work regardless; so, address that corner case - Faction targetFaction = BoardColls.get().getFactionAt(retractPs); + Faction targetFaction = BoardColl.get().getFactionAt(retractPs); if (targetFaction == pistonFaction) return; if (!FPerm.BUILD.has(pistonFaction, targetFaction)) @@ -929,7 +891,7 @@ public class FactionsListenerMain implements Listener String name = player.getName(); if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; - UPlayer uplayer = UPlayer.get(player); + MPlayer uplayer = MPlayer.get(player); if (uplayer.isUsingAdminMode()) return true; return FPerm.BUILD.has(uplayer, ps, !justCheck); @@ -940,7 +902,7 @@ public class FactionsListenerMain implements Listener String name = player.getName(); if (MConf.get().playersWhoBypassAllProtection.contains(name)) return true; - UPlayer me = UPlayer.get(player); + MPlayer me = MPlayer.get(player); if (me.isUsingAdminMode()) return true; PS ps = PS.valueOf(block); @@ -986,13 +948,12 @@ public class FactionsListenerMain implements Listener { // If a player is respawning ... final Player player = event.getPlayer(); - final UPlayer uplayer = UPlayer.get(player); - final UConf uconf = UConf.get(player); + final MPlayer uplayer = MPlayer.get(player); // ... homes are enabled, active and at this priority ... - if (!uconf.homesEnabled) return; - if (!uconf.homesTeleportToOnDeathActive) return; - if (uconf.homesTeleportToOnDeathPriority != priority) return; + if (!MConf.get().homesEnabled) return; + if (!MConf.get().homesTeleportToOnDeathActive) return; + if (MConf.get().homesTeleportToOnDeathPriority != priority) return; // ... and the player has a faction ... final Faction faction = uplayer.getFaction(); diff --git a/src/main/java/com/massivecraft/factions/mixin/PowerMixin.java b/src/main/java/com/massivecraft/factions/mixin/PowerMixin.java index 4f8b96c0..6e27b747 100644 --- a/src/main/java/com/massivecraft/factions/mixin/PowerMixin.java +++ b/src/main/java/com/massivecraft/factions/mixin/PowerMixin.java @@ -1,12 +1,12 @@ package com.massivecraft.factions.mixin; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; public interface PowerMixin { - public double getMaxUniversal(UPlayer uplayer); - public double getMax(UPlayer uplayer); - public double getMin(UPlayer uplayer); - public double getPerHour(UPlayer uplayer); - public double getPerDeath(UPlayer uplayer); + public double getMaxUniversal(MPlayer uplayer); + public double getMax(MPlayer uplayer); + public double getMin(MPlayer uplayer); + public double getPerHour(MPlayer uplayer); + public double getPerDeath(MPlayer uplayer); } diff --git a/src/main/java/com/massivecraft/factions/mixin/PowerMixinDefault.java b/src/main/java/com/massivecraft/factions/mixin/PowerMixinDefault.java index 98f39b14..b3766991 100644 --- a/src/main/java/com/massivecraft/factions/mixin/PowerMixinDefault.java +++ b/src/main/java/com/massivecraft/factions/mixin/PowerMixinDefault.java @@ -1,7 +1,7 @@ package com.massivecraft.factions.mixin; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MConf; +import com.massivecraft.factions.entity.MPlayer; public class PowerMixinDefault implements PowerMixin { @@ -17,33 +17,33 @@ public class PowerMixinDefault implements PowerMixin // -------------------------------------------- // @Override - public double getMaxUniversal(UPlayer uplayer) + public double getMaxUniversal(MPlayer mplayer) { - return this.getMax(uplayer); + return this.getMax(mplayer); } @Override - public double getMax(UPlayer uplayer) + public double getMax(MPlayer mplayer) { - return UConf.get(uplayer).powerMax + uplayer.getPowerBoost(); + return MConf.get().powerMax + mplayer.getPowerBoost(); } @Override - public double getMin(UPlayer uplayer) + public double getMin(MPlayer mplayer) { - return UConf.get(uplayer).powerMin; + return MConf.get().powerMin; } @Override - public double getPerHour(UPlayer uplayer) + public double getPerHour(MPlayer mplayer) { - return UConf.get(uplayer).powerPerHour; + return MConf.get().powerPerHour; } @Override - public double getPerDeath(UPlayer uplayer) + public double getPerDeath(MPlayer mplayer) { - return UConf.get(uplayer).powerPerDeath; + return MConf.get().powerPerDeath; } } diff --git a/src/main/java/com/massivecraft/factions/task/TaskEconLandReward.java b/src/main/java/com/massivecraft/factions/task/TaskEconLandReward.java index 365c3492..75ba09ca 100644 --- a/src/main/java/com/massivecraft/factions/task/TaskEconLandReward.java +++ b/src/main/java/com/massivecraft/factions/task/TaskEconLandReward.java @@ -1,9 +1,7 @@ package com.massivecraft.factions.task; import com.massivecraft.factions.entity.FactionColl; -import com.massivecraft.factions.entity.FactionColls; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.entity.UConf; import com.massivecraft.massivecore.ModuloRepeatTask; import com.massivecraft.massivecore.util.TimeUnit; @@ -35,13 +33,7 @@ public class TaskEconLandReward extends ModuloRepeatTask @Override public void invoke(long now) { - for (FactionColl coll : FactionColls.get().getColls()) - { - // Check disabled - if (UConf.isDisabled(coll)) continue; - - coll.econLandRewardRoutine(); - } + FactionColl.get().econLandRewardRoutine(); } } diff --git a/src/main/java/com/massivecraft/factions/task/TaskPlayerDataRemove.java b/src/main/java/com/massivecraft/factions/task/TaskPlayerDataRemove.java index e006ba99..152cd2df 100644 --- a/src/main/java/com/massivecraft/factions/task/TaskPlayerDataRemove.java +++ b/src/main/java/com/massivecraft/factions/task/TaskPlayerDataRemove.java @@ -1,9 +1,7 @@ package com.massivecraft.factions.task; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayerColl; -import com.massivecraft.factions.entity.UPlayerColls; +import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.massivecore.ModuloRepeatTask; import com.massivecraft.massivecore.util.TimeUnit; @@ -35,13 +33,7 @@ public class TaskPlayerDataRemove extends ModuloRepeatTask @Override public void invoke(long now) { - for (UPlayerColl coll : UPlayerColls.get().getColls()) - { - // Check disabled - if (UConf.isDisabled(coll)) continue; - - coll.removePlayerDataAfterInactiveDaysRoutine(); - } + MPlayerColl.get().removePlayerDataAfterInactiveDaysRoutine(); } } diff --git a/src/main/java/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java b/src/main/java/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java index ac1d8885..103ac9b0 100644 --- a/src/main/java/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java +++ b/src/main/java/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java @@ -4,8 +4,7 @@ import org.bukkit.Bukkit; import org.bukkit.entity.Player; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.factions.entity.UConf; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsPowerChange; import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; import com.massivecraft.massivecore.ModuloRepeatTask; @@ -43,20 +42,17 @@ public class TaskPlayerPowerUpdate extends ModuloRepeatTask for (Player player : Bukkit.getOnlinePlayers()) { - // Check disabled - if (UConf.isDisabled(player)) continue; - if (player.isDead()) continue; - UPlayer uplayer = UPlayer.get(player); - double newPower = uplayer.getPower() + uplayer.getPowerPerHour() * millis / TimeUnit.MILLIS_PER_HOUR; + MPlayer mplayer = MPlayer.get(player); + double newPower = mplayer.getPower() + mplayer.getPowerPerHour() * millis / TimeUnit.MILLIS_PER_HOUR; - EventFactionsPowerChange event = new EventFactionsPowerChange(null, uplayer, PowerChangeReason.TIME, newPower); + EventFactionsPowerChange event = new EventFactionsPowerChange(null, mplayer, PowerChangeReason.TIME, newPower); event.run(); if (event.isCancelled()) continue; newPower = event.getNewPower(); - uplayer.setPower(newPower); + mplayer.setPower(newPower); } } diff --git a/src/main/java/com/massivecraft/factions/util/RelationUtil.java b/src/main/java/com/massivecraft/factions/util/RelationUtil.java index baa10433..a2a46170 100644 --- a/src/main/java/com/massivecraft/factions/util/RelationUtil.java +++ b/src/main/java/com/massivecraft/factions/util/RelationUtil.java @@ -5,7 +5,7 @@ import org.bukkit.ChatColor; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.Rel; import com.massivecraft.factions.RelationParticipator; -import com.massivecraft.factions.entity.UPlayer; +import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.massivecore.util.Txt; @@ -29,7 +29,7 @@ public class RelationUtil if (that instanceof Faction) { - if (me instanceof UPlayer && myFaction == thatFaction) + if (me instanceof MPlayer && myFaction == thatFaction) { ret = "your faction"; } @@ -38,9 +38,9 @@ public class RelationUtil ret = thatFaction.getName(); } } - else if (that instanceof UPlayer) + else if (that instanceof MPlayer) { - UPlayer uplayerthat = (UPlayer) that; + MPlayer uplayerthat = (MPlayer) that; if (that == me) { ret = "you"; @@ -98,9 +98,9 @@ public class RelationUtil ret = Rel.MEMBER; // Do officer and leader check //P.p.log("getRelationOfThatToMe the factions are the same for "+that.getClass().getSimpleName()+" and observer "+me.getClass().getSimpleName()); - if (that instanceof UPlayer) + if (that instanceof MPlayer) { - ret = ((UPlayer)that).getRole(); + ret = ((MPlayer)that).getRole(); //P.p.log("getRelationOfThatToMe it was a player and role is "+ret); } } @@ -119,9 +119,9 @@ public class RelationUtil return (Faction) rp; } - if (rp instanceof UPlayer) + if (rp instanceof MPlayer) { - return ((UPlayer) rp).getFaction(); + return ((MPlayer) rp).getFaction(); } // ERROR