diff options
author | snowleo <schneeleo@gmail.com> | 2011-07-16 01:33:22 +0200 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2011-07-16 01:33:22 +0200 |
commit | a38fe6acd4f5f6d7143c818653e9e02209f312db (patch) | |
tree | 7a993bdc1260364b8fad6a2d811fd608cb24c70c /EssentialsSpawn/src/com/earth2me | |
parent | 25c9557c594a065308dbd6dd4835f83c5028c54d (diff) | |
download | Essentials-a38fe6acd4f5f6d7143c818653e9e02209f312db.tar Essentials-a38fe6acd4f5f6d7143c818653e9e02209f312db.tar.gz Essentials-a38fe6acd4f5f6d7143c818653e9e02209f312db.tar.lz Essentials-a38fe6acd4f5f6d7143c818653e9e02209f312db.tar.xz Essentials-a38fe6acd4f5f6d7143c818653e9e02209f312db.zip |
Heavy cleanup of all classes
ItemDb is not static anymore
Essentials.getStatic() removed
Diffstat (limited to 'EssentialsSpawn/src/com/earth2me')
4 files changed, 30 insertions, 29 deletions
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java index 4f997a14e..6f538ac92 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java @@ -1,8 +1,6 @@ package com.earth2me.essentials.spawn; import org.bukkit.Server; -import com.earth2me.essentials.Essentials; -import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; import com.earth2me.essentials.commands.EssentialsCommand; @@ -18,7 +16,6 @@ public class Commandsetspawn extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - final IEssentials ess = Essentials.getStatic(); charge(user); final String group = args.length > 0 ? getFinalArg(args, 0) : "default"; ess.getSpawn().setSpawn(user.getLocation(), group); diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java index 5660c3778..b3ade7634 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java @@ -2,8 +2,6 @@ package com.earth2me.essentials.spawn; import com.earth2me.essentials.Trade; import org.bukkit.Server; -import com.earth2me.essentials.Essentials; -import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.commands.EssentialsCommand; @@ -18,7 +16,6 @@ public class Commandspawn extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { - final IEssentials ess = Essentials.getStatic(); final Trade charge = new Trade(this.getName(), ess); charge.isAffordableFor(user); user.getTeleport().respawn(ess.getSpawn(), charge); 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."); } } diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java index 96915bd89..f7395b49f 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -1,6 +1,5 @@ package com.earth2me.essentials.spawn; -import com.earth2me.essentials.Essentials; import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.User; import com.earth2me.essentials.Util; @@ -14,10 +13,16 @@ import org.bukkit.event.player.PlayerRespawnEvent; public class EssentialsSpawnPlayerListener extends PlayerListener { + private final transient IEssentials ess; + + public EssentialsSpawnPlayerListener(IEssentials ess) + { + this.ess = ess; + } + @Override public void onPlayerRespawn(final PlayerRespawnEvent event) { - final IEssentials ess = Essentials.getStatic(); final User user = ess.getUser(event.getPlayer()); try @@ -47,7 +52,6 @@ public class EssentialsSpawnPlayerListener extends PlayerListener @Override public void onPlayerJoin(final PlayerJoinEvent event) { - final IEssentials ess = Essentials.getStatic(); final User user = ess.getUser(event.getPlayer()); if (!user.isNew()) |