From 8b4c30e6111f1fd7ac82b84d1ffeffd6d43e15fd Mon Sep 17 00:00:00 2001 From: sauilitired Date: Tue, 14 Jul 2015 02:41:29 +0200 Subject: [PATCH] Fixes styling issues with /plot info and /plot plugin --- .../plot/commands/Info.java | 5 +++-- .../plot/commands/plugin.java | 4 +++- .../intellectualcrafters/plot/config/C.java | 21 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 1fa62f4bc..be533dfd5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -27,6 +27,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import org.apache.commons.lang.StringUtils; @@ -191,7 +192,7 @@ public class Info extends SubCommand { final PlotId id = plot.id; final PlotId id2 = MainUtil.getTopPlot(plot).id; final int num = MainUtil.getPlotSelectionIds(id, id2).size(); - final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"; + final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : C.NONE.s(); Location top = MainUtil.getPlotTopLoc(world, plot.id); Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1,0,1); final String biome = BlockManager.manager.getBiome(bot.add((top.getX() - bot.getX()) / 2, 0, (top.getX() - bot.getX()) / 2)); @@ -199,7 +200,7 @@ public class Info extends SubCommand { final String members = getPlayerList(plot.members); final String denied = getPlayerList(plot.denied); - final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : C.NONE.s()); + final String flags = StringMan.replaceFromMap("$2" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "$1, $2") : C.NONE.s()), C.replacements); final boolean build = (player == null) || plot.isAdded(player.getUUID()); String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners()); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java index c97f9057f..8a74c23b6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/plugin.java @@ -21,8 +21,10 @@ package com.intellectualcrafters.plot.commands; import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import java.io.BufferedReader; @@ -77,7 +79,7 @@ public class plugin extends SubCommand { } }; for (final String s : strings) { - MainUtil.sendMessage(plr, s); + MainUtil.sendMessage(plr, StringMan.replaceFromMap(s, C.replacements)); } } }); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java index 639cb5bea..9a8aa2a78 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/config/C.java @@ -20,19 +20,18 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.config; +import com.intellectualcrafters.configuration.ConfigurationSection; +import com.intellectualcrafters.configuration.file.YamlConfiguration; +import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.util.StringMan; +import org.bukkit.ChatColor; + import java.io.File; import java.util.EnumSet; import java.util.HashMap; import java.util.HashSet; import java.util.Set; -import org.bukkit.ChatColor; - -import com.intellectualcrafters.configuration.ConfigurationSection; -import com.intellectualcrafters.configuration.file.YamlConfiguration; -import com.intellectualcrafters.plot.PS; -import com.intellectualcrafters.plot.util.StringMan; - /** * Captions class. * @@ -486,6 +485,7 @@ public enum C { * Custom */ CUSTOM_STRING("-", "-"); + public static final HashMap replacements = new HashMap<>(); /** * Translated */ @@ -535,7 +535,7 @@ public enum C { C(final String d, String cat) { this(d, true, cat.toLowerCase()); } - + public static String format(C c, Object... args) { String m = c.s; for (int i = args.length - 1 ; i >= 0; i--) { @@ -549,7 +549,7 @@ public enum C { } return m; } - + public static void load(File file) { try { if (!file.exists()) { @@ -598,7 +598,8 @@ public enum C { } ConfigurationSection config = PS.get().style.getConfigurationSection("color"); Set styles = config.getKeys(false); - HashMap replacements = new HashMap<>(); + // HashMap replacements = new HashMap<>(); + replacements.clear(); for (String style : styles) { replacements.put("$" + style, "\u00a7" + config.getString(style)); }