From 8926d0b4343d0587140a109815d7d71d3ec682b2 Mon Sep 17 00:00:00 2001 From: drtshock Date: Thu, 6 Aug 2015 16:09:07 -0500 Subject: [PATCH] Don't allow % in faction descriptions. Was messing up string formatting. Fixes #490 --- .../java/com/massivecraft/factions/cmd/CmdDescription.java | 4 +++- src/main/java/com/massivecraft/factions/cmd/CmdShow.java | 3 +++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java index dc04d8b8..d7c2b71e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdDescription.java @@ -33,7 +33,9 @@ public class CmdDescription extends FCommand { return; } - myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("(&([a-f0-9]))", "& $2")); // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up + // since "&" color tags seem to work even through plain old FPlayer.sendMessage() for some reason, we need to break those up + // And replace all the % because it messes with string formatting and this is easy way around that. + myFaction.setDescription(TextUtil.implode(args, " ").replaceAll("%", "").replaceAll("(&([a-f0-9]))", "& $2")); if (!Conf.broadcastDescriptionChanges) { fme.msg(TL.COMMAND_DESCRIPTION_CHANGED, myFaction.describeTo(fme)); diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index 6cd8035a..2839de39 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -90,6 +90,9 @@ public class CmdShow extends FCommand { // replaces all variables with no home TL parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString(); } + if(parsed.contains("%")) { + parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. + } msg(p.txt.parse(parsed)); } }