From 76f3f044cad06b92c450d151431e8208fda9eca4 Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Fri, 12 Apr 2013 08:56:26 +0200 Subject: [PATCH] Possible converted FPlayer --- src/com/massivecraft/factions/FPerm.java | 4 +- src/com/massivecraft/factions/FPlayer.java | 36 +++++----- .../massivecraft/factions/FPlayerColl.java | 71 ++++++++++++++----- src/com/massivecraft/factions/Faction.java | 50 +++++++------ .../massivecraft/factions/FactionColl.java | 2 +- src/com/massivecraft/factions/Factions.java | 8 +-- .../factions/TerritoryAccess.java | 4 +- .../factions/cmd/CmdFactions.java | 8 --- .../factions/cmd/CmdFactionsAccess.java | 2 - .../factions/cmd/CmdFactionsAdmin.java | 1 - .../factions/cmd/CmdFactionsAutoClaim.java | 1 - .../factions/cmd/CmdFactionsCapeAbstract.java | 2 - .../factions/cmd/CmdFactionsClaim.java | 1 - .../factions/cmd/CmdFactionsCreate.java | 19 +++-- .../factions/cmd/CmdFactionsDeinvite.java | 1 - .../factions/cmd/CmdFactionsDemote.java | 1 - .../factions/cmd/CmdFactionsDescription.java | 3 +- .../factions/cmd/CmdFactionsDisband.java | 3 +- .../factions/cmd/CmdFactionsFlag.java | 1 - .../factions/cmd/CmdFactionsHome.java | 3 +- .../factions/cmd/CmdFactionsInvite.java | 1 - .../factions/cmd/CmdFactionsJoin.java | 3 +- .../factions/cmd/CmdFactionsKick.java | 1 - .../factions/cmd/CmdFactionsLeader.java | 5 +- .../factions/cmd/CmdFactionsLeave.java | 1 - .../factions/cmd/CmdFactionsList.java | 1 - .../factions/cmd/CmdFactionsLock.java | 46 ------------ .../factions/cmd/CmdFactionsMap.java | 1 - .../factions/cmd/CmdFactionsOfficer.java | 1 - .../factions/cmd/CmdFactionsOpen.java | 1 - .../factions/cmd/CmdFactionsPerm.java | 1 - .../factions/cmd/CmdFactionsPower.java | 1 - .../factions/cmd/CmdFactionsPowerBoost.java | 1 - .../factions/cmd/CmdFactionsPromote.java | 1 - .../cmd/CmdFactionsRelationAbstract.java | 1 - .../factions/cmd/CmdFactionsReload.java | 64 ----------------- .../factions/cmd/CmdFactionsSaveAll.java | 36 ---------- .../factions/cmd/CmdFactionsSeeChunk.java | 1 - .../factions/cmd/CmdFactionsSethome.java | 1 - .../factions/cmd/CmdFactionsShow.java | 8 +-- .../factions/cmd/CmdFactionsTag.java | 1 - .../factions/cmd/CmdFactionsTitle.java | 1 - .../factions/cmd/CmdFactionsUnclaim.java | 1 - .../factions/cmd/CmdFactionsUnclaimall.java | 1 - .../factions/cmd/CmdFactionsVersion.java | 1 - .../massivecraft/factions/cmd/FCommand.java | 28 +++----- .../factions/cmd/req/ReqRoleIsAtLeast.java | 5 +- .../factions/event/FactionCreateEvent.java | 3 +- .../factions/event/FactionDisbandEvent.java | 3 +- .../factions/iface/EconomyParticipator.java | 3 +- .../factions/integration/LWCFeatures.java | 4 +- .../factions/integration/SpoutFeatures.java | 11 +-- .../integration/SpoutMainListener.java | 2 +- .../herochat/FactionsChannelAbstract.java | 5 +- .../herochat/HerochatListener.java | 2 +- .../listeners/FactionsBlockListener.java | 3 +- .../listeners/FactionsChatListener.java | 10 +-- .../listeners/FactionsEntityListener.java | 8 +-- .../listeners/FactionsPlayerListener.java | 18 ++--- .../factions/util/AutoLeaveTask.java | 2 +- 60 files changed, 174 insertions(+), 335 deletions(-) delete mode 100644 src/com/massivecraft/factions/cmd/CmdFactionsLock.java delete mode 100644 src/com/massivecraft/factions/cmd/CmdFactionsReload.java delete mode 100644 src/com/massivecraft/factions/cmd/CmdFactionsSaveAll.java diff --git a/src/com/massivecraft/factions/FPerm.java b/src/com/massivecraft/factions/FPerm.java index b50f63e1..d94235fd 100644 --- a/src/com/massivecraft/factions/FPerm.java +++ b/src/com/massivecraft/factions/FPerm.java @@ -139,7 +139,7 @@ public enum FPerm if (testSubject instanceof Player) { - rpSubject = FPlayerColl.i.get((Player)testSubject); + rpSubject = FPlayerColl.get().get(testSubject); } else if (testSubject instanceof RelationParticipator) { @@ -185,7 +185,7 @@ public enum FPerm { FPlayer notify = null; if (testSubject instanceof Player) - notify = FPlayerColl.i.get((Player)testSubject); + notify = FPlayerColl.get().get(testSubject); else if (testSubject instanceof FPlayer) notify = (FPlayer)testSubject; if (notify != null) diff --git a/src/com/massivecraft/factions/FPlayer.java b/src/com/massivecraft/factions/FPlayer.java index 2c17bef6..d9a715ea 100644 --- a/src/com/massivecraft/factions/FPlayer.java +++ b/src/com/massivecraft/factions/FPlayer.java @@ -17,36 +17,27 @@ import com.massivecraft.factions.integration.LWCFeatures; import com.massivecraft.factions.integration.SpoutFeatures; import com.massivecraft.factions.integration.Worldguard; import com.massivecraft.factions.util.RelationUtil; -import com.massivecraft.factions.zcore.persist.PlayerEntity; import com.massivecraft.mcore.ps.PS; +import com.massivecraft.mcore.store.SenderEntity; import com.massivecraft.mcore.util.Txt; -public class FPlayer extends PlayerEntity implements EconomyParticipator +public class FPlayer extends SenderEntity implements EconomyParticipator { // -------------------------------------------- // - // PERSISTANCE + // META // -------------------------------------------- // - @Override - public boolean shouldBeSaved() + public static FPlayer get(Object oid) { - if (this.hasFaction()) return true; - if (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(ConfServer.powerPlayerStarting)) return true; - return false; - } - - // This stuff from the economy participator interface... will it clash with the built in one from the MCore player entity? - public void msg(String str, Object... args) - { - this.sendMessage(Txt.parse(str, args)); + return FPlayerColl.get().get(oid); } // -------------------------------------------- // // OVERRIDE: ENTITY // -------------------------------------------- // - /*@Override + @Override public FPlayer load(FPlayer that) { this.factionId = that.factionId; @@ -58,7 +49,16 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator this.lastLoginTime = that.lastLoginTime; return this; - }*/ + } + + @Override + public boolean isDefault() + { + if (this.hasFaction()) return false; + if (this.getPowerRounded() != this.getPowerMaxRounded() && this.getPowerRounded() != (int) Math.round(ConfServer.powerPlayerStarting)) return false; + + return true; + } // -------------------------------------------- // // FIELDS: RAW PERMANENT @@ -68,7 +68,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator private String factionId; public Faction getFaction() { if(this.factionId == null) {return null;} return FactionColl.i.get(this.factionId); } public String getFactionId() { return this.factionId; } - public boolean hasFaction() { return ! factionId.equals("0"); } + public boolean hasFaction() { return this.factionId != null && ! factionId.equals("0"); } public void setFaction(Faction faction) { Faction oldFaction = this.getFaction(); @@ -545,7 +545,7 @@ public class FPlayer extends PlayerEntity implements EconomyParticipator if (myFaction.isNormal() && !perm && myFaction.getFPlayers().isEmpty()) { // Remove this faction - for (FPlayer fplayer : FPlayerColl.i.getOnline()) + for (FPlayer fplayer : FPlayerColl.get().getAllOnline()) { fplayer.msg("%s was disbanded.", myFaction.describeTo(fplayer, true)); } diff --git a/src/com/massivecraft/factions/FPlayerColl.java b/src/com/massivecraft/factions/FPlayerColl.java index 18f93e8e..d07990ca 100644 --- a/src/com/massivecraft/factions/FPlayerColl.java +++ b/src/com/massivecraft/factions/FPlayerColl.java @@ -3,39 +3,72 @@ package com.massivecraft.factions; import java.io.File; import java.lang.reflect.Type; import java.util.Map; -import java.util.concurrent.ConcurrentSkipListMap; -import java.util.concurrent.CopyOnWriteArrayList; +import java.util.Map.Entry; +import com.massivecraft.mcore.store.MStore; +import com.massivecraft.mcore.store.SenderColl; +import com.massivecraft.mcore.util.DiscUtil; import com.massivecraft.mcore.xlib.gson.reflect.TypeToken; -import com.massivecraft.factions.zcore.persist.PlayerEntityCollection; -public class FPlayerColl extends PlayerEntityCollection +public class FPlayerColl extends SenderColl { - public static FPlayerColl i = new FPlayerColl(); + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + private static FPlayerColl i = new FPlayerColl(); + public static FPlayerColl get() { return i; } private FPlayerColl() { - super - ( - FPlayer.class, - new CopyOnWriteArrayList(), - new ConcurrentSkipListMap(String.CASE_INSENSITIVE_ORDER), - new File(Factions.get().getDataFolder(), "players.json"), - Factions.get().gson - ); - - this.setCreative(true); + super(MStore.getDb(ConfServer.dburi), Factions.get(), Const.COLLECTION_BASENAME_PLAYER, FPlayer.class, true, true); } + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + // TODO: Init and migration routine! + @Override - public Type getMapType() + public void init() { - return new TypeToken>(){}.getType(); + super.init(); + + this.migrate(); } + 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 id2fplayer = Factions.get().gson.fromJson(DiscUtil.readCatch(oldFile), type); + + // Set the data + for (Entry entry : id2fplayer.entrySet()) + { + String playerId = entry.getKey(); + FPlayer fplayer = entry.getValue(); + FPlayerColl.get().create(playerId).load(fplayer); + } + + // Mark as migrated + oldFile.renameTo(newFile); + } + + // -------------------------------------------- // + // EXTRAS + // -------------------------------------------- // + public void clean() { - for (FPlayer fplayer : this.get()) + for (FPlayer fplayer : this.getAll()) { if ( ! FactionColl.i.exists(fplayer.getFactionId())) { @@ -55,7 +88,7 @@ public class FPlayerColl extends PlayerEntityCollection long now = System.currentTimeMillis(); double toleranceMillis = ConfServer.autoLeaveAfterDaysOfInactivity * 24 * 60 * 60 * 1000; - for (FPlayer fplayer : FPlayerColl.i.get()) + for (FPlayer fplayer : this.getAll()) { if (fplayer.isOffline() && now - fplayer.getLastLoginTime() > toleranceMillis) { diff --git a/src/com/massivecraft/factions/Faction.java b/src/com/massivecraft/factions/Faction.java index f81e7b52..a3172cdd 100644 --- a/src/com/massivecraft/factions/Faction.java +++ b/src/com/massivecraft/factions/Faction.java @@ -49,6 +49,26 @@ public class Faction extends Entity implements EconomyParticipator return this; }*/ + // -------------------------------------------- // + // Persistance and entity management + // -------------------------------------------- // + + @Override + public void postDetach() + { + if (Econ.shouldBeUsed()) + { + Econ.setBalance(getAccountId(), 0); + } + + // Clean the board + // TODO: Use events for this instead + BoardColl.get().clean(); + + // Clean the fplayers + FPlayerColl.get().clean(); + } + // -------------------------------------------- // // FIELDS: RAW // -------------------------------------------- // @@ -477,7 +497,7 @@ public class Faction extends Entity implements EconomyParticipator fplayers.clear(); if (this.isNone()) return; - for (FPlayer fplayer : FPlayerColl.i.get()) + for (FPlayer fplayer : FPlayerColl.get().getAll()) { if (fplayer.getFaction() == this) { @@ -550,6 +570,7 @@ public class Faction extends Entity implements EconomyParticipator return ret; } + // TODO: Makes use of bukkit instead of mixin. Fix that? public ArrayList getOnlinePlayers() { ArrayList ret = new ArrayList(); @@ -557,7 +578,7 @@ public class Faction extends Entity implements EconomyParticipator for (Player player: Factions.get().getServer().getOnlinePlayers()) { - FPlayer fplayer = FPlayerColl.i.get(player); + FPlayer fplayer = FPlayerColl.get().get(player); if (fplayer.getFaction() == this) { ret.add(player); @@ -593,7 +614,7 @@ public class Faction extends Entity implements EconomyParticipator if (ConfServer.logFactionDisband) Factions.get().log("The faction "+this.getTag()+" ("+this.getId()+") has been disbanded since it has no members left."); - for (FPlayer fplayer : FPlayerColl.i.getOnline()) + for (FPlayer fplayer : FPlayerColl.get().getAllOnline()) { fplayer.msg("The faction %s was disbanded.", this.getTag(fplayer)); } @@ -614,7 +635,8 @@ public class Faction extends Entity implements EconomyParticipator // Messages // -------------------------------------------- // - public void msg(String message, Object... args) + // TODO: Invalid code since Mixin introduction. Fix this. + public boolean msg(String message, Object... args) { message = Txt.parse(message, args); @@ -622,6 +644,8 @@ public class Faction extends Entity implements EconomyParticipator { fplayer.sendMessage(message); } + + return true; } public void sendMessage(String message) @@ -640,23 +664,5 @@ public class Faction extends Entity implements EconomyParticipator } } - // -------------------------------------------- // - // Persistance and entity management - // -------------------------------------------- // - @Override - public void postDetach() - { - if (Econ.shouldBeUsed()) - { - Econ.setBalance(getAccountId(), 0); - } - - // Clean the board - // TODO: Use events for this instead - BoardColl.get().clean(); - - // Clean the fplayers - FPlayerColl.i.clean(); - } } diff --git a/src/com/massivecraft/factions/FactionColl.java b/src/com/massivecraft/factions/FactionColl.java index 7bb247a9..3faa3106 100644 --- a/src/com/massivecraft/factions/FactionColl.java +++ b/src/com/massivecraft/factions/FactionColl.java @@ -190,7 +190,7 @@ public class FactionColl extends EntityCollection { Factions.get().log(Level.WARNING, "Non existing factionId "+id+" requested! Issuing cleaning!"); BoardColl.get().clean(); - FPlayerColl.i.clean(); + FPlayerColl.get().clean(); } return super.get(id); diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index 82ec7796..42d1ac96 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -56,9 +56,9 @@ public class Factions extends MPlugin public FactionsBlockListener blockListener; // Persistance related - private boolean locked = false; - public boolean getLocked() {return this.locked;} - public void setLocked(boolean val) {this.locked = val; this.setAutoSave(val);} + //private boolean locked = false; + //public boolean getLocked() {return this.locked;} + //public void setLocked(boolean val) {this.locked = val; this.setAutoSave(val);} private Integer AutoLeaveTask = null; private Integer econLandRewardTaskID = null; @@ -79,7 +79,7 @@ public class Factions extends MPlugin ConfServer.get().load(); // Load Conf from disk - FPlayerColl.i.loadFromDisc(); + FPlayerColl.get().init(); FactionColl.i.loadFromDisc(); BoardColl.get().init(); diff --git a/src/com/massivecraft/factions/TerritoryAccess.java b/src/com/massivecraft/factions/TerritoryAccess.java index a59162d1..c32e396e 100644 --- a/src/com/massivecraft/factions/TerritoryAccess.java +++ b/src/com/massivecraft/factions/TerritoryAccess.java @@ -99,7 +99,7 @@ public class TerritoryAccess if (testSubject instanceof String) return hostFactionId.equals((String)testSubject); else if (testSubject instanceof Player) - return hostFactionId.equals(FPlayerColl.i.get((Player)testSubject).getFactionId()); + return hostFactionId.equals(FPlayerColl.get().get(testSubject).getFactionId()); else if (testSubject instanceof FPlayer) return hostFactionId.equals(((FPlayer)testSubject).getFactionId()); else if (testSubject instanceof Faction) @@ -154,7 +154,7 @@ public class TerritoryAccess public boolean subjectHasAccess(Object testSubject) { if (testSubject instanceof Player) - return fPlayerHasAccess(FPlayerColl.i.get((Player)testSubject)); + return fPlayerHasAccess(FPlayerColl.get().get(testSubject)); else if (testSubject instanceof FPlayer) return fPlayerHasAccess((FPlayer)testSubject); else if (testSubject instanceof Faction) diff --git a/src/com/massivecraft/factions/cmd/CmdFactions.java b/src/com/massivecraft/factions/cmd/CmdFactions.java index 51fcac1c..881614c1 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/com/massivecraft/factions/cmd/CmdFactions.java @@ -26,7 +26,6 @@ public class CmdFactions extends FCommand public CmdFactionsKick cmdFactionsKick = new CmdFactionsKick(); public CmdFactionsLeave cmdFactionsLeave = new CmdFactionsLeave(); public CmdFactionsList cmdFactionsList = new CmdFactionsList(); - public CmdFactionsLock cmdFactionsLock = new CmdFactionsLock(); public CmdFactionsMap cmdFactionsMap = new CmdFactionsMap(); public CmdFactionsOfficer cmdFactionsOfficer = new CmdFactionsOfficer(); public CmdFactionsMoney cmdFactionsMoney = new CmdFactionsMoney(); @@ -39,8 +38,6 @@ public class CmdFactions extends FCommand public CmdFactionsRelationEnemy cmdFactionsRelationEnemy = new CmdFactionsRelationEnemy(); public CmdFactionsRelationNeutral cmdFactionsRelationNeutral = new CmdFactionsRelationNeutral(); public CmdFactionsRelationTruce cmdFactionsRelationTruce = new CmdFactionsRelationTruce(); - public CmdFactionsReload cmdFactionsReload = new CmdFactionsReload(); - public CmdFactionsSaveAll cmdFactionsSaveAll = new CmdFactionsSaveAll(); public CmdFactionsSeeChunk cmdFactionsSeeChunk = new CmdFactionsSeeChunk(); public CmdFactionsSethome cmdFactionsSethome = new CmdFactionsSethome(); public CmdFactionsShow cmdFactionsShow = new CmdFactionsShow(); @@ -67,8 +64,6 @@ public class CmdFactions extends FCommand senderMustBeOfficer = false; senderMustBeLeader = false; - this.disableOnLock = false; - this.setHelpShort("The faction base command"); this.helpLong.add(Txt.parse("This command contains all faction stuff.")); @@ -110,9 +105,6 @@ public class CmdFactions extends FCommand this.addSubCommand(this.cmdFactionsAdmin); this.addSubCommand(this.cmdFactionsPowerBoost); this.addSubCommand(this.cmdFactionsPromote); - this.addSubCommand(this.cmdFactionsLock); - this.addSubCommand(this.cmdFactionsReload); - this.addSubCommand(this.cmdFactionsSaveAll); this.addSubCommand(this.cmdFactionsVersion); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java b/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java index 2ec864f5..5125c36d 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAccess.java @@ -22,8 +22,6 @@ public class CmdFactionsAccess extends FCommand this.optionalArgs.put("name", "you"); this.setHelpShort("view or grant access for the claimed territory you are in"); - - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java b/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java index 27f9ad47..472375fa 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAdmin.java @@ -14,7 +14,6 @@ public class CmdFactionsAdmin extends FCommand this.optionalArgs.put("on/off", "flip"); this.permission = Perm.ADMIN.node; - this.disableOnLock = false; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java b/src/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java index 03ce5f9a..9fcf0aaa 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsAutoClaim.java @@ -15,7 +15,6 @@ public class CmdFactionsAutoClaim extends FCommand this.optionalArgs.put("faction", "your"); this.permission = Perm.AUTOCLAIM.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCapeAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsCapeAbstract.java index 48ecbeb1..278598fd 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCapeAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsCapeAbstract.java @@ -16,8 +16,6 @@ public abstract class CmdFactionsCapeAbstract extends FCommand { this.optionalArgs.put("faction", "your"); - this.disableOnLock = true; - senderMustBePlayer = false; senderMustBeMember = false; senderMustBeOfficer = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java b/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java index b6ecef2e..31739d83 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsClaim.java @@ -20,7 +20,6 @@ public class CmdFactionsClaim extends FCommand this.optionalArgs.put("radius", "1"); this.permission = Perm.CLAIM.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java b/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java index 0217e29b..0bf5607e 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java @@ -26,7 +26,6 @@ public class CmdFactionsCreate extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.CREATE.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; @@ -79,18 +78,18 @@ public class CmdFactionsCreate extends FCommand } // finish setting up the Faction - faction.setTag(tag); - - // trigger the faction join event for the creator - FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.i.get(me),faction,FPlayerJoinEvent.PlayerJoinReason.CREATE); - Bukkit.getServer().getPluginManager().callEvent(joinEvent); - // join event cannot be cancelled or you'll have an empty faction - - // finish setting up the FPlayer + faction.setTag(tag); + + // trigger the faction join event for the creator + FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.get().get(me),faction,FPlayerJoinEvent.PlayerJoinReason.CREATE); + Bukkit.getServer().getPluginManager().callEvent(joinEvent); + // join event cannot be cancelled or you'll have an empty faction + + // finish setting up the FPlayer fme.setRole(Rel.LEADER); fme.setFaction(faction); - for (FPlayer follower : FPlayerColl.i.getOnline()) + for (FPlayer follower : FPlayerColl.get().getAllOnline()) { follower.msg("%s created a new faction %s", fme.describeTo(follower, true), faction.getTag(follower)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java b/src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java index d0929b2f..619f08df 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDeinvite.java @@ -16,7 +16,6 @@ public class CmdFactionsDeinvite extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.DEINVITE.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDemote.java b/src/com/massivecraft/factions/cmd/CmdFactionsDemote.java index a5c8e00c..931a529a 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDemote.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDemote.java @@ -16,7 +16,6 @@ public class CmdFactionsDemote extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.DEMOTE.node; - this.disableOnLock = true; //To demote someone from member -> recruit you must be an officer. //To demote someone from officer -> member you must be a leader. diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java b/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java index e32704cd..2fe42f19 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDescription.java @@ -18,7 +18,6 @@ public class CmdFactionsDescription extends FCommand //this.optionalArgs this.permission = Perm.DESCRIPTION.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; @@ -43,7 +42,7 @@ public class CmdFactionsDescription extends FCommand } // Broadcast the description to everyone - for (FPlayer fplayer : FPlayerColl.i.getOnline()) + for (FPlayer fplayer : FPlayerColl.get().getAllOnline()) { fplayer.msg("%s changed their description to:", myFaction.describeTo(fplayer)); fplayer.sendMessage(myFaction.getDescription()); // players can inject "&" or "`" or "" or whatever in their description, thus exploitable (masquerade as server messages or whatever); by the way, &k is particularly interesting looking diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java index c60ff1cf..238b98e7 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsDisband.java @@ -26,7 +26,6 @@ public class CmdFactionsDisband extends FCommand this.optionalArgs.put("faction", "your"); this.permission = Perm.DISBAND.node; - this.disableOnLock = true; senderMustBePlayer = false; senderMustBeMember = false; @@ -60,7 +59,7 @@ public class CmdFactionsDisband extends FCommand } // Inform all players - for (FPlayer fplayer : FPlayerColl.i.getOnline()) + for (FPlayer fplayer : FPlayerColl.get().getAllOnline()) { String who = senderIsConsole ? "A server admin" : fme.describeTo(fplayer); if (fplayer.getFaction() == faction) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsFlag.java b/src/com/massivecraft/factions/cmd/CmdFactionsFlag.java index 15208d50..dfb9e05f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsFlag.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsFlag.java @@ -19,7 +19,6 @@ public class CmdFactionsFlag extends FCommand this.optionalArgs.put("yes/no", "read"); this.permission = Perm.FLAG.node; - this.disableOnLock = true; senderMustBePlayer = false; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java index 1967874a..f419ee35 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -32,7 +32,6 @@ public class CmdFactionsHome extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.HOME.node; - this.disableOnLock = false; senderMustBePlayer = true; senderMustBeMember = true; @@ -107,7 +106,7 @@ public class CmdFactionsHome extends FCommand if (p == null || !p.isOnline() || p.isDead() || p == me || p.getWorld() != w) continue; - FPlayer fp = FPlayerColl.i.get(p); + FPlayer fp = FPlayerColl.get().get(p); if (fme.getRelationTo(fp) != Rel.ENEMY) continue; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java b/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java index 0504e204..a508d88a 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInvite.java @@ -17,7 +17,6 @@ public class CmdFactionsInvite extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.INVITE.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java index 61d2f405..5ac9dad1 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java @@ -21,7 +21,6 @@ public class CmdFactionsJoin extends FCommand this.optionalArgs.put("player", "you"); this.permission = Perm.JOIN.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; @@ -80,7 +79,7 @@ public class CmdFactionsJoin extends FCommand if (samePlayer && ! canAffordCommand(ConfServer.econCostJoin, "to join a faction")) return; // trigger the join event (cancellable) - FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.i.get(me),faction,FPlayerJoinEvent.PlayerJoinReason.COMMAND); + FPlayerJoinEvent joinEvent = new FPlayerJoinEvent(FPlayerColl.get().get(me),faction,FPlayerJoinEvent.PlayerJoinReason.COMMAND); Bukkit.getServer().getPluginManager().callEvent(joinEvent); if (joinEvent.isCancelled()) return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java index 96f819b9..e3fb63a0 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java @@ -23,7 +23,6 @@ public class CmdFactionsKick extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.KICK.node; - this.disableOnLock = false; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsLeader.java b/src/com/massivecraft/factions/cmd/CmdFactionsLeader.java index 2e3bfbf6..6351e87d 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsLeader.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsLeader.java @@ -22,7 +22,6 @@ public class CmdFactionsLeader extends FCommand this.optionalArgs.put("faction", "your"); this.permission = Perm.LEADER.node; - this.disableOnLock = true; senderMustBePlayer = false; senderMustBeMember = false; @@ -71,7 +70,7 @@ public class CmdFactionsLeader extends FCommand // only perform a FPlayerJoinEvent when newLeader isn't actually in the faction if (newLeader.getFaction() != targetFaction) { - FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayerColl.i.get(me),targetFaction,FPlayerJoinEvent.PlayerJoinReason.LEADER); + FPlayerJoinEvent event = new FPlayerJoinEvent(FPlayerColl.get().get(me),targetFaction,FPlayerJoinEvent.PlayerJoinReason.LEADER); Bukkit.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) return; } @@ -95,7 +94,7 @@ public class CmdFactionsLeader extends FCommand msg("You have promoted %s to the position of faction leader.", newLeader.describeTo(fme, true)); // Inform all players - for (FPlayer fplayer : FPlayerColl.i.getOnline()) + for (FPlayer fplayer : FPlayerColl.get().getAllOnline()) { fplayer.msg("%s gave %s the leadership of %s.", senderIsConsole ? "A server admin" : RelationUtil.describeThatToMe(fme, fplayer, true), newLeader.describeTo(fplayer), targetFaction.describeTo(fplayer)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java b/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java index f2bae021..a27c681c 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsLeave.java @@ -13,7 +13,6 @@ public class CmdFactionsLeave extends FCommand { //this.optionalArgs.put("", ""); this.permission = Perm.LEAVE.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = true; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsList.java b/src/com/massivecraft/factions/cmd/CmdFactionsList.java index 3cd6311e..3bb4c6e0 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsList.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsList.java @@ -24,7 +24,6 @@ public class CmdFactionsList extends FCommand this.optionalArgs.put("page", "1"); this.permission = Perm.LIST.node; - this.disableOnLock = false; senderMustBePlayer = false; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsLock.java b/src/com/massivecraft/factions/cmd/CmdFactionsLock.java deleted file mode 100644 index 42e15efe..00000000 --- a/src/com/massivecraft/factions/cmd/CmdFactionsLock.java +++ /dev/null @@ -1,46 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.Perm; - -public class CmdFactionsLock extends FCommand { - - // TODO: This solution needs refactoring. - /* - factions.lock: - description: use the /f lock [on/off] command to temporarily lock the data files from being overwritten - default: op - */ - - public CmdFactionsLock() - { - super(); - this.aliases.add("lock"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("on/off", "flip"); - - this.permission = Perm.LOCK.node; - this.disableOnLock = false; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeOfficer = false; - senderMustBeLeader = false; - } - - @Override - public void perform() - { - p.setLocked(this.argAsBool(0, ! p.getLocked())); - - if( p.getLocked()) - { - msg("Factions is now locked"); - } - else - { - msg("Factions in now unlocked"); - } - } - -} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsMap.java b/src/com/massivecraft/factions/cmd/CmdFactionsMap.java index 7dd6dd23..ac6f9878 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsMap.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsMap.java @@ -17,7 +17,6 @@ public class CmdFactionsMap extends FCommand this.optionalArgs.put("on/off", "once"); this.permission = Perm.MAP.node; - this.disableOnLock = false; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsOfficer.java b/src/com/massivecraft/factions/cmd/CmdFactionsOfficer.java index 04f3ab0f..09bbb76f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsOfficer.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsOfficer.java @@ -17,7 +17,6 @@ public class CmdFactionsOfficer extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.OFFICER.node; - this.disableOnLock = true; senderMustBePlayer = false; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java b/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java index 578701da..13c2895b 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsOpen.java @@ -16,7 +16,6 @@ public class CmdFactionsOpen extends FCommand this.optionalArgs.put("yes/no", "flip"); this.permission = Perm.OPEN.node; - this.disableOnLock = false; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java b/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java index 279cffcf..4b474bf8 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPerm.java @@ -20,7 +20,6 @@ public class CmdFactionsPerm extends FCommand this.optionalArgs.put("yes/no", "read"); this.permission = Perm.PERM.node; - this.disableOnLock = true; this.errorOnToManyArgs = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPower.java b/src/com/massivecraft/factions/cmd/CmdFactionsPower.java index d9111b01..6a48ac57 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPower.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPower.java @@ -17,7 +17,6 @@ public class CmdFactionsPower extends FCommand this.optionalArgs.put("player", "you"); this.permission = Perm.POWER.node; - this.disableOnLock = false; senderMustBePlayer = false; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java b/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java index 29562d08..cb09da75 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPowerBoost.java @@ -17,7 +17,6 @@ public class CmdFactionsPowerBoost extends FCommand this.requiredArgs.add("#"); this.permission = Perm.POWERBOOST.node; - this.disableOnLock = true; senderMustBePlayer = false; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsPromote.java b/src/com/massivecraft/factions/cmd/CmdFactionsPromote.java index c6a26220..37aee943 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsPromote.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsPromote.java @@ -16,7 +16,6 @@ public class CmdFactionsPromote extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.PROMOTE.node; - this.disableOnLock = true; //To promote someone from recruit -> member you must be an officer. //To promote someone from member -> officer you must be a leader. diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index d38b9356..8ecb3ff6 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -21,7 +21,6 @@ public abstract class CmdFactionsRelationAbstract extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.RELATION.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsReload.java b/src/com/massivecraft/factions/cmd/CmdFactionsReload.java deleted file mode 100644 index 8da93423..00000000 --- a/src/com/massivecraft/factions/cmd/CmdFactionsReload.java +++ /dev/null @@ -1,64 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.FPlayerColl; -import com.massivecraft.factions.FactionColl; -import com.massivecraft.factions.Factions; -import com.massivecraft.factions.Perm; - -public class CmdFactionsReload extends FCommand -{ - - public CmdFactionsReload() - { - super(); - this.aliases.add("reload"); - - //this.requiredArgs.add(""); - this.optionalArgs.put("file", "all"); - - this.permission = Perm.RELOAD.node; - this.disableOnLock = false; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeOfficer = false; - senderMustBeLeader = false; - } - - @Override - public void perform() - { - long timeInitStart = System.currentTimeMillis(); - String file = this.argAsString(0, "all").toLowerCase(); - - String fileName; - - if (file.startsWith("f")) - { - FactionColl.i.loadFromDisc(); - fileName = "factions.json"; - } - else if (file.startsWith("p")) - { - FPlayerColl.i.loadFromDisc(); - fileName = "players.json"; - } - else if (file.startsWith("a")) - { - fileName = "all"; - FPlayerColl.i.loadFromDisc(); - FactionColl.i.loadFromDisc(); - } - else - { - Factions.get().log("RELOAD CANCELLED - SPECIFIED FILE INVALID"); - msg("Invalid file specified. Valid files: all, board, factions, players"); - return; - } - - long timeReload = (System.currentTimeMillis()-timeInitStart); - - msg("Reloaded %s from disk, took %dms.", fileName, timeReload); - } - -} diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSaveAll.java b/src/com/massivecraft/factions/cmd/CmdFactionsSaveAll.java deleted file mode 100644 index adb5294c..00000000 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSaveAll.java +++ /dev/null @@ -1,36 +0,0 @@ -package com.massivecraft.factions.cmd; - -import com.massivecraft.factions.FPlayerColl; -import com.massivecraft.factions.FactionColl; -import com.massivecraft.factions.Perm; - -public class CmdFactionsSaveAll extends FCommand -{ - - public CmdFactionsSaveAll() - { - super(); - this.aliases.add("saveall"); - this.aliases.add("save"); - - //this.requiredArgs.add(""); - //this.optionalArgs.put("", ""); - - this.permission = Perm.SAVE.node; - this.disableOnLock = false; - - senderMustBePlayer = false; - senderMustBeMember = false; - senderMustBeOfficer = false; - senderMustBeLeader = false; - } - - @Override - public void perform() - { - FPlayerColl.i.saveToDisc(); - FactionColl.i.saveToDisc(); - msg("Factions saved to disk!"); - } - -} \ No newline at end of file diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java b/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java index 0139bac6..2b9518f2 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSeeChunk.java @@ -17,7 +17,6 @@ public class CmdFactionsSeeChunk extends FCommand this.aliases.add("seechunk"); this.permission = Perm.SEE_CHUNK.node; - this.disableOnLock = false; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java index 6911fd00..e7e30657 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -17,7 +17,6 @@ public class CmdFactionsSethome extends FCommand this.optionalArgs.put("faction", "your"); this.permission = Perm.SETHOME.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsShow.java b/src/com/massivecraft/factions/cmd/CmdFactionsShow.java index 732508d6..8b1d0b06 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsShow.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsShow.java @@ -12,6 +12,7 @@ import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; +import com.massivecraft.mcore.mixin.Mixin; import com.massivecraft.mcore.util.Txt; public class CmdFactionsShow extends FCommand @@ -25,7 +26,6 @@ public class CmdFactionsShow extends FCommand this.optionalArgs.put("faction", "your"); this.permission = Perm.SHOW.node; - this.disableOnLock = false; senderMustBePlayer = true; senderMustBeMember = false; @@ -114,7 +114,7 @@ public class CmdFactionsShow extends FCommand for (FPlayer follower : admins) { - if (follower.isOnlineAndVisibleTo(me)) + if (follower.isOnline() && Mixin.isVisible(me, follower.getId())) { memberOnlineNames.add(follower.getNameAndTitle(fme)); } @@ -126,7 +126,7 @@ public class CmdFactionsShow extends FCommand for (FPlayer follower : mods) { - if (follower.isOnlineAndVisibleTo(me)) + if (follower.isOnline() && Mixin.isVisible(me, follower.getId())) { memberOnlineNames.add(follower.getNameAndTitle(fme)); } @@ -138,7 +138,7 @@ public class CmdFactionsShow extends FCommand for (FPlayer follower : normals) { - if (follower.isOnlineAndVisibleTo(me)) + if (follower.isOnline() && Mixin.isVisible(me, follower.getId())) { memberOnlineNames.add(follower.getNameAndTitle(fme)); } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsTag.java b/src/com/massivecraft/factions/cmd/CmdFactionsTag.java index 8c0e136e..470de5dc 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsTag.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsTag.java @@ -23,7 +23,6 @@ public class CmdFactionsTag extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.TAG.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java b/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java index 6ba68209..87fc6902 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsTitle.java @@ -16,7 +16,6 @@ public class CmdFactionsTitle extends FCommand this.optionalArgs.put("title", ""); this.permission = Perm.TITLE.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java index 19bb28ad..efdd6390 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaim.java @@ -24,7 +24,6 @@ public class CmdFactionsUnclaim extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.UNCLAIM.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java index 5835ae3f..564508f5 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsUnclaimall.java @@ -21,7 +21,6 @@ public class CmdFactionsUnclaimall extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.UNCLAIM_ALL.node; - this.disableOnLock = true; senderMustBePlayer = true; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsVersion.java b/src/com/massivecraft/factions/cmd/CmdFactionsVersion.java index 1a6951fc..f00ecd8e 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsVersion.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsVersion.java @@ -14,7 +14,6 @@ public class CmdFactionsVersion extends FCommand //this.optionalArgs.put("", ""); this.permission = Perm.VERSION.node; - this.disableOnLock = false; senderMustBePlayer = false; senderMustBeMember = false; diff --git a/src/com/massivecraft/factions/cmd/FCommand.java b/src/com/massivecraft/factions/cmd/FCommand.java index 26da3666..7a893ba0 100644 --- a/src/com/massivecraft/factions/cmd/FCommand.java +++ b/src/com/massivecraft/factions/cmd/FCommand.java @@ -21,8 +21,6 @@ import com.massivecraft.mcore.util.Txt; public abstract class FCommand extends MCommand { - public boolean disableOnLock; - public FPlayer fme; public Faction myFaction; @@ -37,9 +35,6 @@ public abstract class FCommand extends MCommand { super(Factions.get()); - // Due to safety reasons it defaults to disable on lock. - disableOnLock = true; - // The money commands must be disabled if money should not be used. isMoneyCommand = false; @@ -53,7 +48,7 @@ public abstract class FCommand extends MCommand { if (sender instanceof Player) { - this.fme = FPlayerColl.i.get((Player)sender); + this.fme = FPlayerColl.get().get(sender); this.myFaction = this.fme.getFaction(); } else @@ -66,13 +61,7 @@ public abstract class FCommand extends MCommand @Override public boolean isEnabled() - { - if (p.getLocked() && this.disableOnLock) - { - msg("Factions was locked by an admin. Please try again later."); - return false; - } - + { if (this.isMoneyCommand && ! ConfServer.econEnabled) { msg("Faction economy features are disabled on this server."); @@ -98,7 +87,7 @@ public abstract class FCommand extends MCommand if ( ! (sender instanceof Player)) return false; - FPlayer fplayer = FPlayerColl.i.get((Player)sender); + FPlayer fplayer = FPlayerColl.get().get((Player)sender); if ( ! fplayer.hasFaction()) { @@ -165,7 +154,7 @@ public abstract class FCommand extends MCommand if (name != null) { - FPlayer fplayer = FPlayerColl.i.get(name); + FPlayer fplayer = FPlayerColl.get().get(name); if (fplayer != null) { ret = fplayer; @@ -199,7 +188,9 @@ public abstract class FCommand extends MCommand if (name != null) { - FPlayer fplayer = FPlayerColl.i.getBestIdMatch(name); + // TODO: Easy fix for now + //FPlayer fplayer = FPlayerColl.get().getBestIdMatch(name); + FPlayer fplayer = FPlayerColl.get().getId2entity().get(name); if (fplayer != null) { ret = fplayer; @@ -250,7 +241,10 @@ public abstract class FCommand extends MCommand // Next we match player names if (faction == null) { - FPlayer fplayer = FPlayerColl.i.getBestIdMatch(name); + // TODO: Easy fix for now + //FPlayer fplayer = FPlayerColl.get().getBestIdMatch(name); + FPlayer fplayer = FPlayerColl.get().getId2entity().get(name); + if (fplayer != null) { faction = fplayer.getFaction(); diff --git a/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java b/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java index 21d3c7b0..5eb7e85b 100644 --- a/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java +++ b/src/com/massivecraft/factions/cmd/req/ReqRoleIsAtLeast.java @@ -3,11 +3,9 @@ package com.massivecraft.factions.cmd.req; import org.bukkit.command.CommandSender; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayerColl; import com.massivecraft.factions.Rel; import com.massivecraft.mcore.cmd.MCommand; import com.massivecraft.mcore.cmd.req.ReqAbstract; -import com.massivecraft.mcore.util.SenderUtil; import com.massivecraft.mcore.util.Txt; public class ReqRoleIsAtLeast extends ReqAbstract @@ -35,8 +33,7 @@ public class ReqRoleIsAtLeast extends ReqAbstract @Override public boolean apply(CommandSender sender, MCommand command) { - - FPlayer fplayer = FPlayerColl.i.get(SenderUtil.getSenderId(sender)); + FPlayer fplayer = FPlayer.get(sender); return fplayer.getRole().isAtLeast(this.rel); } diff --git a/src/com/massivecraft/factions/event/FactionCreateEvent.java b/src/com/massivecraft/factions/event/FactionCreateEvent.java index 1260e5f9..f2607c41 100644 --- a/src/com/massivecraft/factions/event/FactionCreateEvent.java +++ b/src/com/massivecraft/factions/event/FactionCreateEvent.java @@ -6,7 +6,6 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayerColl; import com.massivecraft.factions.FactionColl; public class FactionCreateEvent extends Event implements Cancellable @@ -36,7 +35,7 @@ public class FactionCreateEvent extends Event implements Cancellable public FPlayer getFPlayer() { - return FPlayerColl.i.get(sender); + return FPlayer.get(this.sender); } public String getFactionId() diff --git a/src/com/massivecraft/factions/event/FactionDisbandEvent.java b/src/com/massivecraft/factions/event/FactionDisbandEvent.java index bd2baf37..05b920ab 100644 --- a/src/com/massivecraft/factions/event/FactionDisbandEvent.java +++ b/src/com/massivecraft/factions/event/FactionDisbandEvent.java @@ -6,7 +6,6 @@ import org.bukkit.event.Event; import org.bukkit.event.HandlerList; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayerColl; import com.massivecraft.factions.Faction; import com.massivecraft.factions.FactionColl; @@ -40,7 +39,7 @@ public class FactionDisbandEvent extends Event implements Cancellable public FPlayer getFPlayer() { - return FPlayerColl.i.get(sender); + return FPlayer.get(sender); } public Player getPlayer() diff --git a/src/com/massivecraft/factions/iface/EconomyParticipator.java b/src/com/massivecraft/factions/iface/EconomyParticipator.java index 2a6a86d0..63735008 100644 --- a/src/com/massivecraft/factions/iface/EconomyParticipator.java +++ b/src/com/massivecraft/factions/iface/EconomyParticipator.java @@ -4,6 +4,5 @@ package com.massivecraft.factions.iface; public interface EconomyParticipator extends RelationParticipator { public String getAccountId(); - - public void msg(String str, Object... args); + public boolean msg(String msg, Object... args); } \ No newline at end of file diff --git a/src/com/massivecraft/factions/integration/LWCFeatures.java b/src/com/massivecraft/factions/integration/LWCFeatures.java index 5a029553..0fd2d5c0 100644 --- a/src/com/massivecraft/factions/integration/LWCFeatures.java +++ b/src/com/massivecraft/factions/integration/LWCFeatures.java @@ -13,7 +13,7 @@ import org.bukkit.block.BlockState; import com.griefcraft.lwc.LWC; import com.griefcraft.lwc.LWCPlugin; import com.massivecraft.factions.ConfServer; -import com.massivecraft.factions.FPlayerColl; +import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import com.massivecraft.factions.Factions; import com.massivecraft.mcore.ps.PS; @@ -63,7 +63,7 @@ public class LWCFeatures { if(lwc.findProtection(chests.get(x)) != null) { - if(!faction.getFPlayers().contains(FPlayerColl.i.get(lwc.findProtection(chests.get(x)).getOwner()))) + if(!faction.getFPlayers().contains(FPlayer.get(lwc.findProtection(chests.get(x)).getOwner()))) lwc.findProtection(chests.get(x)).remove(); } } diff --git a/src/com/massivecraft/factions/integration/SpoutFeatures.java b/src/com/massivecraft/factions/integration/SpoutFeatures.java index a2d2f6b1..cade4d32 100644 --- a/src/com/massivecraft/factions/integration/SpoutFeatures.java +++ b/src/com/massivecraft/factions/integration/SpoutFeatures.java @@ -1,6 +1,7 @@ package com.massivecraft.factions.integration; import java.util.Arrays; +import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -73,7 +74,7 @@ public class SpoutFeatures for (Player player : fromPlayers) { - FPlayer fplayer = FPlayerColl.i.get(player); + FPlayer fplayer = FPlayer.get(player); SpoutPlayer splayer = SpoutManager.getPlayer(player); Faction faction = fplayer.getFaction(); @@ -137,13 +138,13 @@ public class SpoutFeatures for (Player player : fromPlayers) { - FPlayer fplayer = FPlayerColl.i.get(player); + FPlayer fplayer = FPlayer.get(player); SpoutPlayer splayer = SpoutManager.getPlayer(player); Faction faction = fplayer.getFaction(); for (Player playerTo : toPlayers) { - FPlayer fplayerTo = FPlayerColl.i.get(playerTo); + FPlayer fplayerTo = FPlayer.get(playerTo); SpoutPlayer splayerTo = SpoutManager.getPlayer(playerTo); Faction factionTo = fplayerTo.getFaction(); @@ -250,7 +251,7 @@ public class SpoutFeatures { if ( ! isEnabled()) return; - Set players = FPlayerColl.i.getOnline(); + Collection players = FPlayerColl.get().getAllOnline(); for (FPlayer player : players) { @@ -279,7 +280,7 @@ public class SpoutFeatures chunk = chunk.getChunk(true); - Set players = FPlayerColl.i.getOnline(); + Collection players = FPlayerColl.get().getAllOnline(); for (FPlayer player : players) { diff --git a/src/com/massivecraft/factions/integration/SpoutMainListener.java b/src/com/massivecraft/factions/integration/SpoutMainListener.java index 6a6b04ba..7d39ad73 100644 --- a/src/com/massivecraft/factions/integration/SpoutMainListener.java +++ b/src/com/massivecraft/factions/integration/SpoutMainListener.java @@ -29,7 +29,7 @@ public class SpoutMainListener implements Listener @EventHandler(priority = EventPriority.NORMAL) public void onSpoutCraftEnable(SpoutCraftEnableEvent event) { - final FPlayer me = FPlayerColl.i.get(event.getPlayer()); + final FPlayer me = FPlayerColl.get().get(event.getPlayer()); SpoutFeatures.updateTitle(me, null); SpoutFeatures.updateTitle(null, me); diff --git a/src/com/massivecraft/factions/integration/herochat/FactionsChannelAbstract.java b/src/com/massivecraft/factions/integration/herochat/FactionsChannelAbstract.java index b13fe7e2..e07251aa 100644 --- a/src/com/massivecraft/factions/integration/herochat/FactionsChannelAbstract.java +++ b/src/com/massivecraft/factions/integration/herochat/FactionsChannelAbstract.java @@ -209,15 +209,16 @@ public abstract class FactionsChannelAbstract implements Channel public abstract Set getTargetRelations(); + // TODO: When I add in universes I will need to separate the channel per universe. public Set getRecipients(Player sender) { Set ret = new HashSet(); - FPlayer fpsender = FPlayerColl.i.get(sender); + FPlayer fpsender = FPlayerColl.get().get(sender); Faction faction = fpsender.getFaction(); ret.addAll(faction.getOnlinePlayers()); - for (FPlayer fplayer : FPlayerColl.i.getOnline()) + for (FPlayer fplayer : FPlayerColl.get().getAllOnline()) { if(this.getTargetRelations().contains(faction.getRelationTo(fplayer))) { diff --git a/src/com/massivecraft/factions/integration/herochat/HerochatListener.java b/src/com/massivecraft/factions/integration/herochat/HerochatListener.java index d7decacc..1c45dd9e 100644 --- a/src/com/massivecraft/factions/integration/herochat/HerochatListener.java +++ b/src/com/massivecraft/factions/integration/herochat/HerochatListener.java @@ -33,7 +33,7 @@ public class HerochatListener implements Listener if ( ! ConfServer.chatParseTags) return; Player from = event.getSender().getPlayer(); - FPlayer fpfrom = FPlayerColl.i.get(from); + FPlayer fpfrom = FPlayerColl.get().get(from); String format = event.getFormat(); format = format.replaceAll("&r", "§r"); diff --git a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java index 0cad1840..2f940b3d 100644 --- a/src/com/massivecraft/factions/listeners/FactionsBlockListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsBlockListener.java @@ -22,7 +22,6 @@ import com.massivecraft.factions.ConfServer; import com.massivecraft.factions.FFlag; import com.massivecraft.factions.FPerm; import com.massivecraft.factions.FPlayer; -import com.massivecraft.factions.FPlayerColl; import com.massivecraft.factions.Faction; import com.massivecraft.mcore.ps.PS; @@ -88,7 +87,7 @@ public class FactionsBlockListener implements Listener String name = player.getName(); if (ConfServer.playersWhoBypassAllProtection.contains(name)) return true; - FPlayer me = FPlayerColl.i.get(name); + FPlayer me = FPlayer.get(name); if (me.hasAdminMode()) return true; PS ps = PS.valueOf(location); diff --git a/src/com/massivecraft/factions/listeners/FactionsChatListener.java b/src/com/massivecraft/factions/listeners/FactionsChatListener.java index f2baf2e1..b9070da0 100644 --- a/src/com/massivecraft/factions/listeners/FactionsChatListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsChatListener.java @@ -84,7 +84,7 @@ public class FactionsChatListener implements Listener //if (ConfServer.chatTagHandledByAnotherPlugin) return; Player from = event.getPlayer(); - FPlayer fpfrom = FPlayerColl.i.get(from); + FPlayer fpfrom = FPlayerColl.get().get(from); String format = event.getFormat(); String message = event.getMessage(); @@ -113,7 +113,7 @@ public class FactionsChatListener implements Listener // 4. We send out the messages to each player with relation color. for (Player to : event.getRecipients()) { - FPlayer fpto = FPlayerColl.i.get(to); + FPlayer fpto = FPlayerColl.get().get(to); String formatWithColor = parseTags(format, from, fpfrom, to, fpto); to.sendMessage(String.format(formatWithColor, from.getDisplayName(), message)); } @@ -178,7 +178,7 @@ public class FactionsChatListener implements Listener public static String parseTags(String str, Player from) { - FPlayer fpfrom = FPlayerColl.i.get(from); + FPlayer fpfrom = FPlayerColl.get().get(from); return parseTags(str, from, fpfrom, null, null); } public static String parseTags(String str, Player from, FPlayer fpfrom) @@ -187,8 +187,8 @@ public class FactionsChatListener implements Listener } public static String parseTags(String str, Player from, Player to) { - FPlayer fpfrom = FPlayerColl.i.get(from); - FPlayer fpto = FPlayerColl.i.get(to); + FPlayer fpfrom = FPlayerColl.get().get(from); + FPlayer fpto = FPlayerColl.get().get(to); return parseTags(str, from, fpfrom, to, fpto); } public static String parseTags(String str, Player from, FPlayer fpfrom, Player to, FPlayer fpto) diff --git a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java index c5afe455..470ab6d8 100644 --- a/src/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -59,7 +59,7 @@ public class FactionsEntityListener implements Listener if ( ! (entity instanceof Player)) return; Player player = (Player) entity; - FPlayer fplayer = FPlayerColl.i.get(player); + FPlayer fplayer = FPlayerColl.get().get(player); Faction faction = BoardColl.get().getFactionAt(PS.valueOf(player)); @@ -221,7 +221,7 @@ public class FactionsEntityListener implements Listener if ( ! (damagee instanceof Player)) return true; - FPlayer defender = FPlayerColl.i.get((Player)damagee); + FPlayer defender = FPlayerColl.get().get(damagee); if (defender == null || defender.getPlayer() == null) return true; @@ -245,7 +245,7 @@ public class FactionsEntityListener implements Listener { if (notify) { - FPlayer attacker = FPlayerColl.i.get((Player)damager); + FPlayer attacker = FPlayerColl.get().get((Player)damager); attacker.msg("PVP is disabled in %s.", defLocFaction.describeTo(attacker)); } return false; @@ -256,7 +256,7 @@ public class FactionsEntityListener implements Listener if ( ! (damager instanceof Player)) return true; - FPlayer attacker = FPlayerColl.i.get((Player)damager); + FPlayer attacker = FPlayerColl.get().get((Player)damager); if (attacker == null || attacker.getPlayer() == null) return true; diff --git a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java index 490bfc5e..e1a2cca9 100644 --- a/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java +++ b/src/com/massivecraft/factions/listeners/FactionsPlayerListener.java @@ -44,7 +44,7 @@ public class FactionsPlayerListener implements Listener public void onPlayerJoin(PlayerJoinEvent event) { // Make sure that all online players do have a fplayer. - final FPlayer me = FPlayerColl.i.get(event.getPlayer()); + final FPlayer me = FPlayerColl.get().get(event.getPlayer()); // Update the lastLoginTime for this fplayer me.setLastLoginTime(System.currentTimeMillis()); @@ -61,7 +61,7 @@ public class FactionsPlayerListener implements Listener @EventHandler(priority = EventPriority.NORMAL) public void onPlayerQuit(PlayerQuitEvent event) { - FPlayer me = FPlayerColl.i.get(event.getPlayer()); + FPlayer me = FPlayerColl.get().get(event.getPlayer()); // Make sure player's power is up to date when they log off. me.getPower(); @@ -88,7 +88,7 @@ public class FactionsPlayerListener implements Listener return; Player player = event.getPlayer(); - FPlayer me = FPlayerColl.i.get(player); + FPlayer me = FPlayerColl.get().get(player); // Did we change coord? PS chunkFrom = me.getCurrentChunk(); @@ -158,7 +158,7 @@ public class FactionsPlayerListener implements Listener int count = attempt.increment(); if (count >= 10) { - FPlayer me = FPlayerColl.i.get(name); + FPlayer me = FPlayerColl.get().get(name); me.msg("Ouch, that is starting to hurt. You should give it a rest."); player.damage(NumberConversions.floor((double)count / 10)); } @@ -204,7 +204,7 @@ public class FactionsPlayerListener implements Listener String name = player.getName(); if (ConfServer.playersWhoBypassAllProtection.contains(name)) return true; - FPlayer me = FPlayerColl.i.get(name); + FPlayer me = FPlayerColl.get().get(name); if (me.hasAdminMode()) return true; if (Const.MATERIALS_EDIT_TOOLS.contains(material) && ! FPerm.BUILD.has(me, loc, ! justCheck)) return false; return true; @@ -214,7 +214,7 @@ public class FactionsPlayerListener implements Listener String name = player.getName(); if (ConfServer.playersWhoBypassAllProtection.contains(name)) return true; - FPlayer me = FPlayerColl.i.get(name); + FPlayer me = FPlayerColl.get().get(name); if (me.hasAdminMode()) return true; Location loc = block.getLocation(); Material material = block.getType(); @@ -230,7 +230,7 @@ public class FactionsPlayerListener implements Listener @EventHandler(priority = EventPriority.HIGH) public void onPlayerRespawn(PlayerRespawnEvent event) { - FPlayer me = FPlayerColl.i.get(event.getPlayer()); + FPlayer me = FPlayerColl.get().get(event.getPlayer()); me.getPower(); // update power, so they won't have gained any while dead @@ -290,7 +290,7 @@ public class FactionsPlayerListener implements Listener { // Get the player Player player = event.getPlayer(); - FPlayer me = FPlayerColl.i.get(player); + FPlayer me = FPlayerColl.get().get(player); // With adminmode no commands are denied. if (me.hasAdminMode()) return; @@ -349,7 +349,7 @@ public class FactionsPlayerListener implements Listener { if (event.isCancelled()) return; - FPlayer badGuy = FPlayerColl.i.get(event.getPlayer()); + FPlayer badGuy = FPlayerColl.get().get(event.getPlayer()); if (badGuy == null) { return; diff --git a/src/com/massivecraft/factions/util/AutoLeaveTask.java b/src/com/massivecraft/factions/util/AutoLeaveTask.java index ad3c8ae3..8c095b6a 100644 --- a/src/com/massivecraft/factions/util/AutoLeaveTask.java +++ b/src/com/massivecraft/factions/util/AutoLeaveTask.java @@ -15,7 +15,7 @@ public class AutoLeaveTask implements Runnable public void run() { - FPlayerColl.i.autoLeaveOnInactivityRoutine(); + FPlayerColl.get().autoLeaveOnInactivityRoutine(); // maybe setting has been changed? if so, restart task at new rate if (this.rate != ConfServer.autoLeaveRoutineRunsEveryXMinutes)