Merge branch 'master' into release

This commit is contained in:
KHobbits 2012-02-02 11:41:18 +00:00
commit 6ca1cdec4f
18 changed files with 88 additions and 46 deletions

View File

@ -61,7 +61,7 @@ import org.yaml.snakeyaml.error.YAMLException;
public class Essentials extends JavaPlugin implements IEssentials public class Essentials extends JavaPlugin implements IEssentials
{ {
public static final int BUKKIT_VERSION = 1818; public static final int BUKKIT_VERSION = 1846;
private static final Logger LOGGER = Logger.getLogger("Minecraft"); private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient ISettings settings; private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this); private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);

View File

@ -110,9 +110,10 @@ public class EssentialsConf extends Configuration
super.load(); super.load();
} }
catch (RuntimeException e) catch (RuntimeException e)
{ {
LOGGER.log(Level.SEVERE, "File broken: " + configFile.toString()); File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis());
throw e; configFile.renameTo(broken);
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), e.getCause());
} }
if (this.root == null) if (this.root == null)

View File

@ -3,6 +3,7 @@ package com.earth2me.essentials;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
import java.util.logging.Level;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -22,10 +23,17 @@ public class EssentialsTimer implements Runnable
final long currentTime = System.currentTimeMillis(); final long currentTime = System.currentTimeMillis();
for (Player player : ess.getServer().getOnlinePlayers()) for (Player player : ess.getServer().getOnlinePlayers())
{ {
final User user = ess.getUser(player); try
onlineUsers.add(user); {
user.setLastOnlineActivity(currentTime); final User user = ess.getUser(player);
user.checkActivity(); onlineUsers.add(user);
user.setLastOnlineActivity(currentTime);
user.checkActivity();
}
catch (Exception e)
{
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
}
} }
final Iterator<User> iterator = onlineUsers.iterator(); final Iterator<User> iterator = onlineUsers.iterator();

View File

@ -1,18 +1,24 @@
package com.earth2me.essentials; package com.earth2me.essentials;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IJails; import com.earth2me.essentials.api.IJails;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder; import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
import static com.earth2me.essentials.I18n._;
import java.io.File; import java.io.File;
import java.util.*; import java.util.*;
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;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.event.Event.Priority; import org.bukkit.event.EventHandler;
import org.bukkit.event.Event.Type; import org.bukkit.event.EventPriority;
import org.bukkit.event.block.*; import org.bukkit.event.Listener;
import org.bukkit.event.player.*; import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerRespawnEvent;
import org.bukkit.event.player.PlayerTeleportEvent;
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause; import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.PluginManager;
@ -33,13 +39,8 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
final PluginManager pluginManager = ess.getServer().getPluginManager(); final PluginManager pluginManager = ess.getServer().getPluginManager();
final JailBlockListener blockListener = new JailBlockListener(); final JailBlockListener blockListener = new JailBlockListener();
final JailPlayerListener playerListener = new JailPlayerListener(); final JailPlayerListener playerListener = new JailPlayerListener();
pluginManager.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Low, ess); pluginManager.registerEvents(blockListener, ess);
pluginManager.registerEvent(Type.BLOCK_DAMAGE, blockListener, Priority.Low, ess); pluginManager.registerEvents(playerListener, ess);
pluginManager.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Low, ess);
pluginManager.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, ess);
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.High, ess);
pluginManager.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, ess);
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.High, ess);
} }
@Override @Override
@ -146,9 +147,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
} }
private class JailBlockListener extends BlockListener private class JailBlockListener implements Listener
{ {
@Override @EventHandler(priority = EventPriority.LOW)
public void onBlockBreak(final BlockBreakEvent event) public void onBlockBreak(final BlockBreakEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
@ -158,7 +159,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
} }
} }
@Override @EventHandler(priority = EventPriority.LOW)
public void onBlockPlace(final BlockPlaceEvent event) public void onBlockPlace(final BlockPlaceEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
@ -168,7 +169,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
} }
} }
@Override @EventHandler(priority = EventPriority.LOW)
public void onBlockDamage(final BlockDamageEvent event) public void onBlockDamage(final BlockDamageEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
@ -180,9 +181,9 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
} }
private class JailPlayerListener extends PlayerListener private class JailPlayerListener implements Listener
{ {
@Override @EventHandler(priority = EventPriority.LOW)
public void onPlayerInteract(final PlayerInteractEvent event) public void onPlayerInteract(final PlayerInteractEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
@ -192,7 +193,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
} }
} }
@Override @EventHandler(priority = EventPriority.HIGH)
public void onPlayerRespawn(final PlayerRespawnEvent event) public void onPlayerRespawn(final PlayerRespawnEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
@ -207,11 +208,18 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
} }
catch (Exception ex) catch (Exception ex)
{ {
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex); if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
}
} }
} }
@Override @EventHandler(priority = EventPriority.HIGH)
public void onPlayerTeleport(final PlayerTeleportEvent event) public void onPlayerTeleport(final PlayerTeleportEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
@ -226,12 +234,19 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
} }
catch (Exception ex) catch (Exception ex)
{ {
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex); if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
}
} }
user.sendMessage(_("jailMessage")); user.sendMessage(_("jailMessage"));
} }
@Override @EventHandler(priority = EventPriority.HIGH)
public void onPlayerJoin(final PlayerJoinEvent event) public void onPlayerJoin(final PlayerJoinEvent event)
{ {
final User user = ess.getUser(event.getPlayer()); final User user = ess.getUser(event.getPlayer());
@ -246,7 +261,14 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
} }
catch (Exception ex) catch (Exception ex)
{ {
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex); if (ess.getSettings().isDebug())
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
}
else
{
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
}
} }
user.sendMessage(_("jailMessage")); user.sendMessage(_("jailMessage"));
} }

View File

@ -544,6 +544,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
public boolean canBuild() public boolean canBuild()
{ {
if (isOp())
{
return true;
}
return ess.getPermissionsHandler().canBuild(base, getGroup()); return ess.getPermissionsHandler().canBuild(base, getGroup());
} }

View File

@ -21,11 +21,17 @@ public class Util
{ {
} }
private final static Logger logger = Logger.getLogger("Minecraft"); private final static Logger logger = Logger.getLogger("Minecraft");
private final static Pattern INVALIDCHARS = Pattern.compile("[^a-z0-9]"); private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");;
public static String sanitizeFileName(final String name) public static String sanitizeFileName(final String name)
{ {
return INVALIDCHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_"); return INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
}
public static String sanitizeString(final String string)
{
return INVALIDCHARS.matcher(string).replaceAll("");
} }
public static String formatDateDiff(long date) public static String formatDateDiff(long date)

View File

@ -40,7 +40,7 @@ public class Commandmail extends EssentialsCommand
{ {
if (!user.isAuthorized("essentials.mail.send")) if (!user.isAuthorized("essentials.mail.send"))
{ {
throw new Exception(_("noPerm","essentials.mail.send")); throw new Exception(_("noPerm", "essentials.mail.send"));
} }
Player player = server.getPlayer(args[1]); Player player = server.getPlayer(args[1]);
@ -59,7 +59,8 @@ public class Commandmail extends EssentialsCommand
} }
if (!u.isIgnoredPlayer(user.getName())) if (!u.isIgnoredPlayer(user.getName()))
{ {
u.addMail(user.getName() + ": " + Util.stripColor(getFinalArg(args, 2))); final String mail = Util.sanitizeString(Util.stripColor(getFinalArg(args, 2)));
u.addMail(user.getName() + ": " + mail);
} }
user.sendMessage(_("mailSent")); user.sendMessage(_("mailSent"));
return; return;
@ -68,7 +69,7 @@ public class Commandmail extends EssentialsCommand
{ {
if (!user.isAuthorized("essentials.mail.sendall")) if (!user.isAuthorized("essentials.mail.sendall"))
{ {
throw new Exception(_("noPerm","essentials.mail.sendall")); throw new Exception(_("noPerm", "essentials.mail.sendall"));
} }
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1)))); ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
user.sendMessage(_("mailSent")); user.sendMessage(_("mailSent"));

View File

@ -80,7 +80,7 @@ public class Commandrepair extends EssentialsCommand
private void repairItem(final ItemStack item) throws Exception private void repairItem(final ItemStack item) throws Exception
{ {
final Material material = Material.getMaterial(item.getTypeId()); final Material material = Material.getMaterial(item.getTypeId());
if (material.isBlock() || material.getMaxDurability() < 0) if (material.isBlock() || material.getMaxDurability() < 1)
{ {
throw new Exception(_("repairInvalidType")); throw new Exception(_("repairInvalidType"));
} }

View File

@ -129,7 +129,7 @@ public class SignProtection extends EssentialsSign
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
{ {
final BlockSign sign = new BlockSign(block); final BlockSign sign = new BlockSign(block);
if (sign.getLine(0).equalsIgnoreCase(this.getSuccessName())) if (sign.getLine(0).equals(this.getSuccessName()))
{ {
return checkProtectionSign(sign, user, username); return checkProtectionSign(sign, user, username);
} }

View File

@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} denied your teleport request.
requestSent=\u00a77Request sent to {0}\u00a77. requestSent=\u00a77Request sent to {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit= * ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org. requiredBukkit= * ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Error occurred when trying to return player to jail. returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=second second=second
seconds=seconds seconds=seconds
seenOffline=Player {0} is offline since {1} seenOffline=Player {0} is offline since {1}

View File

@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} afviste din anmodning om teleport.
requestSent=\u00a77Anmodning sendt til {0}\u00a77. requestSent=\u00a77Anmodning sendt til {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org. requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=En fejl opstod ved fors\u00f8g p\u00e5 at returnere spilleren til f\u00e6ngsel. returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=sekund second=sekund
seconds=sekunder seconds=sekunder
seenOffline=Spilleren {0} har v\u00c3\u00a6ret offline i {1} seenOffline=Spilleren {0} har v\u00c3\u00a6ret offline i {1}

View File

@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} hat deine Teleportierungsanfrage abgelehnt.
requestSent=\u00a77Anfrage gesendet an {0}\u00a77. requestSent=\u00a77Anfrage gesendet an {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org. requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Fehler beim Versuch, den Spieler ins Gef\u00e4ngnis zu teleportieren. returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=Sekunde second=Sekunde
seconds=Sekunden seconds=Sekunden
seenOffline=Spieler {0} ist offline seit {1} seenOffline=Spieler {0} ist offline seit {1}

View File

@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} denied your teleport request
requestSent=\u00a77Request sent to {0}\u00a77. requestSent=\u00a77Request sent to {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org. requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Error occurred when trying to return player to jail. returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=second second=second
seconds=seconds seconds=seconds
seenOffline=Player {0} is offline since {1} seenOffline=Player {0} is offline since {1}

View File

@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} ha denegado tu peticion de teletransporte.
requestSent=\u00a77Peticion enviada a {0}\u00a77. requestSent=\u00a77Peticion enviada a {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org. requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Error al intentar quitar al jugador de la carcel. returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=segundo second=segundo
seconds=segundos seconds=segundos
seenOffline=El jugador {0} esta desconectado desde {1} seenOffline=El jugador {0} esta desconectado desde {1}

View File

@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} a refus\u00e9 votre demande de t\u00e9l\u00e9portat
requestSent=\u00a77Requ\u00eate envoy\u00e9e \u00e0 {0}\u00a77. requestSent=\u00a77Requ\u00eate envoy\u00e9e \u00e0 {0}\u00a77.
requestTimedOut=\u00a7cLa de mande de t\u00e9l\u00e9portation a expir\u00e9. requestTimedOut=\u00a7cLa de mande de t\u00e9l\u00e9portation a expir\u00e9.
requiredBukkit=* ! * Vous avez besoin au moins de la version {0} de CraftBukkit. T\u00e9l\u00e9chargez-la ici http://ci.bukkit.org. requiredBukkit=* ! * Vous avez besoin au moins de la version {0} de CraftBukkit. T\u00e9l\u00e9chargez-la ici http://ci.bukkit.org.
returnPlayerToJailError=Erreur survenue lors de la tentative d'emprisonner de nouveau un joueur. returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=seconde second=seconde
seconds=secondes seconds=secondes
seenOffline=Le joueur {0} est hors ligne depuis {1} seenOffline=Le joueur {0} est hors ligne depuis {1}

View File

@ -295,7 +295,7 @@ requestDeniedFrom=\u00a77{0} denied your teleport request.
requestSent=\u00a77Aanvraag verstuurd naar {0}\u00a77. requestSent=\u00a77Aanvraag verstuurd naar {0}\u00a77.
requestTimedOut=\u00a7cTeleport request has timed out requestTimedOut=\u00a7cTeleport request has timed out
requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org. requiredBukkit=* ! * You need atleast build {0} of CraftBukkit, download it from http://ci.bukkit.org.
returnPlayerToJailError=Fout opgetreden bij terugzetten van speler in gevangenis. returnPlayerToJailError=Error occurred when trying to return player {0} to jail: {1}
second=seconde second=seconde
seconds=seconde seconds=seconde
seenOffline=Speler {0} is offline vanaf {1} seenOffline=Speler {0} is offline vanaf {1}

Binary file not shown.

Binary file not shown.