MassiveCore - MassivePlugin and Active

This commit is contained in:
Olof Larsson 2016-02-25 22:28:09 +01:00
parent ce6a98e27d
commit 1f5e591ce6
38 changed files with 234 additions and 361 deletions

View File

@ -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,47 +126,47 @@ 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);
// Activate
this.activate(
// Command
CmdFactions.get(),
// 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.
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
this.integrate(
IntegrationHerochat.get(),
IntegrationLwc.get(),
IntegrationWorldGuard.get()
);
IntegrationWorldGuard.get(),
// Spigot
SpigotFeatures.activate();
IntegrationSpigot.get(),
// Modulo Repeat Tasks
TaskPlayerPowerUpdate.get().activate();
TaskPlayerDataRemove.get().activate();
TaskEconLandReward.get().activate();
TaskFlagPermCreate.get().activate();
TaskPlayerPowerUpdate.get(),
TaskPlayerDataRemove.get(),
TaskEconLandReward.get(),
TaskFlagPermCreate.get()
);
// Register built in chat modifiers
ChatModifierLc.get().register();

View File

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

View File

@ -84,7 +84,7 @@ public class CmdFactionsCreate extends FactionsCommand
// Inform
msg("<i>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)

View File

@ -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("<i>You should:");
msender.message(Factions.get().getOuterCmdFactions().cmdFactionsSethome.getTemplate());
msender.message(CmdFactions.get().cmdFactionsSethome.getTemplate());
}
return;

View File

@ -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("<i>Click to <c>%s<i>.", command);
Mson remove = Mson.mson(

View File

@ -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 <c>%s<i>.", 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 <c>%s<i>.", command);
Mson invite = Mson.mson(

View File

@ -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(

View File

@ -49,7 +49,7 @@ public class CmdFactionsKick extends FactionsCommand
if (msender == mplayer)
{
msg("<b>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;
}

View File

@ -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)));
}
}

View File

@ -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("<g>Click to <c>%s<i>.", command);

View File

@ -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<i> 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("<i>You have set the home for " + faction.getName(msender) + "<i>.");

View File

@ -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)
{

View File

@ -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);
}

View File

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

View File

@ -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;

View File

@ -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);
}
// -------------------------------------------- //

View File

@ -39,9 +39,11 @@ public class FactionColl extends Coll<Faction>
// -------------------------------------------- //
@Override
public void init()
public void setActive(boolean active)
{
super.init();
super.setActive(active);
if ( ! active) return;
this.createSpecialFactions();
}

View File

@ -42,8 +42,8 @@ public class MConf extends Entity<MConf>
if (!Factions.get().isDatabaseInitialized()) return this;
EngineChat.get().deactivate();
EngineChat.get().activate();
EngineChat.get().setActive(false);
EngineChat.get().setActive(true);
return this;
}

View File

@ -34,9 +34,10 @@ public class MConfColl extends Coll<MConf>
// -------------------------------------------- //
@Override
public void init()
public void setActive(boolean active)
{
super.init();
super.setActive(active);
if ( ! active) return;
MConf.i = this.get(MassiveCore.INSTANCE, true);
}

View File

@ -37,9 +37,10 @@ public class MFlagColl extends Coll<MFlag>
// -------------------------------------------- //
@Override
public void init()
public void setActive(boolean active)
{
super.init();
super.setActive(active);
if ( ! active) return;
MFlag.setupStandardFlags();
}

View File

@ -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<MPerm> implements Prioritized, Registerable, N
Player player = mplayer.getPlayer();
if (player != null && Perm.OVERRIDE.has(player))
{
ret += Txt.parse("\n<i>You can bypass by using " + Factions.get().getOuterCmdFactions().cmdFactionsOverride.getTemplate(false).toPlain(true));
ret += Txt.parse("\n<i>You can bypass by using " + CmdFactions.get().cmdFactionsOverride.getTemplate(false).toPlain(true));
}
return ret;

View File

@ -37,9 +37,10 @@ public class MPermColl extends Coll<MPerm>
// -------------------------------------------- //
@Override
public void init()
public void setActive(boolean active)
{
super.init();
super.setActive(active);
if ( ! active) return;
MPerm.setupStandardPerms();
}

View File

@ -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);
}
// -------------------------------------------- //

View File

@ -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();
}
}

View File

@ -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,31 +31,23 @@ 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()
if (active)
{
super.activate();
LWC.getInstance().getModuleLoader().registerModule(Factions.get(), new FactionsLwcModule(Factions.get()));
}
@Override
public void deactivate()
else
{
super.deactivate();
LWC.getInstance().getModuleLoader().removeModules(Factions.get());
}
}
// -------------------------------------------- //
// LISTENER

View File

@ -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();
}
}

View File

@ -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

View File

@ -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();
}
}

View File

@ -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<Integration>
{
// -------------------------------------------- //
// 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;
}
}
}

View File

@ -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()
if (active)
{
this.worldGuard = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard");
super.activate();
}
@Override
public void deactivate()
else
{
this.worldGuard = null;
super.deactivate();
}
}
// -------------------------------------------- //

View File

@ -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();
}
}

View File

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

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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()
{

View File

@ -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()
{

View File

@ -21,9 +21,10 @@ public class OldConfColl extends Coll<OldConf>
// -------------------------------------------- //
@Override
public void init()
public void setActive(boolean active)
{
super.init();
super.setActive(active);
if ( ! active) return;
this.get(MassiveCore.INSTANCE, true);
}

View File

@ -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 ...