Fixes styling issues with /plot info and /plot plugin

This commit is contained in:
sauilitired 2015-07-14 02:41:29 +02:00
parent a621e72326
commit 8b4c30e611
3 changed files with 17 additions and 13 deletions

View File

@ -27,6 +27,7 @@ import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.*; import com.intellectualcrafters.plot.object.*;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
@ -191,7 +192,7 @@ public class Info extends SubCommand {
final PlotId id = plot.id; final PlotId id = plot.id;
final PlotId id2 = MainUtil.getTopPlot(plot).id; final PlotId id2 = MainUtil.getTopPlot(plot).id;
final int num = MainUtil.getPlotSelectionIds(id, id2).size(); 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 top = MainUtil.getPlotTopLoc(world, plot.id);
Location bot = MainUtil.getPlotBottomLoc(world, plot.id).add(1,0,1); 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)); 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 members = getPlayerList(plot.members);
final String denied = getPlayerList(plot.denied); 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()); final boolean build = (player == null) || plot.isAdded(player.getUUID());
String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners()); String owner = plot.owner == null ? "unowned" : getPlayerList(plot.getOwners());

View File

@ -21,8 +21,10 @@
package com.intellectualcrafters.plot.commands; package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.PS;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.StringMan;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -77,7 +79,7 @@ public class plugin extends SubCommand {
} }
}; };
for (final String s : strings) { for (final String s : strings) {
MainUtil.sendMessage(plr, s); MainUtil.sendMessage(plr, StringMan.replaceFromMap(s, C.replacements));
} }
} }
}); });

View File

@ -20,19 +20,18 @@
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.config; 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.io.File;
import java.util.EnumSet; import java.util.EnumSet;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; 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. * Captions class.
* *
@ -486,6 +485,7 @@ public enum C {
* Custom * Custom
*/ */
CUSTOM_STRING("-", "-"); CUSTOM_STRING("-", "-");
public static final HashMap<String, String> replacements = new HashMap<>();
/** /**
* Translated * Translated
*/ */
@ -535,7 +535,7 @@ public enum C {
C(final String d, String cat) { C(final String d, String cat) {
this(d, true, cat.toLowerCase()); this(d, true, cat.toLowerCase());
} }
public static String format(C c, Object... args) { public static String format(C c, Object... args) {
String m = c.s; String m = c.s;
for (int i = args.length - 1 ; i >= 0; i--) { for (int i = args.length - 1 ; i >= 0; i--) {
@ -549,7 +549,7 @@ public enum C {
} }
return m; return m;
} }
public static void load(File file) { public static void load(File file) {
try { try {
if (!file.exists()) { if (!file.exists()) {
@ -598,7 +598,8 @@ public enum C {
} }
ConfigurationSection config = PS.get().style.getConfigurationSection("color"); ConfigurationSection config = PS.get().style.getConfigurationSection("color");
Set<String> styles = config.getKeys(false); Set<String> styles = config.getKeys(false);
HashMap<String, String> replacements = new HashMap<>(); // HashMap<String, String> replacements = new HashMap<>();
replacements.clear();
for (String style : styles) { for (String style : styles) {
replacements.put("$" + style, "\u00a7" + config.getString(style)); replacements.put("$" + style, "\u00a7" + config.getString(style));
} }