From 948647926d57f3c06ca3790923b6c7c94299aa43 Mon Sep 17 00:00:00 2001 From: Necrodoom Date: Sun, 25 Nov 2012 15:07:25 +0200 Subject: [PATCH 1/4] fix typo at config.yml --- Essentials/src/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 724eb3541..84d8578a6 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -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: From 889f60e58ec646e8199a3d105f91c29714530afc Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 27 Nov 2012 17:45:02 +0000 Subject: [PATCH 2/4] Userdata cleanup --- .../src/com/earth2me/essentials/IUser.java | 2 ++ .../src/com/earth2me/essentials/User.java | 6 +++++ .../src/com/earth2me/essentials/UserData.java | 27 +++++++++++-------- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java index 8c0d6212f..43f9d7210 100644 --- a/Essentials/src/com/earth2me/essentials/IUser.java +++ b/Essentials/src/com/earth2me/essentials/IUser.java @@ -42,4 +42,6 @@ public interface IUser extends Player Teleport getTeleport(); void setJail(String jail); + + boolean isIgnoreExempt(); } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 2aeeba0ac..5de4b7609 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -737,4 +737,10 @@ public class User extends UserData implements Comparable, IReplyTo, IUser { this.rightClickJump = rightClickJump; } + + @Override + public boolean isIgnoreExempt() + { + return this.isAuthorized("essentials.chat.ignoreexempt"); + } } diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java index 3de5c1e48..94b1631f5 100644 --- a/Essentials/src/com/earth2me/essentials/UserData.java +++ b/Essentials/src/com/earth2me/essentials/UserData.java @@ -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 ignoredPlayers; - public List getIgnoredPlayers() + public List _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); } From 61903355cd4817055ab2144097284ccac0861664 Mon Sep 17 00:00:00 2001 From: KHobbits Date: Tue, 27 Nov 2012 18:25:24 +0000 Subject: [PATCH 3/4] Fix kit timers, kit times more than 25 years will be treated as single use. --- Essentials/src/com/earth2me/essentials/Kit.java | 11 ++++++++--- Essentials/src/messages.properties | 1 + Essentials/src/messages_cs.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_es.properties | 1 + Essentials/src/messages_fi.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_it.properties | 1 + Essentials/src/messages_nl.properties | 1 + Essentials/src/messages_pl.properties | 1 + Essentials/src/messages_pt.properties | 1 + Essentials/src/messages_se.properties | 1 + 14 files changed, 21 insertions(+), 3 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java index 476aaea97..89965e589 100644 --- a/Essentials/src/com/earth2me/essentials/Kit.java +++ b/Essentials/src/com/earth2me/essentials/Kit.java @@ -37,7 +37,7 @@ public class Kit } - public static void checkTime(final User user, final String kitName, final Map els) throws NoChargeException + public static void checkTime(final User user, final String kitName, final Map 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); diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index c7170ae0b..a75198a62 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -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. diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index 6eef42338..be5ca4dfd 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -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. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 45329febb..8a6fe98be 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -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. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index b8f087cd7..7535d3cc7 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -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. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index c7170ae0b..a75198a62 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -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. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index a2dec7c90..e3d5bac59 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -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. diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index ff9df7257..0b8fbeb63 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -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. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index fb858afe2..2505ed700 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -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. diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 901433e83..272a1d574 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -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. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index aeaa048b4..03a141a73 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -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. diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index 094a22663..7487679d8 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -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. diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index 513bf2f4d..3e24ee5b0 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -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. diff --git a/Essentials/src/messages_se.properties b/Essentials/src/messages_se.properties index 75d175330..7a8115ab8 100644 --- a/Essentials/src/messages_se.properties +++ b/Essentials/src/messages_se.properties @@ -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. From 0ed29c029dacf5cc440673ab08f4760fb2ca8c6e Mon Sep 17 00:00:00 2001 From: snowleo Date: Tue, 27 Nov 2012 19:51:32 +0100 Subject: [PATCH 4/4] Add log color removal. (This could already be done with the bukkit setting "log-strip-color") --- Essentials/src/com/earth2me/essentials/Util.java | 10 ++++++++++ .../src/com/earth2me/essentials/xmpp/XMPPManager.java | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index cdbf3f82c..12f5c9da6 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -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) diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java index 164f40c2a..673ef3377 100644 --- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java +++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/XMPPManager.java @@ -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;