Rename and repackage the Engines/Listeners.
This commit is contained in:
parent
54e04fee88
commit
f1375ea699
@ -19,6 +19,11 @@ import com.massivecraft.factions.chat.tag.ChatTagNameforce;
|
|||||||
import com.massivecraft.factions.chat.tag.ChatTagRoleprefixforce;
|
import com.massivecraft.factions.chat.tag.ChatTagRoleprefixforce;
|
||||||
import com.massivecraft.factions.chat.tag.ChatTagTitle;
|
import com.massivecraft.factions.chat.tag.ChatTagTitle;
|
||||||
import com.massivecraft.factions.cmd.*;
|
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.Board;
|
||||||
import com.massivecraft.factions.entity.BoardColl;
|
import com.massivecraft.factions.entity.BoardColl;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
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.dynmap.IntegrationDynmapFactions;
|
||||||
import com.massivecraft.factions.integration.herochat.IntegrationHerochat;
|
import com.massivecraft.factions.integration.herochat.IntegrationHerochat;
|
||||||
import com.massivecraft.factions.integration.lwc.IntegrationLwc;
|
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.PowerMixin;
|
||||||
import com.massivecraft.factions.mixin.PowerMixinDefault;
|
import com.massivecraft.factions.mixin.PowerMixinDefault;
|
||||||
import com.massivecraft.factions.task.TaskPlayerDataRemove;
|
import com.massivecraft.factions.task.TaskPlayerDataRemove;
|
||||||
@ -134,16 +135,13 @@ public class Factions extends MassivePlugin
|
|||||||
this.outerCmdFactions = new CmdFactions();
|
this.outerCmdFactions = new CmdFactions();
|
||||||
this.outerCmdFactions.register();
|
this.outerCmdFactions.register();
|
||||||
|
|
||||||
// Setup Listeners
|
// Engines
|
||||||
FactionsListenerMain.get().activate();
|
EngineMain.get().activate();
|
||||||
FactionsListenerChat.get().activate();
|
EngineChat.get().activate();
|
||||||
FactionsListenerExploit.get().activate();
|
EngineExploit.get().activate();
|
||||||
EngineIdUpdate.get().activate();
|
EngineIdUpdate.get().activate();
|
||||||
|
EngineSeeChunk.get().activate();
|
||||||
// TODO: This listener is a work in progress.
|
EngineEcon.get().activate(); // TODO: Take an extra look and make sure all economy stuff is handled using events.
|
||||||
// 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();
|
|
||||||
|
|
||||||
// Integrate
|
// Integrate
|
||||||
this.integrate(
|
this.integrate(
|
||||||
@ -153,7 +151,7 @@ public class Factions extends MassivePlugin
|
|||||||
IntegrationDynmapFactions.get()
|
IntegrationDynmapFactions.get()
|
||||||
);
|
);
|
||||||
|
|
||||||
// Schedule recurring non-tps-dependent tasks
|
// Modulo Repeat Tasks
|
||||||
TaskPlayerPowerUpdate.get().activate(this);
|
TaskPlayerPowerUpdate.get().activate(this);
|
||||||
TaskPlayerDataRemove.get().activate(this);
|
TaskPlayerDataRemove.get().activate(this);
|
||||||
TaskEconLandReward.get().activate(this);
|
TaskEconLandReward.get().activate(this);
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.engine;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.event.Event;
|
import org.bukkit.event.Event;
|
||||||
@ -15,14 +15,14 @@ import com.massivecraft.factions.entity.MConf;
|
|||||||
import com.massivecraft.massivecore.EngineAbstract;
|
import com.massivecraft.massivecore.EngineAbstract;
|
||||||
import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat;
|
import com.massivecraft.massivecore.event.EventMassiveCorePlayerToRecipientChat;
|
||||||
|
|
||||||
public class FactionsListenerChat extends EngineAbstract
|
public class EngineChat extends EngineAbstract
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static FactionsListenerChat i = new FactionsListenerChat();
|
private static EngineChat i = new EngineChat();
|
||||||
public static FactionsListenerChat get() { return i; }
|
public static EngineChat get() { return i; }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
@ -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.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.entity.Faction;
|
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.EventFactionsRelationChange;
|
||||||
import com.massivecraft.factions.event.EventFactionsTitleChange;
|
import com.massivecraft.factions.event.EventFactionsTitleChange;
|
||||||
import com.massivecraft.factions.integration.Econ;
|
import com.massivecraft.factions.integration.Econ;
|
||||||
|
import com.massivecraft.massivecore.EngineAbstract;
|
||||||
import com.massivecraft.massivecore.money.Money;
|
import com.massivecraft.massivecore.money.Money;
|
||||||
|
|
||||||
public class FactionsListenerEcon implements Listener
|
public class EngineEcon extends EngineAbstract
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static FactionsListenerEcon i = new FactionsListenerEcon();
|
private static EngineEcon i = new EngineEcon();
|
||||||
public static FactionsListenerEcon get() { return i; }
|
public static EngineEcon get() { return i; }
|
||||||
public FactionsListenerEcon() {}
|
public EngineEcon() {}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// SETUP
|
// OVERRIDE
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
public void setup()
|
@Override
|
||||||
|
public Plugin getPlugin()
|
||||||
{
|
{
|
||||||
Bukkit.getPluginManager().registerEvents(this, Factions.get());
|
return Factions.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
@ -1,4 +1,4 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.engine;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -19,14 +19,14 @@ import com.massivecraft.factions.entity.MConf;
|
|||||||
import com.massivecraft.massivecore.EngineAbstract;
|
import com.massivecraft.massivecore.EngineAbstract;
|
||||||
|
|
||||||
|
|
||||||
public class FactionsListenerExploit extends EngineAbstract
|
public class EngineExploit extends EngineAbstract
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static FactionsListenerExploit i = new FactionsListenerExploit();
|
private static EngineExploit i = new EngineExploit();
|
||||||
public static FactionsListenerExploit get() { return i; }
|
public static EngineExploit get() { return i; }
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
@ -1,4 +1,4 @@
|
|||||||
package com.massivecraft.factions.listeners;
|
package com.massivecraft.factions.engine;
|
||||||
|
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
import java.util.Collection;
|
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.PlayerUtil;
|
||||||
import com.massivecraft.massivecore.util.Txt;
|
import com.massivecraft.massivecore.util.Txt;
|
||||||
|
|
||||||
public class FactionsListenerMain extends EngineAbstract
|
public class EngineMain extends EngineAbstract
|
||||||
{
|
{
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// INSTANCE & CONSTRUCT
|
// INSTANCE & CONSTRUCT
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
|
||||||
private static FactionsListenerMain i = new FactionsListenerMain();
|
private static EngineMain i = new EngineMain();
|
||||||
public static FactionsListenerMain get() { return i; }
|
public static EngineMain get() { return i; }
|
||||||
public FactionsListenerMain() {}
|
public EngineMain() {}
|
||||||
|
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
// OVERRIDE
|
// OVERRIDE
|
@ -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());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -15,9 +15,9 @@ import org.bukkit.event.EventPriority;
|
|||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
import com.massivecraft.factions.Rel;
|
import com.massivecraft.factions.Rel;
|
||||||
import com.massivecraft.factions.WorldExceptionSet;
|
import com.massivecraft.factions.WorldExceptionSet;
|
||||||
|
import com.massivecraft.factions.engine.EngineChat;
|
||||||
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
import com.massivecraft.factions.event.EventFactionsChunkChangeType;
|
||||||
import com.massivecraft.factions.integration.dynmap.DynmapStyle;
|
import com.massivecraft.factions.integration.dynmap.DynmapStyle;
|
||||||
import com.massivecraft.factions.listeners.FactionsListenerChat;
|
|
||||||
import com.massivecraft.massivecore.store.Entity;
|
import com.massivecraft.massivecore.store.Entity;
|
||||||
import com.massivecraft.massivecore.util.MUtil;
|
import com.massivecraft.massivecore.util.MUtil;
|
||||||
import com.massivecraft.massivecore.util.TimeUnit;
|
import com.massivecraft.massivecore.util.TimeUnit;
|
||||||
@ -42,8 +42,8 @@ public class MConf extends Entity<MConf>
|
|||||||
|
|
||||||
if (!Factions.get().isDatabaseInitialized()) return this;
|
if (!Factions.get().isDatabaseInitialized()) return this;
|
||||||
|
|
||||||
FactionsListenerChat.get().deactivate();
|
EngineChat.get().deactivate();
|
||||||
FactionsListenerChat.get().activate();
|
EngineChat.get().activate();
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -149,12 +149,18 @@ public class MPlayer extends SenderEntity<MPlayer> implements EconomyParticipato
|
|||||||
private Boolean usingAdminMode = null;
|
private Boolean usingAdminMode = null;
|
||||||
|
|
||||||
// The id for the faction this player is currently autoclaiming for.
|
// 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.
|
// Null means the player isn't auto claiming.
|
||||||
|
// NOTE: This field will not be saved to the database ever.
|
||||||
private transient Faction autoClaimFaction = null;
|
private transient Faction autoClaimFaction = null;
|
||||||
public Faction getAutoClaimFaction() { return this.autoClaimFaction; }
|
public Faction getAutoClaimFaction() { return this.autoClaimFaction; }
|
||||||
public void setAutoClaimFaction(Faction autoClaimFaction) { this.autoClaimFaction = 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
|
// CORE UTILITIES
|
||||||
// -------------------------------------------- //
|
// -------------------------------------------- //
|
||||||
|
@ -11,9 +11,9 @@ import com.griefcraft.scripting.JavaModule;
|
|||||||
import com.griefcraft.scripting.event.LWCProtectionInteractEvent;
|
import com.griefcraft.scripting.event.LWCProtectionInteractEvent;
|
||||||
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
|
import com.griefcraft.scripting.event.LWCProtectionRegisterEvent;
|
||||||
import com.massivecraft.factions.Factions;
|
import com.massivecraft.factions.Factions;
|
||||||
|
import com.massivecraft.factions.engine.EngineMain;
|
||||||
import com.massivecraft.factions.entity.MConf;
|
import com.massivecraft.factions.entity.MConf;
|
||||||
import com.massivecraft.factions.entity.MPlayer;
|
import com.massivecraft.factions.entity.MPlayer;
|
||||||
import com.massivecraft.factions.listeners.FactionsListenerMain;
|
|
||||||
import com.massivecraft.massivecore.mixin.Mixin;
|
import com.massivecraft.massivecore.mixin.Mixin;
|
||||||
import com.massivecraft.massivecore.ps.PS;
|
import com.massivecraft.massivecore.ps.PS;
|
||||||
import com.massivecraft.massivecore.util.IdUtil;
|
import com.massivecraft.massivecore.util.IdUtil;
|
||||||
@ -54,7 +54,7 @@ public class FactionsLwcModule extends JavaModule
|
|||||||
|
|
||||||
// ... and the player don't have build rights here ...
|
// ... and the player don't have build rights here ...
|
||||||
// NOTE: We verbosely check the build rights so that a proper info message is sent
|
// 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.
|
// ... then cancel the event.
|
||||||
event.setCancelled(true);
|
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 ...
|
// ... 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: We silently check the build rights for the protection owner.
|
||||||
// NOTE: The protection owner may even be offline at the moment.
|
// 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 ...
|
// ... remove the protection ...
|
||||||
protection.remove();
|
protection.remove();
|
||||||
|
Loading…
Reference in New Issue
Block a user