summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-08-20 23:39:34 +0100
committerKHobbits <rob@khobbits.co.uk>2013-08-20 23:39:34 +0100
commitacc6a12b1c2c3fb851f0cdbe4a8106dcb86ebbe2 (patch)
tree96a1147c1f6b2850806a9847309c3c7c868e8d7f /Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
parente8e4d28b6d0e7a45b2383aa2cfda0acc1855e388 (diff)
downloadEssentials-acc6a12b1c2c3fb851f0cdbe4a8106dcb86ebbe2.tar
Essentials-acc6a12b1c2c3fb851f0cdbe4a8106dcb86ebbe2.tar.gz
Essentials-acc6a12b1c2c3fb851f0cdbe4a8106dcb86ebbe2.tar.lz
Essentials-acc6a12b1c2c3fb851f0cdbe4a8106dcb86ebbe2.tar.xz
Essentials-acc6a12b1c2c3fb851f0cdbe4a8106dcb86ebbe2.zip
Add support for {PLAYERLIST:GROUP} AND {PLAYERLIST:GROUP:<none>}
Replace <none> with what you want to show if there are no players from that group online.
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
index 0fb8ddeb0..b1c45a2a1 100644
--- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
+++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
@@ -18,6 +18,8 @@ import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import static com.earth2me.essentials.I18n._;
+import com.earth2me.essentials.PlayerList;
+import static com.earth2me.essentials.PlayerList.getMergedList;
public class KeywordReplacer implements IText
@@ -72,6 +74,7 @@ public class KeywordReplacer implements IText
{
displayName = address = ipAddress = balance = mails = world = worldTime12 = worldTime24 = worldDate = coords = "";
}
+ Map<String, List<User>> playerList = PlayerList.getPlayerLists(ess, extended);
userName = sender.getName();
int playerHidden = 0;
@@ -160,6 +163,24 @@ public class KeywordReplacer implements IText
line = line.replace("{PLUGINS}", plugins);
line = line.replace("{VERSION}", version);
}
+
+ for (String groupName : playerList.keySet()) {
+ final List<User> groupUsers = playerList.get(groupName);
+ if (groupUsers != null && !groupUsers.isEmpty())
+ {
+ line = line.replaceAll("\\{PLAYERLIST\\:" + groupName.toUpperCase() + "(?:\\:([^\\{\\}]*))?\\}",
+ PlayerList.listUsers(ess, groupUsers, " "));
+ }
+ }
+
+ boolean doReplace = true;
+ while (doReplace) {
+ final String newLine = line.replaceAll("\\{PLAYERLIST\\:\\w*(?:\\:([^\\{\\}]*))?\\}", "$1");
+ if (newLine.equals(line)) {
+ doReplace = false;
+ }
+ line = newLine;
+ }
replaced.add(line);
}