From 616b880e13fd07d880e934f394427df6fa2be5df Mon Sep 17 00:00:00 2001 From: snowleo Date: Sat, 16 Jul 2011 01:33:22 +0200 Subject: Heavy cleanup of all classes ItemDb is not static anymore Essentials.getStatic() removed --- .../earth2me/essentials/spawn/EssentialsSpawn.java | 43 ++++++++++++---------- 1 file changed, 23 insertions(+), 20 deletions(-) (limited to 'EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java') diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java index 77cb9a3cb..fcc8f6276 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java @@ -1,34 +1,37 @@ package com.earth2me.essentials.spawn; -import java.io.*; -import java.util.logging.*; -import com.earth2me.essentials.*; -import org.bukkit.command.*; + +import com.earth2me.essentials.IEssentials; +import com.earth2me.essentials.Util; +import java.util.logging.Level; +import java.util.logging.Logger; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Type; -import org.bukkit.plugin.java.*; +import org.bukkit.plugin.PluginManager; +import org.bukkit.plugin.java.JavaPlugin; public class EssentialsSpawn extends JavaPlugin { - public static final String AUTHORS = Essentials.AUTHORS; - private static final Logger logger = Logger.getLogger("Minecraft"); - - public EssentialsSpawn() throws IOException - { - - } + private static final Logger LOGGER = Logger.getLogger("Minecraft"); + private transient IEssentials ess; public void onEnable() { - EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(); - getServer().getPluginManager().registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.Low, this); - getServer().getPluginManager().registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this); - - if (!this.getDescription().getVersion().equals(Essentials.getStatic().getDescription().getVersion())) { - logger.log(Level.WARNING, Util.i18n("versionMismatchAll")); + final PluginManager pluginManager = getServer().getPluginManager(); + ess = (IEssentials)pluginManager.getPlugin("Essentials"); + final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess); + pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.Low, this); + pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this); + + + if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion())) + { + LOGGER.log(Level.WARNING, Util.i18n("versionMismatchAll")); } - logger.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Essentials.AUTHORS)); + LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team")); } public void onDisable() @@ -38,6 +41,6 @@ public class EssentialsSpawn extends JavaPlugin @Override public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args) { - return Essentials.getStatic().onCommandEssentials(sender, command, commandLabel, args, EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials."); + return ess.onCommandEssentials(sender, command, commandLabel, args, Thread.currentThread().getContextClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials."); } } -- cgit v1.2.3