diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index f40b31c6b..205cd2d4f 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -33,6 +33,7 @@ import com.intellectualcrafters.plot.object.comment.CommentInbox; import com.intellectualcrafters.plot.object.comment.CommentManager; import com.intellectualcrafters.plot.object.comment.PlotComment; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.StringMan; public class Inbox extends SubCommand { public Inbox() { @@ -60,7 +61,7 @@ public class Inbox extends SubCommand { max = comments.length; } final StringBuilder string = new StringBuilder(); - string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("plot","comment").replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n"); + string.append(StringMan.replaceAll(C.COMMENT_LIST_HEADER_PAGED.s(), "%amount%", comments.length, "%cur", page + 1, "%max", totalPages + 1, "%word", "all") + "\n"); PlotComment c; // This might work xD for (int x = (page * 12); x < max; x++) { diff --git a/src/main/java/com/intellectualcrafters/plot/config/C.java b/src/main/java/com/intellectualcrafters/plot/config/C.java index cf1d88958..41fa40b73 100644 --- a/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -395,6 +395,7 @@ public enum C { /* * List */ + COMMENT_LIST_HEADER_PAGED("$2(Page $1%cur$2/$1%max$2) $1List of %amount% comments", "List"), PLOT_LIST_HEADER_PAGED("$2(Page $1%cur$2/$1%max$2) $1List of %amount% plots", "List"), PLOT_LIST_HEADER("$1List of %word% plots", "List"), PLOT_LIST_ITEM("$2>> $1%id$2:$1%world $2- $1%owner", "List"), diff --git a/src/main/java/com/intellectualcrafters/plot/util/StringMan.java b/src/main/java/com/intellectualcrafters/plot/util/StringMan.java index 0fb8e3eea..0a24de332 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/StringMan.java +++ b/src/main/java/com/intellectualcrafters/plot/util/StringMan.java @@ -1,5 +1,6 @@ package com.intellectualcrafters.plot.util; +import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -20,4 +21,12 @@ public class StringMan { } return sb.toString(); } + + public static String replaceAll(String string, Object... pairs) { + HashMap replacements = new HashMap<>(); + for (int i = 0; i < pairs.length; i+=2) { + replacements.put(pairs[i] + "", pairs[i+1] + ""); + } + return replaceFromMap(string, replacements); + } }