diff --git a/pom.xml b/pom.xml index 8c91138..5aa718d 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 com.github.ucchyocean LunaChat - 3.0.1 + 3.0.2 A powerfull chat channel plugin with IME (Kana-Kanji conversion) support https://github.com/ucchyocean/LunaChat @@ -91,6 +91,10 @@ org.jetbrains com.github.ucchyocean.lc.lib.org.jetbrains + + org.bstats + com.github.ucchyocean.lc.lib.org.bstats + @@ -117,7 +121,7 @@ codemc-repo - mcMMO Repository + CodeMC Repository https://repo.codemc.org/repository/maven-public/ @@ -139,15 +143,24 @@ - org.bukkit - bukkit - 1.15.2-R0.1-SNAPSHOT + org.spigotmc + spigot-api + 1.16.1-R0.1-SNAPSHOT + true provided net.md-5 bungeecord-api - 1.15-SNAPSHOT + 1.16-R0.2-SNAPSHOT + true + provided + + + net.md-5 + bungeecord-chat + 1.16-R0.1 + true provided @@ -156,6 +169,12 @@ 1.7 true provided + + + org.bukkit + bukkit + + org.dynmap @@ -163,6 +182,12 @@ 2.0 true provided + + + org.bukkit + bukkit + + com.onarandombox.multiversecore @@ -177,6 +202,28 @@ 2.1.128 true provided + + + org.apache.maven.scm + maven-scm-provider-gitexe + + + org.bstats + bstats-bukkit + + + org.spigotmc + spigot-api + + + com.sk89q.worldguard + worldguard-core + + + com.sk89q.worldguard + worldguard-legacy + + net.alpenblock @@ -185,6 +232,25 @@ true provided + + net.luckperms + api + 5.1 + true + provided + + + org.bstats + bstats-bukkit + 1.7 + compile + + + org.bstats + bstats-bungeecord + 1.7 + compile + com.google.code.gson gson diff --git a/src/main/java/com/github/ucchyocean/lc/channel/Channel.java b/src/main/java/com/github/ucchyocean/lc/channel/Channel.java index e7cd32d..1743b0e 100644 --- a/src/main/java/com/github/ucchyocean/lc/channel/Channel.java +++ b/src/main/java/com/github/ucchyocean/lc/channel/Channel.java @@ -90,7 +90,6 @@ public class Channel { * @deprecated Legacy Version */ public void chat(ChannelPlayer player, String message) { - // TODO player.getPlayer()で問題ないか、要確認 channel.chat(ChannelMember.getChannelMember(player.getPlayer()), message); } diff --git a/src/main/java/com/github/ucchyocean/lc3/ChatColor.java b/src/main/java/com/github/ucchyocean/lc3/ChatColor.java deleted file mode 100644 index eaca301..0000000 --- a/src/main/java/com/github/ucchyocean/lc3/ChatColor.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * @author ucchy - * @license LGPLv3 - * @copyright Copyright ucchy 2020 - */ -package com.github.ucchyocean.lc3; - -import org.jetbrains.annotations.NotNull; - -/** - * チャットカラー - * @author ucchy - */ -public enum ChatColor { - - BLACK('0', 0x00), - DARK_BLUE('1', 0x1), - DARK_GREEN('2', 0x2), - DARK_AQUA('3', 0x3), - DARK_RED('4', 0x4), - DARK_PURPLE('5', 0x5), - GOLD('6', 0x6), - GRAY('7', 0x7), - DARK_GRAY('8', 0x8), - BLUE('9', 0x9), - GREEN('a', 0xA), - AQUA('b', 0xB), - RED('c', 0xC), - LIGHT_PURPLE('d', 0xD), - YELLOW('e', 0xE), - WHITE('f', 0xF), - MAGIC('k', 0x10, true), - BOLD('l', 0x11, true), - STRIKETHROUGH('m', 0x12, true), - UNDERLINE('n', 0x13, true), - ITALIC('o', 0x14, true), - RESET('r', 0x15); - - public static final char COLOR_CHAR = '\u00A7'; - - @SuppressWarnings("unused") - private final int intCode; - private final char code; - private final boolean isFormat; - private final String toString; - - private ChatColor(char code, int intCode) { - this(code, intCode, false); - } - - private ChatColor(char code, int intCode, boolean isFormat) { - this.code = code; - this.intCode = intCode; - this.isFormat = isFormat; - this.toString = new String(new char[] {COLOR_CHAR, code}); - } - - public char getChar() { - return code; - } - - @NotNull - @Override - public String toString() { - return toString; - } - - public boolean isFormat() { - return isFormat; - } -} diff --git a/src/main/java/com/github/ucchyocean/lc3/LunaChatBukkit.java b/src/main/java/com/github/ucchyocean/lc3/LunaChatBukkit.java index 6d74a8c..d09831c 100644 --- a/src/main/java/com/github/ucchyocean/lc3/LunaChatBukkit.java +++ b/src/main/java/com/github/ucchyocean/lc3/LunaChatBukkit.java @@ -11,6 +11,7 @@ import java.util.Set; import java.util.TreeSet; import java.util.logging.Level; +import org.bstats.bukkit.Metrics; import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; @@ -66,6 +67,9 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface { LunaChat.setPlugin(this); LunaChat.setMode(LunaChatMode.BUKKIT); + // Metrics + new Metrics(this, 7936); + // 変数などの初期化 config = new LunaChatConfig(getDataFolder(), getFile()); uuidCacheData = new UUIDCacheData(getDataFolder()); diff --git a/src/main/java/com/github/ucchyocean/lc3/LunaChatBungee.java b/src/main/java/com/github/ucchyocean/lc3/LunaChatBungee.java index 5b658dd..d9c0e35 100644 --- a/src/main/java/com/github/ucchyocean/lc3/LunaChatBungee.java +++ b/src/main/java/com/github/ucchyocean/lc3/LunaChatBungee.java @@ -11,7 +11,10 @@ import java.util.Set; import java.util.TreeSet; import java.util.logging.Level; +import org.bstats.bungeecord.Metrics; + import com.github.ucchyocean.lc3.bridge.BungeePermsBridge; +import com.github.ucchyocean.lc3.bridge.LuckPermsBridge; import com.github.ucchyocean.lc3.bungee.BungeeEventListener; import com.github.ucchyocean.lc3.bungee.BungeeEventSender; import com.github.ucchyocean.lc3.bungee.JapanizeCommandBungee; @@ -39,6 +42,7 @@ public class LunaChatBungee extends Plugin implements PluginInterface { private LunaChatLogger normalChatLogger; private BungeePermsBridge bungeeperms; + private LuckPermsBridge luckperms; /** * プラグインが有効化されたときに呼び出されるメソッド @@ -50,6 +54,9 @@ public class LunaChatBungee extends Plugin implements PluginInterface { LunaChat.setPlugin(this); LunaChat.setMode(LunaChatMode.BUNGEE); + // Metrics + new Metrics(this, 7936); + // 初期化 config = new LunaChatConfig(getDataFolder(), getFile()); uuidCacheData = new UUIDCacheData(getDataFolder()); @@ -65,7 +72,16 @@ public class LunaChatBungee extends Plugin implements PluginInterface { } // BungeePermsのロード - bungeeperms = BungeePermsBridge.load(); + Plugin temp = getProxy().getPluginManager().getPlugin("BungeePerms"); + if ( temp != null ) { + bungeeperms = BungeePermsBridge.load(temp); + } + + // LuckPermsのロード + temp = getProxy().getPluginManager().getPlugin("LuckPerms"); + if ( temp != null ) { + luckperms = LuckPermsBridge.load(temp); + } // コマンド登録 getProxy().getPluginManager().registerCommand(this, @@ -210,4 +226,12 @@ public class LunaChatBungee extends Plugin implements PluginInterface { public BungeePermsBridge getBungeePerms() { return bungeeperms; } + + /** + * LuckPerms連携クラスを取得する + * @return LuckPerms連携クラス + */ + public LuckPermsBridge getLuckPerms() { + return luckperms; + } } diff --git a/src/main/java/com/github/ucchyocean/lc3/LunaChatConfig.java b/src/main/java/com/github/ucchyocean/lc3/LunaChatConfig.java index 4b6c021..fd27efb 100644 --- a/src/main/java/com/github/ucchyocean/lc3/LunaChatConfig.java +++ b/src/main/java/com/github/ucchyocean/lc3/LunaChatConfig.java @@ -12,6 +12,9 @@ import java.util.logging.Level; import java.util.regex.Pattern; import com.github.ucchyocean.lc3.japanize.JapanizeType; +import com.github.ucchyocean.lc3.util.EventPriority; +import com.github.ucchyocean.lc3.util.Utility; +import com.github.ucchyocean.lc3.util.YamlConfig; /** * LunaChatのコンフィグクラス @@ -247,7 +250,7 @@ public class LunaChatConfig { japanizeLine1Format = config.getString("japanizeLine1Format", "%msg &6(%japanize)"); japanizeLine2Format = config.getString("japanizeLine2Format", "&6[JP] %japanize"); japanizeIgnorePlayerName = config.getBoolean("japanizeIgnorePlayerName", true); - noneJapanizeMarker = config.getString("noneJapanizeMarker", "#"); + noneJapanizeMarker = config.getString("noneJapanizeMarker", "$"); japanizeWait = config.getInt("japanizeWait", 1); // globalチャンネルが、使用可能なチャンネル名かどうかを調べる diff --git a/src/main/java/com/github/ucchyocean/lc3/LunaChatLogger.java b/src/main/java/com/github/ucchyocean/lc3/LunaChatLogger.java index 240eca0..7bdc0eb 100644 --- a/src/main/java/com/github/ucchyocean/lc3/LunaChatLogger.java +++ b/src/main/java/com/github/ucchyocean/lc3/LunaChatLogger.java @@ -19,6 +19,8 @@ import java.util.Calendar; import java.util.Collections; import java.util.Date; +import com.github.ucchyocean.lc3.util.Utility; + /** * LunaChatロガー * @author ucchy diff --git a/src/main/java/com/github/ucchyocean/lc3/LunaChatStandalone.java b/src/main/java/com/github/ucchyocean/lc3/LunaChatStandalone.java index d7678cc..523edce 100644 --- a/src/main/java/com/github/ucchyocean/lc3/LunaChatStandalone.java +++ b/src/main/java/com/github/ucchyocean/lc3/LunaChatStandalone.java @@ -83,7 +83,7 @@ public class LunaChatStandalone implements PluginInterface { @Override public void log(Level level, String msg) { - // TODO 未実装 + // TODO Standaloneサーバーのログ出力 未実装 } /** diff --git a/src/main/java/com/github/ucchyocean/lc3/Messages.java b/src/main/java/com/github/ucchyocean/lc3/Messages.java index d902650..18a989b 100644 --- a/src/main/java/com/github/ucchyocean/lc3/Messages.java +++ b/src/main/java/com/github/ucchyocean/lc3/Messages.java @@ -10,6 +10,10 @@ import java.io.IOException; import java.util.jar.JarFile; import java.util.zip.ZipEntry; +import com.github.ucchyocean.lc3.util.KeywordReplacer; +import com.github.ucchyocean.lc3.util.Utility; +import com.github.ucchyocean.lc3.util.YamlConfig; + /** * プラグインのメッセージリソース管理クラス * @author ucchy @@ -87,10 +91,11 @@ public class Messages { public static String joinMessage(Object color, Object channel, Object player) { String msg = resources.getString("joinMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -99,10 +104,11 @@ public class Messages { public static String quitMessage(Object color, Object channel, Object player) { String msg = resources.getString("quitMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -111,9 +117,10 @@ public class Messages { public static String breakupMessage(Object color, Object channel) { String msg = resources.getString("breakupMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -122,10 +129,11 @@ public class Messages { public static String banMessage(Object color, Object channel, Object player) { String msg = resources.getString("banMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -134,10 +142,11 @@ public class Messages { public static String kickMessage(Object color, Object channel, Object player) { String msg = resources.getString("kickMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -146,10 +155,11 @@ public class Messages { public static String muteMessage(Object color, Object channel, Object player) { String msg = resources.getString("muteMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -158,10 +168,11 @@ public class Messages { public static String banNGWordMessage(Object color, Object channel, Object player) { String msg = resources.getString("banNGWordMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -170,10 +181,11 @@ public class Messages { public static String kickNGWordMessage(Object color, Object channel, Object player) { String msg = resources.getString("kickNGWordMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -182,10 +194,11 @@ public class Messages { public static String muteNGWordMessage(Object color, Object channel, Object player) { String msg = resources.getString("muteNGWordMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -194,11 +207,12 @@ public class Messages { public static String banWithExpireMessage(Object color, Object channel, Object player, Object minutes) { String msg = resources.getString("banWithExpireMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%minutes%", minutes.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + kr.replace("%minutes%", minutes.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -207,11 +221,12 @@ public class Messages { public static String muteWithExpireMessage(Object color, Object channel, Object player, Object minutes) { String msg = resources.getString("muteWithExpireMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%minutes%", minutes.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + kr.replace("%minutes%", minutes.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -220,10 +235,11 @@ public class Messages { public static String pardonMessage(Object color, Object channel, Object player) { String msg = resources.getString("pardonMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -232,10 +248,11 @@ public class Messages { public static String unmuteMessage(Object color, Object channel, Object player) { String msg = resources.getString("unmuteMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -244,10 +261,11 @@ public class Messages { public static String expiredBanMessage(Object color, Object channel, Object player) { String msg = resources.getString("expiredBanMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -256,10 +274,11 @@ public class Messages { public static String expiredMuteMessage(Object color, Object channel, Object player) { String msg = resources.getString("expiredMuteMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -268,10 +287,11 @@ public class Messages { public static String addModeratorMessage(Object color, Object channel, Object player) { String msg = resources.getString("addModeratorMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -280,10 +300,11 @@ public class Messages { public static String removeModeratorMessage(Object color, Object channel, Object player) { String msg = resources.getString("removeModeratorMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -292,9 +313,10 @@ public class Messages { public static String noRecipientMessage(Object color, Object channel) { String msg = resources.getString("noRecipientMessage"); if ( msg == null ) return ""; - msg = msg.replace("%color%", color.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%color%", color.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -303,7 +325,8 @@ public class Messages { public static String listFirstLine() { String msg = resources.getString("listFirstLine"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -312,9 +335,10 @@ public class Messages { public static String listFirstLinePaging(Object page, Object max) { String msg = resources.getString("listFirstLinePaging"); if ( msg == null ) return ""; - msg = msg.replace("%page%", page.toString()); - msg = msg.replace("%max%", max.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%page%", page.toString()); + kr.replace("%max%", max.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -323,7 +347,8 @@ public class Messages { public static String listEndLine() { String msg = resources.getString("listEndLine"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -332,11 +357,12 @@ public class Messages { public static String listFormat(Object channel, Object online, Object total, Object topic) { String msg = resources.getString("listFormat"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%online%", online.toString()); - msg = msg.replace("%total%", total.toString()); - msg = msg.replace("%topic%", topic.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + kr.replace("%online%", online.toString()); + kr.replace("%total%", total.toString()); + kr.replace("%topic%", topic.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -345,7 +371,8 @@ public class Messages { public static String listPlainPrefix() { String msg = resources.getString("listPlainPrefix"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -354,7 +381,8 @@ public class Messages { public static String channelInfoFirstLine() { String msg = resources.getString("channelInfoFirstLine"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -363,7 +391,8 @@ public class Messages { public static String channelInfoPrefix() { String msg = resources.getString("channelInfoPrefix"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -372,7 +401,8 @@ public class Messages { public static String channelInfoAlias() { String msg = resources.getString("channelInfoAlias"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -381,7 +411,8 @@ public class Messages { public static String channelInfoGlobal() { String msg = resources.getString("channelInfoGlobal"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -390,7 +421,8 @@ public class Messages { public static String channelInfoBroadcast() { String msg = resources.getString("channelInfoBroadcast"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -399,7 +431,8 @@ public class Messages { public static String channelInfoSecret() { String msg = resources.getString("channelInfoSecret"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -408,7 +441,8 @@ public class Messages { public static String channelInfoPassword() { String msg = resources.getString("channelInfoPassword"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -417,7 +451,8 @@ public class Messages { public static String channelInfoWorldChat() { String msg = resources.getString("channelInfoWorldChat"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -426,8 +461,9 @@ public class Messages { public static String channelInfoRangeChat(Object block) { String msg = resources.getString("channelInfoRangeChat"); if ( msg == null ) return ""; - msg = msg.replace("%block%", block.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%block%", block.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -436,7 +472,8 @@ public class Messages { public static String channelInfoFormat() { String msg = resources.getString("channelInfoFormat"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -445,7 +482,8 @@ public class Messages { public static String channelInfoBanned() { String msg = resources.getString("channelInfoBanned"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -454,7 +492,8 @@ public class Messages { public static String channelInfoMuted() { String msg = resources.getString("channelInfoMuted"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -463,7 +502,8 @@ public class Messages { public static String motdFirstLine() { String msg = resources.getString("motdFirstLine"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -472,7 +512,8 @@ public class Messages { public static String hideChannelFirstLine() { String msg = resources.getString("hideChannelFirstLine"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -481,7 +522,8 @@ public class Messages { public static String hidePlayerFirstLine() { String msg = resources.getString("hidePlayerFirstLine"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -490,8 +532,9 @@ public class Messages { public static String logDisplayFirstLine(Object channel) { String msg = resources.getString("logDisplayFirstLine"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -500,7 +543,8 @@ public class Messages { public static String logDisplayEndLine() { String msg = resources.getString("logDisplayEndLine"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -509,10 +553,11 @@ public class Messages { public static String logDisplayFormat(Object date, Object player, Object message) { String msg = resources.getString("logDisplayFormat"); if ( msg == null ) return ""; - msg = msg.replace("%date%", date.toString()); - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%message%", message.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%date%", date.toString()); + kr.replace("%player%", player.toString()); + kr.replace("%message%", message.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -521,7 +566,8 @@ public class Messages { public static String infoPrefix() { String msg = resources.getString("infoPrefix"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -530,7 +576,8 @@ public class Messages { public static String errorPrefix() { String msg = resources.getString("errorPrefix"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -539,8 +586,9 @@ public class Messages { public static String cmdmsgJoin(Object channel) { String msg = resources.getString("cmdmsgJoin"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -549,8 +597,9 @@ public class Messages { public static String cmdmsgSet(Object channel) { String msg = resources.getString("cmdmsgSet"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -559,8 +608,9 @@ public class Messages { public static String cmdmsgSetTopic(Object topic) { String msg = resources.getString("cmdmsgSetTopic"); if ( msg == null ) return ""; - msg = msg.replace("%topic%", topic.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%topic%", topic.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -569,7 +619,8 @@ public class Messages { public static String cmdmsgSetHide() { String msg = resources.getString("cmdmsgSetHide"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -578,8 +629,9 @@ public class Messages { public static String cmdmsgLeave(Object channel) { String msg = resources.getString("cmdmsgLeave"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -588,9 +640,10 @@ public class Messages { public static String cmdmsgInvite(Object player, Object channel) { String msg = resources.getString("cmdmsgInvite"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -599,9 +652,10 @@ public class Messages { public static String cmdmsgInvited1(Object player, Object channel) { String msg = resources.getString("cmdmsgInvited1"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -610,7 +664,8 @@ public class Messages { public static String cmdmsgInvited2() { String msg = resources.getString("cmdmsgInvited2"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -619,7 +674,8 @@ public class Messages { public static String cmdmsgDeny() { String msg = resources.getString("cmdmsgDeny"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -628,7 +684,8 @@ public class Messages { public static String cmdmsgDenyed() { String msg = resources.getString("cmdmsgDenyed"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -637,9 +694,10 @@ public class Messages { public static String cmdmsgKick(Object player, Object channel) { String msg = resources.getString("cmdmsgKick"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -648,8 +706,9 @@ public class Messages { public static String cmdmsgKicked(Object channel) { String msg = resources.getString("cmdmsgKicked"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -658,9 +717,10 @@ public class Messages { public static String cmdmsgBan(Object player, Object channel) { String msg = resources.getString("cmdmsgBan"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -669,10 +729,11 @@ public class Messages { public static String cmdmsgBanWithExpire(Object player, Object channel, Object minutes) { String msg = resources.getString("cmdmsgBanWithExpire"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%minutes%", minutes.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%minutes%", minutes.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -681,8 +742,9 @@ public class Messages { public static String cmdmsgBanned(Object channel) { String msg = resources.getString("cmdmsgBanned"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -691,9 +753,10 @@ public class Messages { public static String cmdmsgPardon(Object player, Object channel) { String msg = resources.getString("cmdmsgPardon"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -702,8 +765,9 @@ public class Messages { public static String cmdmsgPardoned(Object channel) { String msg = resources.getString("cmdmsgPardoned"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -712,9 +776,10 @@ public class Messages { public static String cmdmsgMute(Object player, Object channel) { String msg = resources.getString("cmdmsgMute"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -723,10 +788,11 @@ public class Messages { public static String cmdmsgMuteWithExpire(Object player, Object channel, Object minutes) { String msg = resources.getString("cmdmsgMuteWithExpire"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%minutes%", minutes.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + kr.replace("%minutes%", minutes.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -735,8 +801,9 @@ public class Messages { public static String cmdmsgMuted(Object channel) { String msg = resources.getString("cmdmsgMuted"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -745,9 +812,10 @@ public class Messages { public static String cmdmsgUnmute(Object player, Object channel) { String msg = resources.getString("cmdmsgUnmute"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -756,8 +824,9 @@ public class Messages { public static String cmdmsgUnmuted(Object channel) { String msg = resources.getString("cmdmsgUnmuted"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -766,8 +835,9 @@ public class Messages { public static String cmdmsgHided(Object channel) { String msg = resources.getString("cmdmsgHided"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -776,8 +846,9 @@ public class Messages { public static String cmdmsgHidedPlayer(Object player) { String msg = resources.getString("cmdmsgHidedPlayer"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -786,8 +857,9 @@ public class Messages { public static String cmdmsgUnhided(Object channel) { String msg = resources.getString("cmdmsgUnhided"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -796,8 +868,9 @@ public class Messages { public static String cmdmsgUnhidedPlayer(Object channel) { String msg = resources.getString("cmdmsgUnhidedPlayer"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -806,7 +879,8 @@ public class Messages { public static String cmdmsgReload() { String msg = resources.getString("cmdmsgReload"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -815,8 +889,9 @@ public class Messages { public static String cmdmsgCreate(Object channel) { String msg = resources.getString("cmdmsgCreate"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -825,8 +900,9 @@ public class Messages { public static String cmdmsgRemove(Object channel) { String msg = resources.getString("cmdmsgRemove"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -835,8 +911,9 @@ public class Messages { public static String cmdmsgFormat(Object format) { String msg = resources.getString("cmdmsgFormat"); if ( msg == null ) return ""; - msg = msg.replace("%format%", format.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%format%", format.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -845,9 +922,10 @@ public class Messages { public static String cmdmsgModerator(Object player, Object channel) { String msg = resources.getString("cmdmsgModerator"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -856,9 +934,10 @@ public class Messages { public static String cmdmsgModeratorMinus(Object player, Object channel) { String msg = resources.getString("cmdmsgModeratorMinus"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -867,9 +946,10 @@ public class Messages { public static String cmdmsgDictionaryAdd(Object key, Object value) { String msg = resources.getString("cmdmsgDictionaryAdd"); if ( msg == null ) return ""; - msg = msg.replace("%key%", key.toString()); - msg = msg.replace("%value%", value.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%key%", key.toString()); + kr.replace("%value%", value.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -878,8 +958,9 @@ public class Messages { public static String cmdmsgDictionaryRemove(Object key) { String msg = resources.getString("cmdmsgDictionaryRemove"); if ( msg == null ) return ""; - msg = msg.replace("%key%", key.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%key%", key.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -888,9 +969,10 @@ public class Messages { public static String cmdmsgOption(Object key, Object value) { String msg = resources.getString("cmdmsgOption"); if ( msg == null ) return ""; - msg = msg.replace("%key%", key.toString()); - msg = msg.replace("%value%", value.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%key%", key.toString()); + kr.replace("%value%", value.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -899,9 +981,10 @@ public class Messages { public static String cmdmsgTemplate(Object index, Object value) { String msg = resources.getString("cmdmsgTemplate"); if ( msg == null ) return ""; - msg = msg.replace("%index%", index.toString()); - msg = msg.replace("%value%", value.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%index%", index.toString()); + kr.replace("%value%", value.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -910,8 +993,9 @@ public class Messages { public static String cmdmsgTemplateRemove(Object index) { String msg = resources.getString("cmdmsgTemplateRemove"); if ( msg == null ) return ""; - msg = msg.replace("%index%", index.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%index%", index.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -920,9 +1004,10 @@ public class Messages { public static String cmdmsgSetDefault(Object player, Object channel) { String msg = resources.getString("cmdmsgSetDefault"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -931,8 +1016,9 @@ public class Messages { public static String cmdmsgPlayerJapanize(Object value) { String msg = resources.getString("cmdmsgPlayerJapanize"); if ( msg == null ) return ""; - msg = msg.replace("%value%", value.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%value%", value.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -941,9 +1027,10 @@ public class Messages { public static String cmdmsgPlayerJapanizeOther(Object player, Object value) { String msg = resources.getString("cmdmsgPlayerJapanizeOther"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - msg = msg.replace("%value%", value.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + kr.replace("%value%", value.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -952,9 +1039,10 @@ public class Messages { public static String cmdmsgReplyInviter(Object inviter, Object invited) { String msg = resources.getString("cmdmsgReplyInviter"); if ( msg == null ) return ""; - msg = msg.replace("%inviter%", inviter.toString()); - msg = msg.replace("%invited%", invited.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%inviter%", inviter.toString()); + kr.replace("%invited%", invited.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -963,8 +1051,9 @@ public class Messages { public static String cmdmsgReplyInviterNone(Object inviter) { String msg = resources.getString("cmdmsgReplyInviterNone"); if ( msg == null ) return ""; - msg = msg.replace("%inviter%", inviter.toString()); - return Utility.replaceColorCode(resources.getString("infoPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%inviter%", inviter.toString()); + return Utility.replaceColorCode(resources.getString("infoPrefix", "") + kr.toString()); } /** @@ -973,7 +1062,8 @@ public class Messages { public static String errmsgIngame() { String msg = resources.getString("errmsgIngame"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -982,7 +1072,8 @@ public class Messages { public static String errmsgCommand() { String msg = resources.getString("errmsgCommand"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -991,7 +1082,8 @@ public class Messages { public static String errmsgNotExist() { String msg = resources.getString("errmsgNotExist"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1000,7 +1092,8 @@ public class Messages { public static String errmsgNotExistChannelAndPlayer() { String msg = resources.getString("errmsgNotExistChannelAndPlayer"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1009,7 +1102,8 @@ public class Messages { public static String errmsgNotExistOrNotSpecified() { String msg = resources.getString("errmsgNotExistOrNotSpecified"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1018,7 +1112,8 @@ public class Messages { public static String errmsgExist() { String msg = resources.getString("errmsgExist"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1027,7 +1122,8 @@ public class Messages { public static String errmsgNomember() { String msg = resources.getString("errmsgNomember"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1036,7 +1132,8 @@ public class Messages { public static String errmsgNomemberOther() { String msg = resources.getString("errmsgNomemberOther"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1045,8 +1142,9 @@ public class Messages { public static String errmsgNotfoundPlayer(Object player) { String msg = resources.getString("errmsgNotfoundPlayer"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1055,7 +1153,8 @@ public class Messages { public static String errmsgNotInvited() { String msg = resources.getString("errmsgNotInvited"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1064,7 +1163,8 @@ public class Messages { public static String errmsgNotfoundChannel() { String msg = resources.getString("errmsgNotfoundChannel"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1073,8 +1173,9 @@ public class Messages { public static String errmsgInvitedAlreadyExist(Object player) { String msg = resources.getString("errmsgInvitedAlreadyExist"); if ( msg == null ) return ""; - msg = msg.replace("%player%", player.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%player%", player.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1083,7 +1184,8 @@ public class Messages { public static String errmsgInvitedAlreadyJoin() { String msg = resources.getString("errmsgInvitedAlreadyJoin"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1092,7 +1194,8 @@ public class Messages { public static String errmsgNoJoin() { String msg = resources.getString("errmsgNoJoin"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1101,7 +1204,8 @@ public class Messages { public static String errmsgBanned() { String msg = resources.getString("errmsgBanned"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1110,7 +1214,8 @@ public class Messages { public static String errmsgMuted() { String msg = resources.getString("errmsgMuted"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1119,7 +1224,8 @@ public class Messages { public static String errmsgAlreadyBanned() { String msg = resources.getString("errmsgAlreadyBanned"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1128,7 +1234,8 @@ public class Messages { public static String errmsgAlreadyMuted() { String msg = resources.getString("errmsgAlreadyMuted"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1137,7 +1244,8 @@ public class Messages { public static String errmsgAlreadyHided() { String msg = resources.getString("errmsgAlreadyHided"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1146,7 +1254,8 @@ public class Messages { public static String errmsgAlreadyHidedPlayer() { String msg = resources.getString("errmsgAlreadyHidedPlayer"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1155,7 +1264,8 @@ public class Messages { public static String errmsgAlreadyUnhided() { String msg = resources.getString("errmsgAlreadyUnhided"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1164,7 +1274,8 @@ public class Messages { public static String errmsgAlreadyUnhidedPlayer() { String msg = resources.getString("errmsgAlreadyUnhidedPlayer"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1173,7 +1284,8 @@ public class Messages { public static String errmsgCannotJoinPersonal() { String msg = resources.getString("errmsgCannotJoinPersonal"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1182,7 +1294,8 @@ public class Messages { public static String errmsgNotModerator() { String msg = resources.getString("errmsgNotModerator"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1191,7 +1304,8 @@ public class Messages { public static String errmsgNotBanned() { String msg = resources.getString("errmsgNotBanned"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1200,7 +1314,8 @@ public class Messages { public static String errmsgNotMuted() { String msg = resources.getString("errmsgNotMuted"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1209,7 +1324,8 @@ public class Messages { public static String errmsgInvalidOptions() { String msg = resources.getString("errmsgInvalidOptions"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1218,7 +1334,8 @@ public class Messages { public static String errmsgPassword1() { String msg = resources.getString("errmsgPassword1"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1227,7 +1344,8 @@ public class Messages { public static String errmsgPassword2() { String msg = resources.getString("errmsgPassword2"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1236,7 +1354,8 @@ public class Messages { public static String errmsgPassword3() { String msg = resources.getString("errmsgPassword3"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1245,7 +1364,8 @@ public class Messages { public static String errmsgPasswordNotmatch() { String msg = resources.getString("errmsgPasswordNotmatch"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1254,8 +1374,9 @@ public class Messages { public static String errmsgPermission(Object permission) { String msg = resources.getString("errmsgPermission"); if ( msg == null ) return ""; - msg = msg.replace("%permission%", permission.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%permission%", permission.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1264,8 +1385,9 @@ public class Messages { public static String errmsgCannotLeaveGlobal(Object channel) { String msg = resources.getString("errmsgCannotLeaveGlobal"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1274,8 +1396,9 @@ public class Messages { public static String errmsgCannotKickGlobal(Object channel) { String msg = resources.getString("errmsgCannotKickGlobal"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1284,8 +1407,9 @@ public class Messages { public static String errmsgCannotBANGlobal(Object channel) { String msg = resources.getString("errmsgCannotBANGlobal"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1294,8 +1418,9 @@ public class Messages { public static String errmsgCannotRemoveGlobal(Object channel) { String msg = resources.getString("errmsgCannotRemoveGlobal"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1304,8 +1429,9 @@ public class Messages { public static String errmsgCannotModeratorGlobal(Object channel) { String msg = resources.getString("errmsgCannotModeratorGlobal"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1314,8 +1440,9 @@ public class Messages { public static String errmsgCannotLeaveForceJoin(Object channel) { String msg = resources.getString("errmsgCannotLeaveForceJoin"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1324,7 +1451,8 @@ public class Messages { public static String errmsgNotfoundPM() { String msg = resources.getString("errmsgNotfoundPM"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1333,7 +1461,8 @@ public class Messages { public static String errmsgCannotSendPMSelf() { String msg = resources.getString("errmsgCannotSendPMSelf"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1342,8 +1471,9 @@ public class Messages { public static String errmsgCannotUseForChannel(Object channel) { String msg = resources.getString("errmsgCannotUseForChannel"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1352,9 +1482,10 @@ public class Messages { public static String errmsgCannotUseForChannelTooShort(Object channel, Object min) { String msg = resources.getString("errmsgCannotUseForChannelTooShort"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%min%", min.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + kr.replace("%min%", min.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1363,9 +1494,10 @@ public class Messages { public static String errmsgCannotUseForChannelTooLong(Object channel, Object max) { String msg = resources.getString("errmsgCannotUseForChannelTooLong"); if ( msg == null ) return ""; - msg = msg.replace("%channel%", channel.toString()); - msg = msg.replace("%max%", max.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%channel%", channel.toString()); + kr.replace("%max%", max.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1374,8 +1506,9 @@ public class Messages { public static String errmsgCannotUseForGlobal(Object word) { String msg = resources.getString("errmsgCannotUseForGlobal"); if ( msg == null ) return ""; - msg = msg.replace("%word%", word.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%word%", word.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1384,8 +1517,9 @@ public class Messages { public static String errmsgInvalidColorCode(Object value) { String msg = resources.getString("errmsgInvalidColorCode"); if ( msg == null ) return ""; - msg = msg.replace("%value%", value.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%value%", value.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1394,7 +1528,8 @@ public class Messages { public static String errmsgInvalidTemplateNumber() { String msg = resources.getString("errmsgInvalidTemplateNumber"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1403,8 +1538,9 @@ public class Messages { public static String errmsgToolongDescription(Object max) { String msg = resources.getString("errmsgToolongDescription"); if ( msg == null ) return ""; - msg = msg.replace("%max%", max.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%max%", max.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1413,8 +1549,9 @@ public class Messages { public static String errmsgToolongAlias(Object max) { String msg = resources.getString("errmsgToolongAlias"); if ( msg == null ) return ""; - msg = msg.replace("%max%", max.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%max%", max.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1423,8 +1560,9 @@ public class Messages { public static String errmsgToolongPassword(Object max) { String msg = resources.getString("errmsgToolongPassword"); if ( msg == null ) return ""; - msg = msg.replace("%max%", max.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%max%", max.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1433,8 +1571,9 @@ public class Messages { public static String errmsgInvalidBooleanOption(Object key) { String msg = resources.getString("errmsgInvalidBooleanOption"); if ( msg == null ) return ""; - msg = msg.replace("%key%", key.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%key%", key.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1443,7 +1582,8 @@ public class Messages { public static String errmsgInvalidRangeOption() { String msg = resources.getString("errmsgInvalidRangeOption"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1452,9 +1592,10 @@ public class Messages { public static String errmsgInvalidJapanizeOption(Object key, Object value) { String msg = resources.getString("errmsgInvalidJapanizeOption"); if ( msg == null ) return ""; - msg = msg.replace("%key%", key.toString()); - msg = msg.replace("%value%", value.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%key%", key.toString()); + kr.replace("%value%", value.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1463,7 +1604,8 @@ public class Messages { public static String errmsgCannotOffGlobalBroadcast() { String msg = resources.getString("errmsgCannotOffGlobalBroadcast"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1472,8 +1614,9 @@ public class Messages { public static String errmsgFormatConstraint(Object key) { String msg = resources.getString("errmsgFormatConstraint"); if ( msg == null ) return ""; - msg = msg.replace("%key%", key.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%key%", key.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1482,7 +1625,8 @@ public class Messages { public static String errmsgInvalidBanExpireParameter() { String msg = resources.getString("errmsgInvalidBanExpireParameter"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1491,7 +1635,8 @@ public class Messages { public static String errmsgInvalidMuteExpireParameter() { String msg = resources.getString("errmsgInvalidMuteExpireParameter"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1500,7 +1645,8 @@ public class Messages { public static String errmsgCannotHideSelf() { String msg = resources.getString("errmsgCannotHideSelf"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1509,9 +1655,10 @@ public class Messages { public static String errmsgDuplicatedAlias(Object aliase, Object channel) { String msg = resources.getString("errmsgDuplicatedAlias"); if ( msg == null ) return ""; - msg = msg.replace("%aliase%", aliase.toString()); - msg = msg.replace("%channel%", channel.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%aliase%", aliase.toString()); + kr.replace("%channel%", channel.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1520,8 +1667,9 @@ public class Messages { public static String errmsgNotPermission(Object permission) { String msg = resources.getString("errmsgNotPermission"); if ( msg == null ) return ""; - msg = msg.replace("%permission%", permission.toString()); - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%permission%", permission.toString()); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1530,7 +1678,8 @@ public class Messages { public static String errmsgChannelChatDisabled() { String msg = resources.getString("errmsgChannelChatDisabled"); if ( msg == null ) return ""; - return Utility.replaceColorCode(resources.getString("errorPrefix", "") + msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(resources.getString("errorPrefix", "") + kr.toString()); } /** @@ -1539,8 +1688,9 @@ public class Messages { public static String usageJoin(Object label) { String msg = resources.getString("usageJoin"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1549,8 +1699,9 @@ public class Messages { public static String usageLeave(Object label) { String msg = resources.getString("usageLeave"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1559,8 +1710,9 @@ public class Messages { public static String usageList(Object label) { String msg = resources.getString("usageList"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1569,8 +1721,9 @@ public class Messages { public static String usageInvite(Object label) { String msg = resources.getString("usageInvite"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1579,8 +1732,9 @@ public class Messages { public static String usageAccept(Object label) { String msg = resources.getString("usageAccept"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1589,8 +1743,9 @@ public class Messages { public static String usageDeny(Object label) { String msg = resources.getString("usageDeny"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1599,8 +1754,9 @@ public class Messages { public static String usageKick(Object label) { String msg = resources.getString("usageKick"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1609,8 +1765,9 @@ public class Messages { public static String usageBan(Object label) { String msg = resources.getString("usageBan"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1619,8 +1776,9 @@ public class Messages { public static String usageBan2(Object label) { String msg = resources.getString("usageBan2"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1629,8 +1787,9 @@ public class Messages { public static String usagePardon(Object label) { String msg = resources.getString("usagePardon"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1639,8 +1798,9 @@ public class Messages { public static String usageMute(Object label) { String msg = resources.getString("usageMute"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1649,8 +1809,9 @@ public class Messages { public static String usageMute2(Object label) { String msg = resources.getString("usageMute2"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1659,8 +1820,9 @@ public class Messages { public static String usageUnmute(Object label) { String msg = resources.getString("usageUnmute"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1669,8 +1831,9 @@ public class Messages { public static String usageHide(Object label) { String msg = resources.getString("usageHide"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1679,8 +1842,9 @@ public class Messages { public static String usageHidePlayer(Object label) { String msg = resources.getString("usageHidePlayer"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1689,8 +1853,9 @@ public class Messages { public static String usageUnhide(Object label) { String msg = resources.getString("usageUnhide"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1699,8 +1864,9 @@ public class Messages { public static String usageUnhidePlayer(Object label) { String msg = resources.getString("usageUnhidePlayer"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1709,8 +1875,9 @@ public class Messages { public static String usageInfo(Object label) { String msg = resources.getString("usageInfo"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1719,8 +1886,9 @@ public class Messages { public static String usageLog(Object label) { String msg = resources.getString("usageLog"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1729,8 +1897,9 @@ public class Messages { public static String usageCreate(Object label) { String msg = resources.getString("usageCreate"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1739,8 +1908,9 @@ public class Messages { public static String usageRemove(Object label) { String msg = resources.getString("usageRemove"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1749,8 +1919,9 @@ public class Messages { public static String usageFormat(Object label) { String msg = resources.getString("usageFormat"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1759,8 +1930,9 @@ public class Messages { public static String usageModerator(Object label) { String msg = resources.getString("usageModerator"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1769,8 +1941,9 @@ public class Messages { public static String usageMod(Object label) { String msg = resources.getString("usageMod"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1779,8 +1952,9 @@ public class Messages { public static String usageDictionary(Object label) { String msg = resources.getString("usageDictionary"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1789,8 +1963,9 @@ public class Messages { public static String usageDic(Object label) { String msg = resources.getString("usageDic"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1799,8 +1974,9 @@ public class Messages { public static String usageOption(Object label) { String msg = resources.getString("usageOption"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1809,8 +1985,9 @@ public class Messages { public static String usageTemplate(Object label) { String msg = resources.getString("usageTemplate"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1819,8 +1996,9 @@ public class Messages { public static String usageCheck1(Object label) { String msg = resources.getString("usageCheck1"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1829,8 +2007,9 @@ public class Messages { public static String usageCheck2(Object label) { String msg = resources.getString("usageCheck2"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1839,8 +2018,9 @@ public class Messages { public static String usageReload(Object label) { String msg = resources.getString("usageReload"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1849,8 +2029,9 @@ public class Messages { public static String usageHelp(Object label) { String msg = resources.getString("usageHelp"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1859,8 +2040,9 @@ public class Messages { public static String usageSet1(Object label) { String msg = resources.getString("usageSet1"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1869,8 +2051,9 @@ public class Messages { public static String usageMessage(Object label) { String msg = resources.getString("usageMessage"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1879,8 +2062,9 @@ public class Messages { public static String usageReply(Object label) { String msg = resources.getString("usageReply"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1889,8 +2073,9 @@ public class Messages { public static String usageJapanize(Object label) { String msg = resources.getString("usageJapanize"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1899,8 +2084,9 @@ public class Messages { public static String usageJapanizeOther(Object label) { String msg = resources.getString("usageJapanizeOther"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1909,10 +2095,11 @@ public class Messages { public static String usageTop(Object type, Object num, Object max) { String msg = resources.getString("usageTop"); if ( msg == null ) return ""; - msg = msg.replace("%type%", type.toString()); - msg = msg.replace("%num%", num.toString()); - msg = msg.replace("%max%", max.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%type%", type.toString()); + kr.replace("%num%", num.toString()); + kr.replace("%max%", max.toString()); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1921,7 +2108,8 @@ public class Messages { public static String usageFoot() { String msg = resources.getString("usageFoot"); if ( msg == null ) return ""; - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + return Utility.replaceColorCode(kr.toString()); } /** @@ -1930,10 +2118,11 @@ public class Messages { public static String usageNoticeNextPage(Object label, Object type, Object next) { String msg = resources.getString("usageNoticeNextPage"); if ( msg == null ) return ""; - msg = msg.replace("%label%", label.toString()); - msg = msg.replace("%type%", type.toString()); - msg = msg.replace("%next%", next.toString()); - return Utility.replaceColorCode(msg); + KeywordReplacer kr = new KeywordReplacer(msg); + kr.replace("%label%", label.toString()); + kr.replace("%type%", type.toString()); + kr.replace("%next%", next.toString()); + return Utility.replaceColorCode(kr.toString()); } // === Auto-generated methods area end. === } diff --git a/src/main/java/com/github/ucchyocean/lc3/UUIDCacheData.java b/src/main/java/com/github/ucchyocean/lc3/UUIDCacheData.java index 2c813a1..d3e49d3 100644 --- a/src/main/java/com/github/ucchyocean/lc3/UUIDCacheData.java +++ b/src/main/java/com/github/ucchyocean/lc3/UUIDCacheData.java @@ -10,6 +10,8 @@ import java.io.IOException; import org.jetbrains.annotations.Nullable; +import com.github.ucchyocean.lc3.util.YamlConfig; + /** * UUIDのキャッシュデータを管理するクラス * @author ucchy @@ -80,4 +82,20 @@ public class UUIDCacheData { public @Nullable String get(String uuid) { return cache.getString(uuid); } + + /** + * プレイヤー名からUUIDを取得する + * @param name プレイヤー名 + * @return UUID(キャッシュされていない場合はnullが返される) + */ + public @Nullable String getUUIDFromName(String name) { + if ( name == null ) return null; + for ( String uuid : cache.getKeys(false) ) { + String n = cache.getString(uuid); + if ( name.equalsIgnoreCase(n) ) { + return uuid; + } + } + return null; + } } diff --git a/src/main/java/com/github/ucchyocean/lc3/YamlConfig.java b/src/main/java/com/github/ucchyocean/lc3/YamlConfig.java deleted file mode 100644 index 753a8c7..0000000 --- a/src/main/java/com/github/ucchyocean/lc3/YamlConfig.java +++ /dev/null @@ -1,164 +0,0 @@ -/* - * @author ucchy - * @license LGPLv3 - * @copyright Copyright ucchy 2020 - */ -package com.github.ucchyocean.lc3; - -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileWriter; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.io.Reader; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Set; - -import org.yaml.snakeyaml.Yaml; - -/** - * Yaml設定読み書きユーティリティクラス - * このクラスは、階層構造のデータ形式に対応していないので注意。 - * @author ucchy - */ -public class YamlConfig { - - private Map map = new HashMap<>(); - private Map defaults = new HashMap<>(); - - public static YamlConfig load(InputStream stream) throws IOException { - - YamlConfig config = new YamlConfig(); - if ( stream == null ) return config; - - Yaml yaml = new Yaml(); - - @SuppressWarnings("unchecked") - Map map = yaml.loadAs(stream, Map.class); - if ( map == null ) { - throw new IOException("Cannot load stream as yaml."); - } - - config.map = map; - return config; - } - - public static YamlConfig load(Reader reader) throws IOException { - - YamlConfig config = new YamlConfig(); - if ( reader == null ) return config; - - Yaml yaml = new Yaml(); - - @SuppressWarnings("unchecked") - Map map = yaml.loadAs(reader, Map.class); - if ( map == null ) { - throw new IOException("Cannot load reader as yaml."); - } - - config.map = map; - return config; - } - - public static YamlConfig load(File file) { - - // 対象ファイルが存在しない場合やからっぽの場合は、からっぽのYamlConfigを返す - if ( !file.exists() || !file.isFile() || file.length() == 0 ) return new YamlConfig(); - - // 読み込む - try ( InputStreamReader reader = new InputStreamReader(new FileInputStream(file), "UTF-8") ) { - return load(reader); - } catch (IOException e) { - e.printStackTrace(); - } - - // 読み込みに失敗した場合は、からっぽのYamlConfigを返す - return new YamlConfig(); - } - - public void save(File file) throws IOException { - - Yaml yaml = new Yaml(); - String data = yaml.dumpAsMap(map); - - try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { - writer.write(data); - } - } - - public String getRawData() { - Yaml yaml = new Yaml(); - return yaml.dumpAsMap(map); - } - - public void set(String key, Object value) { - map.put(key, value); - } - - public Object get(String key) { - return map.get(key); - } - - public boolean getBoolean(String key) { - return getBoolean(key, false); - } - - public boolean getBoolean(String key, boolean defaultValue) { - Object val = map.getOrDefault(key, defaults.get(key)); - return ( val != null && val instanceof Boolean ) ? (boolean)val : defaultValue; - } - - public int getInt(String key) { - return getInt(key, 0); - } - - public int getInt(String key, int defaultValue) { - Object val = map.getOrDefault(key, defaults.get(key)); - return ( val != null && val instanceof Integer ) ? (int)val : defaultValue; - } - - public String getString(String key) { - return getString(key, null); - } - - public String getString(String key, String defaultValue) { - Object val = map.getOrDefault(key, defaults.get(key)); - return ( val != null ) ? val.toString() : null; - } - - public List getStringList(String key) { - return getStringList(key, null); - } - - @SuppressWarnings("unchecked") - public List getStringList(String key, ArrayList defaultValue) { - Object val = map.getOrDefault(key, defaults.get(key)); - return ( val != null && val instanceof ArrayList ) ? (List)val : null; - } - - public boolean contains(String key) { - return map.containsKey(key); - } - - public Set getKeys(boolean deeps) { - if ( !deeps ) { - return map.keySet(); - } else { - // TODO 未実装 - return map.keySet(); - } - } - - public void addDefaults(YamlConfig defaults) { - if (defaults == null) { - this.defaults = new HashMap(); - } else { - this.defaults = defaults.map; - } - } -} diff --git a/src/main/java/com/github/ucchyocean/lc3/bridge/BungeePermsBridge.java b/src/main/java/com/github/ucchyocean/lc3/bridge/BungeePermsBridge.java index e2aa48e..be03ffd 100644 --- a/src/main/java/com/github/ucchyocean/lc3/bridge/BungeePermsBridge.java +++ b/src/main/java/com/github/ucchyocean/lc3/bridge/BungeePermsBridge.java @@ -6,7 +6,7 @@ package com.github.ucchyocean.lc3.bridge; import net.alpenblock.bungeeperms.BungeePermsAPI; -import net.md_5.bungee.api.ProxyServer; +import net.md_5.bungee.api.plugin.Plugin; /** * BungeePerms連携クラス @@ -20,12 +20,13 @@ public class BungeePermsBridge { /** * BungeePermsをロードする + * @param plugin BungeePermsのインスタンス * @return ロードされたBungeePermsBridge */ - public static BungeePermsBridge load() { + public static BungeePermsBridge load(Plugin plugin) { - // BungeePermsが動作しているかどうか確認 - boolean loaded = ProxyServer.getInstance().getPluginManager().getPlugin("BungeePerms") != null; + // BungeePermsが指定されたかどうかを確認 + boolean loaded = (plugin != null); // ロードされているならBungeePermsBridgeのインスタンスを、ロードされていないならnullを返す return loaded ? new BungeePermsBridge() : null; diff --git a/src/main/java/com/github/ucchyocean/lc3/bridge/LuckPermsBridge.java b/src/main/java/com/github/ucchyocean/lc3/bridge/LuckPermsBridge.java new file mode 100644 index 0000000..3f8eb87 --- /dev/null +++ b/src/main/java/com/github/ucchyocean/lc3/bridge/LuckPermsBridge.java @@ -0,0 +1,63 @@ +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.bridge; + +import java.util.UUID; + +import net.luckperms.api.LuckPerms; +import net.luckperms.api.LuckPermsProvider; +import net.luckperms.api.model.user.User; +import net.md_5.bungee.api.plugin.Plugin; + +/** + * LuckPerms連携クラス + * @author ucchy + */ +public class LuckPermsBridge { + + private LuckPerms api; + + // コンストラクタは外から利用不可 + private LuckPermsBridge(LuckPerms api) { + this.api = api; + } + + /** + * LuckPermsをロードする + * @param plugin LuckPermsのインスタンス + * @return ロードされたLuckPermsBridge + */ + public static LuckPermsBridge load(Plugin plugin) { + + // LuckPermsが指定されたかどうかを確認 + if ( plugin == null ) return null; + + // ロードされているならLuckPermsBridgeのインスタンスを作成して返す + return new LuckPermsBridge(LuckPermsProvider.get()); + } + + /** + * プレイヤーのprefixを取得します。 + * @param uniqueId プレイヤーのUUID + * @return プレイヤーのprefix + */ + public String getPlayerPrefix(UUID uniqueId) { + User user = api.getUserManager().getUser(uniqueId); + String prefix = user.getCachedData().getMetaData().getPrefix(); + return (prefix != null) ? prefix : ""; + } + + /** + * プレイヤーのsuffixを取得します。 + * @param uniqueId プレイヤーのUUID + * @return プレイヤーのsuffix + */ + public String getPlayerSuffix(UUID uniqueId) { + User user = api.getUserManager().getUser(uniqueId); + String suffix = user.getCachedData().getMetaData().getSuffix(); + return (suffix != null) ? suffix : ""; + } +} diff --git a/src/main/java/com/github/ucchyocean/lc3/bridge/McMMOBridge.java b/src/main/java/com/github/ucchyocean/lc3/bridge/McMMOBridge.java index f24672c..6c8b663 100644 --- a/src/main/java/com/github/ucchyocean/lc3/bridge/McMMOBridge.java +++ b/src/main/java/com/github/ucchyocean/lc3/bridge/McMMOBridge.java @@ -18,10 +18,10 @@ import com.github.ucchyocean.lc3.LunaChat; import com.github.ucchyocean.lc3.LunaChatAPI; import com.github.ucchyocean.lc3.LunaChatBukkit; import com.github.ucchyocean.lc3.LunaChatConfig; -import com.github.ucchyocean.lc3.Utility; import com.github.ucchyocean.lc3.bukkit.BukkitRecipientChatJapanizeTask; import com.github.ucchyocean.lc3.japanize.JapanizeType; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.Utility; import com.gmail.nossr50.api.PartyAPI; import com.gmail.nossr50.events.chat.McMMOPartyChatEvent; diff --git a/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java b/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java index 74256ce..70f19c9 100644 --- a/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java +++ b/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java @@ -27,13 +27,14 @@ import com.github.ucchyocean.lc3.LunaChatAPI; import com.github.ucchyocean.lc3.LunaChatBukkit; import com.github.ucchyocean.lc3.LunaChatConfig; import com.github.ucchyocean.lc3.Messages; -import com.github.ucchyocean.lc3.Utility; import com.github.ucchyocean.lc3.bridge.VaultChatBridge; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.event.EventResult; import com.github.ucchyocean.lc3.japanize.JapanizeType; import com.github.ucchyocean.lc3.member.ChannelMember; import com.github.ucchyocean.lc3.member.ChannelMemberBukkit; +import com.github.ucchyocean.lc3.util.KeywordReplacer; +import com.github.ucchyocean.lc3.util.Utility; /** * Bukkit関連のイベントを監視するリスナ @@ -455,16 +456,16 @@ public class BukkitEventListener implements Listener { */ private String replaceNormalChatFormatKeywords(String org, Player player) { - String format = org; - format = format.replace("%username", "%1$s"); - format = format.replace("%msg", "%2$s"); - format = format.replace("%player", player.getName()); + KeywordReplacer format = new KeywordReplacer(org); + format.replace("%username", "%1$s"); + format.replace("%msg", "%2$s"); + format.replace("%player", player.getName()); if ( format.contains("%date") ) { - format = format.replace("%date", dateFormat.format(new Date())); + format.replace("%date", dateFormat.format(new Date())); } if ( format.contains("%time") ) { - format = format.replace("%time", timeFormat.format(new Date())); + format.replace("%time", timeFormat.format(new Date())); } if ( format.contains("%prefix") || format.contains("%suffix") ) { @@ -476,8 +477,8 @@ public class BukkitEventListener implements Listener { prefix = vaultchat.getPlayerPrefix(player); suffix = vaultchat.getPlayerSuffix(player); } - format = format.replace("%prefix", prefix); - format = format.replace("%suffix", suffix); + format.replace("%prefix", prefix); + format.replace("%suffix", suffix); } if ( format.contains("%world") ) { @@ -489,12 +490,12 @@ public class BukkitEventListener implements Listener { if ( worldname == null || worldname.equals("") ) { worldname = player.getWorld().getName(); } - format = format.replace("%world", worldname); + format.replace("%world", worldname); } - format = format.replace("%server", ""); + format.replace("%server", ""); - return Utility.replaceColorCode(format); + return Utility.replaceColorCode(format.toString()); } /** diff --git a/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java b/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java index 5aea49d..16de23f 100644 --- a/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java +++ b/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java @@ -14,18 +14,20 @@ import java.util.concurrent.TimeUnit; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.github.ucchyocean.lc3.ChatColor; import com.github.ucchyocean.lc3.LunaChat; import com.github.ucchyocean.lc3.LunaChatAPI; import com.github.ucchyocean.lc3.LunaChatBungee; import com.github.ucchyocean.lc3.LunaChatConfig; import com.github.ucchyocean.lc3.Messages; -import com.github.ucchyocean.lc3.Utility; import com.github.ucchyocean.lc3.bridge.BungeePermsBridge; +import com.github.ucchyocean.lc3.bridge.LuckPermsBridge; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.event.EventResult; import com.github.ucchyocean.lc3.japanize.Japanizer; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.ChatColor; +import com.github.ucchyocean.lc3.util.KeywordReplacer; +import com.github.ucchyocean.lc3.util.Utility; import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.chat.TextComponent; @@ -400,40 +402,45 @@ public class BungeeEventListener implements Listener { */ private String replaceNormalChatFormatKeywords(String org, ProxiedPlayer player, String msg) { - String format = org; - format = format.replace("%username", player.getDisplayName()); - format = format.replace("%msg", msg); - format = format.replace("%player", player.getName()); + KeywordReplacer format = new KeywordReplacer(org); + format.replace("%username", player.getDisplayName()); + format.replace("%msg", msg); + format.replace("%player", player.getName()); if ( format.contains("%date") ) { - format = format.replace("%date", dateFormat.format(new Date())); + format.replace("%date", dateFormat.format(new Date())); } if ( format.contains("%time") ) { - format = format.replace("%time", timeFormat.format(new Date())); + format.replace("%time", timeFormat.format(new Date())); } if ( format.contains("%prefix") || format.contains("%suffix") ) { String prefix = ""; String suffix = ""; + LuckPermsBridge luckperms = LunaChatBungee.getInstance().getLuckPerms(); + if ( luckperms != null ) { + prefix = luckperms.getPlayerPrefix(player.getUniqueId()); + suffix = luckperms.getPlayerSuffix(player.getUniqueId()); + } BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms(); if ( bungeeperms != null ) { prefix = bungeeperms.userPrefix(player.getUniqueId().toString(), null, null); suffix = bungeeperms.userSuffix(player.getUniqueId().toString(), null, null); } - format = format.replace("%prefix", prefix); - format = format.replace("%suffix", suffix); + format.replace("%prefix", prefix); + format.replace("%suffix", suffix); } if ( format.contains("%world") ) { - format = format.replace("%world", ""); + format.replace("%world", ""); } if ( format.contains("%server") ) { - format = format.replace("%server", player.getServer().getInfo().getName()); + format.replace("%server", player.getServer().getInfo().getName()); } - return Utility.replaceColorCode(format); + return Utility.replaceColorCode(format.toString()); } /** diff --git a/src/main/java/com/github/ucchyocean/lc3/channel/BukkitChannel.java b/src/main/java/com/github/ucchyocean/lc3/channel/BukkitChannel.java index 62f325d..9d56be0 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/BukkitChannel.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/BukkitChannel.java @@ -21,12 +21,13 @@ import com.github.ucchyocean.lc3.LunaChatAPI; import com.github.ucchyocean.lc3.LunaChatBukkit; import com.github.ucchyocean.lc3.LunaChatConfig; import com.github.ucchyocean.lc3.Messages; -import com.github.ucchyocean.lc3.Utility; -import com.github.ucchyocean.lc3.UtilityBukkit; import com.github.ucchyocean.lc3.bridge.DynmapBridge; import com.github.ucchyocean.lc3.event.EventResult; import com.github.ucchyocean.lc3.member.ChannelMember; import com.github.ucchyocean.lc3.member.ChannelMemberBukkit; +import com.github.ucchyocean.lc3.util.KeywordReplacer; +import com.github.ucchyocean.lc3.util.Utility; +import com.github.ucchyocean.lc3.util.UtilityBukkit; /** * チャンネルの実装クラス @@ -80,6 +81,8 @@ public class BukkitChannel extends Channel { // 範囲チャット if ( player instanceof ChannelMemberBukkit ) { + // ↑常にtrueだと思うが、念のため。 + Location origin = ((ChannelMemberBukkit)player).getLocation(); for ( Player p : Bukkit.getOnlinePlayers() ) { ChannelMember cp = ChannelMember.getChannelMember(p); @@ -89,8 +92,6 @@ public class BukkitChannel extends Channel { recipients.add(ChannelMember.getChannelMember(p)); } } - } else { - // TODO 何かするか?検討する } } else { @@ -265,43 +266,43 @@ public class BukkitChannel extends Channel { LunaChatAPI api = LunaChat.getAPI(); - String msg = format; + KeywordReplacer msg = new KeywordReplacer(format); // テンプレートのキーワードを、まず最初に置き換える for ( int i=0; i<=9; i++ ) { String key = "%" + i; if ( msg.contains(key) ) { if ( api.getTemplate("" + i) != null ) { - msg = msg.replace(key, api.getTemplate("" + i)); + msg.replace(key, api.getTemplate("" + i)); break; } } } - msg = msg.replace("%ch", getName()); - //msg = msg.replace("%msg", message); - msg = msg.replace("%color", getColorCode()); + msg.replace("%ch", getName()); + //msg.replace("%msg", message); + msg.replace("%color", getColorCode()); if ( getPrivateMessageTo() != null ) { - msg = msg.replace("%to", getPrivateMessageTo().getDisplayName()); + msg.replace("%to", getPrivateMessageTo().getDisplayName()); } else { - msg = msg.replace("%to", ""); + msg.replace("%to", ""); } - msg = msg.replace("%recieverserver", ""); + msg.replace("%recieverserver", ""); if ( msg.contains("%date") ) { - msg = msg.replace("%date", dateFormat.format(new Date())); + msg.replace("%date", dateFormat.format(new Date())); } if ( msg.contains("%time") ) { - msg = msg.replace("%time", timeFormat.format(new Date())); + msg.replace("%time", timeFormat.format(new Date())); } if ( player != null ) { - msg = msg.replace("%username", player.getDisplayName()); - msg = msg.replace("%player", player.getName()); + msg.replace("%username", player.getDisplayName()); + msg.replace("%player", player.getName()); if ( msg.contains("%prefix") || msg.contains("%suffix") ) { - msg = msg.replace("%prefix", player.getPrefix()); - msg = msg.replace("%suffix", player.getSuffix()); + msg.replace("%prefix", player.getPrefix()); + msg.replace("%suffix", player.getSuffix()); } if ( msg.contains("%world") ) { @@ -313,21 +314,21 @@ public class BukkitChannel extends Channel { if ( worldname == null || worldname.equals("") ) { worldname = player.getWorldName(); } - msg = msg.replace("%world", worldname); + msg.replace("%world", worldname); } - msg = msg.replace("%server", ""); + msg.replace("%server", ""); } else { - msg = msg.replace("%username", ""); - msg = msg.replace("%player", ""); - msg = msg.replace("%prefix", ""); - msg = msg.replace("%suffix", ""); - msg = msg.replace("%world", ""); - msg = msg.replace("%server", ""); + msg.replace("%username", ""); + msg.replace("%player", ""); + msg.replace("%prefix", ""); + msg.replace("%suffix", ""); + msg.replace("%world", ""); + msg.replace("%server", ""); } - return Utility.replaceColorCode(msg); + return Utility.replaceColorCode(msg.toString()); } /** diff --git a/src/main/java/com/github/ucchyocean/lc3/channel/BungeeChannel.java b/src/main/java/com/github/ucchyocean/lc3/channel/BungeeChannel.java index 8158d4a..c25ab92 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/BungeeChannel.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/BungeeChannel.java @@ -14,10 +14,11 @@ import com.github.ucchyocean.lc3.LunaChat; import com.github.ucchyocean.lc3.LunaChatAPI; import com.github.ucchyocean.lc3.LunaChatBungee; import com.github.ucchyocean.lc3.LunaChatConfig; -import com.github.ucchyocean.lc3.Utility; import com.github.ucchyocean.lc3.event.EventResult; import com.github.ucchyocean.lc3.member.ChannelMember; import com.github.ucchyocean.lc3.member.ChannelMemberProxiedPlayer; +import com.github.ucchyocean.lc3.util.KeywordReplacer; +import com.github.ucchyocean.lc3.util.Utility; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.connection.ProxiedPlayer; @@ -195,71 +196,71 @@ public class BungeeChannel extends Channel { LunaChatAPI api = LunaChat.getAPI(); - String msg = format; + KeywordReplacer msg = new KeywordReplacer(format); // テンプレートのキーワードを、まず最初に置き換える for ( int i=0; i<=9; i++ ) { String key = "%" + i; if ( msg.contains(key) ) { if ( api.getTemplate("" + i) != null ) { - msg = msg.replace(key, api.getTemplate("" + i)); + msg.replace(key, api.getTemplate("" + i)); break; } } } - msg = msg.replace("%ch", getName()); - //msg = msg.replace("%msg", message); - msg = msg.replace("%color", getColorCode()); + msg.replace("%ch", getName()); + //msg.replace("%msg", message); + msg.replace("%color", getColorCode()); if ( getPrivateMessageTo() != null ) { - msg = msg.replace("%to", getPrivateMessageTo().getDisplayName()); + msg.replace("%to", getPrivateMessageTo().getDisplayName()); if ( getPrivateMessageTo() instanceof ChannelMemberProxiedPlayer ) { ChannelMemberProxiedPlayer cm = (ChannelMemberProxiedPlayer)getPrivateMessageTo(); - msg = msg.replace("%recieverserver", cm.getServer().getInfo().getName()); + msg.replace("%recieverserver", cm.getServer().getInfo().getName()); } else { - msg = msg.replace("%recieverserver", ""); + msg.replace("%recieverserver", ""); } } else { - msg = msg.replace("%to", ""); - msg = msg.replace("%recieverserver", ""); + msg.replace("%to", ""); + msg.replace("%recieverserver", ""); } if ( msg.contains("%date") ) { - msg = msg.replace("%date", dateFormat.format(new Date())); + msg.replace("%date", dateFormat.format(new Date())); } if ( msg.contains("%time") ) { - msg = msg.replace("%time", timeFormat.format(new Date())); + msg.replace("%time", timeFormat.format(new Date())); } if ( player != null ) { - msg = msg.replace("%username", player.getDisplayName()); - msg = msg.replace("%player", player.getName()); + msg.replace("%username", player.getDisplayName()); + msg.replace("%player", player.getName()); if ( msg.contains("%prefix") || msg.contains("%suffix") ) { - msg = msg.replace("%prefix", player.getPrefix()); - msg = msg.replace("%suffix", player.getSuffix()); + msg.replace("%prefix", player.getPrefix()); + msg.replace("%suffix", player.getSuffix()); } - msg = msg.replace("%world", ""); + msg.replace("%world", ""); if ( msg.contains("%server") ) { if ( player instanceof ChannelMemberProxiedPlayer ) { String serverName = ((ChannelMemberProxiedPlayer)player).getServer().getInfo().getName(); - msg = msg.replace("%server", serverName); + msg.replace("%server", serverName); } - msg = msg.replace("%server", ""); + msg.replace("%server", ""); } } else { - msg = msg.replace("%username", ""); - msg = msg.replace("%player", ""); - msg = msg.replace("%prefix", ""); - msg = msg.replace("%suffix", ""); - msg = msg.replace("%world", ""); - msg = msg.replace("%server", ""); + msg.replace("%username", ""); + msg.replace("%player", ""); + msg.replace("%prefix", ""); + msg.replace("%suffix", ""); + msg.replace("%world", ""); + msg.replace("%server", ""); } - return Utility.replaceColorCode(msg); + return Utility.replaceColorCode(msg.toString()); } /** diff --git a/src/main/java/com/github/ucchyocean/lc3/channel/Channel.java b/src/main/java/com/github/ucchyocean/lc3/channel/Channel.java index ec10118..847a0be 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/Channel.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/Channel.java @@ -16,7 +16,6 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.github.ucchyocean.lc3.ChatColor; import com.github.ucchyocean.lc3.LunaChat; import com.github.ucchyocean.lc3.LunaChatAPI; import com.github.ucchyocean.lc3.LunaChatConfig; @@ -24,11 +23,12 @@ import com.github.ucchyocean.lc3.LunaChatLogger; import com.github.ucchyocean.lc3.LunaChatMode; import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.NGWordAction; -import com.github.ucchyocean.lc3.Utility; -import com.github.ucchyocean.lc3.YamlConfig; import com.github.ucchyocean.lc3.event.EventResult; import com.github.ucchyocean.lc3.japanize.JapanizeType; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.ChatColor; +import com.github.ucchyocean.lc3.util.Utility; +import com.github.ucchyocean.lc3.util.YamlConfig; /** * チャンネル diff --git a/src/main/java/com/github/ucchyocean/lc3/channel/ChannelManager.java b/src/main/java/com/github/ucchyocean/lc3/channel/ChannelManager.java index 70016e3..e78d1d2 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/ChannelManager.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/ChannelManager.java @@ -16,10 +16,10 @@ import com.github.ucchyocean.lc3.LunaChat; import com.github.ucchyocean.lc3.LunaChatAPI; import com.github.ucchyocean.lc3.LunaChatMode; import com.github.ucchyocean.lc3.Messages; -import com.github.ucchyocean.lc3.YamlConfig; import com.github.ucchyocean.lc3.event.EventResult; import com.github.ucchyocean.lc3.japanize.JapanizeType; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.YamlConfig; /** * チャンネルマネージャー diff --git a/src/main/java/com/github/ucchyocean/lc3/channel/JapanizeConvertTask.java b/src/main/java/com/github/ucchyocean/lc3/channel/JapanizeConvertTask.java index 5dcd011..149180f 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/JapanizeConvertTask.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/JapanizeConvertTask.java @@ -12,12 +12,12 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import com.github.ucchyocean.lc3.LunaChat; -import com.github.ucchyocean.lc3.Utility; import com.github.ucchyocean.lc3.event.EventResult; import com.github.ucchyocean.lc3.japanize.IMEConverter; import com.github.ucchyocean.lc3.japanize.JapanizeType; import com.github.ucchyocean.lc3.japanize.YukiKanaConverter; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.Utility; /** * Japanize変換を実行して、実行後に発言を行うタスク diff --git a/src/main/java/com/github/ucchyocean/lc3/command/DictionaryCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/DictionaryCommand.java index 75f409d..bc4a303 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/DictionaryCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/DictionaryCommand.java @@ -7,9 +7,9 @@ package com.github.ucchyocean.lc3.command; import java.util.Map; -import com.github.ucchyocean.lc3.ChatColor; import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.ChatColor; /** * dictionaryコマンドの実行クラス diff --git a/src/main/java/com/github/ucchyocean/lc3/command/HideCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/HideCommand.java index bf3f8ab..7fcd0b9 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/HideCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/HideCommand.java @@ -8,9 +8,9 @@ package com.github.ucchyocean.lc3.command; import java.util.ArrayList; import com.github.ucchyocean.lc3.Messages; -import com.github.ucchyocean.lc3.Utility; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.Utility; /** * hideコマンドの実行クラス diff --git a/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java index 3e64e5c..29b33d5 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java @@ -9,10 +9,10 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; -import com.github.ucchyocean.lc3.ChatColor; import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.ChatColor; /** * listコマンドの実行クラス diff --git a/src/main/java/com/github/ucchyocean/lc3/command/OptionCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/OptionCommand.java index d82d5b4..1e8913c 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/OptionCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/OptionCommand.java @@ -11,11 +11,11 @@ import java.util.Map; import com.github.ucchyocean.lc3.LunaChat; import com.github.ucchyocean.lc3.Messages; -import com.github.ucchyocean.lc3.Utility; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.event.EventResult; import com.github.ucchyocean.lc3.japanize.JapanizeType; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.Utility; /** * optionコマンドの実行クラス @@ -198,16 +198,19 @@ public class OptionCommand extends LunaChatSubCommand { } else { String code = options.get("color"); + String colorForMsg = options.get("color").replace("&", "&").replace("#", "#"); if ( Utility.isValidColor(code) ) { code = Utility.changeToColorCode(code); } if ( Utility.isAltColorCode(code) ) { channel.setColorCode(code); - sender.sendMessage(Messages.cmdmsgOption("color", options.get("color"))); + sender.sendMessage(Messages.cmdmsgOption("color", colorForMsg) + .replace("#", "#").replace("&", "&")); setOption = true; } else { - sender.sendMessage(Messages.errmsgInvalidColorCode(options.get("color"))); + sender.sendMessage(Messages.errmsgInvalidColorCode(colorForMsg) + .replace("#", "#").replace("&", "&")); } } } diff --git a/src/main/java/com/github/ucchyocean/lc3/command/UnhideCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/UnhideCommand.java index 0c69ecf..46112a6 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/UnhideCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/UnhideCommand.java @@ -6,9 +6,9 @@ package com.github.ucchyocean.lc3.command; import com.github.ucchyocean.lc3.Messages; -import com.github.ucchyocean.lc3.Utility; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; +import com.github.ucchyocean.lc3.util.Utility; /** * unhideコマンドの実行クラス diff --git a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberProxiedPlayer.java b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberProxiedPlayer.java index 383bfe4..8cbd639 100644 --- a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberProxiedPlayer.java +++ b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberProxiedPlayer.java @@ -12,6 +12,7 @@ import org.jetbrains.annotations.Nullable; import com.github.ucchyocean.lc3.LunaChat; import com.github.ucchyocean.lc3.LunaChatBungee; import com.github.ucchyocean.lc3.bridge.BungeePermsBridge; +import com.github.ucchyocean.lc3.bridge.LuckPermsBridge; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.TextComponent; @@ -105,11 +106,16 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee { */ @Override public String getPrefix() { - BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms(); - if ( bungeeperms == null ) { - return ""; + + LuckPermsBridge luckperms = LunaChatBungee.getInstance().getLuckPerms(); + if ( luckperms != null ) { + return luckperms.getPlayerPrefix(id); } - return bungeeperms.userPrefix(id.toString(), null, null); + BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms(); + if ( bungeeperms != null ) { + return bungeeperms.userPrefix(id.toString(), null, null); + } + return ""; } /** @@ -119,11 +125,16 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee { */ @Override public String getSuffix() { - BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms(); - if ( bungeeperms == null ) { - return ""; + + LuckPermsBridge luckperms = LunaChatBungee.getInstance().getLuckPerms(); + if ( luckperms != null ) { + return luckperms.getPlayerPrefix(id); } - return bungeeperms.userSuffix(id.toString(), null, null); + BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms(); + if ( bungeeperms != null ) { + return bungeeperms.userPrefix(id.toString(), null, null); + } + return ""; } /** diff --git a/src/main/java/com/github/ucchyocean/lc3/tool/MessageParser.java b/src/main/java/com/github/ucchyocean/lc3/tool/MessageParser.java index 2223ea8..d6f3870 100644 --- a/src/main/java/com/github/ucchyocean/lc3/tool/MessageParser.java +++ b/src/main/java/com/github/ucchyocean/lc3/tool/MessageParser.java @@ -16,7 +16,7 @@ import java.util.List; import java.util.regex.Matcher; import java.util.regex.Pattern; -import com.github.ucchyocean.lc3.YamlConfig; +import com.github.ucchyocean.lc3.util.YamlConfig; /** * messages_ja.yml を読んで、Messagesクラス用のメソッドを生成するツール @@ -109,17 +109,18 @@ public class MessageParser { " String msg = resources.getString(\"%s\");", key)); result.add(String.format( " if ( msg == null ) return \"\";", key)); + result.add(" KeywordReplacer kr = new KeywordReplacer(msg);"); for ( String keyword : keywords ) { result.add(String.format( - " msg = msg.replace(\"%%%s%%\", %s.toString());", keyword, keyword)); + " kr.replace(\"%%%s%%\", %s.toString());", keyword, keyword)); } if ( key.startsWith("errmsg") ) { - result.add(" return Utility.replaceColorCode(resources.getString(\"errorPrefix\", \"\") + msg);"); + result.add(" return Utility.replaceColorCode(resources.getString(\"errorPrefix\", \"\") + kr.toString());"); } else if ( key.startsWith("cmdmsg") ) { - result.add(" return Utility.replaceColorCode(resources.getString(\"infoPrefix\", \"\") + msg);"); + result.add(" return Utility.replaceColorCode(resources.getString(\"infoPrefix\", \"\") + kr.toString());"); } else { - result.add(" return Utility.replaceColorCode(msg);"); + result.add(" return Utility.replaceColorCode(kr.toString());"); } result.add(" }"); } diff --git a/src/main/java/com/github/ucchyocean/lc3/util/ChatColor.java b/src/main/java/com/github/ucchyocean/lc3/util/ChatColor.java new file mode 100644 index 0000000..8b44f66 --- /dev/null +++ b/src/main/java/com/github/ucchyocean/lc3/util/ChatColor.java @@ -0,0 +1,140 @@ +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.util; + +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +/** + * チャットカラー + * @author ucchy + */ +public final class ChatColor { + + public static final ChatColor BLACK = new ChatColor("BLACK", '0', 0x00); + public static final ChatColor DARK_BLUE = new ChatColor("DARK_BLUE", '1', 0x1); + public static final ChatColor DARK_GREEN = new ChatColor("DARK_GREEN", '2', 0x2); + public static final ChatColor DARK_AQUA = new ChatColor("DARK_AQUA", '3', 0x3); + public static final ChatColor DARK_RED = new ChatColor("DARK_RED", '4', 0x4); + public static final ChatColor DARK_PURPLE = new ChatColor("DARK_PURPLE", '5', 0x5); + public static final ChatColor GOLD = new ChatColor("GOLD", '6', 0x6); + public static final ChatColor GRAY = new ChatColor("GRAY", '7', 0x7); + public static final ChatColor DARK_GRAY = new ChatColor("DARK_GRAY", '8', 0x8); + public static final ChatColor BLUE = new ChatColor("BLUE", '9', 0x9); + public static final ChatColor GREEN = new ChatColor("GREEN", 'a', 0xA); + public static final ChatColor AQUA = new ChatColor("AQUA", 'b', 0xB); + public static final ChatColor RED = new ChatColor("RED", 'c', 0xC); + public static final ChatColor LIGHT_PURPLE = new ChatColor("LIGHT_PURPLE", 'd', 0xD); + public static final ChatColor YELLOW = new ChatColor("YELLOW", 'e', 0xE); + public static final ChatColor WHITE = new ChatColor("WHITE", 'f', 0xF); + public static final ChatColor MAGIC = new ChatColor("MAGIC", 'k', 0x10, true); + public static final ChatColor BOLD = new ChatColor("BOLD", 'l', 0x11, true); + public static final ChatColor STRIKETHROUGH = new ChatColor("STRIKETHROUGH", 'm', 0x12, true); + public static final ChatColor UNDERLINE = new ChatColor("UNDERLINE", 'n', 0x13, true); + public static final ChatColor ITALIC = new ChatColor("ITALIC", 'o', 0x14, true); + public static final ChatColor RESET = new ChatColor("RESET", 'r', 0x15); + + public static final char COLOR_CHAR = '\u00A7'; + + @SuppressWarnings("unused") + private final int intCode; + private final char code; + private final boolean isFormat; + private final String toString; + private final String name; + + private ChatColor(String name, char code, int intCode) { + this(name, code, intCode, false); + } + + private ChatColor(String name, char code, int intCode, boolean isFormat) { + this.name = name; + this.code = code; + this.intCode = intCode; + this.isFormat = isFormat; + this.toString = new String(new char[] {COLOR_CHAR, code}); + } + + private ChatColor(String name, String toString) { + this.name = name; + this.toString = toString; + this.isFormat = false; + this.code = 'c'; + this.intCode =0xFF; + } + + public String name() { + return name; + } + + public char getChar() { + return code; + } + + @NotNull + @Override + public String toString() { + return toString; + } + + public boolean isFormat() { + return isFormat; + } + + public static @Nullable ChatColor getChatColorFromWebColor(String code) { + if ( code == null ) return null; + if ( code.matches("#[0-9a-fA-F]{3}") ) { + return new ChatColor(code, code.replaceAll( + "#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])", + "\u00A7x\u00A7$1\u00A7$1\u00A7$2\u00A7$2\u00A7$3\u00A7$3")); + } else if ( code.matches("#[0-9a-fA-F]{6}") ) { + return new ChatColor(code, code.replaceAll( + "#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])", + "\u00A7x\u00A7$1\u00A7$2\u00A7$3\u00A7$4\u00A7$5\u00A7$6")); + } + return null; + } + + public static ChatColor[] values() { + return new ChatColor[] { + BLACK, + DARK_BLUE, + DARK_GREEN, + DARK_AQUA, + DARK_RED, + DARK_PURPLE, + GOLD, + GRAY, + DARK_GRAY, + BLUE, + GREEN, + AQUA, + RED, + LIGHT_PURPLE, + YELLOW, + WHITE, + MAGIC, + BOLD, + STRIKETHROUGH, + UNDERLINE, + ITALIC, + RESET, + }; + } + + public static ChatColor valueOf(String code) { + if ( code.matches("#[0-9a-fA-F]{6}") ) { + return new ChatColor(code, code.replaceAll( + "#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])", + "\u00A7x\u00A7$1\u00A7$2\u00A7$3\u00A7$4\u00A7$5\u00A7$6")); + } else { + for ( ChatColor v : values() ) { + if ( v.name.equals(code) ) return v; + } + } + return null; + } +} diff --git a/src/main/java/com/github/ucchyocean/lc3/EventPriority.java b/src/main/java/com/github/ucchyocean/lc3/util/EventPriority.java similarity index 80% rename from src/main/java/com/github/ucchyocean/lc3/EventPriority.java rename to src/main/java/com/github/ucchyocean/lc3/util/EventPriority.java index 509ee5f..289640e 100644 --- a/src/main/java/com/github/ucchyocean/lc3/EventPriority.java +++ b/src/main/java/com/github/ucchyocean/lc3/util/EventPriority.java @@ -3,7 +3,7 @@ * @license LGPLv3 * @copyright Copyright ucchy 2020 */ -package com.github.ucchyocean.lc3; +package com.github.ucchyocean.lc3.util; /** * Event優先度列挙子 diff --git a/src/main/java/com/github/ucchyocean/lc3/util/KeywordReplacer.java b/src/main/java/com/github/ucchyocean/lc3/util/KeywordReplacer.java new file mode 100644 index 0000000..2f6bc2f --- /dev/null +++ b/src/main/java/com/github/ucchyocean/lc3/util/KeywordReplacer.java @@ -0,0 +1,54 @@ +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.util; + +/** + * 文字列のキーワード置き換えを行うユーティリティクラス + * @author ucchy + */ +public class KeywordReplacer { + + private StringBuilder str; + + /** + * 指定された文字列で初期化を行う + * @param src + */ + public KeywordReplacer(String src) { + str = new StringBuilder(src); + } + + /** + * 文字列keywordえを、文字列valueに置き替える + * @param keyword キーワード + * @param value 値 + */ + public void replace(String keyword, String value) { + int start; + while ( (start = str.indexOf(keyword)) > -1 ) { + str.replace(start, start + keyword.length(), value); + } + } + + /** + * 指定された文字列が含まれているかどうかを判定する + * @param keyword キーワード + * @return 含まれているかどうか + */ + public boolean contains(String keyword) { + return str.indexOf(keyword) > -1; + } + + /** + * 文字列をStringで取得する + * @return String + * @see java.lang.Object#toString() + */ + @Override + public String toString() { + return str.toString(); + } +} diff --git a/src/main/java/com/github/ucchyocean/lc3/Utility.java b/src/main/java/com/github/ucchyocean/lc3/util/Utility.java similarity index 77% rename from src/main/java/com/github/ucchyocean/lc3/Utility.java rename to src/main/java/com/github/ucchyocean/lc3/util/Utility.java index 34745a3..7a274d1 100644 --- a/src/main/java/com/github/ucchyocean/lc3/Utility.java +++ b/src/main/java/com/github/ucchyocean/lc3/util/Utility.java @@ -3,7 +3,7 @@ * @license LGPLv3 * @copyright Copyright ucchy 2020 */ -package com.github.ucchyocean.lc3; +package com.github.ucchyocean.lc3.util; import java.io.BufferedReader; import java.io.BufferedWriter; @@ -17,6 +17,9 @@ import java.util.Locale; import java.util.jar.JarFile; import java.util.zip.ZipEntry; +import com.github.ucchyocean.lc3.LunaChat; +import com.github.ucchyocean.lc3.LunaChatMode; + /** * ユーティリティクラス * @author ucchy @@ -76,7 +79,23 @@ public class Utility { */ public static String replaceColorCode(String source) { if (source == null) return null; - return source.replaceAll("&([0-9a-fk-or])", "\u00A7$1"); + return replaceWebColorCode(source) + .replaceAll("&([0-9a-fk-orA-FK-OR])", "\u00A7$1"); + } + + /** + * Webカラーコード(#99AABBなど)を、カラーコードに置き換えする + * @param source 置き換え元の文字列 + * @return 置き換え後の文字列 + */ + private static String replaceWebColorCode(String source) { + return source + .replaceAll( + "#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])", + "\u00A7x\u00A7$1\u00A7$2\u00A7$3\u00A7$4\u00A7$5\u00A7$6") + .replaceAll( + "#([0-9a-fA-F])([0-9a-fA-F])([0-9a-fA-F])", + "\u00A7x\u00A7$1\u00A7$1\u00A7$2\u00A7$2\u00A7$3\u00A7$3"); } /** @@ -86,7 +105,7 @@ public class Utility { */ public static String stripColorCode(String source) { if (source == null) return null; - return stripAltColorCode(source).replaceAll("\u00A7([0-9a-fk-or])", "").replaceAll("&([0-9a-fk-or])", ""); + return stripAltColorCode(source).replaceAll("\u00A7([0-9a-fk-orxA-FK-ORX])", ""); } /** @@ -96,7 +115,8 @@ public class Utility { */ public static String stripAltColorCode(String source) { if (source == null) return null; - return source.replaceAll("&([0-9a-fk-or])", ""); + source = source.replaceAll("#[0-9a-fA-F]{6}", "").replaceAll("#[0-9a-fA-F]{3}", ""); + return source.replaceAll("&([0-9a-fk-orxA-FK-ORX])", ""); } /** @@ -106,7 +126,7 @@ public class Utility { */ public static boolean isColorCode(String code) { if (code == null) return false; - return code.matches("\u00A7[0-9a-fk-orA-FK-OR]"); + return code.matches("\u00A7[0-9a-fk-orxA-FK-ORX]"); } /** @@ -116,7 +136,7 @@ public class Utility { */ public static boolean isAltColorCode(String code) { if (code == null) return false; - return code.matches("&[0-9a-fk-orA-FK-OR]"); + return code.matches("(&[0-9a-fk-orA-FK-OR]|#[0-9a-fA-F]{3}|#[0-9a-fA-F]{6})"); } /** @@ -135,12 +155,11 @@ public class Utility { } /** - * カラー表記の文字列を、カラーコードに変換する + * カラー表記の文字列(REDとかGREENとか)を、カラーコード候補(&a)に変換する * @param color カラー表記の文字列 - * @return カラーコード + * @return カラーコード候補 */ public static String changeToColorCode(String color) { - return "&" + changeToChatColor(color).getChar(); } @@ -150,7 +169,6 @@ public class Utility { * @return ChatColorクラス */ public static ChatColor changeToChatColor(String color) { - if (isValidColor(color)) { return ChatColor.valueOf(color.toUpperCase()); } @@ -176,7 +194,12 @@ public class Utility { * @return 接続したことがあるかどうか */ public static boolean existsOfflinePlayer(String name) { - // TODO 未実装 + if ( LunaChat.getUUIDCacheData().getUUIDFromName(name) != null ) { + return true; + } + if ( LunaChat.getMode() == LunaChatMode.BUKKIT ) { + return UtilityBukkit.existsOfflinePlayer(name); + } return false; } diff --git a/src/main/java/com/github/ucchyocean/lc3/UtilityBukkit.java b/src/main/java/com/github/ucchyocean/lc3/util/UtilityBukkit.java similarity index 78% rename from src/main/java/com/github/ucchyocean/lc3/UtilityBukkit.java rename to src/main/java/com/github/ucchyocean/lc3/util/UtilityBukkit.java index fa46c43..01e64e2 100644 --- a/src/main/java/com/github/ucchyocean/lc3/UtilityBukkit.java +++ b/src/main/java/com/github/ucchyocean/lc3/util/UtilityBukkit.java @@ -3,7 +3,7 @@ * @license LGPLv3 * @copyright Copyright ucchy 2020 */ -package com.github.ucchyocean.lc3; +package com.github.ucchyocean.lc3.util; import java.util.Collection; @@ -55,4 +55,13 @@ public class UtilityBukkit { public static Player getPlayerExact(String name) { return Bukkit.getPlayer(Utility.stripColorCode(name)); } + + /** + * 指定された名前のプレイヤーが接続したことがあるかどうかを検索する + * @param name プレイヤー名 + * @return 接続したことがあるかどうか + */ + public static boolean existsOfflinePlayer(String name) { + return (getOfflinePlayer(name) != null); + } } diff --git a/src/main/java/com/github/ucchyocean/lc3/util/YamlConfig.java b/src/main/java/com/github/ucchyocean/lc3/util/YamlConfig.java new file mode 100644 index 0000000..cb5b2cb --- /dev/null +++ b/src/main/java/com/github/ucchyocean/lc3/util/YamlConfig.java @@ -0,0 +1,108 @@ +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.util; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.util.Map; + +import org.jetbrains.annotations.NotNull; +import org.yaml.snakeyaml.Yaml; + +/** + * Yaml設定読み書きユーティリティクラス + * @author ucchy + */ +public class YamlConfig extends YamlSection { + + /** + * InputStreamからYamlConfigをロードする + * @param stream InputStream + * @return ロードされたYamlConfig + * @throws IOException InputStreamの入力がyamlとして解析できない場合など + */ + public static YamlConfig load(InputStream stream) throws IOException { + + YamlConfig config = new YamlConfig(); + if ( stream == null ) return config; + + Yaml yaml = new Yaml(); + + @SuppressWarnings("unchecked") + Map map = yaml.loadAs(stream, Map.class); + if ( map == null ) { + throw new IOException("Cannot load stream as yaml."); + } + + config.map = map; + return config; + } + + /** + * ReaderからYamlConfigをロードする + * @param reader Reader + * @return ロードされたYamlConfig + * @throws IOException Readerの入力がyamlとして解析できない場合など + */ + public static YamlConfig load(Reader reader) throws IOException { + + YamlConfig config = new YamlConfig(); + if ( reader == null ) return config; + + Yaml yaml = new Yaml(); + + @SuppressWarnings("unchecked") + Map map = yaml.loadAs(reader, Map.class); + if ( map == null ) { + throw new IOException("Cannot load reader as yaml."); + } + + config.map = map; + return config; + } + + /** + * FileからYamlConfigをロードする + * @param file File + * @return ロードされたYamlConfig(ロードに失敗した場合は空のYamlConfigが返される) + */ + public static @NotNull YamlConfig load(File file) { + + // 対象ファイルが存在しない場合やからっぽの場合は、からっぽのYamlConfigを返す + if ( !file.exists() || !file.isFile() || file.length() == 0 ) return new YamlConfig(); + + // 読み込む + try ( InputStreamReader reader = new InputStreamReader(new FileInputStream(file), "UTF-8") ) { + return load(reader); + } catch (IOException e) { + e.printStackTrace(); + } + + // 読み込みに失敗した場合は、からっぽのYamlConfigを返す + return new YamlConfig(); + } + + /** + * 保存する + * @param file 保存先 + * @throws IOException 保存に失敗した場合など + */ + public void save(File file) throws IOException { + + Yaml yaml = new Yaml(); + String data = yaml.dumpAsMap(map); + + try (BufferedWriter writer = new BufferedWriter(new FileWriter(file))) { + writer.write(data); + } + } +} diff --git a/src/main/java/com/github/ucchyocean/lc3/util/YamlSection.java b/src/main/java/com/github/ucchyocean/lc3/util/YamlSection.java new file mode 100644 index 0000000..ef59067 --- /dev/null +++ b/src/main/java/com/github/ucchyocean/lc3/util/YamlSection.java @@ -0,0 +1,295 @@ +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.util; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.TreeSet; + +import org.jetbrains.annotations.Nullable; +import org.yaml.snakeyaml.Yaml; + +/** + * Yaml設定読み書きユーティリティクラス + * @author ucchy + */ +public class YamlSection { + + Map map; + private Map defaults = new HashMap<>(); + + /** + * コンストラクタ + */ + public YamlSection() { + map = new HashMap<>(); + } + + /** + * コンストラクタ + * @param map 初期データ + */ + public YamlSection(Map map) { + this.map = map; + } + + /** + * 保持しているデータをStringに変換して返す + * @return Stringに変換されたデータ + */ + public String getRawData() { + Yaml yaml = new Yaml(); + return yaml.dumpAsMap(map); + } + + /** + * 指定されたkeyにvalueを設定する + * @param key + * @param value + */ + public void set(String key, Object value) { + if ( key.contains(".") ) { + String parent = key.substring(0, key.indexOf(".")); + YamlSection section = getSection(parent); + if ( section == null ) { + section = createSection(parent); + } + String remain = key.substring(key.indexOf(".") + 1); + section.set(remain, value); + } else { + map.put(key, value); + } + } + + /** + * 指定されたkeyの値を取得する + * @param key + * @return keyに対応する値(値が無い場合はnullが返される) + */ + public @Nullable Object get(String key) { + return get(key, null); + } + + /** + * 指定されたkeyの値を取得する + * @param key + * @param defaultValue デフォルト値 + * @return keyに対応する値(値が無い場合はdefaultValueが返される) + */ + public Object get(String key, Object defaultValue) { + if ( key.contains(".") ) { + String parent = key.substring(0, key.indexOf(".")); + YamlSection section = getSection(parent); + if ( section == null ) return defaultValue; + String remain = key.substring(key.indexOf(".") + 1); + return section.get(remain, defaultValue); + } else { + Object val = map.getOrDefault(key, defaults.get(key)); + return ( val != null ) ? val : defaultValue; + } + } + + /** + * 指定されたkeyの値をbooleanに変換して返す + * @param key + * @return keyに対応する値(値が無いかbooleanに変換できない場合はfalseが返される) + */ + public boolean getBoolean(String key) { + return getBoolean(key, false); + } + + /** + * 指定されたkeyの値をbooleanに変換して返す + * @param key + * @param defaultValue デフォルト値 + * @return keyに対応する値(値が無いかbooleanに変換できない場合はdefaultValueが返される) + */ + public boolean getBoolean(String key, boolean defaultValue) { + Object val = get(key, defaults.get(key)); + return ( val != null && val instanceof Boolean ) ? (boolean)val : defaultValue; + } + + /** + * 指定されたkeyの値をintに変換して返す + * @param key + * @return keyに対応する値(値が無いかintに変換できない場合は0が返される) + */ + public int getInt(String key) { + return getInt(key, 0); + } + + /** + * 指定されたkeyの値をintに変換して返す + * @param key + * @param defaultValue デフォルト値 + * @return keyに対応する値(値が無いかintに変換できない場合はdefaultValueが返される) + */ + public int getInt(String key, int defaultValue) { + Object val = get(key, defaults.get(key)); + return ( val != null && val instanceof Integer ) ? (int)val : defaultValue; + } + + /** + * 指定されたkeyの値をStringに変換して返す + * @param key + * @return keyに対応する値(値が無いかStringに変換できない場合は0が返される) + */ + public @Nullable String getString(String key) { + return getString(key, null); + } + + /** + * 指定されたkeyの値をStringに変換して返す + * @param key + * @param defaultValue デフォルト値 + * @return keyに対応する値(値が無いかStringに変換できない場合はdefaultValueが返される) + */ + public String getString(String key, String defaultValue) { + Object val = get(key, defaults.get(key)); + return ( val != null ) ? val.toString() : defaultValue; + } + + /** + * 指定されたkeyの値をList<String>に変換して返す + * @param key + * @return keyに対応する値(値が無いかList<String>に変換できない場合はnullが返される) + */ + public @Nullable List getStringList(String key) { + return getStringList(key, null); + } + + /** + * 指定されたkeyの値をList<String>に変換して返す + * @param key + * @param defaultValue デフォルト値 + * @return keyに対応する値(値が無いかList<String>に変換できない場合はdefaultValueが返される) + */ + @SuppressWarnings("unchecked") + public List getStringList(String key, ArrayList defaultValue) { + Object val = get(key, defaults.get(key)); + return ( val != null && val instanceof ArrayList ) ? (List)val : defaultValue; + } + + /** + * 指定されたkeyの値をMap<String, Object>に変換して返す + * @param key + * @return keyに対応する値(値が無いかMap<String, Object>に変換できない場合はnullが返される) + */ + public @Nullable Map getMap(String key) { + return getMap(key, null); + } + + /** + * 指定されたkeyの値をMap<String, Object>に変換して返す + * @param key + * @param defaultValue デフォルト値 + * @return keyに対応する値(値が無いかMap<String, Object>に変換できない場合はdefaultValueが返される) + */ + @SuppressWarnings("unchecked") + public Map getMap(String key, Map defaultValue) { + Object val = get(key, defaults.get(key)); + return ( val != null && val instanceof Map ) ? (Map)val : defaultValue; + } + + /** + * 指定されたkeyの値をYamlSectionに変換して返す + * @param key + * @return YamlSection(値が無いかMap<String, Object>に変換できない場合はnullが返される) + */ + public @Nullable YamlSection getSection(String key) { + return getSection(key, null); + } + + /** + * 指定されたkeyの値をYamlSectionに変換して返す + * @param key + * @param defaultValue デフォルト値 + * @return YamlSection(値が無いかMap<String, Object>に変換できない場合はdefaultValueが返される) + */ + public YamlSection getSection(String key, YamlSection defaultValue) { + Map m = getMap(key); + if ( m == null ) return defaultValue; + return new YamlSection(m); + } + + /** + * 指定されたkeyの値があるかどうか判定する + * @param key + * @return 値があるかどうか + */ + public boolean contains(String key) { + if ( key.contains(".") ) { + String parent = key.substring(0, key.indexOf(".")); + YamlSection section = getSection(parent); + if ( section == null ) return false; + String remain = key.substring(key.indexOf(".") + 1); + return section.contains(remain); + } else { + return map.containsKey(key); + } + } + + /** + * 指定されたkeyに対応するサブセクションがあるかどうか判定する + * @param key + * @return サブセクションがあるかどうか + */ + public boolean containsSection(String key) { + return (getMap(key) != null); + } + + /** + * 指定されたkeyのサブセクションを作成する
+ * 注意:階層構造指定でセクションを作成した場合、最下層のセクションが戻り値として返されることに注意すること。
+ * 例えば、createSection("aa.bb.cc") の戻り値は "cc" のセクションとなる。 + * @param key + * @return サブセクション + */ + public YamlSection createSection(String key) { + if ( containsSection(key) ) return getSection(key); + Map map = new HashMap(); + set(key, map); + return new YamlSection(map); + } + + /** + * 階層のkeyを羅列する + * @param deeps 再帰的にkeyを取得するかどうか + * @return keyの羅列 + */ + public Set getKeys(boolean deeps) { + if ( !deeps ) { + return map.keySet(); + } else { + Set result = new TreeSet(); + for ( String key : map.keySet() ) { + result.add(key); + if ( containsSection(key) ) { + YamlSection sec = getSection(key); + for ( String sub : sec.getKeys(true) ) { + result.add(key + "." + sub); + } + } + } + return result; + } + } + + /** + * デフォルト値を設定する + * @param defaults デフォルト値 + */ + public void addDefaults(YamlSection defaults) { + if (defaults == null) { + this.defaults = new HashMap(); + } else { + this.defaults = defaults.map; + } + } +} diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 777eb86..ebba587 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -203,4 +203,4 @@ japanizeIgnorePlayerName: true # Non-Japanese marker. # If this is at the beginning of your remark, do not temporarily perform Japanize conversion. -noneJapanizeMarker: '#' +noneJapanizeMarker: '$' diff --git a/src/main/resources/config_ja.yml b/src/main/resources/config_ja.yml index 063ee99..279e695 100644 --- a/src/main/resources/config_ja.yml +++ b/src/main/resources/config_ja.yml @@ -213,6 +213,6 @@ japanizeIgnorePlayerName: true # ノンジャパナイズマーカー。 # これが発言の頭に入っている場合は、一時的にJapanize変換を実行しない。 -noneJapanizeMarker: '#' +noneJapanizeMarker: '$' diff --git a/src/test/java/com/github/ucchyocean/lc3/util/UtilityTester.java b/src/test/java/com/github/ucchyocean/lc3/util/UtilityTester.java new file mode 100644 index 0000000..3611b04 --- /dev/null +++ b/src/test/java/com/github/ucchyocean/lc3/util/UtilityTester.java @@ -0,0 +1,28 @@ +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.util; + +import junit.framework.TestCase; + +/** + * + * @author ucchy + */ +public class UtilityTester extends TestCase { + + public void testColorCode() { + + String testee = "#FFEEDDtesuto#112233aiueo"; + System.out.println(Utility.replaceColorCode(testee)); + + assertTrue("§x§F§F§E§E§D§Dtesuto§x§1§1§2§2§3§3aiueo".equals(Utility.replaceColorCode(testee))); + + testee = "#FEDtesuto#123aiueo"; + System.out.println(Utility.replaceColorCode(testee)); + + assertTrue("§x§F§F§E§E§D§Dtesuto§x§1§1§2§2§3§3aiueo".equals(Utility.replaceColorCode(testee))); + } +} diff --git a/src/test/java/com/github/ucchyocean/lc3/util/YamlConfigTester.java b/src/test/java/com/github/ucchyocean/lc3/util/YamlConfigTester.java new file mode 100644 index 0000000..f053e7c --- /dev/null +++ b/src/test/java/com/github/ucchyocean/lc3/util/YamlConfigTester.java @@ -0,0 +1,47 @@ +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.util; + +import java.util.ArrayList; +import java.util.List; + +import junit.framework.TestCase; + +/** + * YamlConfigのテスト + * @author ucchy + */ +public class YamlConfigTester extends TestCase { + + public void testYamlConfig() { + + YamlConfig config = new YamlConfig(); + + config.set("aaa.bbb", "test"); + config.set("aaa.int", 1); + + YamlSection section = config.createSection("bbb"); + + section.set("aiueo.aaa", "testdesu"); + List list = new ArrayList<>(); + list.add("aa"); + list.add("bb"); + section.set("list", list); + + System.out.println("=== Yaml Values ==="); + System.out.println(config.getRawData()); + System.out.println(); + System.out.println("=== Yaml Keys (deeps=true) ==="); + for ( String key : config.getKeys(true) ) { + System.out.println(key); + } + + assertTrue("test".equals(config.getString("aaa.bbb"))); + assertTrue("testdesu".equals(config.getString("bbb.aiueo.aaa"))); + assertTrue(config.getInt("aaa.int") == 1); + assertTrue(config.getStringList("bbb.list").size() == 2); + } +}