mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-08-03 02:55:46 +00:00
Heavy cleanup of all classes
ItemDb is not static anymore Essentials.getStatic() removed
This commit is contained in:
parent
25c9557c59
commit
a38fe6acd4
48 changed files with 330 additions and 294 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue