MassiveCore - MassivePlugin and Active

This commit is contained in:
Olof Larsson 2016-02-25 22:28:55 +01:00
parent e26e174837
commit 6c1bd25ae9
42 changed files with 768 additions and 707 deletions

View File

@ -0,0 +1,11 @@
package com.massivecraft.massivecore;
public interface Active
{
public boolean isActive();
public void setActive(boolean active);
public MassivePlugin setActivePlugin(MassivePlugin plugin);
public MassivePlugin getActivePlugin();
}

View File

@ -1,22 +1,162 @@
package com.massivecraft.massivecore;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.Plugin;
import org.bukkit.event.block.BlockMultiPlaceEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.scheduler.BukkitTask;
public interface Engine extends Listener, Runnable
import com.massivecraft.massivecore.predicate.PredicateStartsWithIgnoreCase;
public abstract class Engine implements Active, Listener, Runnable
{
public Plugin getPlugin();
// -------------------------------------------- //
// PLUGIN
// -------------------------------------------- //
public void activate();
public void deactivate();
private MassivePlugin plugin = null;
public MassivePlugin getPlugin() { return this.plugin; }
public boolean hasPlugin() { return this.getPlugin() != null; }
public void setPlugin(MassivePlugin plugin) { this.plugin = plugin; }
public void setPluginSoft(MassivePlugin plugin)
{
if (this.hasPlugin()) return;
this.plugin = plugin;
}
public Long getDelay();
public Long getPeriod();
// -------------------------------------------- //
// TASK
// -------------------------------------------- //
public Integer getTaskId();
private Long delay = 0L;
public Long getDelay() { return this.delay; }
public void setDelay(Long delay) { this.delay = delay; }
public BukkitTask getBukkitTask();
public boolean isSync();
private Long period = null;
public Long getPeriod() { return this.period; }
public void setPeriod(Long period) { this.period = period; }
private boolean sync = true;
public boolean isSync() { return this.sync; }
public void setSync(boolean sync) { this.sync = sync; }
private BukkitTask task = null;
public BukkitTask getTask() { return this.task; }
public Integer getTaskId() { return this.task == null ? null : this.task.getTaskId(); }
@Override
public void run()
{
}
// -------------------------------------------- //
// ACTIVE
// -------------------------------------------- //
private boolean active = false;
@Override
public boolean isActive()
{
return this.active;
}
@Override
public void setActive(boolean active)
{
this.setActiveListener(active);
this.setActiveTask(active);
this.setActiveInner(active);
this.active = active;
}
@Override
public MassivePlugin setActivePlugin(MassivePlugin activePlugin)
{
this.setPluginSoft(activePlugin);
return null;
}
@Override
public MassivePlugin getActivePlugin()
{
return this.getPlugin();
}
// -------------------------------------------- //
// ACTIVE > EVENTS
// -------------------------------------------- //
public void setActiveListener(boolean active)
{
if (active)
{
Bukkit.getPluginManager().registerEvents(this, this.getPlugin());
}
else
{
HandlerList.unregisterAll(this);
}
}
// -------------------------------------------- //
// ACTIVE > TASK
// -------------------------------------------- //
public void setActiveTask(boolean active)
{
if (active)
{
if (this.getPeriod() != null)
{
if (this.isSync())
{
Bukkit.getScheduler().runTaskTimer(this.getPlugin(), this, this.getDelay(), this.getPeriod());
}
else
{
Bukkit.getScheduler().runTaskTimerAsynchronously(this.getPlugin(), this, this.getDelay(), this.getPeriod());
}
}
}
else
{
if (this.task != null)
{
this.task.cancel();
this.task = null;
}
}
}
// -------------------------------------------- //
// ACTIVE > INNER
// -------------------------------------------- //
public void setActiveInner(boolean active)
{
// NOTE: Here you can add some extra custom logic.
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static final PredicateStartsWithIgnoreCase STARTING_WITH_FAKE = PredicateStartsWithIgnoreCase.get("fake");
public static boolean isFake(Event event)
{
final Class<?> clazz = event.getClass();
if (event instanceof BlockPlaceEvent)
{
return ! BlockPlaceEvent.class.equals(clazz) && ! BlockMultiPlaceEvent.class.equals(clazz);
}
else
{
return STARTING_WITH_FAKE.apply(clazz.getSimpleName());
}
}
}

View File

@ -1,102 +0,0 @@
package com.massivecraft.massivecore;
import org.bukkit.Bukkit;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.event.block.BlockMultiPlaceEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.scheduler.BukkitTask;
import com.massivecraft.massivecore.predicate.PredicateStartsWithIgnoreCase;
public abstract class EngineAbstract implements Engine
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private BukkitTask task;
@Override public Integer getTaskId() { return this.task.getTaskId(); }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void activate()
{
Bukkit.getPluginManager().registerEvents(this, this.getPlugin());
if (this.getPeriod() != null)
{
if (this.isSync())
{
Bukkit.getScheduler().runTaskTimer(this.getPlugin(), this, this.getDelay(), this.getPeriod());
}
else
{
Bukkit.getScheduler().runTaskTimerAsynchronously(this.getPlugin(), this, this.getDelay(), this.getPeriod());
}
}
}
@Override
public void deactivate()
{
HandlerList.unregisterAll(this);
if (this.task != null)
{
this.task.cancel();
this.task = null;
}
}
@Override
public Long getDelay()
{
return 0L;
}
@Override
public Long getPeriod()
{
return null;
}
@Override
public void run()
{
}
@Override
public BukkitTask getBukkitTask()
{
return this.task;
}
@Override
public boolean isSync()
{
return true;
}
// -------------------------------------------- //
// FAKE
// -------------------------------------------- //
public static final PredicateStartsWithIgnoreCase STARTING_WITH_FAKE = PredicateStartsWithIgnoreCase.get("fake");
public static boolean isFake(Event event)
{
final Class<?> clazz = event.getClass();
if (event instanceof BlockPlaceEvent)
{
return ! BlockPlaceEvent.class.equals(clazz) && ! BlockMultiPlaceEvent.class.equals(clazz);
}
else
{
return STARTING_WITH_FAKE.apply(clazz.getSimpleName());
}
}
}

View File

@ -0,0 +1,185 @@
package com.massivecraft.massivecore;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.predicate.Predicate;
import com.massivecraft.massivecore.predicate.PredicateIntegration;
import com.massivecraft.massivecore.util.Txt;
public class Integration extends Engine
{
// -------------------------------------------- //
// NAME
// -------------------------------------------- //
private String name = null;
public String getName() { return this.name; }
public Integration setName(String name) { this.name = name; return this; }
// -------------------------------------------- //
// PREDICATE
// -------------------------------------------- //
private Predicate<Integration> predicate = PredicateIntegration.get();
public Predicate<Integration> getPredicate() { return this.predicate; }
public Integration setPredicate(Predicate<Integration> predicate) { this.predicate = predicate; return this; }
private List<String> pluginNames = Collections.emptyList();
public List<String> getPluginNames() { return this.pluginNames; }
public Integration setPluginNames(Collection<String> pluginNames) { this.pluginNames = new MassiveList<>(pluginNames); return this; }
public Integration setPluginNames(String... pluginNames) { return this.setPluginNames(Arrays.asList(pluginNames)); }
public Integration setPluginName(String pluginName) { return this.setPluginNames(pluginName); }
private List<String> classNames = Collections.emptyList();
public List<String> getClassNames() { return this.classNames; }
public Integration setClassNames(Collection<String> classNames) { this.classNames = new MassiveList<>(classNames); return this; }
public Integration setClassNames(String... classNames) { return this.setClassNames(Arrays.asList(classNames)); }
public Integration setClassName(String className) { return this.setClassNames(className); }
// -------------------------------------------- //
// INTEGRATION ACTIVE
// -------------------------------------------- //
// NOTE: We must make use of duplicate information to avoid triggering class loads.
private boolean integrationActive = false;
public boolean isIntegrationActive() { return this.integrationActive; }
public void setIntegrationActive(Boolean integrationActive)
{
// Calc
if (integrationActive == null)
{
integrationActive = this.getPredicate().apply(this);
}
// NoChange
if (this.isIntegrationActive() == integrationActive) return;
try
{
this.setIntegrationActiveEngines(integrationActive);
this.setIntegrationActiveInner(integrationActive);
this.integrationActive = integrationActive;
String message = Txt.parse(integrationActive ? "<g>Activated Integration <h>%s" : "<b>Deactivated Integration <h>%s", this.getName());
this.getPlugin().log(message);
}
catch (Throwable t)
{
String message = Txt.parse(integrationActive ? "<b>Activating Integration <h>%s<b> FAILED:" : "<b>Deactivating Integration <h>%s<b> FAILED:", this.getName());
this.getPlugin().log(message);
t.printStackTrace();
}
}
public void setIntegrationActive()
{
this.setIntegrationActive(null);
}
// -------------------------------------------- //
// INTEGRATION ACTIVE > ENGINES
// -------------------------------------------- //
public void setIntegrationActiveEngines(boolean active)
{
for (Engine engine : this.getEngines())
{
engine.setPluginSoft(this.getPlugin());
engine.setActive(active);
}
}
public List<Engine> getEngines()
{
Engine engine = this.getEngine();
if (engine == null) return Collections.emptyList();
return Collections.singletonList(engine);
}
public Engine getEngine()
{
return null;
}
// -------------------------------------------- //
// INTEGRATION ACTIVE > INNER
// -------------------------------------------- //
public void setIntegrationActiveInner(boolean active)
{
}
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public Integration()
{
// TODO: Improve upon this one
this.setName(this.getClass().getSimpleName());
// TODO: Is this period fine?
this.setPeriod(10L);
}
// -------------------------------------------- //
// TICK > ACTIVE
// -------------------------------------------- //
@Override
public void setActiveInner(boolean active)
{
if (active)
{
this.setIntegrationActive();
}
else
{
this.setIntegrationActive(false);
}
}
// -------------------------------------------- //
// TICK > RUN
// -------------------------------------------- //
@Override
public void run()
{
this.setIntegrationActive();
}
// -------------------------------------------- //
// TICK > EVENT LISTENERS
// -------------------------------------------- //
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event)
{
if (this.getPlugin().equals(event.getPlugin()))
{
this.setIntegrationActive(false);
}
else
{
this.setIntegrationActive();
}
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event)
{
this.setIntegrationActive();
}
}

View File

@ -1,7 +1,6 @@
package com.massivecraft.massivecore;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.Map.Entry;
import java.util.Random;
import java.util.Set;
@ -97,7 +96,10 @@ public class MassiveCore extends MassivePlugin
private static MassiveCore i;
public static MassiveCore get() { return i; }
public MassiveCore() { i = this; }
public MassiveCore()
{
i = this;
}
// -------------------------------------------- //
// STATIC
@ -152,26 +154,6 @@ public class MassiveCore extends MassivePlugin
return false;
}
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
// Commands
private CmdMassiveCore outerCmdMassiveCore;
public CmdMassiveCore getOuterCmdMassiveCore() { return this.outerCmdMassiveCore; }
private CmdMassiveCoreUsys outerCmdMassiveCoreUsys;
public CmdMassiveCoreUsys getOuterCmdMassiveCoreUsys() { return this.outerCmdMassiveCoreUsys; }
private CmdMassiveCoreStore outerCmdMassiveCoreStore;
public CmdMassiveCoreStore getOuterCmdMassiveCoreStore() { return this.outerCmdMassiveCoreStore; }
private CmdMassiveCoreBuffer outerCmdMassiveCoreBuffer;
public CmdMassiveCoreBuffer getOuterCmdMassiveCoreBuffer() { return this.outerCmdMassiveCoreBuffer; }
private CmdMassiveCoreCmdurl outerCmdMassiveCoreCmdurl;
public CmdMassiveCoreCmdurl getOuterCmdMassiveCoreCmdurl() { return this.outerCmdMassiveCoreCmdurl; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@ -185,7 +167,7 @@ public class MassiveCore extends MassivePlugin
}
@Override
public void onEnable()
public void onEnableInner()
{
// This is safe since all plugins using Persist should bukkit-depend this plugin.
// Note this one must be before preEnable. dooh.
@ -193,68 +175,57 @@ public class MassiveCore extends MassivePlugin
// TODO: Test and ensure reload compat.
// Coll.instances.clear();
if ( ! preEnable()) return;
// Load Server Config
ConfServer.get().load();
// Setup IdUtil
IdUtil.setup();
// Activate
this.activate(
// Coll
MultiverseColl.get(),
AspectColl.get(),
MassiveCoreMConfColl.get(),
// Engine
EngineMassiveCoreChestGui.get().activate();
EngineMassiveCoreCollTick.get().activate();
EngineMassiveCoreCommandRegistration.get().activate();
EngineMassiveCoreDatabase.get().activate();
EngineMassiveCoreDestination.get().activate();
EngineMassiveCoreGank.get().activate();
EngineMassiveCoreMain.get().activate();
EngineMassiveCorePlayerLeave.get().activate();
EngineMassiveCorePlayerState.get().activate();
EngineMassiveCorePlayerUpdate.get().activate();
EngineMassiveCoreScheduledTeleport.get().activate();
EngineMassiveCoreTeleportMixinCause.get().activate();
EngineMassiveCoreVariable.get().activate();
EngineMassiveCoreWorldNameSet.get().activate();
EngineMassiveCoreChestGui.get(),
EngineMassiveCoreCollTick.get(),
EngineMassiveCoreCommandRegistration.get(),
EngineMassiveCoreDatabase.get(),
EngineMassiveCoreDestination.get(),
EngineMassiveCoreGank.get(),
EngineMassiveCoreMain.get(),
EngineMassiveCorePlayerLeave.get(),
EngineMassiveCorePlayerState.get(),
EngineMassiveCorePlayerUpdate.get(),
EngineMassiveCoreScheduledTeleport.get(),
EngineMassiveCoreTeleportMixinCause.get(),
EngineMassiveCoreVariable.get(),
EngineMassiveCoreWorldNameSet.get(),
PlayerUtil.get().activate();
// Util
PlayerUtil.get(),
// Collections
MultiverseColl.get().init();
AspectColl.get().init();
MassiveCoreMConfColl.get().init();
// Integration
IntegrationVault.get(),
// Command
CmdMassiveCore.get(),
CmdMassiveCoreUsys.get(),
CmdMassiveCoreStore.get(),
CmdMassiveCoreBuffer.get(),
CmdMassiveCoreCmdurl.get()
);
// Start the examine threads
// Start AFTER initializing the MConf, because they rely on the MConf.
ModificationPollerLocal.get().start();
ModificationPollerRemote.get().start();
// Register commands
this.outerCmdMassiveCore = new CmdMassiveCore() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCore; } };
this.outerCmdMassiveCore.register(this);
this.outerCmdMassiveCoreUsys = new CmdMassiveCoreUsys() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCoreUsys; } };
this.outerCmdMassiveCoreUsys.register(this);
this.outerCmdMassiveCoreStore = new CmdMassiveCoreStore() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCoreStore; } };
this.outerCmdMassiveCoreStore.register(this);
this.outerCmdMassiveCoreBuffer = new CmdMassiveCoreBuffer() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCoreBuffer; } };
this.outerCmdMassiveCoreBuffer.register(this);
this.outerCmdMassiveCoreCmdurl = new CmdMassiveCoreCmdurl() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCoreCmdurl; } };
this.outerCmdMassiveCoreCmdurl.register(this);
// Integration
this.integrate(
IntegrationVault.get()
);
// Delete Files (at once and additionally after all plugins loaded)
MassiveCoreTaskDeleteFiles.get().run();
Bukkit.getScheduler().scheduleSyncDelayedTask(this, MassiveCoreTaskDeleteFiles.get());
this.postEnable();
}
@Override

View File

@ -32,13 +32,9 @@ public class MassiveCoreMConf extends Entity<MassiveCoreMConf>
public int maxTabCompletions = 100;
public List<String> aliasesOuterMassiveCore = MUtil.list("massivecore", "mcore");
public List<String> aliasesOuterMassiveCoreUsys = MUtil.list("usys");
public List<String> aliasesOuterMassiveCoreStore = MUtil.list("massivestore", "mstore");
public List<String> aliasesOuterMassiveCoreBuffer = MUtil.list("buffer");
public List<String> aliasesOuterMassiveCoreCmdurl = MUtil.list("cmdurl");
public boolean usingRecipientChatEvent = true;

View File

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

View File

@ -11,8 +11,6 @@ import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.integration.IntegrationGlue;
import com.massivecraft.massivecore.integration.Integration;
import com.massivecraft.massivecore.store.Coll;
import com.massivecraft.massivecore.util.Txt;
import com.massivecraft.massivecore.xlib.gson.Gson;
@ -49,6 +47,9 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener
log("=== ENABLE START ===");
// Version Synchronization
this.checkVersionSynchronization();
// Create Gson
Gson gson = this.getGsonBuilder().create();
this.setGson(gson);
@ -74,9 +75,6 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener
public void postEnable()
{
long ms = System.currentTimeMillis() - enableTime;
this.checkVersionSynchronization();
log(Txt.parse("=== ENABLE <g>COMPLETE <i>(Took <h>" + ms + "ms<i>) ==="));
}
@ -120,9 +118,16 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener
{
if ( ! this.preEnable()) return;
this.onEnableInner();
this.postEnable();
}
public void onEnableInner()
{
}
// -------------------------------------------- //
// DISABLE
// -------------------------------------------- //
@ -137,7 +142,7 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener
for (Coll<?> coll : Coll.getInstances())
{
if (coll.getPlugin() != this) continue;
coll.deinit();
coll.setActive(false);
}
log("Disabled");
@ -158,15 +163,16 @@ public abstract class MassivePlugin extends JavaPlugin implements Listener
public void suicide()
{
log(Txt.parse("<b>Now I suicide!"));
this.log(Txt.parse("<b>Now I suicide!"));
Bukkit.getPluginManager().disablePlugin(this);
}
public void integrate(Integration... features)
public void activate(Active... actives)
{
for (Integration f : features)
for (Active active : actives)
{
new IntegrationGlue(this, f);
active.setActivePlugin(this);
active.setActive(true);
}
}

View File

@ -4,7 +4,7 @@ package com.massivecraft.massivecore;
* This class will allow you to create non-tps-dependent repeating tasks.
* It makes use of the Bukkit scheduler internally.
*/
public abstract class ModuloRepeatTask extends EngineAbstract
public abstract class ModuloRepeatTask extends Engine
{
// -------------------------------------------- //
// FIELDS: RAW

View File

@ -31,9 +31,11 @@ public class MultiverseColl extends Coll<Multiverse>
// -------------------------------------------- //
@Override
public void init()
public void setActive(boolean active)
{
super.init();
super.setActive(active);
if ( ! active) return;
// Ensure the default multiverse exits
this.get(MassiveCore.DEFAULT, true);

View File

@ -14,11 +14,14 @@ import java.util.Set;
import org.apache.commons.lang.StringUtils;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.command.PluginIdentifiableCommand;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.Active;
import com.massivecraft.massivecore.Lang;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.MassivePlugin;
import com.massivecraft.massivecore.collections.MassiveList;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.command.requirement.Requirement;
@ -30,7 +33,7 @@ import com.massivecraft.massivecore.predicate.PredicateStartsWithIgnoreCase;
import com.massivecraft.massivecore.util.PermUtil;
import com.massivecraft.massivecore.util.Txt;
public class MassiveCommand
public class MassiveCommand implements Active, PluginIdentifiableCommand
{
// -------------------------------------------- //
// REGISTER
@ -49,15 +52,15 @@ public class MassiveCommand
// When registering again we use the fresh and current aliases.
// STATIC
private static final transient Map<MassiveCommand, Plugin> registry = new LinkedHashMap<MassiveCommand, Plugin>();
public static Map<MassiveCommand, Plugin> getRegistry() { return registry; }
private static final transient Map<MassiveCommand, MassivePlugin> registry = new LinkedHashMap<MassiveCommand, MassivePlugin>();
public static Map<MassiveCommand, MassivePlugin> getRegistry() { return registry; }
public static Set<MassiveCommand> getRegisteredCommands() { return registry.keySet(); }
public static void unregister(Plugin plugin)
{
Iterator<Entry<MassiveCommand, Plugin>> iter = registry.entrySet().iterator();
Iterator<Entry<MassiveCommand, MassivePlugin>> iter = registry.entrySet().iterator();
while (iter.hasNext())
{
Entry<MassiveCommand, Plugin> entry = iter.next();
Entry<MassiveCommand, MassivePlugin> entry = iter.next();
if (plugin.equals(entry.getValue()))
{
iter.remove();
@ -65,11 +68,48 @@ public class MassiveCommand
}
}
// INSTANCE
public Plugin register(Plugin plugin) { return registry.put(this, plugin); }
public void unregister() { registry.remove(this); }
public boolean isRegistered() { return registry.containsKey(this); }
public Plugin getRegisteredPlugin() { return registry.get(this); }
// -------------------------------------------- //
// ACTIVE
// -------------------------------------------- //
@Override
public boolean isActive()
{
return registry.containsKey(this);
}
@Override
public void setActive(boolean active)
{
// NOTE: Not Implemented
}
public MassivePlugin setActivePlugin(MassivePlugin activePlugin)
{
if (activePlugin == null)
{
return registry.remove(this);
}
else
{
return registry.put(this, activePlugin);
}
}
public MassivePlugin getActivePlugin()
{
return registry.get(this);
}
// -------------------------------------------- //
// PLUGIN IDENTIFIABLE COMMAND
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return this.getActivePlugin();
}
// -------------------------------------------- //
// FIELDS

View File

@ -47,7 +47,7 @@ public class MassiveCoreBukkitCommand extends Command implements PluginIdentifia
@Override
public Plugin getPlugin()
{
return this.getMassiveCommand().getRegisteredPlugin();
return this.getMassiveCommand().getPlugin();
}
// -------------------------------------------- //

View File

@ -1,6 +1,9 @@
package com.massivecraft.massivecore.command.massivecore;
import java.util.List;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.VersionCommand;
@ -8,6 +11,13 @@ import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCore extends MassiveCommand
{
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static CmdMassiveCore i = new CmdMassiveCore();
public static CmdMassiveCore get() { return i; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
@ -41,4 +51,14 @@ public class CmdMassiveCore extends MassiveCommand
this.addRequirements(RequirementHasPerm.get(MassiveCorePerm.BASECOMMAND.node));
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public List<String> getAliases()
{
return MassiveCoreMConf.get().aliasesOuterMassiveCore;
}
}

View File

@ -1,11 +1,21 @@
package com.massivecraft.massivecore.command.massivecore;
import java.util.List;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreBuffer extends MassiveCommand
{
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static CmdMassiveCoreBuffer i = new CmdMassiveCoreBuffer() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCoreBuffer; } };
public static CmdMassiveCoreBuffer get() { return i; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //

View File

@ -8,6 +8,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.command.MassiveCommand;
@ -19,6 +20,13 @@ import com.massivecraft.massivecore.util.WebUtil;
public class CmdMassiveCoreCmdurl extends MassiveCommand
{
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static CmdMassiveCoreCmdurl i = new CmdMassiveCoreCmdurl() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCoreCmdurl; } };
public static CmdMassiveCoreCmdurl get() { return i; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //

View File

@ -1,11 +1,21 @@
package com.massivecraft.massivecore.command.massivecore;
import java.util.List;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreStore extends MassiveCommand
{
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static CmdMassiveCoreStore i = new CmdMassiveCoreStore() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCoreStore; } };
public static CmdMassiveCoreStore get() { return i; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //

View File

@ -1,11 +1,21 @@
package com.massivecraft.massivecore.command.massivecore;
import java.util.List;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.requirement.RequirementHasPerm;
public class CmdMassiveCoreUsys extends MassiveCommand
{
// -------------------------------------------- //
// INSTANCE
// -------------------------------------------- //
private static CmdMassiveCoreUsys i = new CmdMassiveCoreUsys() { public List<String> getAliases() { return MassiveCoreMConf.get().aliasesOuterMassiveCoreUsys; } };
public static CmdMassiveCoreUsys get() { return i; }
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //

View File

@ -6,16 +6,13 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryCloseEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.chestgui.ChestAction;
import com.massivecraft.massivecore.chestgui.ChestGui;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.util.InventoryUtil;
public class EngineMassiveCoreChestGui extends EngineAbstract
public class EngineMassiveCoreChestGui extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -24,16 +21,6 @@ public class EngineMassiveCoreChestGui extends EngineAbstract
private static EngineMassiveCoreChestGui i = new EngineMassiveCoreChestGui();
public static EngineMassiveCoreChestGui get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
// -------------------------------------------- //
// LISTENER
// -------------------------------------------- //

View File

@ -1,34 +1,19 @@
package com.massivecraft.massivecore.engine;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.store.Coll;
public class EngineMassiveCoreCollTick extends EngineAbstract
public class EngineMassiveCoreCollTick extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
protected static EngineMassiveCoreCollTick i = new EngineMassiveCoreCollTick();
private static EngineMassiveCoreCollTick i = new EngineMassiveCoreCollTick();
public static EngineMassiveCoreCollTick get() { return i; }
// -------------------------------------------- //
// OVERRIDE: ENGINE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
public EngineMassiveCoreCollTick()
{
return MassiveCore.get();
}
@Override
public Long getPeriod()
{
return 1L;
this.setPeriod(1L);
}
// -------------------------------------------- //

View File

@ -12,13 +12,12 @@ import org.bukkit.command.Command;
import org.bukkit.command.SimpleCommandMap;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.command.MassiveCommand;
import com.massivecraft.massivecore.command.MassiveCoreBukkitCommand;
import com.massivecraft.massivecore.util.ReflectionUtil;
public class EngineMassiveCoreCommandRegistration extends EngineAbstract
public class EngineMassiveCoreCommandRegistration extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -26,22 +25,9 @@ public class EngineMassiveCoreCommandRegistration extends EngineAbstract
private static EngineMassiveCoreCommandRegistration i = new EngineMassiveCoreCommandRegistration();
public static EngineMassiveCoreCommandRegistration get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
public EngineMassiveCoreCommandRegistration()
{
return MassiveCore.get();
}
@Override
public Long getPeriod()
{
// Every second
return 1 * 20L;
this.setPeriod(20L); // Every second
}
// -------------------------------------------- //

View File

@ -14,9 +14,7 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent.Result;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave;
@ -28,7 +26,7 @@ import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.xlib.gson.JsonObject;
public class EngineMassiveCoreDatabase extends EngineAbstract
public class EngineMassiveCoreDatabase extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -37,22 +35,6 @@ public class EngineMassiveCoreDatabase extends EngineAbstract
private static EngineMassiveCoreDatabase i = new EngineMassiveCoreDatabase();
public static EngineMassiveCoreDatabase get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
@Override
public void activate()
{
super.activate();
}
// -------------------------------------------- //
// PLAYER AND SENDER REFERENCES
// -------------------------------------------- //

View File

@ -9,10 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassiveException;
import com.massivecraft.massivecore.collections.MassiveSet;
import com.massivecraft.massivecore.command.type.TypePS;
@ -31,7 +28,7 @@ import com.massivecraft.massivecore.teleport.DestinationUtil;
import com.massivecraft.massivecore.teleport.DestinationWorld;
import com.massivecraft.massivecore.util.IdUtil;
public class EngineMassiveCoreDestination extends EngineAbstract
public class EngineMassiveCoreDestination extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -40,16 +37,6 @@ public class EngineMassiveCoreDestination extends EngineAbstract
private static EngineMassiveCoreDestination i = new EngineMassiveCoreDestination();
public static EngineMassiveCoreDestination get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
// -------------------------------------------- //
// DESTINATION ARG
// -------------------------------------------- //

View File

@ -10,14 +10,11 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.collections.MassiveMap;
import com.massivecraft.massivecore.util.MUtil;
public class EngineMassiveCoreGank extends EngineAbstract
public class EngineMassiveCoreGank extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -25,17 +22,6 @@ public class EngineMassiveCoreGank extends EngineAbstract
private static EngineMassiveCoreGank i = new EngineMassiveCoreGank();
public static EngineMassiveCoreGank get() { return i; }
public EngineMassiveCoreGank() {}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
// -------------------------------------------- //
// PROTECTED

View File

@ -18,9 +18,7 @@ import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.SenderPresence;
@ -36,7 +34,7 @@ import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.SmokeUtil;
public class EngineMassiveCoreMain extends EngineAbstract
public class EngineMassiveCoreMain extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -45,22 +43,6 @@ public class EngineMassiveCoreMain extends EngineAbstract
private static EngineMassiveCoreMain i = new EngineMassiveCoreMain();
public static EngineMassiveCoreMain get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
@Override
public void activate()
{
super.activate();
}
// -------------------------------------------- //
// RECIPIENT CHAT
// -------------------------------------------- //

View File

@ -7,14 +7,12 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerKickEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave;
import com.massivecraft.massivecore.util.MUtil;
public class EngineMassiveCorePlayerLeave extends EngineAbstract
public class EngineMassiveCorePlayerLeave extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -23,20 +21,11 @@ public class EngineMassiveCorePlayerLeave extends EngineAbstract
private static EngineMassiveCorePlayerLeave i = new EngineMassiveCorePlayerLeave();
public static EngineMassiveCorePlayerLeave get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
public void setActiveInner(boolean active)
{
return MassiveCore.get();
}
if ( ! active) return;
@Override
public void activate()
{
super.activate();
EventMassiveCorePlayerLeave.player2event.clear();
}

View File

@ -12,15 +12,13 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerLoginEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.PlayerState;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave;
import com.massivecraft.massivecore.util.MUtil;
public class EngineMassiveCorePlayerState extends EngineAbstract
public class EngineMassiveCorePlayerState extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -34,15 +32,9 @@ public class EngineMassiveCorePlayerState extends EngineAbstract
// -------------------------------------------- //
@Override
public Plugin getPlugin()
public void setActiveInner(boolean active)
{
return MassiveCore.get();
}
@Override
public void activate()
{
super.activate();
if ( ! active) return;
idToState.clear();
for (Player player : MUtil.getOnlinePlayers())

View File

@ -12,10 +12,7 @@ import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.event.EventMassiveCoreAfterPlayerRespawn;
import com.massivecraft.massivecore.event.EventMassiveCoreAfterPlayerTeleport;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerUpdate;
@ -25,7 +22,7 @@ import com.massivecraft.massivecore.util.MUtil;
* This event triggers the EventMassiveCorePlayerUpdate on every block change.
* It also runs it in reset mode rather than update mode upon world change.
*/
public class EngineMassiveCorePlayerUpdate extends EngineAbstract
public class EngineMassiveCorePlayerUpdate extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -34,16 +31,6 @@ public class EngineMassiveCorePlayerUpdate extends EngineAbstract
private static EngineMassiveCorePlayerUpdate i = new EngineMassiveCorePlayerUpdate();
public static EngineMassiveCorePlayerUpdate get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
// -------------------------------------------- //
// UPDATE
// -------------------------------------------- //

View File

@ -13,10 +13,7 @@ import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.inventory.InventoryOpenEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.event.EventMassiveCorePlayerLeave;
import com.massivecraft.massivecore.mixin.Mixin;
import com.massivecraft.massivecore.teleport.ScheduledTeleport;
@ -24,7 +21,7 @@ import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.TimeUnit;
public class EngineMassiveCoreScheduledTeleport extends EngineAbstract
public class EngineMassiveCoreScheduledTeleport extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -32,6 +29,10 @@ public class EngineMassiveCoreScheduledTeleport extends EngineAbstract
private static EngineMassiveCoreScheduledTeleport i = new EngineMassiveCoreScheduledTeleport();
public static EngineMassiveCoreScheduledTeleport get() { return i; }
public EngineMassiveCoreScheduledTeleport()
{
this.setPeriod(1L);
}
// -------------------------------------------- //
// SCHEDULED TELEPORT INDEX
@ -69,18 +70,6 @@ public class EngineMassiveCoreScheduledTeleport extends EngineAbstract
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
@Override
public Long getPeriod()
{
return 1L;
}
@Override
public void run()
{

View File

@ -8,12 +8,10 @@ import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassiveCore;
public class EngineMassiveCoreTeleportMixinCause extends EngineAbstract
public class EngineMassiveCoreTeleportMixinCause extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -21,17 +19,6 @@ public class EngineMassiveCoreTeleportMixinCause extends EngineAbstract
private static EngineMassiveCoreTeleportMixinCause i = new EngineMassiveCoreTeleportMixinCause();
public static EngineMassiveCoreTeleportMixinCause get() { return i; }
public EngineMassiveCoreTeleportMixinCause() {}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
// -------------------------------------------- //
// FIELDS

View File

@ -15,17 +15,14 @@ import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.BookMeta;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.MassiveCoreMConf;
import com.massivecraft.massivecore.MassiveCorePerm;
import com.massivecraft.massivecore.util.IdUtil;
import com.massivecraft.massivecore.util.MUtil;
import com.massivecraft.massivecore.util.Txt;
public class EngineMassiveCoreVariable extends EngineAbstract
public class EngineMassiveCoreVariable extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -34,16 +31,6 @@ public class EngineMassiveCoreVariable extends EngineAbstract
private static EngineMassiveCoreVariable i = new EngineMassiveCoreVariable();
public static EngineMassiveCoreVariable get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
// -------------------------------------------- //
// VARIABLE
// -------------------------------------------- //

View File

@ -10,12 +10,9 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.world.WorldLoadEvent;
import org.bukkit.event.world.WorldUnloadEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
public class EngineMassiveCoreWorldNameSet extends EngineAbstract
public class EngineMassiveCoreWorldNameSet extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -29,15 +26,9 @@ public class EngineMassiveCoreWorldNameSet extends EngineAbstract
// -------------------------------------------- //
@Override
public Plugin getPlugin()
public void setActiveInner(boolean active)
{
return MassiveCore.get();
}
@Override
public void activate()
{
super.activate();
if ( ! active) return;
this.worldNamesInner.clear();
for (World world : Bukkit.getWorlds())

View File

@ -1,10 +0,0 @@
package com.massivecraft.massivecore.integration;
import java.util.List;
public interface Integration
{
public List<String> getTargetPluginNames();
public void activate();
public void deactivate();
}

View File

@ -1,46 +0,0 @@
package com.massivecraft.massivecore.integration;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public abstract class IntegrationAbstract implements Integration
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
private List<String> targetPluginNames;
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public IntegrationAbstract(String... targetPluginNames)
{
this.targetPluginNames = new ArrayList<String>(Arrays.asList(targetPluginNames));
}
// -------------------------------------------- //
// OVERRIDES
// -------------------------------------------- //
@Override
public List<String> getTargetPluginNames()
{
return this.targetPluginNames;
}
@Override
public void activate()
{
}
@Override
public void deactivate()
{
}
}

View File

@ -1,121 +0,0 @@
package com.massivecraft.massivecore.integration;
import java.util.Collection;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.server.PluginDisableEvent;
import org.bukkit.event.server.PluginEnableEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.MassivePlugin;
import com.massivecraft.massivecore.util.Txt;
public class IntegrationGlue implements Listener
{
// -------------------------------------------- //
// FIELDS
// -------------------------------------------- //
protected MassivePlugin ourPlugin;
protected Integration features;
protected boolean active = false;
public boolean isActive() { return this.active; }
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public IntegrationGlue(MassivePlugin ourPlugin, Integration features)
{
this.ourPlugin = ourPlugin;
this.features = features;
Bukkit.getServer().getPluginManager().registerEvents(this, this.ourPlugin);
this.tick();
}
// -------------------------------------------- //
// LOGIC
// -------------------------------------------- //
public void tick()
{
String namelist = Txt.implodeCommaAndDot(this.features.getTargetPluginNames(), "<h>%s", "<i>, ", " <i>and ", "<i>.");
if (isPluginsEnabled(this.features.getTargetPluginNames()))
{
if (!this.active)
{
try
{
this.features.activate();
this.active = true;
this.ourPlugin.log(Txt.parse("<g>Activated <i>integration with "+namelist));
}
catch (Exception e)
{
this.ourPlugin.log(Txt.parse("<b>Failed to activate <i>integration with "+namelist));
e.printStackTrace();
}
}
}
else
{
if (this.active)
{
try
{
this.active = false;
this.features.deactivate();
this.ourPlugin.log(Txt.parse("<g>Deactivated <i>integration with "+namelist));
}
catch (Exception e)
{
this.ourPlugin.log(Txt.parse("<b>Failed to deactivate <i>integration with "+namelist));
e.printStackTrace();
}
}
}
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
public static boolean isPluginEnabled(String pluginName)
{
Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
if (plugin == null) return false;
return plugin.isEnabled();
}
public static boolean isPluginsEnabled(Collection<String> pluginNames)
{
for (String pluginName : pluginNames)
{
if (!isPluginEnabled(pluginName)) return false;
}
return true;
}
// -------------------------------------------- //
// EVENT LISTENERS
// -------------------------------------------- //
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginDisable(PluginDisableEvent event)
{
this.tick();
}
@EventHandler(priority = EventPriority.MONITOR)
public void onPluginEnable(PluginEnableEvent event)
{
this.tick();
}
}

View File

@ -1,9 +1,9 @@
package com.massivecraft.massivecore.integration.vault;
import com.massivecraft.massivecore.integration.IntegrationAbstract;
import com.massivecraft.massivecore.Integration;
import com.massivecraft.massivecore.money.MoneyMixinVault;
public class IntegrationVault extends IntegrationAbstract
public class IntegrationVault extends Integration
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -11,22 +11,26 @@ public class IntegrationVault extends IntegrationAbstract
private static IntegrationVault i = new IntegrationVault();
public static IntegrationVault get() { return i; }
private IntegrationVault() { super("Vault"); }
private IntegrationVault()
{
this.setPluginName("Vault");
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void activate()
public void setIntegrationActiveInner(boolean active)
{
if (active)
{
MoneyMixinVault.get().activate();
}
@Override
public void deactivate()
else
{
MoneyMixinVault.get().deactivate();
}
}
}

View File

@ -0,0 +1,76 @@
package com.massivecraft.massivecore.predicate;
import java.util.Collection;
import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.Integration;
public class PredicateIntegration implements Predicate<Integration>
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
// -------------------------------------------- //
private static PredicateIntegration i = new PredicateIntegration();
public static PredicateIntegration get() { return i; }
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public boolean apply(Integration integration)
{
return isPluginNamesPresent(integration.getPluginNames()) && isClassNamesPresent(integration.getClassNames());
}
// -------------------------------------------- //
// PLUGINS
// -------------------------------------------- //
public static boolean isPluginNamesPresent(Collection<String> pluginNames)
{
for (String pluginName : pluginNames)
{
if (isPluginNamePresent(pluginName)) continue;
return false;
}
return true;
}
public static boolean isPluginNamePresent(String pluginName)
{
Plugin plugin = Bukkit.getPluginManager().getPlugin(pluginName);
if (plugin == null) return false;
return plugin.isEnabled();
}
// -------------------------------------------- //
// CLASSES
// -------------------------------------------- //
public static boolean isClassNamesPresent(Collection<String> classNames)
{
for (String className : classNames)
{
if (isClassNamePresent(className)) continue;
return false;
}
return true;
}
public static boolean isClassNamePresent(String className)
{
try
{
Class.forName(className);
return true;
}
catch (Throwable t)
{
return false;
}
}
}

View File

@ -74,18 +74,13 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
// SUPPORTING SYSTEM
// -------------------------------------------- //
protected Plugin plugin;
@Override public Plugin getPlugin() { return this.plugin; }
protected MassivePlugin plugin;
@Override public MassivePlugin getPlugin() { return this.plugin; }
public Gson getGson()
{
if (this.getPlugin() instanceof MassivePlugin)
{
return ((MassivePlugin)this.getPlugin()).getGson();
}
else
{
return MassiveCore.gson;
}
MassivePlugin plugin = this.getPlugin();
if (plugin == null) return MassiveCore.gson;
return plugin.getGson();
}
protected Db db;
@ -700,7 +695,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
case LOCAL_ALTER:
case LOCAL_ATTACH:
this.saveToRemoteFixed(id);
if (this.inited())
if (this.isActive())
{
this.addSyncCountFixed(TOTAL, false);
this.addSyncCountFixed(id, false);
@ -708,7 +703,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
break;
case LOCAL_DETACH:
this.removeAtRemoteFixed(id);
if (this.inited())
if (this.isActive())
{
this.addSyncCountFixed(TOTAL, false);
this.addSyncCountFixed(id, false);
@ -717,7 +712,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
case REMOTE_ALTER:
case REMOTE_ATTACH:
this.loadFromRemoteFixed(id, remoteEntry);
if (this.inited())
if (this.isActive())
{
this.addSyncCountFixed(TOTAL, true);
this.addSyncCountFixed(id, true);
@ -725,7 +720,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
break;
case REMOTE_DETACH:
this.removeAtLocalFixed(id);
if (this.inited())
if (this.isActive())
{
this.addSyncCountFixed(TOTAL, true);
this.addSyncCountFixed(id, true);
@ -934,7 +929,7 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
// CONSTRUCT
// -------------------------------------------- //
public Coll(String name, Class<E> entityClass, Db db, Plugin plugin)
public Coll(String name, Class<E> entityClass, Db db, MassivePlugin plugin)
{
// Setup the name and the parsed parts
this.name = name;
@ -969,11 +964,33 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
};
}
@Override
public void init()
{
if (this.inited()) throw new IllegalStateException("Already initialised.");
// -------------------------------------------- //
// ACTIVE
// -------------------------------------------- //
@Override
public MassivePlugin setActivePlugin(MassivePlugin plugin)
{
MassivePlugin ret = this.plugin;
this.plugin = plugin;
return ret;
}
@Override
public MassivePlugin getActivePlugin()
{
return this.plugin;
}
@Override
public void setActive(boolean active)
{
// NoChange
if (this.isActive() == active) throw new IllegalStateException("Active Already " + active);
// TODO: Clean up this stuff below. It branches too late.
if (active)
{
if (this.supportsPusher())
{
this.getPusher().init();
@ -984,12 +1001,8 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
name2instance.put(this.getName(), this);
}
@Override
public void deinit()
else
{
if ( ! this.inited()) throw new IllegalStateException("Not initialised.");
if (this.supportsPusher())
{
this.getPusher().deinit();
@ -1000,9 +1013,10 @@ public class Coll<E extends Entity<E>> extends CollAbstract<E>
name2instance.remove(this.getName());
}
}
@Override
public boolean inited()
public boolean isActive()
{
return name2instance.containsKey(this.getName());
}

View File

@ -6,13 +6,13 @@ import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.Active;
import com.massivecraft.massivecore.MassivePlugin;
import com.massivecraft.massivecore.Named;
import com.massivecraft.massivecore.predicate.Predicate;
import com.massivecraft.massivecore.xlib.gson.JsonObject;
public interface CollInterface<E extends Entity<E>> extends Named
public interface CollInterface<E extends Entity<E>> extends Named, Active
{
// -------------------------------------------- //
// WHAT DO WE HANDLE?
@ -27,7 +27,7 @@ public interface CollInterface<E extends Entity<E>> extends Named
// SUPPORTING SYSTEM
// -------------------------------------------- //
public Plugin getPlugin();
public MassivePlugin getPlugin();
public Db getDb();
public Object getCollDriverObject();
@ -214,12 +214,4 @@ public interface CollInterface<E extends Entity<E>> extends Named
public Runnable getTickTask();
public void onTick();
// -------------------------------------------- //
// CONSTRUCT
// -------------------------------------------- //
public void init();
public void deinit();
public boolean inited();
}

View File

@ -5,11 +5,13 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.massivecraft.massivecore.Active;
import com.massivecraft.massivecore.Aspect;
import com.massivecraft.massivecore.MassivePlugin;
import com.massivecraft.massivecore.Multiverse;
import com.massivecraft.massivecore.util.MUtil;
public abstract class Colls<C extends Coll<E>, E extends Entity<E>>
public abstract class Colls<C extends Coll<E>, E extends Entity<E>> implements Active
{
protected Map<String, C> name2coll = new HashMap<String, C>();
@ -21,11 +23,6 @@ public abstract class Colls<C extends Coll<E>, E extends Entity<E>>
// CONSTRUCT
// -------------------------------------------- //
public void init()
{
this.getColls();
}
public List<C> getColls()
{
List<C> ret = new ArrayList<C>();
@ -38,6 +35,44 @@ public abstract class Colls<C extends Coll<E>, E extends Entity<E>>
return ret;
}
// -------------------------------------------- //
// ACTIVE
// -------------------------------------------- //
private boolean active = false;
@Override
public boolean isActive()
{
return this.active;
}
@Override
public void setActive(boolean active)
{
this.active = active;
if (active)
{
this.getColls();
}
else
{
// TODO: Uuuuuh
}
}
private MassivePlugin plugin = null;
@Override
public MassivePlugin setActivePlugin(MassivePlugin plugin)
{
MassivePlugin ret = this.plugin;
this.plugin = plugin;
return ret;
}
@Override
public MassivePlugin getActivePlugin()
{
return this.plugin;
}
// -------------------------------------------- //
// UTIL
// -------------------------------------------- //
@ -78,7 +113,8 @@ public abstract class Colls<C extends Coll<E>, E extends Entity<E>>
{
ret = this.createColl(collname);
this.name2coll.put(collname, ret);
ret.init();
ret.setActivePlugin(this.getActivePlugin());
ret.setActive(true);
}
return ret;
}

View File

@ -118,7 +118,7 @@ public class Entity<E extends Entity<E>>
Coll<E> coll = this.getColl();
if (coll == null) return false;
if ( ! coll.inited()) return false;
if ( ! coll.isActive()) return false;
return true;
}

View File

@ -5,8 +5,8 @@ import java.util.Collection;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.MassivePlugin;
import com.massivecraft.massivecore.SenderPresence;
import com.massivecraft.massivecore.SenderType;
import com.massivecraft.massivecore.command.type.sender.TypeSenderEntity;
@ -21,7 +21,7 @@ public class SenderColl<E extends SenderEntity<E>> extends Coll<E> implements Se
// CONSTRUCT
// -------------------------------------------- //
public SenderColl(String name, Class<E> entityClass, Db db, Plugin plugin)
public SenderColl(String name, Class<E> entityClass, Db db, MassivePlugin plugin)
{
super(name, entityClass, db, plugin);
this.setCreative(true);

View File

@ -16,12 +16,9 @@ import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.plugin.Plugin;
import com.massivecraft.massivecore.Engine;
import com.massivecraft.massivecore.EngineAbstract;
import com.massivecraft.massivecore.MassiveCore;
public class PlayerUtil extends EngineAbstract
public class PlayerUtil extends Engine
{
// -------------------------------------------- //
// INSTANCE & CONSTRUCT
@ -29,15 +26,19 @@ public class PlayerUtil extends EngineAbstract
private static PlayerUtil i = new PlayerUtil();
public static PlayerUtil get() { return i; }
public PlayerUtil()
{
this.setPeriod(1L);
}
// -------------------------------------------- //
// OVERRIDE
// -------------------------------------------- //
@Override
public void activate()
public void setActiveInner(boolean active)
{
super.activate();
if ( ! active) return;
idToDeathEvent.clear();
idToDamageEvent.clear();
@ -46,18 +47,6 @@ public class PlayerUtil extends EngineAbstract
idToLastMoveMillis.clear();
}
@Override
public Plugin getPlugin()
{
return MassiveCore.get();
}
@Override
public Long getPeriod()
{
return 1L;
}
@Override
public void run()
{