diff options
author | ementalo <suror@gmx.co.uk> | 2011-07-18 22:16:58 +0100 |
---|---|---|
committer | ementalo <suror@gmx.co.uk> | 2011-07-18 22:16:58 +0100 |
commit | 81cc5b1f28345640c20a762783af294ebd4da7e7 (patch) | |
tree | c0fd2df3db9c7cde972f6c8f302b9c9f2d94bd24 | |
parent | 7aea8a3fcee1bc72de87873a63a2b1c2bdbc96a8 (diff) | |
download | Essentials-81cc5b1f28345640c20a762783af294ebd4da7e7.tar Essentials-81cc5b1f28345640c20a762783af294ebd4da7e7.tar.gz Essentials-81cc5b1f28345640c20a762783af294ebd4da7e7.tar.lz Essentials-81cc5b1f28345640c20a762783af294ebd4da7e7.tar.xz Essentials-81cc5b1f28345640c20a762783af294ebd4da7e7.zip |
Add yet another way to get a user from our users list, Don't teleport an offline player when jailed
Added playerjoin to jaillistener to teleport a player on login
6 files changed, 38 insertions, 4 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Essentials.java b/Essentials/src/com/earth2me/essentials/Essentials.java index 1bd909f05..f13075b03 100644 --- a/Essentials/src/com/earth2me/essentials/Essentials.java +++ b/Essentials/src/com/earth2me/essentials/Essentials.java @@ -217,6 +217,7 @@ public class Essentials extends JavaPlugin implements IEssentials pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.Low, this); pm.registerEvent(Type.PLAYER_RESPAWN, jailPlayerListener, Priority.High, this); pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this); + pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this); if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2) { diff --git a/Essentials/src/com/earth2me/essentials/Jail.java b/Essentials/src/com/earth2me/essentials/Jail.java index a73bb0948..f867a68fd 100644 --- a/Essentials/src/com/earth2me/essentials/Jail.java +++ b/Essentials/src/com/earth2me/essentials/Jail.java @@ -42,7 +42,10 @@ public class Jail extends BlockListener implements IConf public void sendToJail(User user, String jail) throws Exception { - user.getTeleport().now(getJail(jail)); + if (user.getLastActivity() > 0) + { + user.getTeleport().now(getJail(jail)); + } user.setJail(jail); } diff --git a/Essentials/src/com/earth2me/essentials/JailPlayerListener.java b/Essentials/src/com/earth2me/essentials/JailPlayerListener.java index 5ba333952..da8c165cb 100644 --- a/Essentials/src/com/earth2me/essentials/JailPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/JailPlayerListener.java @@ -3,6 +3,7 @@ package com.earth2me.essentials; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerListener; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.event.player.PlayerTeleportEvent; @@ -62,6 +63,22 @@ public class JailPlayerListener extends PlayerListener } user.sendMessage(Util.i18n("jailMessage")); } - - + + @Override + public void onPlayerJoin(final PlayerJoinEvent event) + { + User u = ess.getUser(event.getPlayer()); + if (u.isJailed()) + { + try + { + ess.getJail().sendToJail(u, u.getJail()); + } + catch (Exception ex) + { + LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex); + } + u.sendMessage(Util.i18n("jailMessage")); + } + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java index 42b5a1953..76fe766c3 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java @@ -15,6 +15,7 @@ public class Commandsetjail extends EssentialsCommand @Override public void run(Server server, User user, String commandLabel, String[] args) throws Exception { + if (args.length < 1) { throw new NotEnoughArgumentsException(); diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java index 899ac37dd..c994cabaa 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java @@ -74,7 +74,10 @@ public class Commandtogglejail extends EssentialsCommand p.setJailTimeout(0); p.sendMessage("§7You have been released"); p.setJail(null); - p.getTeleport().back(); + if (p.getLastActivity() > 0) + { + p.getTeleport().back(); + } sender.sendMessage("§7Player " + p.getName() + " unjailed."); } } diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java index 5ea2bf8b0..23f0b5014 100644 --- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java +++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java @@ -41,6 +41,15 @@ public abstract class EssentialsCommand implements IEssentialsCommand protected User getPlayer(Server server, String[] args, int pos, boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException { if (args.length <= pos) throw new NotEnoughArgumentsException(); + User user = ess.getAllUsers().get(args[pos]); + if (user != null) + { + if(user.isHidden()) + { + throw new NoSuchFieldException(Util.i18n("playerNotFound")); + } + return user; + } List<Player> matches = server.matchPlayer(args[pos]); if (matches.size() < 1) |