Merge branch 'master' into release

This commit is contained in:
snowleo 2011-07-19 00:42:10 +02:00
commit aa3606007a
8 changed files with 58 additions and 5 deletions

View File

@ -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)
{
@ -328,6 +329,7 @@ public class Essentials extends JavaPlugin implements IEssentials
}
}
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length - playerHidden));
m = m.replace("{UNIQUE}", Integer.toString(users.size()));
if (m.matches(".*\\{PLAYERLIST\\}.*"))
{

View File

@ -103,6 +103,11 @@ public final class InventoryWorkaround
for (int i = 0; i < combined.length; i++)
{
final ItemStack item = combined[i];
if (item == null)
{
continue;
}
while (true)
{
// Do we already have a stack of it?

View File

@ -41,8 +41,11 @@ public class Jail extends BlockListener implements IConf
}
public void sendToJail(User user, String jail) throws Exception
{
if (!(user.getBase() instanceof OfflinePlayer))
{
user.getTeleport().now(getJail(jail));
}
user.setJail(jail);
}

View File

@ -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;
@ -63,5 +64,21 @@ 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"));
}
}
}

View File

@ -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();

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
@ -74,7 +75,10 @@ public class Commandtogglejail extends EssentialsCommand
p.setJailTimeout(0);
p.sendMessage("§7You have been released");
p.setJail(null);
if (!(p.getBase() instanceof OfflinePlayer))
{
p.getTeleport().back();
}
sender.sendMessage("§7Player " + p.getName() + " unjailed.");
}
}

View File

@ -22,13 +22,25 @@ public class Commandwhois extends EssentialsCommand
{
throw new NotEnoughArgumentsException();
}
boolean showhidden = false;
if (sender instanceof Player)
{
if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
{
showhidden = true;
}
}
else
{
showhidden = true;
}
String whois = args[0].toLowerCase();
charge(sender);
int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length();
for (Player p : server.getOnlinePlayers())
{
User u = ess.getUser(p);
if (u.isHidden())
if (u.isHidden() && !showhidden)
{
continue;
}

View File

@ -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].toLowerCase());
if (user != null)
{
if(!getOffline && user.isHidden())
{
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
}
return user;
}
List<Player> matches = server.matchPlayer(args[pos]);
if (matches.size() < 1)