From 1f5e591ce6f7fc20ef2ff8a8b69e224ed98ee58b Mon Sep 17 00:00:00 2001 From: Olof Larsson Date: Thu, 25 Feb 2016 22:28:09 +0100 Subject: [PATCH] MassiveCore - MassivePlugin and Active --- src/com/massivecraft/factions/Factions.java | 77 +++++++++---------- .../factions/cmd/CmdFactions.java | 7 ++ .../factions/cmd/CmdFactionsCreate.java | 2 +- .../factions/cmd/CmdFactionsHome.java | 3 +- .../factions/cmd/CmdFactionsInviteAdd.java | 3 +- .../factions/cmd/CmdFactionsInviteRemove.java | 5 +- .../factions/cmd/CmdFactionsJoin.java | 4 +- .../factions/cmd/CmdFactionsKick.java | 2 +- .../factions/cmd/CmdFactionsRankOld.java | 3 +- .../cmd/CmdFactionsRelationAbstract.java | 9 +-- .../factions/cmd/CmdFactionsSethome.java | 3 +- .../factions/engine/EngineChat.java | 19 ++--- .../factions/engine/EngineEcon.java | 35 +++------ .../factions/engine/EngineExploit.java | 16 +--- .../factions/engine/EngineMain.java | 22 ++---- .../factions/engine/EngineSeeChunk.java | 24 +----- .../factions/entity/FactionColl.java | 6 +- .../massivecraft/factions/entity/MConf.java | 4 +- .../factions/entity/MConfColl.java | 5 +- .../factions/entity/MFlagColl.java | 5 +- .../massivecraft/factions/entity/MPerm.java | 4 +- .../factions/entity/MPermColl.java | 5 +- .../integration/herochat/EngineHerochat.java | 22 ++---- .../herochat/IntegrationHerochat.java | 20 +++-- .../factions/integration/lwc/EngineLwc.java | 31 +++----- .../integration/lwc/IntegrationLwc.java | 20 +++-- .../spigot/EngineSpigot.java | 34 +------- .../integration/spigot/IntegrationSpigot.java | 29 +++++++ .../integration/spigot/PredicateSpigot.java | 37 +++++++++ .../worldguard/EngineWorldGuard.java | 35 +++------ .../worldguard/IntegrationWorldGuard.java | 20 +++-- .../factions/spigot/SpigotFeatures.java | 37 --------- .../factions/task/TaskEconLandReward.java | 13 ---- .../factions/task/TaskFlagPermCreate.java | 9 --- .../factions/task/TaskPlayerDataRemove.java | 9 --- .../factions/task/TaskPlayerPowerUpdate.java | 9 --- .../factions/update/OldConfColl.java | 5 +- .../factions/update/UpdateUtil.java | 2 +- 38 files changed, 234 insertions(+), 361 deletions(-) rename src/com/massivecraft/factions/{ => integration}/spigot/EngineSpigot.java (84%) create mode 100644 src/com/massivecraft/factions/integration/spigot/IntegrationSpigot.java create mode 100644 src/com/massivecraft/factions/integration/spigot/PredicateSpigot.java delete mode 100644 src/com/massivecraft/factions/spigot/SpigotFeatures.java diff --git a/src/com/massivecraft/factions/Factions.java b/src/com/massivecraft/factions/Factions.java index a80aa11c..58195e47 100644 --- a/src/com/massivecraft/factions/Factions.java +++ b/src/com/massivecraft/factions/Factions.java @@ -36,10 +36,10 @@ import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.factions.entity.MConfColl; import com.massivecraft.factions.integration.herochat.IntegrationHerochat; import com.massivecraft.factions.integration.lwc.IntegrationLwc; +import com.massivecraft.factions.integration.spigot.IntegrationSpigot; import com.massivecraft.factions.integration.worldguard.IntegrationWorldGuard; import com.massivecraft.factions.mixin.PowerMixin; import com.massivecraft.factions.mixin.PowerMixinDefault; -import com.massivecraft.factions.spigot.SpigotFeatures; import com.massivecraft.factions.task.TaskFlagPermCreate; import com.massivecraft.factions.task.TaskPlayerDataRemove; import com.massivecraft.factions.task.TaskEconLandReward; @@ -75,16 +75,18 @@ public class Factions extends MassivePlugin private static Factions i; public static Factions get() { return i; } - public Factions() { Factions.i = this; } + public Factions() + { + Factions.i = this; + + // Version Synchronized + this.setVersionSynchronized(true); + } // -------------------------------------------- // // FIELDS // -------------------------------------------- // - // Commands - private CmdFactions outerCmdFactions; - public CmdFactions getOuterCmdFactions() { return this.outerCmdFactions; } - // Aspects // TODO: Remove in the future when the update has been removed. private Aspect aspect; @@ -108,13 +110,8 @@ public class Factions extends MassivePlugin // -------------------------------------------- // @Override - public void onEnable() + public void onEnableInner() { - if ( ! preEnable()) return; - - // Version Synchronized - this.setVersionSynchronized(true); - // Initialize Aspects this.aspect = AspectColl.get().get(Const.ASPECT, true); this.aspect.register(); @@ -129,48 +126,48 @@ public class Factions extends MassivePlugin // Initialize Database this.databaseInitialized = false; - MFlagColl.get().init(); - MPermColl.get().init(); - MConfColl.get().init(); + MFlagColl.get().setActive(true); + MPermColl.get().setActive(true); + MConfColl.get().setActive(true); UpdateUtil.update(); - MPlayerColl.get().init(); - FactionColl.get().init(); - BoardColl.get().init(); + MPlayerColl.get().setActive(true); + FactionColl.get().setActive(true); + BoardColl.get().setActive(true); UpdateUtil.updateSpecialIds(); FactionColl.get().reindexMPlayers(); this.databaseInitialized = true; - // Commands - this.outerCmdFactions = new CmdFactions(); - this.outerCmdFactions.register(this); - - // Engines - EngineMain.get().activate(); - EngineChat.get().activate(); - EngineExploit.get().activate(); - EngineSeeChunk.get().activate(); - EngineEcon.get().activate(); // TODO: Take an extra look and make sure all economy stuff is handled using events. + // Activate + this.activate( + // Command + CmdFactions.get(), - // Integrate - this.integrate( + // Engines + EngineMain.get(), + EngineChat.get(), + EngineExploit.get(), + EngineSeeChunk.get(), + EngineEcon.get(), // TODO: Take an extra look and make sure all economy stuff is handled using events. + + // Integrate IntegrationHerochat.get(), IntegrationLwc.get(), - IntegrationWorldGuard.get() + IntegrationWorldGuard.get(), + + // Spigot + IntegrationSpigot.get(), + + // Modulo Repeat Tasks + TaskPlayerPowerUpdate.get(), + TaskPlayerDataRemove.get(), + TaskEconLandReward.get(), + TaskFlagPermCreate.get() ); - // Spigot - SpigotFeatures.activate(); - - // Modulo Repeat Tasks - TaskPlayerPowerUpdate.get().activate(); - TaskPlayerDataRemove.get().activate(); - TaskEconLandReward.get().activate(); - TaskFlagPermCreate.get().activate(); - // Register built in chat modifiers ChatModifierLc.get().register(); ChatModifierLp.get().register(); diff --git a/src/com/massivecraft/factions/cmd/CmdFactions.java b/src/com/massivecraft/factions/cmd/CmdFactions.java index 6049871d..99c6bd9f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactions.java +++ b/src/com/massivecraft/factions/cmd/CmdFactions.java @@ -10,6 +10,13 @@ import com.massivecraft.massivecore.command.VersionCommand; public class CmdFactions extends FactionsCommand { + // -------------------------------------------- // + // INSTANCE + // -------------------------------------------- // + + private static CmdFactions i = new CmdFactions(); + public static CmdFactions get() { return i; } + // -------------------------------------------- // // FIELDS // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java b/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java index 85053900..93656547 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsCreate.java @@ -84,7 +84,7 @@ public class CmdFactionsCreate extends FactionsCommand // Inform msg("You created the faction %s", faction.getName(msender)); - message(Mson.mson(mson("You should now: ").color(ChatColor.YELLOW), Factions.get().getOuterCmdFactions().cmdFactionsDescription.getTemplate())); + message(Mson.mson(mson("You should now: ").color(ChatColor.YELLOW), CmdFactions.get().cmdFactionsDescription.getTemplate())); // Log if (MConf.get().logFactionCreate) diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java index 97dfa510..17b439de 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsHome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsHome.java @@ -4,7 +4,6 @@ import org.bukkit.Location; import org.bukkit.World; import org.bukkit.entity.Player; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.type.TypeFaction; @@ -73,7 +72,7 @@ public class CmdFactionsHome extends FactionsCommandHome if (MPerm.getPermSethome().has(msender, faction, false)) { msender.msg("You should:"); - msender.message(Factions.get().getOuterCmdFactions().cmdFactionsSethome.getTemplate()); + msender.message(CmdFactions.get().cmdFactionsSethome.getTemplate()); } return; diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInviteAdd.java b/src/com/massivecraft/factions/cmd/CmdFactionsInviteAdd.java index 027cc196..d3807eb2 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInviteAdd.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInviteAdd.java @@ -4,7 +4,6 @@ import java.util.Collection; import org.bukkit.ChatColor; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.type.TypeMPlayer; import com.massivecraft.factions.entity.MPerm; @@ -77,7 +76,7 @@ public class CmdFactionsInviteAdd extends FactionsCommand else { // Mson - String command = Factions.get().getOuterCmdFactions().cmdFactionsInvite.cmdFactionsInviteRemove.getCommandLine(mplayer.getName()); + String command = CmdFactions.get().cmdFactionsInvite.cmdFactionsInviteRemove.getCommandLine(mplayer.getName()); String tooltip = Txt.parse("Click to %s.", command); Mson remove = Mson.mson( diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsInviteRemove.java b/src/com/massivecraft/factions/cmd/CmdFactionsInviteRemove.java index 2151d3b2..73997812 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsInviteRemove.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsInviteRemove.java @@ -7,7 +7,6 @@ import java.util.Set; import org.bukkit.ChatColor; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.type.TypeMPlayer; import com.massivecraft.factions.entity.MPerm; @@ -73,7 +72,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand if (mplayer.getFaction() == msenderFaction) { // Mson - String command = Factions.get().getOuterCmdFactions().cmdFactionsKick.getCommandLine(mplayer.getName()); + String command = CmdFactions.get().cmdFactionsKick.getCommandLine(mplayer.getName()); String tooltip = Txt.parse("Click to %s.", command); Mson kick = Mson.mson( @@ -116,7 +115,7 @@ public class CmdFactionsInviteRemove extends FactionsCommand else { // Mson - String command = Factions.get().getOuterCmdFactions().cmdFactionsInvite.cmdFactionsInviteAdd.getCommandLine(mplayer.getName()); + String command = CmdFactions.get().cmdFactionsInvite.cmdFactionsInviteAdd.getCommandLine(mplayer.getName()); String tooltip = Txt.parse("Click to %s.", command); Mson invite = Mson.mson( diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java index 4ffc54d0..aee9dbc6 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsJoin.java @@ -60,7 +60,7 @@ public class CmdFactionsJoin extends FactionsCommand if (faction == mplayerFaction) { - String command = Factions.get().getOuterCmdFactions().cmdFactionsKick.getCommandLine(mplayer.getName()); + String command = CmdFactions.get().cmdFactionsKick.getCommandLine(mplayer.getName()); // Mson creation Mson alreadyMember = Mson.mson( @@ -80,7 +80,7 @@ public class CmdFactionsJoin extends FactionsCommand if (mplayerFaction.isNormal()) { - String command = Factions.get().getOuterCmdFactions().cmdFactionsLeave.getCommandLine(mplayer.getName()); + String command = CmdFactions.get().cmdFactionsLeave.getCommandLine(mplayer.getName()); // Mson creation Mson leaveFirst = Mson.mson( diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java index 1361b794..1ccbeb4f 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsKick.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsKick.java @@ -49,7 +49,7 @@ public class CmdFactionsKick extends FactionsCommand if (msender == mplayer) { msg("You can't kick yourself."); - message(mson(mson("You might want to: ").color(ChatColor.YELLOW), Factions.get().getOuterCmdFactions().cmdFactionsLeave.getTemplate(false))); + message(mson(mson("You might want to: ").color(ChatColor.YELLOW), CmdFactions.get().cmdFactionsLeave.getTemplate(false))); return; } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRankOld.java b/src/com/massivecraft/factions/cmd/CmdFactionsRankOld.java index b9d97b64..527af817 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRankOld.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRankOld.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.cmd.type.TypeFaction; import com.massivecraft.factions.cmd.type.TypeMPlayer; import com.massivecraft.massivecore.command.Visibility; @@ -41,7 +40,7 @@ public class CmdFactionsRankOld extends FactionsCommand @Override public void perform() { - Factions.get().getOuterCmdFactions().cmdFactionsRank.execute(sender, MUtil.list(this.argAt(0), this.rankName, this.argAt(1))); + CmdFactions.get().cmdFactionsRank.execute(sender, MUtil.list(this.argAt(0), this.rankName, this.argAt(1))); } } diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java index 9a5730ba..8a398516 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsRelationAbstract.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.cmd.req.ReqHasFaction; @@ -88,10 +87,10 @@ public abstract class CmdFactionsRelationAbstract extends FactionsCommand else { MassiveCommand relationshipCommand = null; - if (newRelation.equals(Rel.NEUTRAL)) relationshipCommand = Factions.get().getOuterCmdFactions().cmdFactionsRelationNeutral; - else if (newRelation.equals(Rel.TRUCE)) relationshipCommand = Factions.get().getOuterCmdFactions().cmdFactionsRelationTruce; - else if (newRelation.equals(Rel.ALLY)) relationshipCommand = Factions.get().getOuterCmdFactions().cmdFactionsRelationAlly; - else if (newRelation.equals(Rel.ENEMY)) relationshipCommand = Factions.get().getOuterCmdFactions().cmdFactionsRelationEnemy; + if (newRelation.equals(Rel.NEUTRAL)) relationshipCommand = CmdFactions.get().cmdFactionsRelationNeutral; + else if (newRelation.equals(Rel.TRUCE)) relationshipCommand = CmdFactions.get().cmdFactionsRelationTruce; + else if (newRelation.equals(Rel.ALLY)) relationshipCommand = CmdFactions.get().cmdFactionsRelationAlly; + else if (newRelation.equals(Rel.ENEMY)) relationshipCommand = CmdFactions.get().cmdFactionsRelationEnemy; String command = relationshipCommand.getCommandLine(msenderFaction.getName()); String tooltip = Txt.parse("Click to %s.", command); diff --git a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java index d67ce356..2648b592 100644 --- a/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java +++ b/src/com/massivecraft/factions/cmd/CmdFactionsSethome.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.cmd; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.cmd.type.TypeFaction; import com.massivecraft.factions.entity.Faction; @@ -63,7 +62,7 @@ public class CmdFactionsSethome extends FactionsCommandHome // Inform faction.msg("%s set the home for your faction. You can now use:", msender.describeTo(msenderFaction, true)); - faction.sendMessage(Factions.get().getOuterCmdFactions().cmdFactionsHome.getTemplate()); + faction.sendMessage(CmdFactions.get().cmdFactionsHome.getTemplate()); if (faction != msenderFaction) { msender.msg("You have set the home for " + faction.getName(msender) + "."); diff --git a/src/com/massivecraft/factions/engine/EngineChat.java b/src/com/massivecraft/factions/engine/EngineChat.java index 5620edb2..9379b8c2 100644 --- a/src/com/massivecraft/factions/engine/EngineChat.java +++ b/src/com/massivecraft/factions/engine/EngineChat.java @@ -8,16 +8,15 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.plugin.EventExecutor; -import org.bukkit.plugin.Plugin; import com.massivecraft.factions.Factions; import com.massivecraft.factions.chat.ChatFormatter; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat; import com.massivecraft.massivecore.util.MUtil; -public class EngineChat extends EngineAbstract +public class EngineChat extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -25,21 +24,19 @@ public class EngineChat extends EngineAbstract private static EngineChat i = new EngineChat(); public static EngineChat get() { return i; } + public EngineChat() + { + this.setPlugin(Factions.get()); + } // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @Override - public Plugin getPlugin() + public void setActiveInner(boolean active) { - return Factions.get(); - } - - @Override - public void activate() - { - super.activate(); + if ( ! active) return; if (MConf.get().chatSetFormat) { diff --git a/src/com/massivecraft/factions/engine/EngineEcon.java b/src/com/massivecraft/factions/engine/EngineEcon.java index 8f82586d..73c8a39a 100644 --- a/src/com/massivecraft/factions/engine/EngineEcon.java +++ b/src/com/massivecraft/factions/engine/EngineEcon.java @@ -7,9 +7,9 @@ import java.util.Set; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.plugin.Plugin; import com.massivecraft.factions.Factions; +import com.massivecraft.factions.cmd.CmdFactions; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayer; @@ -29,12 +29,12 @@ import com.massivecraft.factions.event.EventFactionsFlagChange; import com.massivecraft.factions.event.EventFactionsRelationChange; import com.massivecraft.factions.event.EventFactionsTitleChange; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.money.Money; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.Txt; -public class EngineEcon extends EngineAbstract +public class EngineEcon extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -42,17 +42,6 @@ public class EngineEcon extends EngineAbstract private static EngineEcon i = new EngineEcon(); public static EngineEcon get() { return i; } - public EngineEcon() {} - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Plugin getPlugin() - { - return Factions.get(); - } // -------------------------------------------- // // TAKE ON LEAVE @@ -180,7 +169,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsRelationChange event) { Double cost = MConf.get().econRelCost.get(event.getNewRelation()); - String desc = Factions.get().getOuterCmdFactions().cmdFactionsRelationNeutral.getDesc(); + String desc = CmdFactions.get().cmdFactionsRelationNeutral.getDesc(); payForAction(event, cost, desc); } @@ -189,7 +178,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsHomeChange event) { Double cost = MConf.get().econCostSethome; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsSethome.getDesc(); + String desc = CmdFactions.get().cmdFactionsSethome.getDesc(); payForAction(event, cost, desc); } @@ -198,7 +187,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsCreate event) { Double cost = MConf.get().econCostCreate; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsCreate.getDesc(); + String desc = CmdFactions.get().cmdFactionsCreate.getDesc(); payForAction(event, cost, desc); } @@ -207,7 +196,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsDescriptionChange event) { Double cost = MConf.get().econCostDescription; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsDescription.getDesc(); + String desc = CmdFactions.get().cmdFactionsDescription.getDesc(); payForAction(event, cost, desc); } @@ -216,7 +205,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsNameChange event) { Double cost = MConf.get().econCostName; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsName.getDesc(); + String desc = CmdFactions.get().cmdFactionsName.getDesc(); payForAction(event, cost, desc); } @@ -225,7 +214,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsTitleChange event) { Double cost = MConf.get().econCostTitle; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsTitle.getDesc(); + String desc = CmdFactions.get().cmdFactionsTitle.getDesc(); payForAction(event, cost, desc); } @@ -234,7 +223,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsFlagChange event) { Double cost = MConf.get().econCostFlag; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsFlag.getDesc(); + String desc = CmdFactions.get().cmdFactionsFlag.getDesc(); payForAction(event, cost, desc); } @@ -243,7 +232,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsInvitedChange event) { Double cost = event.isNewInvited() ? MConf.get().econCostInvite : MConf.get().econCostDeinvite; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsInvite.getDesc(); + String desc = CmdFactions.get().cmdFactionsInvite.getDesc(); payForAction(event, cost, desc); } @@ -252,7 +241,7 @@ public class EngineEcon extends EngineAbstract public void payForCommand(EventFactionsHomeTeleport event) { Double cost = MConf.get().econCostHome; - String desc = Factions.get().getOuterCmdFactions().cmdFactionsHome.getDesc(); + String desc = CmdFactions.get().cmdFactionsHome.getDesc(); payForAction(event, cost, desc); } diff --git a/src/com/massivecraft/factions/engine/EngineExploit.java b/src/com/massivecraft/factions/engine/EngineExploit.java index 68fca26a..af2b098f 100644 --- a/src/com/massivecraft/factions/engine/EngineExploit.java +++ b/src/com/massivecraft/factions/engine/EngineExploit.java @@ -15,18 +15,16 @@ import org.bukkit.event.player.PlayerTeleportEvent; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.plugin.Plugin; import org.bukkit.Location; import org.bukkit.Material; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.MConf; -import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; -public class EngineExploit extends EngineAbstract +public class EngineExploit extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -35,16 +33,6 @@ public class EngineExploit extends EngineAbstract private static EngineExploit i = new EngineExploit(); public static EngineExploit get() { return i; } - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Plugin getPlugin() - { - return Factions.get(); - } - // -------------------------------------------- // // OBSIDIAN GENERATORS // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/engine/EngineMain.java b/src/com/massivecraft/factions/engine/EngineMain.java index f30a65fa..5c35f251 100644 --- a/src/com/massivecraft/factions/engine/EngineMain.java +++ b/src/com/massivecraft/factions/engine/EngineMain.java @@ -65,7 +65,6 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerKickEvent; import org.bukkit.event.player.PlayerMoveEvent; import org.bukkit.event.player.PlayerRespawnEvent; -import org.bukkit.plugin.Plugin; import org.bukkit.projectiles.ProjectileSource; import com.massivecraft.factions.Const; @@ -89,9 +88,9 @@ import com.massivecraft.factions.event.EventFactionsPowerChange; import com.massivecraft.factions.event.EventFactionsPowerChange.PowerChangeReason; import com.massivecraft.factions.event.EventFactionsPvpDisallowed; import com.massivecraft.factions.integration.Econ; -import com.massivecraft.factions.spigot.SpigotFeatures; +import com.massivecraft.factions.integration.spigot.IntegrationSpigot; import com.massivecraft.factions.util.VisualizeUtil; -import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.PriorityLines; import com.massivecraft.massivecore.collections.MassiveSet; import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave; @@ -104,7 +103,7 @@ import com.massivecraft.massivecore.util.TimeDiffUtil; import com.massivecraft.massivecore.util.TimeUnit; import com.massivecraft.massivecore.util.Txt; -public class EngineMain extends EngineAbstract +public class EngineMain extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -112,17 +111,6 @@ public class EngineMain extends EngineAbstract private static EngineMain i = new EngineMain(); public static EngineMain get() { return i; } - public EngineMain() {} - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Plugin getPlugin() - { - return Factions.get(); - } // -------------------------------------------- // // CONSTANTS @@ -1462,7 +1450,7 @@ public class EngineMain extends EngineAbstract public void blockBuild(BlockPistonExtendEvent event) { // Is using Spigot or is checking deactivated by MConf? - if (SpigotFeatures.isActive() || ! MConf.get().handlePistonProtectionThroughDenyBuild) return; + if (IntegrationSpigot.get().isIntegrationActive() || ! MConf.get().handlePistonProtectionThroughDenyBuild) return; Block block = event.getBlock(); @@ -1494,7 +1482,7 @@ public class EngineMain extends EngineAbstract public void blockBuild(BlockPistonRetractEvent event) { // Is using Spigot or is checking deactivated by MConf? - if (SpigotFeatures.isActive() || ! MConf.get().handlePistonProtectionThroughDenyBuild) return; + if (IntegrationSpigot.get().isIntegrationActive() || ! MConf.get().handlePistonProtectionThroughDenyBuild) return; // If not a sticky piston, retraction should be fine if ( ! event.isSticky()) return; diff --git a/src/com/massivecraft/factions/engine/EngineSeeChunk.java b/src/com/massivecraft/factions/engine/EngineSeeChunk.java index 459a35f3..973ffc10 100644 --- a/src/com/massivecraft/factions/engine/EngineSeeChunk.java +++ b/src/com/massivecraft/factions/engine/EngineSeeChunk.java @@ -10,19 +10,16 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.player.PlayerChangedWorldEvent; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayer; -import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave; import com.massivecraft.massivecore.particleeffect.ParticleEffect; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; import com.massivecraft.massivecore.util.PeriodUtil; -public class EngineSeeChunk extends EngineAbstract +public class EngineSeeChunk extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -30,22 +27,9 @@ public class EngineSeeChunk extends EngineAbstract private static EngineSeeChunk i = new EngineSeeChunk(); public static EngineSeeChunk get() { return i; } - public EngineSeeChunk() {} - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Plugin getPlugin() + public EngineSeeChunk() { - return Factions.get(); - } - - @Override - public Long getPeriod() - { - return 1L; + this.setPeriod(1L); } // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/entity/FactionColl.java b/src/com/massivecraft/factions/entity/FactionColl.java index 3ef4c15d..98725f24 100644 --- a/src/com/massivecraft/factions/entity/FactionColl.java +++ b/src/com/massivecraft/factions/entity/FactionColl.java @@ -39,9 +39,11 @@ public class FactionColl extends Coll // -------------------------------------------- // @Override - public void init() + public void setActive(boolean active) { - super.init(); + super.setActive(active); + + if ( ! active) return; this.createSpecialFactions(); } diff --git a/src/com/massivecraft/factions/entity/MConf.java b/src/com/massivecraft/factions/entity/MConf.java index e9d0ebbc..7d7ac060 100644 --- a/src/com/massivecraft/factions/entity/MConf.java +++ b/src/com/massivecraft/factions/entity/MConf.java @@ -42,8 +42,8 @@ public class MConf extends Entity if (!Factions.get().isDatabaseInitialized()) return this; - EngineChat.get().deactivate(); - EngineChat.get().activate(); + EngineChat.get().setActive(false); + EngineChat.get().setActive(true); return this; } diff --git a/src/com/massivecraft/factions/entity/MConfColl.java b/src/com/massivecraft/factions/entity/MConfColl.java index 96829f58..2716bbb8 100644 --- a/src/com/massivecraft/factions/entity/MConfColl.java +++ b/src/com/massivecraft/factions/entity/MConfColl.java @@ -34,9 +34,10 @@ public class MConfColl extends Coll // -------------------------------------------- // @Override - public void init() + public void setActive(boolean active) { - super.init(); + super.setActive(active); + if ( ! active) return; MConf.i = this.get(MassiveCore.INSTANCE, true); } diff --git a/src/com/massivecraft/factions/entity/MFlagColl.java b/src/com/massivecraft/factions/entity/MFlagColl.java index 67be72ad..9ec9c1c2 100644 --- a/src/com/massivecraft/factions/entity/MFlagColl.java +++ b/src/com/massivecraft/factions/entity/MFlagColl.java @@ -37,9 +37,10 @@ public class MFlagColl extends Coll // -------------------------------------------- // @Override - public void init() + public void setActive(boolean active) { - super.init(); + super.setActive(active); + if ( ! active) return; MFlag.setupStandardFlags(); } diff --git a/src/com/massivecraft/factions/entity/MPerm.java b/src/com/massivecraft/factions/entity/MPerm.java index b8307834..2045ed35 100644 --- a/src/com/massivecraft/factions/entity/MPerm.java +++ b/src/com/massivecraft/factions/entity/MPerm.java @@ -7,10 +7,10 @@ import java.util.Set; import org.bukkit.entity.Player; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.Perm; import com.massivecraft.factions.Rel; import com.massivecraft.factions.TerritoryAccess; +import com.massivecraft.factions.cmd.CmdFactions; import com.massivecraft.factions.event.EventFactionsCreatePerms; import com.massivecraft.massivecore.Named; import com.massivecraft.massivecore.Prioritized; @@ -298,7 +298,7 @@ public class MPerm extends Entity implements Prioritized, Registerable, N Player player = mplayer.getPlayer(); if (player != null && Perm.OVERRIDE.has(player)) { - ret += Txt.parse("\nYou can bypass by using " + Factions.get().getOuterCmdFactions().cmdFactionsOverride.getTemplate(false).toPlain(true)); + ret += Txt.parse("\nYou can bypass by using " + CmdFactions.get().cmdFactionsOverride.getTemplate(false).toPlain(true)); } return ret; diff --git a/src/com/massivecraft/factions/entity/MPermColl.java b/src/com/massivecraft/factions/entity/MPermColl.java index 68a915f4..ba61f733 100644 --- a/src/com/massivecraft/factions/entity/MPermColl.java +++ b/src/com/massivecraft/factions/entity/MPermColl.java @@ -37,9 +37,10 @@ public class MPermColl extends Coll // -------------------------------------------- // @Override - public void init() + public void setActive(boolean active) { - super.init(); + super.setActive(active); + if ( ! active) return; MPerm.setupStandardPerms(); } diff --git a/src/com/massivecraft/factions/integration/herochat/EngineHerochat.java b/src/com/massivecraft/factions/integration/herochat/EngineHerochat.java index 66792016..242b06cd 100644 --- a/src/com/massivecraft/factions/integration/herochat/EngineHerochat.java +++ b/src/com/massivecraft/factions/integration/herochat/EngineHerochat.java @@ -1,19 +1,14 @@ package com.massivecraft.factions.integration.herochat; -import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.event.HandlerList; -import org.bukkit.event.Listener; - import com.dthielke.herochat.ChannelChatEvent; import com.dthielke.herochat.Herochat; -import com.massivecraft.factions.Factions; import com.massivecraft.factions.chat.ChatFormatter; import com.massivecraft.factions.entity.MConf; +import com.massivecraft.massivecore.Engine; - -public class EngineHerochat implements Listener +public class EngineHerochat extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -21,23 +16,18 @@ public class EngineHerochat implements Listener private static EngineHerochat i = new EngineHerochat(); public static EngineHerochat get() { return i; } - private EngineHerochat() {} // -------------------------------------------- // // ACTIVATE & DEACTIVATE // -------------------------------------------- // - public void activate() + @Override + public void setActiveInner(boolean active) { + if ( ! active) return; + Herochat.getChannelManager().addChannel(new ChannelFactionsFaction()); Herochat.getChannelManager().addChannel(new ChannelFactionsAllies()); - - Bukkit.getPluginManager().registerEvents(this, Factions.get()); - } - - public void deactivate() - { - HandlerList.unregisterAll(this); } // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/integration/herochat/IntegrationHerochat.java b/src/com/massivecraft/factions/integration/herochat/IntegrationHerochat.java index 3b70dee9..d2a6789e 100644 --- a/src/com/massivecraft/factions/integration/herochat/IntegrationHerochat.java +++ b/src/com/massivecraft/factions/integration/herochat/IntegrationHerochat.java @@ -1,8 +1,9 @@ package com.massivecraft.factions.integration.herochat; -import com.massivecraft.massivecore.integration.IntegrationAbstract; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.Integration; -public class IntegrationHerochat extends IntegrationAbstract +public class IntegrationHerochat extends Integration { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -10,22 +11,19 @@ public class IntegrationHerochat extends IntegrationAbstract private static IntegrationHerochat i = new IntegrationHerochat(); public static IntegrationHerochat get() { return i; } - private IntegrationHerochat() { super("Herochat"); } + private IntegrationHerochat() + { + this.setPluginName("HeroChat"); + } // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @Override - public void activate() + public Engine getEngine() { - EngineHerochat.get().activate(); - } - - @Override - public void deactivate() - { - EngineHerochat.get().deactivate(); + return EngineHerochat.get(); } } diff --git a/src/com/massivecraft/factions/integration/lwc/EngineLwc.java b/src/com/massivecraft/factions/integration/lwc/EngineLwc.java index 868f9e8c..81490b00 100644 --- a/src/com/massivecraft/factions/integration/lwc/EngineLwc.java +++ b/src/com/massivecraft/factions/integration/lwc/EngineLwc.java @@ -8,7 +8,6 @@ import java.util.Set; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.plugin.Plugin; import com.griefcraft.lwc.LWC; import com.griefcraft.model.Protection; @@ -19,12 +18,12 @@ import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsChunksChange; import com.massivecraft.factions.event.EventFactionsChunkChangeType; -import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.IdUtil; -public class EngineLwc extends EngineAbstract +public class EngineLwc extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -32,30 +31,22 @@ public class EngineLwc extends EngineAbstract private static EngineLwc i = new EngineLwc(); public static EngineLwc get() { return i; } - private EngineLwc() {} // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @Override - public Plugin getPlugin() + public void setActiveInner(boolean active) { - return Factions.get(); - } - - @Override - public void activate() - { - super.activate(); - LWC.getInstance().getModuleLoader().registerModule(Factions.get(), new FactionsLwcModule(Factions.get())); - } - - @Override - public void deactivate() - { - super.deactivate(); - LWC.getInstance().getModuleLoader().removeModules(Factions.get()); + if (active) + { + LWC.getInstance().getModuleLoader().registerModule(Factions.get(), new FactionsLwcModule(Factions.get())); + } + else + { + LWC.getInstance().getModuleLoader().removeModules(Factions.get()); + } } // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/integration/lwc/IntegrationLwc.java b/src/com/massivecraft/factions/integration/lwc/IntegrationLwc.java index ac5764c5..6dbe4e8b 100644 --- a/src/com/massivecraft/factions/integration/lwc/IntegrationLwc.java +++ b/src/com/massivecraft/factions/integration/lwc/IntegrationLwc.java @@ -1,8 +1,9 @@ package com.massivecraft.factions.integration.lwc; -import com.massivecraft.massivecore.integration.IntegrationAbstract; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.Integration; -public class IntegrationLwc extends IntegrationAbstract +public class IntegrationLwc extends Integration { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -10,22 +11,19 @@ public class IntegrationLwc extends IntegrationAbstract private static IntegrationLwc i = new IntegrationLwc(); public static IntegrationLwc get() { return i; } - private IntegrationLwc() { super("LWC"); } + private IntegrationLwc() + { + this.setPluginName("LWC"); + } // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @Override - public void activate() + public Engine getEngine() { - EngineLwc.get().activate(); - } - - @Override - public void deactivate() - { - EngineLwc.get().deactivate(); + return EngineLwc.get(); } } diff --git a/src/com/massivecraft/factions/spigot/EngineSpigot.java b/src/com/massivecraft/factions/integration/spigot/EngineSpigot.java similarity index 84% rename from src/com/massivecraft/factions/spigot/EngineSpigot.java rename to src/com/massivecraft/factions/integration/spigot/EngineSpigot.java index aef0b094..5371fba4 100644 --- a/src/com/massivecraft/factions/spigot/EngineSpigot.java +++ b/src/com/massivecraft/factions/integration/spigot/EngineSpigot.java @@ -1,4 +1,4 @@ -package com.massivecraft.factions.spigot; +package com.massivecraft.factions.integration.spigot; import java.util.List; @@ -11,20 +11,17 @@ import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPistonExtendEvent; import org.bukkit.event.block.BlockPistonRetractEvent; import org.bukkit.event.player.PlayerInteractAtEntityEvent; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.Factions; import com.massivecraft.factions.engine.EngineMain; import com.massivecraft.factions.entity.BoardColl; import com.massivecraft.factions.entity.Faction; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPerm; -import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.ps.PS; import com.massivecraft.massivecore.util.MUtil; -public class EngineSpigot extends EngineAbstract +public class EngineSpigot extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -32,31 +29,6 @@ public class EngineSpigot extends EngineAbstract private static EngineSpigot i = new EngineSpigot(); public static EngineSpigot get() { return i; } - private EngineSpigot() {} - - // -------------------------------------------- // - // OVERRIDE - // -------------------------------------------- // - - @Override - public Plugin getPlugin() - { - return Factions.get(); - } - - @Override - public void activate() - { - super.activate(); - SpigotFeatures.setActive(true); - } - - @Override - public void deactivate() - { - super.deactivate(); - SpigotFeatures.setActive(false); - } // -------------------------------------------- // // LISTENER diff --git a/src/com/massivecraft/factions/integration/spigot/IntegrationSpigot.java b/src/com/massivecraft/factions/integration/spigot/IntegrationSpigot.java new file mode 100644 index 00000000..e55ec0a4 --- /dev/null +++ b/src/com/massivecraft/factions/integration/spigot/IntegrationSpigot.java @@ -0,0 +1,29 @@ +package com.massivecraft.factions.integration.spigot; + +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.Integration; + +public class IntegrationSpigot extends Integration +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static IntegrationSpigot i = new IntegrationSpigot(); + public static IntegrationSpigot get() { return i; } + private IntegrationSpigot() + { + this.setPredicate(PredicateSpigot.get()); + } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public Engine getEngine() + { + return EngineSpigot.get(); + } + +} diff --git a/src/com/massivecraft/factions/integration/spigot/PredicateSpigot.java b/src/com/massivecraft/factions/integration/spigot/PredicateSpigot.java new file mode 100644 index 00000000..520ad50a --- /dev/null +++ b/src/com/massivecraft/factions/integration/spigot/PredicateSpigot.java @@ -0,0 +1,37 @@ +package com.massivecraft.factions.integration.spigot; + +import org.bukkit.event.player.PlayerInteractAtEntityEvent; + +import com.massivecraft.massivecore.Integration; +import com.massivecraft.massivecore.predicate.Predicate; + +public class PredicateSpigot implements Predicate +{ + // -------------------------------------------- // + // INSTANCE & CONSTRUCT + // -------------------------------------------- // + + private static PredicateSpigot i = new PredicateSpigot(); + public static PredicateSpigot get() { return i; } + + // -------------------------------------------- // + // OVERRIDE + // -------------------------------------------- // + + @Override + public boolean apply(Integration integration) + { + try + { + // This line will throw if the class does not exist. + PlayerInteractAtEntityEvent.class.getName(); + + return true; + } + catch (Throwable t) + { + return false; + } + } + +} diff --git a/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java b/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java index 3f907fdc..f3d9ac1b 100644 --- a/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java +++ b/src/com/massivecraft/factions/integration/worldguard/EngineWorldGuard.java @@ -7,14 +7,11 @@ import java.util.Map; import org.bukkit.Bukkit; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsChunksChange; -import com.massivecraft.massivecore.EngineAbstract; +import com.massivecraft.massivecore.Engine; import com.massivecraft.massivecore.ps.PS; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldguard.bukkit.WorldGuardPlugin; @@ -22,7 +19,7 @@ import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedRegion; -public class EngineWorldGuard extends EngineAbstract +public class EngineWorldGuard extends Engine { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -30,7 +27,6 @@ public class EngineWorldGuard extends EngineAbstract private static EngineWorldGuard i = new EngineWorldGuard(); public static EngineWorldGuard get() { return i; } - private EngineWorldGuard() {} // -------------------------------------------- // // FIELDS @@ -43,25 +39,16 @@ public class EngineWorldGuard extends EngineAbstract // -------------------------------------------- // @Override - public Plugin getPlugin() + public void setActiveInner(boolean active) { - return Factions.get(); - } - - @Override - public void activate() - { - this.worldGuard = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard"); - - super.activate(); - } - - @Override - public void deactivate() - { - this.worldGuard = null; - - super.deactivate(); + if (active) + { + this.worldGuard = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard"); + } + else + { + this.worldGuard = null; + } } // -------------------------------------------- // diff --git a/src/com/massivecraft/factions/integration/worldguard/IntegrationWorldGuard.java b/src/com/massivecraft/factions/integration/worldguard/IntegrationWorldGuard.java index b8382f39..e2b42d8f 100644 --- a/src/com/massivecraft/factions/integration/worldguard/IntegrationWorldGuard.java +++ b/src/com/massivecraft/factions/integration/worldguard/IntegrationWorldGuard.java @@ -1,8 +1,9 @@ package com.massivecraft.factions.integration.worldguard; -import com.massivecraft.massivecore.integration.IntegrationAbstract; +import com.massivecraft.massivecore.Engine; +import com.massivecraft.massivecore.Integration; -public class IntegrationWorldGuard extends IntegrationAbstract +public class IntegrationWorldGuard extends Integration { // -------------------------------------------- // // INSTANCE & CONSTRUCT @@ -10,22 +11,19 @@ public class IntegrationWorldGuard extends IntegrationAbstract private static IntegrationWorldGuard i = new IntegrationWorldGuard(); public static IntegrationWorldGuard get() { return i; } - private IntegrationWorldGuard() { super("WorldGuard"); } + private IntegrationWorldGuard() + { + this.setPluginName("WorldGuard"); + } // -------------------------------------------- // // OVERRIDE // -------------------------------------------- // @Override - public void activate() + public Engine getEngine() { - EngineWorldGuard.get().activate(); - } - - @Override - public void deactivate() - { - EngineWorldGuard.get().deactivate(); + return EngineWorldGuard.get(); } } diff --git a/src/com/massivecraft/factions/spigot/SpigotFeatures.java b/src/com/massivecraft/factions/spigot/SpigotFeatures.java deleted file mode 100644 index 66e4dba8..00000000 --- a/src/com/massivecraft/factions/spigot/SpigotFeatures.java +++ /dev/null @@ -1,37 +0,0 @@ -package com.massivecraft.factions.spigot; - -import org.bukkit.event.player.PlayerInteractAtEntityEvent; - -public class SpigotFeatures -{ - // -------------------------------------------- // - // STATIC FIELDS - // -------------------------------------------- // - - // The "active" field is set from inside the EngineSpigot - - private static boolean active = false; - public static boolean isActive() { return active; } - public static void setActive(boolean active) { SpigotFeatures.active = active; } - - // -------------------------------------------- // - // ACTIVATE - // -------------------------------------------- // - - public static void activate() - { - try - { - // This line will throw if the class does not exist. - PlayerInteractAtEntityEvent.class.getName(); - - // But if the event class exists we activate. - EngineSpigot.get().activate(); - } - catch (Throwable t) - { - // ignored - } - } - -} diff --git a/src/com/massivecraft/factions/task/TaskEconLandReward.java b/src/com/massivecraft/factions/task/TaskEconLandReward.java index 87c87250..4bf1e8a3 100644 --- a/src/com/massivecraft/factions/task/TaskEconLandReward.java +++ b/src/com/massivecraft/factions/task/TaskEconLandReward.java @@ -1,8 +1,5 @@ package com.massivecraft.factions.task; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.FactionColl; import com.massivecraft.factions.entity.MConf; import com.massivecraft.massivecore.MassiveCore; @@ -18,16 +15,6 @@ public class TaskEconLandReward extends ModuloRepeatTask private static TaskEconLandReward i = new TaskEconLandReward(); public static TaskEconLandReward get() { return i; } - // -------------------------------------------- // - // OVERRIDE: MODULO REPEAT TASK - // -------------------------------------------- // - - @Override - public Plugin getPlugin() - { - return Factions.get(); - } - @Override public long getDelayMillis() { diff --git a/src/com/massivecraft/factions/task/TaskFlagPermCreate.java b/src/com/massivecraft/factions/task/TaskFlagPermCreate.java index 591e370f..3db342ba 100644 --- a/src/com/massivecraft/factions/task/TaskFlagPermCreate.java +++ b/src/com/massivecraft/factions/task/TaskFlagPermCreate.java @@ -1,8 +1,5 @@ package com.massivecraft.factions.task; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.MFlag; import com.massivecraft.factions.entity.MPerm; import com.massivecraft.massivecore.ModuloRepeatTask; @@ -21,12 +18,6 @@ public class TaskFlagPermCreate extends ModuloRepeatTask // OVERRIDE: MODULO REPEAT TASK // -------------------------------------------- // - @Override - public Plugin getPlugin() - { - return Factions.get(); - } - @Override public long getDelayMillis() { diff --git a/src/com/massivecraft/factions/task/TaskPlayerDataRemove.java b/src/com/massivecraft/factions/task/TaskPlayerDataRemove.java index 94d55e16..eeacd251 100644 --- a/src/com/massivecraft/factions/task/TaskPlayerDataRemove.java +++ b/src/com/massivecraft/factions/task/TaskPlayerDataRemove.java @@ -1,8 +1,5 @@ package com.massivecraft.factions.task; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayerColl; import com.massivecraft.massivecore.MassiveCore; @@ -22,12 +19,6 @@ public class TaskPlayerDataRemove extends ModuloRepeatTask // OVERRIDE: MODULO REPEAT TASK // -------------------------------------------- // - @Override - public Plugin getPlugin() - { - return Factions.get(); - } - @Override public long getDelayMillis() { diff --git a/src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java b/src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java index 79def210..9d3f9d2a 100644 --- a/src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java +++ b/src/com/massivecraft/factions/task/TaskPlayerPowerUpdate.java @@ -1,9 +1,6 @@ package com.massivecraft.factions.task; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; - -import com.massivecraft.factions.Factions; import com.massivecraft.factions.entity.MConf; import com.massivecraft.factions.entity.MPlayer; import com.massivecraft.factions.event.EventFactionsPowerChange; @@ -25,12 +22,6 @@ public class TaskPlayerPowerUpdate extends ModuloRepeatTask // OVERRIDE: MODULO REPEAT TASK // -------------------------------------------- // - @Override - public Plugin getPlugin() - { - return Factions.get(); - } - @Override public long getDelayMillis() { diff --git a/src/com/massivecraft/factions/update/OldConfColl.java b/src/com/massivecraft/factions/update/OldConfColl.java index e71a70ba..2822e063 100644 --- a/src/com/massivecraft/factions/update/OldConfColl.java +++ b/src/com/massivecraft/factions/update/OldConfColl.java @@ -21,9 +21,10 @@ public class OldConfColl extends Coll // -------------------------------------------- // @Override - public void init() + public void setActive(boolean active) { - super.init(); + super.setActive(active); + if ( ! active) return; this.get(MassiveCore.INSTANCE, true); } diff --git a/src/com/massivecraft/factions/update/UpdateUtil.java b/src/com/massivecraft/factions/update/UpdateUtil.java index 68d50a60..04bd27bc 100644 --- a/src/com/massivecraft/factions/update/UpdateUtil.java +++ b/src/com/massivecraft/factions/update/UpdateUtil.java @@ -48,7 +48,7 @@ public class UpdateUtil Factions.get().log("Updating Database to New Version!"); // ... load the old uconf data ... - OldConfColls.get().init(); + OldConfColls.get().setActive(true); OldConf oldConf = OldConfColls.get().getForUniverse(universe).get(MassiveCore.INSTANCE, true); // ... transfer the old uconf data over to the new mconf ...