Rename and repackage the Engines/Listeners.

This commit is contained in:
Olof Larsson 2014-10-08 06:38:26 +02:00
parent 54e04fee88
commit f1375ea699
9 changed files with 107 additions and 44 deletions

View File

@ -19,6 +19,11 @@ import com.massivecraft.factions.chat.tag.ChatTagNameforce;
import com.massivecraft.factions.chat.tag.ChatTagRoleprefixforce;
import com.massivecraft.factions.chat.tag.ChatTagTitle;
import com.massivecraft.factions.cmd.*;
import com.massivecraft.factions.engine.EngineChat;
import com.massivecraft.factions.engine.EngineEcon;
import com.massivecraft.factions.engine.EngineExploit;
import com.massivecraft.factions.engine.EngineMain;
import com.massivecraft.factions.engine.EngineSeeChunk;
import com.massivecraft.factions.entity.Board;
import com.massivecraft.factions.entity.BoardColl;
import com.massivecraft.factions.entity.Faction;
@ -31,10 +36,6 @@ import com.massivecraft.factions.integration.dynmap.IntegrationDynmap;
import com.massivecraft.factions.integration.dynmap.IntegrationDynmapFactions;
import com.massivecraft.factions.integration.herochat.IntegrationHerochat;
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
import com.massivecraft.factions.listeners.FactionsListenerChat;
import com.massivecraft.factions.listeners.FactionsListenerEcon;
import com.massivecraft.factions.listeners.FactionsListenerExploit;
import com.massivecraft.factions.listeners.FactionsListenerMain;
import com.massivecraft.factions.mixin.PowerMixin;
import com.massivecraft.factions.mixin.PowerMixinDefault;
import com.massivecraft.factions.task.TaskPlayerDataRemove;
@ -134,16 +135,13 @@ public class Factions extends MassivePlugin
this.outerCmdFactions = new CmdFactions();
this.outerCmdFactions.register();
// Setup Listeners
FactionsListenerMain.get().activate();
FactionsListenerChat.get().activate();
FactionsListenerExploit.get().activate();
// Engines
EngineMain.get().activate();
EngineChat.get().activate();
EngineExploit.get().activate();
EngineIdUpdate.get().activate();
// TODO: This listener is a work in progress.
// The goal is that the Econ integration should be completely based on listening to our own events.
// Right now only a few situations are handled through this listener.
FactionsListenerEcon.get().setup();
EngineSeeChunk.get().activate();
EngineEcon.get().activate(); // TODO: Take an extra look and make sure all economy stuff is handled using events.
// Integrate
this.integrate(
@ -153,7 +151,7 @@ public class Factions extends MassivePlugin
IntegrationDynmapFactions.get()
);
// Schedule recurring non-tps-dependent tasks
// Modulo Repeat Tasks
TaskPlayerPowerUpdate.get().activate(this);
TaskPlayerDataRemove.get().activate(this);
TaskEconLandReward.get().activate(this);

View File

@ -1,4 +1,4 @@
package com.massivecraft.factions.listeners;
package com.massivecraft.factions.engine;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
@ -15,14 +15,14 @@ import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat;
public class FactionsListenerChat extends EngineAbstract
public class EngineChat extends EngineAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static FactionsListenerChat i = new FactionsListenerChat();
public static FactionsListenerChat get() { return i; }
private static EngineChat i = new EngineChat();
public static EngineChat get() { return i; }
// -------------------------------------------- //
// OVERRIDE

View File

@ -1,9 +1,8 @@
package com.massivecraft.factions.listeners;
package com.massivecraft.factions.engine;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.entity.Faction;
@ -25,25 +24,27 @@ 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.money.Money;
public class FactionsListenerEcon implements Listener
public class EngineEcon extends EngineAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static FactionsListenerEcon i = new FactionsListenerEcon();
public static FactionsListenerEcon get() { return i; }
public FactionsListenerEcon() {}
private static EngineEcon i = new EngineEcon();
public static EngineEcon get() { return i; }
public EngineEcon() {}
// -------------------------------------------- //
// SETUP
// OVERRIDE
// -------------------------------------------- //
public void setup()
@Override
public Plugin getPlugin()
{
Bukkit.getPluginManager().registerEvents(this, Factions.get());
return Factions.get();
}
// -------------------------------------------- //

View File

@ -1,4 +1,4 @@
package com.massivecraft.factions.listeners;
package com.massivecraft.factions.engine;
import java.util.ArrayList;
import java.util.List;
@ -19,14 +19,14 @@ import com.massivecraft.factions.entity.MConf;
import com.massivecraft.massivecore.EngineAbstract;
public class FactionsListenerExploit extends EngineAbstract
public class EngineExploit extends EngineAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static FactionsListenerExploit i = new FactionsListenerExploit();
public static FactionsListenerExploit get() { return i; }
private static EngineExploit i = new EngineExploit();
public static EngineExploit get() { return i; }
// -------------------------------------------- //
// OVERRIDE

View File

@ -1,4 +1,4 @@
package com.massivecraft.factions.listeners;
package com.massivecraft.factions.engine;
import java.text.MessageFormat;
import java.util.Collection;
@ -80,15 +80,15 @@ import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.PlayerUtil;
import com.massivecraft.massivecore.util.Txt;
public class FactionsListenerMain extends EngineAbstract
public class EngineMain extends EngineAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static FactionsListenerMain i = new FactionsListenerMain();
public static FactionsListenerMain get() { return i; }
public FactionsListenerMain() {}
private static EngineMain i = new EngineMain();
public static EngineMain get() { return i; }
public EngineMain() {}
// -------------------------------------------- //
// OVERRIDE

View File

@ -0,0 +1,58 @@
package com.massivecraft.factions.engine;
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.MPlayer;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave;
public class EngineSeeChunk extends EngineAbstract
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static EngineSeeChunk i = new EngineSeeChunk();
public static EngineSeeChunk get() { return i; }
public EngineSeeChunk() {}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return Factions.get();
}
// -------------------------------------------- //
// LEAVE AND WORLD CHANGE REMOVAL
// -------------------------------------------- //
public static void leaveAndWorldChangeRemoval(Player player)
{
final MPlayer mplayer = MPlayer.get(player);
mplayer.setSeeingChunk(false);
}
// Can't be cancelled
@EventHandler(priority = EventPriority.NORMAL)
public void leaveAndWorldChangeRemoval(EventMassiveCorePlayerLeave event)
{
leaveAndWorldChangeRemoval(event.getPlayer());
}
// Can't be cancelled
@EventHandler(priority = EventPriority.NORMAL)
public void leaveAndWorldChangeRemoval(PlayerChangedWorldEvent event)
{
leaveAndWorldChangeRemoval(event.getPlayer());
}
}

View File

@ -15,9 +15,9 @@ import org.bukkit.event.EventPriority;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.Rel;
import com.massivecraft.factions.WorldExceptionSet;
import com.massivecraft.factions.engine.EngineChat;
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
import com.massivecraft.factions.integration.dynmap.DynmapStyle;
import com.massivecraft.factions.listeners.FactionsListenerChat;
import com.massivecraft.massivecore.store.Entity;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.TimeUnit;
@ -42,8 +42,8 @@ public class MConf extends Entity<MConf>
if (!Factions.get().isDatabaseInitialized()) return this;
FactionsListenerChat.get().deactivate();
FactionsListenerChat.get().activate();
EngineChat.get().deactivate();
EngineChat.get().activate();
return this;
}

View File

@ -149,12 +149,18 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
private Boolean usingAdminMode = null;
// The id for the faction this player is currently autoclaiming for.
// NOTE: This field will not be saved to the database ever.
// Null means the player isn't auto claiming.
// NOTE: This field will not be saved to the database ever.
private transient Faction autoClaimFaction = null;
public Faction getAutoClaimFaction() { return this.autoClaimFaction; }
public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = autoClaimFaction; }
// Does the player have /f seechunk activated?
// NOTE: This field will not be saved to the database ever.
private transient boolean seeingChunk = false;
public boolean isSeeingChunk() { return this.seeingChunk; }
public void setSeeingChunk(boolean seeingChunk) { this.seeingChunk = seeingChunk; }
// -------------------------------------------- //
// CORE UTILITIES
// -------------------------------------------- //

View File

@ -11,9 +11,9 @@ import com.griefcraft.scripting.JavaModule;
import com.griefcraft.scripting.event.LWCProtectionInteractEvent;
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
import com.massivecraft.factions.Factions;
import com.massivecraft.factions.engine.EngineMain;
import com.massivecraft.factions.entity.MConf;
import com.massivecraft.factions.entity.MPlayer;
import com.massivecraft.factions.listeners.FactionsListenerMain;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.ps.PS;
import com.massivecraft.massivecore.util.IdUtil;
@ -54,7 +54,7 @@ public class FactionsLwcModule extends JavaModule
// ... and the player don't have build rights here ...
// NOTE: We verbosely check the build rights so that a proper info message is sent
if (FactionsListenerMain.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) return;
if (EngineMain.canPlayerBuildAt(event.getPlayer(), PS.valueOf(event.getBlock()), true)) return;
// ... then cancel the event.
event.setCancelled(true);
@ -79,7 +79,7 @@ public class FactionsLwcModule extends JavaModule
// ... and if the protection owner no longer has build rights for the area ...
// NOTE: We silently check the build rights for the protection owner.
// NOTE: The protection owner may even be offline at the moment.
if (FactionsListenerMain.canPlayerBuildAt(mowner, ps, false)) return;
if (EngineMain.canPlayerBuildAt(mowner, ps, false)) return;
// ... remove the protection ...
protection.remove();