This commit is contained in:
Iaccidentally 2012-11-27 14:54:18 -05:00
commit 92bdd51cd4
20 changed files with 59 additions and 18 deletions

View file

@ -42,4 +42,6 @@ public interface IUser extends Player
Teleport getTeleport();
void setJail(String jail);
boolean isIgnoreExempt();
}

View file

@ -37,7 +37,7 @@ public class Kit
}
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws Exception
{
if (user.isAuthorized("essentials.kit.exemptdelay")) {
return;
@ -46,7 +46,7 @@ public class Kit
final Calendar time = new GregorianCalendar();
// Take the current time, and remove the delay from it.
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0.0d;
final Calendar earliestTime = new GregorianCalendar();
earliestTime.add(Calendar.SECOND, -(int)delay);
earliestTime.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
@ -56,7 +56,7 @@ public class Kit
// When was the last kit used?
final long lastTime = user.getKitTimestamp(kitName);
if (lastTime < earliestLong)
if (lastTime < earliestLong || lastTime == 0L)
{
user.setKitTimestamp(kitName, time.getTimeInMillis());
}
@ -66,6 +66,11 @@ public class Kit
// If this happens, let's give the user the benifit of the doubt.
user.setKitTimestamp(kitName, time.getTimeInMillis());
}
else if (earliestLong < 0L)
{
user.sendMessage(_("kitOnce"));
throw new NoChargeException();
}
else
{
time.setTimeInMillis(lastTime);

View file

@ -737,4 +737,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
{
this.rightClickJump = rightClickJump;
}
@Override
public boolean isIgnoreExempt()
{
return this.isAuthorized("essentials.chat.ignoreexempt");
}
}

View file

@ -49,23 +49,23 @@ public abstract class UserData extends PlayerExtension implements IConf
lastHealTimestamp = _getLastHealTimestamp();
jail = _getJail();
mails = _getMails();
teleportEnabled = getTeleportEnabled();
ignoredPlayers = getIgnoredPlayers();
teleportEnabled = _getTeleportEnabled();
godmode = _getGodModeEnabled();
muted = getMuted();
muted = _getMuted();
muteTimeout = _getMuteTimeout();
jailed = getJailed();
jailed = _getJailed();
jailTimeout = _getJailTimeout();
lastLogin = _getLastLogin();
lastLogout = _getLastLogout();
lastLoginAddress = _getLastLoginAddress();
afk = getAfk();
afk = _getAfk();
geolocation = _getGeoLocation();
isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC();
arePowerToolsEnabled = _arePowerToolsEnabled();
kitTimestamps = _getKitTimestamps();
nickname = _getNickname();
setIgnoredPlayers(_getIgnoredPlayers());
}
private double money;
@ -415,7 +415,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean teleportEnabled;
private boolean getTeleportEnabled()
private boolean _getTeleportEnabled()
{
return config.getBoolean("teleportenabled", true);
}
@ -447,7 +447,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private List<String> ignoredPlayers;
public List<String> getIgnoredPlayers()
public List<String> _getIgnoredPlayers()
{
return Collections.synchronizedList(config.getStringList("ignore"));
}
@ -480,7 +480,7 @@ public abstract class UserData extends PlayerExtension implements IConf
public boolean isIgnoredPlayer(IUser user)
{
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isAuthorized("essentials.chat.ignoreexempt"));
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isIgnoreExempt());
}
public void setIgnoredPlayer(IUser user, boolean set)
@ -515,10 +515,15 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean muted;
public boolean getMuted()
public boolean _getMuted()
{
return config.getBoolean("muted", false);
}
public boolean getMuted()
{
return muted;
}
public boolean isMuted()
{
@ -551,7 +556,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean jailed;
private boolean getJailed()
private boolean _getJailed()
{
return config.getBoolean("jailed", false);
}
@ -678,7 +683,7 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean afk;
private boolean getAfk()
private boolean _getAfk()
{
return config.getBoolean("afk", false);
}

View file

@ -605,6 +605,7 @@ public class Util
}
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
private static transient final Pattern LOGCOLOR_PATTERN = Pattern.compile("\\x1B\\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]");
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
@ -622,6 +623,15 @@ public class Util
return VANILLA_PATTERN.matcher(input).replaceAll("");
}
public static String stripLogColorFormat(final String input)
{
if (input == null)
{
return null;
}
return LOGCOLOR_PATTERN.matcher(input).replaceAll("");
}
public static String replaceFormat(final String input)
{
if (input == null)

View file

@ -92,8 +92,8 @@ disabled-commands:
# - nick
# If you do not wish to use a permission system, you can define a list of 'player perms' below.
# This list has no effect if your using a supported permissions system.
# If your using an unsupported permissions system simply delete this section.
# This list has no effect if you are using a supported permissions system.
# If you are using an unsupported permissions system simply delete this section.
# Whitelist the commands and permissions you wish to give players by default (everything else is op only).
# These are the permissions without the "essentials." part.
player-commands:

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -465,3 +465,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Nombre de warp invalido
userUnknown=\u00a74Peligro: El jugador '\u00a7c{0}\u00a74' Nunca a ingresado a este servidor.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Nom de warp invalide
userUnknown=\u00a74Attention : Le joueur '\u00a7c{0}\u00a74' n'est jamais venu sur ce serveur.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -462,3 +462,4 @@ invalidWarpName=\u00a74Invalid warp name
userUnknown=\u00a74Warning: The user '\u00a7c{0}\u00a74' has never joined this server.
teleportationEnabledFor=\u00a76Teleportation enabled for {0}
teleportationDisabledFor=\u00a76Teleportation disabled for {0}
kitOnce=\u00a74You can't use that kit again.

View file

@ -12,8 +12,8 @@ import java.util.logging.Level;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
import org.bukkit.entity.Player;
import org.jivesoftware.smack.Roster.SubscriptionMode;
import org.jivesoftware.smack.*;
import org.jivesoftware.smack.Roster.SubscriptionMode;
import org.jivesoftware.smack.packet.Message;
import org.jivesoftware.smack.packet.Presence;
import org.jivesoftware.smack.util.StringUtils;
@ -263,7 +263,7 @@ public class XMPPManager extends Handler implements MessageListener, ChatManager
for (LogRecord logRecord : copy)
{
final String message = String.format("[" + logRecord.getLevel().getLocalizedName() + "] " + logRecord.getMessage(), logRecord.getParameters());
if (!XMPPManager.this.sendMessage(user, message))
if (!XMPPManager.this.sendMessage(user, Util.stripLogColorFormat(message)))
{
failedUsers.add(user);
break;