diff --git a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java index 283b12fee..502bffb2c 100644 --- a/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java +++ b/Essentials/src/com/earth2me/essentials/signs/EssentialsSign.java @@ -54,7 +54,7 @@ public class EssentialsSign { try { final boolean ret = onSignCreate(sign, user, getUsername(user), ess); if (ret) { - sign.setLine(0, getSuccessName()); + sign.setLine(0, getSuccessName(ess)); } return ret; } catch (ChargeException ex) { @@ -66,8 +66,22 @@ public class EssentialsSign { return true; } + public String getSuccessName(IEssentials ess) { + String successName = getSuccessName(); + if (successName == null) { + ess.getLogger().severe("signFormatSuccess message must use the {0} argument."); + } + return successName; + } + public String getSuccessName() { - return tl("signFormatSuccess", this.signName); + String successName = tl("signFormatSuccess", this.signName); + if (successName.isEmpty() || !successName.contains(this.signName)) { + // Set to null to cause an error in place of no functionality. This makes an error obvious as opposed to leaving users baffled by lack of + // functionality. + successName = null; + } + return successName; } public String getTemplateName() { diff --git a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java index f3ee48bed..86c59ef05 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignBlockListener.java @@ -1,5 +1,6 @@ package com.earth2me.essentials.signs; +import com.earth2me.essentials.I18n; import com.earth2me.essentials.User; import com.earth2me.essentials.utils.FormatUtil; import net.ess3.api.IEssentials; @@ -57,7 +58,7 @@ public class SignBlockListener implements Listener { final Sign csign = (Sign) block.getState(); for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName()) && !sign.onSignBreak(block, player, ess)) { + if (csign.getLine(0).equalsIgnoreCase(sign.getSuccessName(ess)) && !sign.onSignBreak(block, player, ess)) { return true; } } @@ -94,7 +95,13 @@ public class SignBlockListener implements Listener { // If the top sign line contains any of the success name (excluding colors), just remove all colours from the first line. // This is to ensure we are only modifying possible Essentials Sign and not just removing colors from the first line of all signs. // Top line and sign#getSuccessName() are both lowercased since contains is case-sensitive. - String lSuccessName = ChatColor.stripColor(sign.getSuccessName().toLowerCase()); + String successName = sign.getSuccessName(ess); + if (successName == null) { + event.getPlayer().sendMessage(I18n.tl("errorWithMessage", + "Please report this error to a staff member.")); + return; + } + String lSuccessName = ChatColor.stripColor(successName.toLowerCase()); if (lColorlessTopLine.contains(lSuccessName)) { // If this sign is not enabled and it has been requested to not protect it's name (when disabled), then do not protect the name. @@ -116,7 +123,7 @@ public class SignBlockListener implements Listener { } for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (event.getLine(0).equalsIgnoreCase(sign.getSuccessName())) { + if (event.getLine(0).equalsIgnoreCase(sign.getSuccessName(ess))) { event.setCancelled(true); return; } diff --git a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java index ac2c9b8ca..b7d975c6c 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignPlayerListener.java @@ -56,7 +56,7 @@ public class SignPlayerListener implements Listener { if (mat == Material.SIGN_POST || mat == Material.WALL_SIGN) { final String csign = ((Sign) block.getState()).getLine(0); for (EssentialsSign sign : ess.getSettings().enabledSigns()) { - if (csign.equalsIgnoreCase(sign.getSuccessName())) { + if (csign.equalsIgnoreCase(sign.getSuccessName(ess))) { sign.onSignInteract(block, event.getPlayer(), ess); event.setCancelled(true); return; diff --git a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java index b39b41498..befbedbfe 100644 --- a/Essentials/src/com/earth2me/essentials/signs/SignProtection.java +++ b/Essentials/src/com/earth2me/essentials/signs/SignProtection.java @@ -105,7 +105,7 @@ public class SignProtection extends EssentialsSign { private SignProtectionState checkProtectionSign(final Block block, final User user, final String username) { if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN) { final BlockSign sign = new BlockSign(block); - if (sign.getLine(0).equals(this.getSuccessName())) { + if (sign.getLine(0).equals(this.getSuccessName())) { // TODO call getSuccessName(IEssentials) return checkProtectionSign(sign, user, username); } }