2011-03-19 22:39:51 +00:00
|
|
|
package com.earth2me.essentials.spawn;
|
|
|
|
|
2011-11-21 01:55:26 +00:00
|
|
|
import static com.earth2me.essentials.I18n._;
|
2011-07-15 23:33:22 +00:00
|
|
|
import com.earth2me.essentials.IEssentials;
|
2011-12-06 12:41:29 +00:00
|
|
|
import com.earth2me.essentials.IEssentialsModule;
|
2011-07-15 23:33:22 +00:00
|
|
|
import java.util.logging.Level;
|
|
|
|
import java.util.logging.Logger;
|
2011-12-06 12:41:29 +00:00
|
|
|
import org.bukkit.Bukkit;
|
2011-07-15 23:33:22 +00:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2011-03-19 22:39:51 +00:00
|
|
|
import org.bukkit.event.Event.Priority;
|
|
|
|
import org.bukkit.event.Event.Type;
|
2011-07-15 23:33:22 +00:00
|
|
|
import org.bukkit.plugin.PluginManager;
|
|
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
public class EssentialsSpawn extends JavaPlugin
|
|
|
|
{
|
2011-12-06 12:41:29 +00:00
|
|
|
private static final Logger LOGGER = Bukkit.getLogger();
|
2011-07-15 23:33:22 +00:00
|
|
|
private transient IEssentials ess;
|
2011-12-06 12:41:29 +00:00
|
|
|
private transient SpawnStorage spawns;
|
2011-03-19 22:39:51 +00:00
|
|
|
|
|
|
|
public void onEnable()
|
|
|
|
{
|
2011-07-15 23:33:22 +00:00
|
|
|
final PluginManager pluginManager = getServer().getPluginManager();
|
|
|
|
ess = (IEssentials)pluginManager.getPlugin("Essentials");
|
|
|
|
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
|
|
|
|
{
|
2011-11-21 01:55:26 +00:00
|
|
|
LOGGER.log(Level.WARNING, _("versionMismatchAll"));
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
2011-12-06 12:41:29 +00:00
|
|
|
if (!ess.isEnabled())
|
|
|
|
{
|
2011-11-30 19:48:42 +00:00
|
|
|
this.setEnabled(false);
|
|
|
|
return;
|
|
|
|
}
|
2011-12-06 12:41:29 +00:00
|
|
|
|
|
|
|
spawns = new SpawnStorage(ess);
|
2011-12-06 13:39:52 +00:00
|
|
|
ess.addReloadListener(spawns);
|
2011-12-06 12:41:29 +00:00
|
|
|
|
|
|
|
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
|
2011-11-30 19:48:42 +00:00
|
|
|
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.Low, this);
|
|
|
|
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this);
|
|
|
|
|
2011-11-21 01:55:26 +00:00
|
|
|
LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void onDisable()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2011-12-06 12:41:29 +00:00
|
|
|
public boolean onCommand(final CommandSender sender, final Command command,
|
|
|
|
final String commandLabel, final String[] args)
|
2011-03-19 22:39:51 +00:00
|
|
|
{
|
2011-12-06 12:41:29 +00:00
|
|
|
return ess.onCommandEssentials(sender, command, commandLabel, args, EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials.", spawns);
|
2011-03-19 22:39:51 +00:00
|
|
|
}
|
|
|
|
}
|