1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-27 22:59:18 +02:00

Updated all modules to new api, some settings are still missing

This commit is contained in:
snowleo
2011-12-14 16:31:08 +01:00
parent 9ab2fe54fc
commit 0155bcedb7
23 changed files with 106 additions and 88 deletions

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.chat; package com.earth2me.essentials.chat;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentSkipListMap; import java.util.concurrent.ConcurrentSkipListMap;

View File

@@ -2,9 +2,9 @@ package com.earth2me.essentials.chat;
import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.ChargeException;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Location; import org.bukkit.Location;
@@ -53,7 +53,7 @@ public abstract class EssentialsChatPlayer extends PlayerListener
} }
} }
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
if (!isAffordableFor(user, command)) if (!isAffordableFor(user, command))
{ {
event.setCancelled(true); event.setCancelled(true);
@@ -106,7 +106,7 @@ public abstract class EssentialsChatPlayer extends PlayerListener
return true; return true;
} }
protected void sendLocalChat(final User sender, final long radius, final PlayerChatEvent event) protected void sendLocalChat(final IUser sender, final long radius, final PlayerChatEvent event)
{ {
event.setCancelled(true); event.setCancelled(true);
logger.info(_("localFormat", sender.getName(), event.getMessage())); logger.info(_("localFormat", sender.getName(), event.getMessage()));
@@ -116,9 +116,9 @@ public abstract class EssentialsChatPlayer extends PlayerListener
for (Player onlinePlayer : server.getOnlinePlayers()) for (Player onlinePlayer : server.getOnlinePlayers())
{ {
String type = "[L]"; String type = "[L]";
final User user = ess.getUser(onlinePlayer); final IUser user = ess.getUser(onlinePlayer);
//TODO: remove reference to op //TODO: remove reference to op
if (user.isIgnoredPlayer(sender.getName()) && !sender.isOp()) if (user.isIgnoringPlayer(sender.getName()) && !sender.isOp())
{ {
continue; continue;
} }

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.chat; package com.earth2me.essentials.chat;
import com.earth2me.essentials.ChargeException; import com.earth2me.essentials.ChargeException;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import java.util.Map; import java.util.Map;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
@@ -37,7 +37,7 @@ public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer
/** /**
* This file should handle charging the user for the action before returning control back * This file should handle charging the user for the action before returning control back
*/ */
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
try try
{ {
@@ -45,7 +45,7 @@ public class EssentialsChatPlayerListenerHighest extends EssentialsChatPlayer
} }
catch (ChargeException e) catch (ChargeException e)
{ {
ess.showError(user, e, charge); ess.getCommandHandler().showCommandError(user, charge, e);
event.setCancelled(true); event.setCancelled(true);
return; return;
} }

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.chat; package com.earth2me.essentials.chat;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.bukkit.Server; import org.bukkit.Server;
@@ -28,7 +28,7 @@ public class EssentialsChatPlayerListenerLowest extends EssentialsChatPlayer
/** /**
* This listener should apply the general chat formatting only...then return control back the event handler * This listener should apply the general chat formatting only...then return control back the event handler
*/ */
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
if (user.isAuthorized("essentials.chat.color")) if (user.isAuthorized("essentials.chat.color"))
{ {
event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "\u00a7$1")); event.setMessage(event.getMessage().replaceAll("&([0-9a-f])", "\u00a7$1"));

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.chat; package com.earth2me.essentials.chat;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import java.util.Locale; import java.util.Locale;
import java.util.Map; import java.util.Map;
import org.bukkit.Server; import org.bukkit.Server;
@@ -48,7 +48,7 @@ public class EssentialsChatPlayerListenerNormal extends EssentialsChatPlayer
return; return;
} }
radius *= radius; radius *= radius;
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
if (event.getMessage().length() > 0 && chatType.length() > 0) if (event.getMessage().length() > 0 && chatType.length() > 0)
{ {

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.geoip; package com.earth2me.essentials.geoip;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.event.Event.Priority; import org.bukkit.event.Event.Priority;

View File

@@ -2,9 +2,9 @@ package com.earth2me.essentials.geoip;
import com.earth2me.essentials.EssentialsConf; import com.earth2me.essentials.EssentialsConf;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IConf; import com.earth2me.essentials.api.IReload;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import com.maxmind.geoip.Location; import com.maxmind.geoip.Location;
import com.maxmind.geoip.LookupService; import com.maxmind.geoip.LookupService;
import com.maxmind.geoip.regionName; import com.maxmind.geoip.regionName;
@@ -21,7 +21,7 @@ import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
public class EssentialsGeoIPPlayerListener extends PlayerListener implements IConf public class EssentialsGeoIPPlayerListener extends PlayerListener implements IReload
{ {
LookupService ls = null; LookupService ls = null;
private static final Logger logger = Logger.getLogger("Minecraft"); private static final Logger logger = Logger.getLogger("Minecraft");
@@ -36,13 +36,13 @@ public class EssentialsGeoIPPlayerListener extends PlayerListener implements ICo
this.dataFolder = dataFolder; this.dataFolder = dataFolder;
this.config = new EssentialsConf(new File(dataFolder, "config.yml")); this.config = new EssentialsConf(new File(dataFolder, "config.yml"));
config.setTemplateName("/config.yml", EssentialsGeoIP.class); config.setTemplateName("/config.yml", EssentialsGeoIP.class);
reloadConfig(); onReload();
} }
@Override @Override
public void onPlayerJoin(PlayerJoinEvent event) public void onPlayerJoin(PlayerJoinEvent event)
{ {
User u = ess.getUser(event.getPlayer()); IUser u = ess.getUser(event.getPlayer());
if (u.isAuthorized("essentials.geoip.hide")) if (u.isAuthorized("essentials.geoip.hide"))
{ {
return; return;
@@ -73,13 +73,21 @@ public class EssentialsGeoIPPlayerListener extends PlayerListener implements ICo
} }
if (config.getBoolean("show-on-whois", true)) if (config.getBoolean("show-on-whois", true))
{ {
u.setGeoLocation(sb.toString()); u.acquireWriteLock();
try
{
u.getData().setGeolocation(sb.toString());
}
finally
{
u.unlock();
}
} }
if (config.getBoolean("show-on-login", true) && !u.isHidden()) if (config.getBoolean("show-on-login", true) && !u.isHidden())
{ {
for (Player player : event.getPlayer().getServer().getOnlinePlayers()) for (Player player : event.getPlayer().getServer().getOnlinePlayers())
{ {
User user = ess.getUser(player); IUser user = ess.getUser(player);
if (user.isAuthorized("essentials.geoip.show")) if (user.isAuthorized("essentials.geoip.show"))
{ {
user.sendMessage(_("geoipJoinFormat", u.getDisplayName(), sb.toString())); user.sendMessage(_("geoipJoinFormat", u.getDisplayName(), sb.toString()));
@@ -89,7 +97,7 @@ public class EssentialsGeoIPPlayerListener extends PlayerListener implements ICo
} }
@Override @Override
public final void reloadConfig() public final void onReload()
{ {
config.load(); config.load();

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.protect; package com.earth2me.essentials.protect;
import com.earth2me.essentials.IConf; import com.earth2me.essentials.api.IReload;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.protect.data.ProtectedBlockMemory; import com.earth2me.essentials.protect.data.ProtectedBlockMemory;
import com.earth2me.essentials.protect.data.ProtectedBlockMySQL; import com.earth2me.essentials.protect.data.ProtectedBlockMySQL;
import com.earth2me.essentials.protect.data.ProtectedBlockSQLite; import com.earth2me.essentials.protect.data.ProtectedBlockSQLite;
@@ -45,7 +45,7 @@ public class EssentialsConnect
return ess; return ess;
} }
public void alert(final User user, final String item, final String type) public void alert(final IUser user, final String item, final String type)
{ {
final Location loc = user.getLocation(); final Location loc = user.getLocation();
final String warnMessage = _("alertFormat", user.getName(), type, item, final String warnMessage = _("alertFormat", user.getName(), type, item,
@@ -54,7 +54,7 @@ public class EssentialsConnect
LOGGER.log(Level.WARNING, warnMessage); LOGGER.log(Level.WARNING, warnMessage);
for (Player p : ess.getServer().getOnlinePlayers()) for (Player p : ess.getServer().getOnlinePlayers())
{ {
final User alertUser = ess.getUser(p); final IUser alertUser = ess.getUser(p);
if (alertUser.isAuthorized("essentials.protect.alerts")) if (alertUser.isAuthorized("essentials.protect.alerts"))
{ {
alertUser.sendMessage(warnMessage); alertUser.sendMessage(warnMessage);
@@ -63,10 +63,10 @@ public class EssentialsConnect
} }
private class ProtectReloader implements IConf private class ProtectReloader implements IReload
{ {
@Override @Override
public void reloadConfig() public void onReload()
{ {
if (protect.getStorage() != null) if (protect.getStorage() != null)
{ {

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.protect; package com.earth2me.essentials.protect;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.protect.data.IProtectedBlock; import com.earth2me.essentials.protect.data.IProtectedBlock;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@@ -31,7 +31,7 @@ public class EssentialsProtectBlockListener extends BlockListener
return; return;
} }
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild()) if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild())
{ {
@@ -228,7 +228,7 @@ public class EssentialsProtectBlockListener extends BlockListener
{ {
return; return;
} }
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild()) if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild())
{ {

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.protect; package com.earth2me.essentials.protect;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.craftbukkit.FakeExplosion; import com.earth2me.essentials.craftbukkit.FakeExplosion;
import java.util.Locale; import java.util.Locale;
import org.bukkit.Material; import org.bukkit.Material;
@@ -39,7 +39,7 @@ public class EssentialsProtectEntityListener extends EntityListener
return; return;
} }
final User user = ess.getUser(target); final IUser user = target instanceof Player ? ess.getUser((Player)target) : null;
if (event instanceof EntityDamageByBlockEvent) if (event instanceof EntityDamageByBlockEvent)
{ {
final DamageCause cause = event.getCause(); final DamageCause cause = event.getCause();
@@ -77,7 +77,7 @@ public class EssentialsProtectEntityListener extends EntityListener
{ {
final EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event; final EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
final Entity eAttack = edEvent.getDamager(); final Entity eAttack = edEvent.getDamager();
final User attacker = ess.getUser(eAttack); final IUser attacker = eAttack instanceof Player ? ess.getUser((Player)eAttack) : null;
// PVP Settings // PVP Settings
if (target instanceof Player && eAttack instanceof Player if (target instanceof Player && eAttack instanceof Player
@@ -134,7 +134,7 @@ public class EssentialsProtectEntityListener extends EntityListener
|| (((Projectile)edEvent.getDamager()).getShooter() instanceof Player || (((Projectile)edEvent.getDamager()).getShooter() instanceof Player
&& prot.getSettingBool(ProtectConfig.disable_pvp) && prot.getSettingBool(ProtectConfig.disable_pvp)
&& (!user.isAuthorized("essentials.protect.pvp") && (!user.isAuthorized("essentials.protect.pvp")
|| !ess.getUser(((Projectile)edEvent.getDamager()).getShooter()).isAuthorized("essentials.protect.pvp"))))) || !ess.getUser((Player)((Projectile)edEvent.getDamager()).getShooter()).isAuthorized("essentials.protect.pvp")))))
{ {
event.setCancelled(true); event.setCancelled(true);
return; return;
@@ -299,7 +299,7 @@ public class EssentialsProtectEntityListener extends EntityListener
{ {
return; return;
} }
final User user = ess.getUser(event.getTarget()); final IUser user = ess.getUser((Player)event.getTarget());
if ((event.getReason() == TargetReason.CLOSEST_PLAYER if ((event.getReason() == TargetReason.CLOSEST_PLAYER
|| event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY || event.getReason() == TargetReason.TARGET_ATTACKED_ENTITY
|| event.getReason() == TargetReason.PIG_ZOMBIE_TARGET || event.getReason() == TargetReason.PIG_ZOMBIE_TARGET

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.protect; package com.earth2me.essentials.protect;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
@@ -26,7 +26,7 @@ public class EssentialsProtectPlayerListener extends PlayerListener
public void onPlayerInteract(final PlayerInteractEvent event) public void onPlayerInteract(final PlayerInteractEvent event)
{ {
// Do not return if cancelled, because the interact event has 2 cancelled states. // Do not return if cancelled, because the interact event has 2 cancelled states.
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
if (event.hasItem() if (event.hasItem()
&& (event.getItem().getType() == Material.WATER_BUCKET && (event.getItem().getType() == Material.WATER_BUCKET

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.spawn; package com.earth2me.essentials.spawn;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.EssentialsCommand;
import org.bukkit.Server; import org.bukkit.Server;
@@ -14,7 +14,7 @@ public class Commandsetspawn extends EssentialsCommand
} }
@Override @Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception
{ {
final String group = args.length > 0 ? getFinalArg(args, 0) : "default"; final String group = args.length > 0 ? getFinalArg(args, 0) : "default";
((SpawnStorage)module).setSpawn(user.getLocation(), group); ((SpawnStorage)module).setSpawn(user.getLocation(), group);

View File

@@ -2,7 +2,7 @@ package com.earth2me.essentials.spawn;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.Trade; import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.NotEnoughArgumentsException; import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import org.bukkit.Location; import org.bukkit.Location;
@@ -19,13 +19,13 @@ public class Commandspawn extends EssentialsCommand
} }
@Override @Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception public void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws Exception
{ {
final Trade charge = new Trade(this.getName(), ess); final Trade charge = new Trade(this.getName(), ess);
charge.isAffordableFor(user); charge.isAffordableFor(user);
if (args.length > 0 && user.isAuthorized("essentials.spawn.others")) if (args.length > 0 && user.isAuthorized("essentials.spawn.others"))
{ {
final User otherUser = getPlayer(server, args, 0); final IUser otherUser = getPlayer(server, args, 0);
respawn(otherUser, null); respawn(otherUser, null);
if (!otherUser.equals(user)) if (!otherUser.equals(user))
{ {
@@ -46,13 +46,13 @@ public class Commandspawn extends EssentialsCommand
{ {
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
final User user = getPlayer(server, args, 0); final IUser user = getPlayer(server, args, 0);
respawn(user, null); respawn(user, null);
user.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn")); user.sendMessage(_("teleportAtoB", user.getDisplayName(), "spawn"));
sender.sendMessage(_("teleporting")); sender.sendMessage(_("teleporting"));
} }
private void respawn (final User user, final Trade charge) throws Exception { private void respawn (final IUser user, final Trade charge) throws Exception {
final SpawnStorage spawns = (SpawnStorage)this.module; final SpawnStorage spawns = (SpawnStorage)this.module;
final Location spawn = spawns.getSpawn(user.getGroup()); final Location spawn = spawns.getSpawn(user.getGroup());
user.getTeleport().teleport(spawn, charge, TeleportCause.COMMAND); user.getTeleport().teleport(spawn, charge, TeleportCause.COMMAND);

View File

@@ -1,8 +1,10 @@
package com.earth2me.essentials.spawn; package com.earth2me.essentials.spawn;
import com.earth2me.essentials.EssentialsCommandHandler;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.ICommandHandler;
import com.earth2me.essentials.IEssentialsModule; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IEssentialsModule;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@@ -19,6 +21,7 @@ public class EssentialsSpawn extends JavaPlugin
private static final Logger LOGGER = Bukkit.getLogger(); private static final Logger LOGGER = Bukkit.getLogger();
private transient IEssentials ess; private transient IEssentials ess;
private transient SpawnStorage spawns; private transient SpawnStorage spawns;
private transient ICommandHandler commandHandler;
public void onEnable() public void onEnable()
{ {
@@ -37,6 +40,8 @@ public class EssentialsSpawn extends JavaPlugin
spawns = new SpawnStorage(ess); spawns = new SpawnStorage(ess);
ess.addReloadListener(spawns); ess.addReloadListener(spawns);
commandHandler = new EssentialsCommandHandler(EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials.", spawns, ess);
final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns); final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns);
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, ess.getSettings().getRespawnPriority(), this); pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, ess.getSettings().getRespawnPriority(), this);
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this); pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this);
@@ -52,6 +57,6 @@ public class EssentialsSpawn extends JavaPlugin
public boolean onCommand(final CommandSender sender, final Command command, public boolean onCommand(final CommandSender sender, final Command command,
final String commandLabel, final String[] args) final String commandLabel, final String[] args)
{ {
return ess.onCommandEssentials(sender, command, commandLabel, args, EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials.", spawns); return commandHandler.handleCommand(sender, command, commandLabel, args);
} }
} }

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.spawn; package com.earth2me.essentials.spawn;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import java.util.logging.Level; import java.util.logging.Level;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
@@ -27,7 +27,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
@Override @Override
public void onPlayerRespawn(final PlayerRespawnEvent event) public void onPlayerRespawn(final PlayerRespawnEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
if (ess.getSettings().getRespawnAtHome()) if (ess.getSettings().getRespawnAtHome())
{ {
@@ -52,7 +52,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
@Override @Override
public void onPlayerJoin(final PlayerJoinEvent event) public void onPlayerJoin(final PlayerJoinEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
if (!user.isNew() || user.getBedSpawnLocation() != null) if (!user.isNew() || user.getBedSpawnLocation() != null)
{ {
@@ -73,9 +73,9 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
private class NewPlayerTeleport implements Runnable private class NewPlayerTeleport implements Runnable
{ {
private final transient User user; private final transient IUser user;
public NewPlayerTeleport(final User user) public NewPlayerTeleport(final IUser user)
{ {
this.user = user; this.user = user;
} }

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.spawn; package com.earth2me.essentials.spawn;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.IEssentialsModule; import com.earth2me.essentials.api.IEssentialsModule;
import com.earth2me.essentials.settings.Spawns; import com.earth2me.essentials.settings.Spawns;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder; import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
import java.io.File; import java.io.File;
@@ -17,7 +17,7 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE
public SpawnStorage(final IEssentials ess) public SpawnStorage(final IEssentials ess)
{ {
super(ess, Spawns.class); super(ess, Spawns.class);
reloadConfig(); onReload();
} }
@Override @Override

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.xmpp; package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.commands.EssentialsCommand; import com.earth2me.essentials.commands.EssentialsCommand;
import com.earth2me.essentials.commands.NotEnoughArgumentsException; import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import org.bukkit.Server; import org.bukkit.Server;
@@ -14,7 +14,7 @@ public class Commandsetxmpp extends EssentialsCommand
} }
@Override @Override
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws NotEnoughArgumentsException protected void run(final Server server, final IUser user, final String commandLabel, final String[] args) throws NotEnoughArgumentsException
{ {
if (args.length < 1) if (args.length < 1)
{ {

View File

@@ -31,7 +31,7 @@ public class Commandxmpp extends EssentialsCommand
else else
{ {
final String message = getFinalArg(args, 1); final String message = getFinalArg(args, 1);
final String senderName = sender instanceof Player ? ess.getUser(sender).getDisplayName() : Console.NAME; final String senderName = sender instanceof Player ? ess.getUser((Player)sender).getDisplayName() : Console.NAME;
sender.sendMessage("[" + senderName + ">" + address + "] " + message); sender.sendMessage("[" + senderName + ">" + address + "] " + message);
if (!EssentialsXMPP.getInstance().sendMessage(address, "[" + senderName + "] " + message)) if (!EssentialsXMPP.getInstance().sendMessage(address, "[" + senderName + "] " + message))
{ {

View File

@@ -1,8 +1,10 @@
package com.earth2me.essentials.xmpp; package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.EssentialsCommandHandler;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.ICommandHandler;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.logging.Level; import java.util.logging.Level;
@@ -23,6 +25,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
private transient UserManager users; private transient UserManager users;
private transient XMPPManager xmpp; private transient XMPPManager xmpp;
private transient IEssentials ess; private transient IEssentials ess;
private transient ICommandHandler commandHandler;
public static IEssentialsXMPP getInstance() public static IEssentialsXMPP getInstance()
{ {
@@ -57,6 +60,8 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
ess.addReloadListener(users); ess.addReloadListener(users);
ess.addReloadListener(xmpp); ess.addReloadListener(xmpp);
commandHandler = new EssentialsCommandHandler(EssentialsXMPP.class.getClassLoader(), "com.earth2me.essentials.xmpp.Command", "essentials.", ess);
LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team")); LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team"));
} }
@@ -73,7 +78,7 @@ public class EssentialsXMPP extends JavaPlugin implements IEssentialsXMPP
@Override @Override
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args) public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
{ {
return ess.onCommandEssentials(sender, command, commandLabel, args, EssentialsXMPP.class.getClassLoader(), "com.earth2me.essentials.xmpp.Command", "essentials.", null); return commandHandler.handleCommand(sender, command, commandLabel, args);
} }
@Override @Override

View File

@@ -1,7 +1,7 @@
package com.earth2me.essentials.xmpp; package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.User; import com.earth2me.essentials.api.IUser;
import org.bukkit.event.player.PlayerChatEvent; import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerListener;
@@ -21,21 +21,21 @@ class EssentialsXMPPPlayerListener extends PlayerListener
@Override @Override
public void onPlayerJoin(final PlayerJoinEvent event) public void onPlayerJoin(final PlayerJoinEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
sendMessageToSpyUsers("Player " + user.getDisplayName() + " joined the game"); sendMessageToSpyUsers("Player " + user.getDisplayName() + " joined the game");
} }
@Override @Override
public void onPlayerChat(final PlayerChatEvent event) public void onPlayerChat(final PlayerChatEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
sendMessageToSpyUsers(String.format(event.getFormat(), user.getDisplayName(), event.getMessage())); sendMessageToSpyUsers(String.format(event.getFormat(), user.getDisplayName(), event.getMessage()));
} }
@Override @Override
public void onPlayerQuit(final PlayerQuitEvent event) public void onPlayerQuit(final PlayerQuitEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final IUser user = ess.getUser(event.getPlayer());
sendMessageToSpyUsers("Player " + user.getDisplayName() + " left the game"); sendMessageToSpyUsers("Player " + user.getDisplayName() + " left the game");
} }

View File

@@ -1,6 +1,6 @@
package com.earth2me.essentials.xmpp; package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.api.IUser;
import java.util.List; import java.util.List;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;

View File

@@ -1,12 +1,12 @@
package com.earth2me.essentials.xmpp; package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.EssentialsConf; import com.earth2me.essentials.EssentialsConf;
import com.earth2me.essentials.IConf; import com.earth2me.essentials.api.IReload;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
public class UserManager implements IConf public class UserManager implements IReload
{ {
private final transient EssentialsConf users; private final transient EssentialsConf users;
private final transient List<String> spyusers = new ArrayList<String>(); private final transient List<String> spyusers = new ArrayList<String>();
@@ -16,7 +16,7 @@ public class UserManager implements IConf
public UserManager(final File folder) public UserManager(final File folder)
{ {
users = new EssentialsConf(new File(folder, "users.yml")); users = new EssentialsConf(new File(folder, "users.yml"));
reloadConfig(); onReload();
} }
public final boolean isSpy(final String username) public final boolean isSpy(final String username)
@@ -65,11 +65,11 @@ public class UserManager implements IConf
userdata.put(SPY, spy); userdata.put(SPY, spy);
users.setProperty(username, userdata); users.setProperty(username, userdata);
users.save(); users.save();
reloadConfig(); onReload();
} }
@Override @Override
public final void reloadConfig() public final void onReload()
{ {
users.load(); users.load();
spyusers.clear(); spyusers.clear();

View File

@@ -2,8 +2,8 @@ package com.earth2me.essentials.xmpp;
import com.earth2me.essentials.Console; import com.earth2me.essentials.Console;
import com.earth2me.essentials.EssentialsConf; import com.earth2me.essentials.EssentialsConf;
import com.earth2me.essentials.IConf; import com.earth2me.essentials.api.IReload;
import com.earth2me.essentials.IUser; import com.earth2me.essentials.api.IUser;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
import java.util.logging.Handler; import java.util.logging.Handler;
@@ -18,7 +18,7 @@ import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils; import org.jivesoftware.smack.util.StringUtils;
public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IConf public class XMPPManager extends Handler implements MessageListener, ChatManagerListener, IReload
{ {
private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final Logger LOGGER = Logger.getLogger("Minecraft");
private final transient EssentialsConf config; private final transient EssentialsConf config;
@@ -39,7 +39,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
this.parent = parent; this.parent = parent;
config = new EssentialsConf(new File(parent.getDataFolder(), "config.yml")); config = new EssentialsConf(new File(parent.getDataFolder(), "config.yml"));
config.setTemplateName("/config.yml", EssentialsXMPP.class); config.setTemplateName("/config.yml", EssentialsXMPP.class);
reloadConfig(); onReload();
} }
public boolean sendMessage(final String address, final String message) public boolean sendMessage(final String address, final String message)
@@ -166,7 +166,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
} }
@Override @Override
public final void reloadConfig() public final void onReload()
{ {
LOGGER.removeHandler(this); LOGGER.removeHandler(this);
config.load(); config.load();