diff --git a/src/main/java/com/github/ucchyocean/lc3/Messages.java b/src/main/java/com/github/ucchyocean/lc3/Messages.java index 10b353b..4e148da 100644 --- a/src/main/java/com/github/ucchyocean/lc3/Messages.java +++ b/src/main/java/com/github/ucchyocean/lc3/Messages.java @@ -84,11 +84,11 @@ public class Messages { */ public static String joinMessage(Object color, Object channel, Object player) { String msg = resources.getString("joinMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -96,11 +96,11 @@ public class Messages { */ public static String quitMessage(Object color, Object channel, Object player) { String msg = resources.getString("quitMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -108,10 +108,10 @@ public class Messages { */ public static String breakupMessage(Object color, Object channel) { String msg = resources.getString("breakupMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -119,11 +119,11 @@ public class Messages { */ public static String banMessage(Object color, Object channel, Object player) { String msg = resources.getString("banMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -131,11 +131,11 @@ public class Messages { */ public static String kickMessage(Object color, Object channel, Object player) { String msg = resources.getString("kickMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -143,11 +143,11 @@ public class Messages { */ public static String muteMessage(Object color, Object channel, Object player) { String msg = resources.getString("muteMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -155,11 +155,11 @@ public class Messages { */ public static String banNGWordMessage(Object color, Object channel, Object player) { String msg = resources.getString("banNGWordMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -167,11 +167,11 @@ public class Messages { */ public static String kickNGWordMessage(Object color, Object channel, Object player) { String msg = resources.getString("kickNGWordMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -179,11 +179,11 @@ public class Messages { */ public static String muteNGWordMessage(Object color, Object channel, Object player) { String msg = resources.getString("muteNGWordMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -191,12 +191,12 @@ public class Messages { */ public static String banWithExpireMessage(Object color, Object channel, Object player, Object minutes) { String msg = resources.getString("banWithExpireMessage"); - if ( msg == null || msg.equals("") ) return ""; + 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 msg; + return Utility.replaceColorCode(msg); } /** @@ -204,12 +204,12 @@ public class Messages { */ public static String muteWithExpireMessage(Object color, Object channel, Object player, Object minutes) { String msg = resources.getString("muteWithExpireMessage"); - if ( msg == null || msg.equals("") ) return ""; + 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 msg; + return Utility.replaceColorCode(msg); } /** @@ -217,11 +217,11 @@ public class Messages { */ public static String pardonMessage(Object color, Object channel, Object player) { String msg = resources.getString("pardonMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -229,11 +229,11 @@ public class Messages { */ public static String unmuteMessage(Object color, Object channel, Object player) { String msg = resources.getString("unmuteMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -241,11 +241,11 @@ public class Messages { */ public static String expiredBanMessage(Object color, Object channel, Object player) { String msg = resources.getString("expiredBanMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -253,11 +253,11 @@ public class Messages { */ public static String expiredMuteMessage(Object color, Object channel, Object player) { String msg = resources.getString("expiredMuteMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -265,11 +265,11 @@ public class Messages { */ public static String addModeratorMessage(Object color, Object channel, Object player) { String msg = resources.getString("addModeratorMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -277,11 +277,11 @@ public class Messages { */ public static String removeModeratorMessage(Object color, Object channel, Object player) { String msg = resources.getString("removeModeratorMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%player%", player.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -289,10 +289,10 @@ public class Messages { */ public static String noRecipientMessage(Object color, Object channel) { String msg = resources.getString("noRecipientMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%color%", color.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -300,8 +300,8 @@ public class Messages { */ public static String listFirstLine() { String msg = resources.getString("listFirstLine"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -309,10 +309,10 @@ public class Messages { */ public static String listFirstLinePaging(Object page, Object max) { String msg = resources.getString("listFirstLinePaging"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%page%", page.toString()); msg = msg.replace("%max%", max.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -320,8 +320,8 @@ public class Messages { */ public static String listEndLine() { String msg = resources.getString("listEndLine"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -329,12 +329,12 @@ public class Messages { */ public static String listFormat(Object channel, Object online, Object total, Object topic) { String msg = resources.getString("listFormat"); - if ( msg == null || msg.equals("") ) return ""; + 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 msg; + return Utility.replaceColorCode(msg); } /** @@ -342,8 +342,8 @@ public class Messages { */ public static String listPlainPrefix() { String msg = resources.getString("listPlainPrefix"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -351,8 +351,8 @@ public class Messages { */ public static String channelInfoFirstLine() { String msg = resources.getString("channelInfoFirstLine"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -360,8 +360,8 @@ public class Messages { */ public static String channelInfoPrefix() { String msg = resources.getString("channelInfoPrefix"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -369,8 +369,8 @@ public class Messages { */ public static String channelInfoAlias() { String msg = resources.getString("channelInfoAlias"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -378,8 +378,8 @@ public class Messages { */ public static String channelInfoGlobal() { String msg = resources.getString("channelInfoGlobal"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -387,8 +387,8 @@ public class Messages { */ public static String channelInfoBroadcast() { String msg = resources.getString("channelInfoBroadcast"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -396,8 +396,8 @@ public class Messages { */ public static String channelInfoSecret() { String msg = resources.getString("channelInfoSecret"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -405,8 +405,8 @@ public class Messages { */ public static String channelInfoPassword() { String msg = resources.getString("channelInfoPassword"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -414,8 +414,8 @@ public class Messages { */ public static String channelInfoWorldChat() { String msg = resources.getString("channelInfoWorldChat"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -423,9 +423,9 @@ public class Messages { */ public static String channelInfoRangeChat(Object block) { String msg = resources.getString("channelInfoRangeChat"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%block%", block.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -433,8 +433,8 @@ public class Messages { */ public static String channelInfoFormat() { String msg = resources.getString("channelInfoFormat"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -442,8 +442,8 @@ public class Messages { */ public static String channelInfoBanned() { String msg = resources.getString("channelInfoBanned"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -451,8 +451,8 @@ public class Messages { */ public static String channelInfoMuted() { String msg = resources.getString("channelInfoMuted"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -460,8 +460,8 @@ public class Messages { */ public static String motdFirstLine() { String msg = resources.getString("motdFirstLine"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -469,8 +469,8 @@ public class Messages { */ public static String hideChannelFirstLine() { String msg = resources.getString("hideChannelFirstLine"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -478,8 +478,8 @@ public class Messages { */ public static String hidePlayerFirstLine() { String msg = resources.getString("hidePlayerFirstLine"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -487,9 +487,9 @@ public class Messages { */ public static String logDisplayFirstLine(Object channel) { String msg = resources.getString("logDisplayFirstLine"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -497,8 +497,8 @@ public class Messages { */ public static String logDisplayEndLine() { String msg = resources.getString("logDisplayEndLine"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -506,11 +506,11 @@ public class Messages { */ public static String logDisplayFormat(Object date, Object player, Object message) { String msg = resources.getString("logDisplayFormat"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%date%", date.toString()); msg = msg.replace("%player%", player.toString()); msg = msg.replace("%message%", message.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -518,8 +518,8 @@ public class Messages { */ public static String infoPrefix() { String msg = resources.getString("infoPrefix"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -527,8 +527,8 @@ public class Messages { */ public static String errorPrefix() { String msg = resources.getString("errorPrefix"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -536,9 +536,9 @@ public class Messages { */ public static String cmdmsgJoin(Object channel) { String msg = resources.getString("cmdmsgJoin"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -546,9 +546,9 @@ public class Messages { */ public static String cmdmsgSet(Object channel) { String msg = resources.getString("cmdmsgSet"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -556,9 +556,9 @@ public class Messages { */ public static String cmdmsgSetTopic(Object topic) { String msg = resources.getString("cmdmsgSetTopic"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%topic%", topic.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -566,8 +566,8 @@ public class Messages { */ public static String cmdmsgSetHide() { String msg = resources.getString("cmdmsgSetHide"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return resources.getString("infoPrefix", "") + msg; } /** @@ -575,9 +575,9 @@ public class Messages { */ public static String cmdmsgLeave(Object channel) { String msg = resources.getString("cmdmsgLeave"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -585,10 +585,10 @@ public class Messages { */ public static String cmdmsgInvite(Object player, Object channel) { String msg = resources.getString("cmdmsgInvite"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -596,10 +596,10 @@ public class Messages { */ public static String cmdmsgInvited1(Object player, Object channel) { String msg = resources.getString("cmdmsgInvited1"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -607,8 +607,8 @@ public class Messages { */ public static String cmdmsgInvited2() { String msg = resources.getString("cmdmsgInvited2"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return resources.getString("infoPrefix", "") + msg; } /** @@ -616,8 +616,8 @@ public class Messages { */ public static String cmdmsgDeny() { String msg = resources.getString("cmdmsgDeny"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return resources.getString("infoPrefix", "") + msg; } /** @@ -625,8 +625,8 @@ public class Messages { */ public static String cmdmsgDenyed() { String msg = resources.getString("cmdmsgDenyed"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return resources.getString("infoPrefix", "") + msg; } /** @@ -634,10 +634,10 @@ public class Messages { */ public static String cmdmsgKick(Object player, Object channel) { String msg = resources.getString("cmdmsgKick"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -645,9 +645,9 @@ public class Messages { */ public static String cmdmsgKicked(Object channel) { String msg = resources.getString("cmdmsgKicked"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -655,10 +655,10 @@ public class Messages { */ public static String cmdmsgBan(Object player, Object channel) { String msg = resources.getString("cmdmsgBan"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -666,11 +666,11 @@ public class Messages { */ public static String cmdmsgBanWithExpire(Object player, Object channel, Object minutes) { String msg = resources.getString("cmdmsgBanWithExpire"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%minutes%", minutes.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -678,9 +678,9 @@ public class Messages { */ public static String cmdmsgBanned(Object channel) { String msg = resources.getString("cmdmsgBanned"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -688,10 +688,10 @@ public class Messages { */ public static String cmdmsgPardon(Object player, Object channel) { String msg = resources.getString("cmdmsgPardon"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -699,9 +699,9 @@ public class Messages { */ public static String cmdmsgPardoned(Object channel) { String msg = resources.getString("cmdmsgPardoned"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -709,10 +709,10 @@ public class Messages { */ public static String cmdmsgMute(Object player, Object channel) { String msg = resources.getString("cmdmsgMute"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -720,11 +720,11 @@ public class Messages { */ public static String cmdmsgMuteWithExpire(Object player, Object channel, Object minutes) { String msg = resources.getString("cmdmsgMuteWithExpire"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%minutes%", minutes.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -732,9 +732,9 @@ public class Messages { */ public static String cmdmsgMuted(Object channel) { String msg = resources.getString("cmdmsgMuted"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -742,10 +742,10 @@ public class Messages { */ public static String cmdmsgUnmute(Object player, Object channel) { String msg = resources.getString("cmdmsgUnmute"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -753,9 +753,9 @@ public class Messages { */ public static String cmdmsgUnmuted(Object channel) { String msg = resources.getString("cmdmsgUnmuted"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -763,9 +763,9 @@ public class Messages { */ public static String cmdmsgHided(Object channel) { String msg = resources.getString("cmdmsgHided"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -773,9 +773,9 @@ public class Messages { */ public static String cmdmsgHidedPlayer(Object player) { String msg = resources.getString("cmdmsgHidedPlayer"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -783,9 +783,9 @@ public class Messages { */ public static String cmdmsgUnhided(Object channel) { String msg = resources.getString("cmdmsgUnhided"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -793,9 +793,9 @@ public class Messages { */ public static String cmdmsgUnhidedPlayer(Object channel) { String msg = resources.getString("cmdmsgUnhidedPlayer"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -803,8 +803,8 @@ public class Messages { */ public static String cmdmsgReload() { String msg = resources.getString("cmdmsgReload"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return resources.getString("infoPrefix", "") + msg; } /** @@ -812,9 +812,9 @@ public class Messages { */ public static String cmdmsgCreate(Object channel) { String msg = resources.getString("cmdmsgCreate"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -822,9 +822,9 @@ public class Messages { */ public static String cmdmsgRemove(Object channel) { String msg = resources.getString("cmdmsgRemove"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -832,9 +832,9 @@ public class Messages { */ public static String cmdmsgFormat(Object format) { String msg = resources.getString("cmdmsgFormat"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%format%", format.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -842,10 +842,10 @@ public class Messages { */ public static String cmdmsgModerator(Object player, Object channel) { String msg = resources.getString("cmdmsgModerator"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -853,10 +853,10 @@ public class Messages { */ public static String cmdmsgModeratorMinus(Object player, Object channel) { String msg = resources.getString("cmdmsgModeratorMinus"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -864,10 +864,10 @@ public class Messages { */ public static String cmdmsgDictionaryAdd(Object key, Object value) { String msg = resources.getString("cmdmsgDictionaryAdd"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%key%", key.toString()); msg = msg.replace("%value%", value.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -875,9 +875,9 @@ public class Messages { */ public static String cmdmsgDictionaryRemove(Object key) { String msg = resources.getString("cmdmsgDictionaryRemove"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%key%", key.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -885,10 +885,10 @@ public class Messages { */ public static String cmdmsgOption(Object key, Object value) { String msg = resources.getString("cmdmsgOption"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%key%", key.toString()); msg = msg.replace("%value%", value.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -896,10 +896,10 @@ public class Messages { */ public static String cmdmsgTemplate(Object index, Object value) { String msg = resources.getString("cmdmsgTemplate"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%index%", index.toString()); msg = msg.replace("%value%", value.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -907,9 +907,9 @@ public class Messages { */ public static String cmdmsgTemplateRemove(Object index) { String msg = resources.getString("cmdmsgTemplateRemove"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%index%", index.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -917,10 +917,10 @@ public class Messages { */ public static String cmdmsgSetDefault(Object player, Object channel) { String msg = resources.getString("cmdmsgSetDefault"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%channel%", channel.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -928,9 +928,9 @@ public class Messages { */ public static String cmdmsgPlayerJapanize(Object value) { String msg = resources.getString("cmdmsgPlayerJapanize"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%value%", value.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -938,10 +938,10 @@ public class Messages { */ public static String cmdmsgPlayerJapanizeOther(Object player, Object value) { String msg = resources.getString("cmdmsgPlayerJapanizeOther"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); msg = msg.replace("%value%", value.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -949,10 +949,10 @@ public class Messages { */ public static String cmdmsgReplyInviter(Object inviter, Object invited) { String msg = resources.getString("cmdmsgReplyInviter"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%inviter%", inviter.toString()); msg = msg.replace("%invited%", invited.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -960,9 +960,9 @@ public class Messages { */ public static String cmdmsgReplyInviterNone(Object inviter) { String msg = resources.getString("cmdmsgReplyInviterNone"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%inviter%", inviter.toString()); - return msg; + return resources.getString("infoPrefix", "") + msg; } /** @@ -970,7 +970,7 @@ public class Messages { */ public static String errmsgIngame() { String msg = resources.getString("errmsgIngame"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -979,7 +979,7 @@ public class Messages { */ public static String errmsgCommand() { String msg = resources.getString("errmsgCommand"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -988,7 +988,7 @@ public class Messages { */ public static String errmsgNotExist() { String msg = resources.getString("errmsgNotExist"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -997,7 +997,7 @@ public class Messages { */ public static String errmsgNotExistChannelAndPlayer() { String msg = resources.getString("errmsgNotExistChannelAndPlayer"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1006,7 +1006,7 @@ public class Messages { */ public static String errmsgNotExistOrNotSpecified() { String msg = resources.getString("errmsgNotExistOrNotSpecified"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1015,7 +1015,7 @@ public class Messages { */ public static String errmsgExist() { String msg = resources.getString("errmsgExist"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1024,7 +1024,7 @@ public class Messages { */ public static String errmsgNomember() { String msg = resources.getString("errmsgNomember"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1033,7 +1033,7 @@ public class Messages { */ public static String errmsgNomemberOther() { String msg = resources.getString("errmsgNomemberOther"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1042,7 +1042,7 @@ public class Messages { */ public static String errmsgNotfoundPlayer(Object player) { String msg = resources.getString("errmsgNotfoundPlayer"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1052,7 +1052,7 @@ public class Messages { */ public static String errmsgNotInvited() { String msg = resources.getString("errmsgNotInvited"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1061,7 +1061,7 @@ public class Messages { */ public static String errmsgNotfoundChannel() { String msg = resources.getString("errmsgNotfoundChannel"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1070,7 +1070,7 @@ public class Messages { */ public static String errmsgInvitedAlreadyExist(Object player) { String msg = resources.getString("errmsgInvitedAlreadyExist"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%player%", player.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1080,7 +1080,7 @@ public class Messages { */ public static String errmsgInvitedAlreadyJoin() { String msg = resources.getString("errmsgInvitedAlreadyJoin"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1089,7 +1089,7 @@ public class Messages { */ public static String errmsgNoJoin() { String msg = resources.getString("errmsgNoJoin"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1098,7 +1098,7 @@ public class Messages { */ public static String errmsgBanned() { String msg = resources.getString("errmsgBanned"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1107,7 +1107,7 @@ public class Messages { */ public static String errmsgMuted() { String msg = resources.getString("errmsgMuted"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1116,7 +1116,7 @@ public class Messages { */ public static String errmsgAlreadyBanned() { String msg = resources.getString("errmsgAlreadyBanned"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1125,7 +1125,7 @@ public class Messages { */ public static String errmsgAlreadyMuted() { String msg = resources.getString("errmsgAlreadyMuted"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1134,7 +1134,7 @@ public class Messages { */ public static String errmsgAlreadyHided() { String msg = resources.getString("errmsgAlreadyHided"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1143,7 +1143,7 @@ public class Messages { */ public static String errmsgAlreadyHidedPlayer() { String msg = resources.getString("errmsgAlreadyHidedPlayer"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1152,7 +1152,7 @@ public class Messages { */ public static String errmsgAlreadyUnhided() { String msg = resources.getString("errmsgAlreadyUnhided"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1161,7 +1161,7 @@ public class Messages { */ public static String errmsgAlreadyUnhidedPlayer() { String msg = resources.getString("errmsgAlreadyUnhidedPlayer"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1170,7 +1170,7 @@ public class Messages { */ public static String errmsgCannotJoinPersonal() { String msg = resources.getString("errmsgCannotJoinPersonal"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1179,7 +1179,7 @@ public class Messages { */ public static String errmsgNotModerator() { String msg = resources.getString("errmsgNotModerator"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1188,7 +1188,7 @@ public class Messages { */ public static String errmsgNotBanned() { String msg = resources.getString("errmsgNotBanned"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1197,7 +1197,7 @@ public class Messages { */ public static String errmsgNotMuted() { String msg = resources.getString("errmsgNotMuted"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1206,7 +1206,7 @@ public class Messages { */ public static String errmsgInvalidOptions() { String msg = resources.getString("errmsgInvalidOptions"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1215,7 +1215,7 @@ public class Messages { */ public static String errmsgPassword1() { String msg = resources.getString("errmsgPassword1"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1224,7 +1224,7 @@ public class Messages { */ public static String errmsgPassword2() { String msg = resources.getString("errmsgPassword2"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1233,7 +1233,7 @@ public class Messages { */ public static String errmsgPassword3() { String msg = resources.getString("errmsgPassword3"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1242,7 +1242,7 @@ public class Messages { */ public static String errmsgPasswordNotmatch() { String msg = resources.getString("errmsgPasswordNotmatch"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1251,7 +1251,7 @@ public class Messages { */ public static String errmsgPermission(Object permission) { String msg = resources.getString("errmsgPermission"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%permission%", permission.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1261,7 +1261,7 @@ public class Messages { */ public static String errmsgCannotLeaveGlobal(Object channel) { String msg = resources.getString("errmsgCannotLeaveGlobal"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1271,7 +1271,7 @@ public class Messages { */ public static String errmsgCannotKickGlobal(Object channel) { String msg = resources.getString("errmsgCannotKickGlobal"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1281,7 +1281,7 @@ public class Messages { */ public static String errmsgCannotBANGlobal(Object channel) { String msg = resources.getString("errmsgCannotBANGlobal"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1291,7 +1291,7 @@ public class Messages { */ public static String errmsgCannotRemoveGlobal(Object channel) { String msg = resources.getString("errmsgCannotRemoveGlobal"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1301,7 +1301,7 @@ public class Messages { */ public static String errmsgCannotModeratorGlobal(Object channel) { String msg = resources.getString("errmsgCannotModeratorGlobal"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1311,7 +1311,7 @@ public class Messages { */ public static String errmsgCannotLeaveForceJoin(Object channel) { String msg = resources.getString("errmsgCannotLeaveForceJoin"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1321,7 +1321,7 @@ public class Messages { */ public static String errmsgNotfoundPM() { String msg = resources.getString("errmsgNotfoundPM"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1330,7 +1330,7 @@ public class Messages { */ public static String errmsgCannotSendPMSelf() { String msg = resources.getString("errmsgCannotSendPMSelf"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1339,7 +1339,7 @@ public class Messages { */ public static String errmsgCannotUseForChannel(Object channel) { String msg = resources.getString("errmsgCannotUseForChannel"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1349,7 +1349,7 @@ public class Messages { */ public static String errmsgCannotUseForChannelTooShort(Object channel, Object min) { String msg = resources.getString("errmsgCannotUseForChannelTooShort"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%min%", min.toString()); return resources.getString("errorPrefix", "") + msg; @@ -1360,7 +1360,7 @@ public class Messages { */ public static String errmsgCannotUseForChannelTooLong(Object channel, Object max) { String msg = resources.getString("errmsgCannotUseForChannelTooLong"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%channel%", channel.toString()); msg = msg.replace("%max%", max.toString()); return resources.getString("errorPrefix", "") + msg; @@ -1371,7 +1371,7 @@ public class Messages { */ public static String errmsgCannotUseForGlobal(Object word) { String msg = resources.getString("errmsgCannotUseForGlobal"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%word%", word.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1381,7 +1381,7 @@ public class Messages { */ public static String errmsgInvalidColorCode(Object value) { String msg = resources.getString("errmsgInvalidColorCode"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%value%", value.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1391,7 +1391,7 @@ public class Messages { */ public static String errmsgInvalidTemplateNumber() { String msg = resources.getString("errmsgInvalidTemplateNumber"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1400,7 +1400,7 @@ public class Messages { */ public static String errmsgToolongDescription(Object max) { String msg = resources.getString("errmsgToolongDescription"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%max%", max.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1410,7 +1410,7 @@ public class Messages { */ public static String errmsgToolongAlias(Object max) { String msg = resources.getString("errmsgToolongAlias"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%max%", max.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1420,7 +1420,7 @@ public class Messages { */ public static String errmsgToolongPassword(Object max) { String msg = resources.getString("errmsgToolongPassword"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%max%", max.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1430,7 +1430,7 @@ public class Messages { */ public static String errmsgInvalidBooleanOption(Object key) { String msg = resources.getString("errmsgInvalidBooleanOption"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%key%", key.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1440,7 +1440,7 @@ public class Messages { */ public static String errmsgInvalidRangeOption() { String msg = resources.getString("errmsgInvalidRangeOption"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1449,7 +1449,7 @@ public class Messages { */ public static String errmsgInvalidJapanizeOption(Object key, Object value) { String msg = resources.getString("errmsgInvalidJapanizeOption"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%key%", key.toString()); msg = msg.replace("%value%", value.toString()); return resources.getString("errorPrefix", "") + msg; @@ -1460,7 +1460,7 @@ public class Messages { */ public static String errmsgCannotOffGlobalBroadcast() { String msg = resources.getString("errmsgCannotOffGlobalBroadcast"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1469,7 +1469,7 @@ public class Messages { */ public static String errmsgFormatConstraint(Object key) { String msg = resources.getString("errmsgFormatConstraint"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%key%", key.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1479,7 +1479,7 @@ public class Messages { */ public static String errmsgInvalidBanExpireParameter() { String msg = resources.getString("errmsgInvalidBanExpireParameter"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1488,7 +1488,7 @@ public class Messages { */ public static String errmsgInvalidMuteExpireParameter() { String msg = resources.getString("errmsgInvalidMuteExpireParameter"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1497,7 +1497,7 @@ public class Messages { */ public static String errmsgCannotHideSelf() { String msg = resources.getString("errmsgCannotHideSelf"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1506,7 +1506,7 @@ public class Messages { */ public static String errmsgDuplicatedAlias(Object aliase, Object channel) { String msg = resources.getString("errmsgDuplicatedAlias"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%aliase%", aliase.toString()); msg = msg.replace("%channel%", channel.toString()); return resources.getString("errorPrefix", "") + msg; @@ -1517,7 +1517,7 @@ public class Messages { */ public static String errmsgNotPermission(Object permission) { String msg = resources.getString("errmsgNotPermission"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%permission%", permission.toString()); return resources.getString("errorPrefix", "") + msg; } @@ -1527,7 +1527,7 @@ public class Messages { */ public static String errmsgChannelChatDisabled() { String msg = resources.getString("errmsgChannelChatDisabled"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; return resources.getString("errorPrefix", "") + msg; } @@ -1536,9 +1536,9 @@ public class Messages { */ public static String usageJoin(Object label) { String msg = resources.getString("usageJoin"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1546,9 +1546,9 @@ public class Messages { */ public static String usageLeave(Object label) { String msg = resources.getString("usageLeave"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1556,9 +1556,9 @@ public class Messages { */ public static String usageList(Object label) { String msg = resources.getString("usageList"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1566,9 +1566,9 @@ public class Messages { */ public static String usageInvite(Object label) { String msg = resources.getString("usageInvite"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1576,9 +1576,9 @@ public class Messages { */ public static String usageAccept(Object label) { String msg = resources.getString("usageAccept"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1586,9 +1586,9 @@ public class Messages { */ public static String usageDeny(Object label) { String msg = resources.getString("usageDeny"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1596,9 +1596,9 @@ public class Messages { */ public static String usageKick(Object label) { String msg = resources.getString("usageKick"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1606,9 +1606,9 @@ public class Messages { */ public static String usageBan(Object label) { String msg = resources.getString("usageBan"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1616,9 +1616,9 @@ public class Messages { */ public static String usageBan2(Object label) { String msg = resources.getString("usageBan2"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1626,9 +1626,9 @@ public class Messages { */ public static String usagePardon(Object label) { String msg = resources.getString("usagePardon"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1636,9 +1636,9 @@ public class Messages { */ public static String usageMute(Object label) { String msg = resources.getString("usageMute"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1646,9 +1646,9 @@ public class Messages { */ public static String usageMute2(Object label) { String msg = resources.getString("usageMute2"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1656,9 +1656,9 @@ public class Messages { */ public static String usageUnmute(Object label) { String msg = resources.getString("usageUnmute"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1666,9 +1666,9 @@ public class Messages { */ public static String usageHide(Object label) { String msg = resources.getString("usageHide"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1676,9 +1676,9 @@ public class Messages { */ public static String usageHidePlayer(Object label) { String msg = resources.getString("usageHidePlayer"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1686,9 +1686,9 @@ public class Messages { */ public static String usageUnhide(Object label) { String msg = resources.getString("usageUnhide"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1696,9 +1696,9 @@ public class Messages { */ public static String usageUnhidePlayer(Object label) { String msg = resources.getString("usageUnhidePlayer"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1706,9 +1706,9 @@ public class Messages { */ public static String usageInfo(Object label) { String msg = resources.getString("usageInfo"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1716,9 +1716,9 @@ public class Messages { */ public static String usageLog(Object label) { String msg = resources.getString("usageLog"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1726,9 +1726,9 @@ public class Messages { */ public static String usageCreate(Object label) { String msg = resources.getString("usageCreate"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1736,9 +1736,9 @@ public class Messages { */ public static String usageRemove(Object label) { String msg = resources.getString("usageRemove"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1746,9 +1746,9 @@ public class Messages { */ public static String usageFormat(Object label) { String msg = resources.getString("usageFormat"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1756,9 +1756,9 @@ public class Messages { */ public static String usageModerator(Object label) { String msg = resources.getString("usageModerator"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1766,9 +1766,9 @@ public class Messages { */ public static String usageMod(Object label) { String msg = resources.getString("usageMod"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1776,9 +1776,9 @@ public class Messages { */ public static String usageDictionary(Object label) { String msg = resources.getString("usageDictionary"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1786,9 +1786,9 @@ public class Messages { */ public static String usageDic(Object label) { String msg = resources.getString("usageDic"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1796,9 +1796,9 @@ public class Messages { */ public static String usageOption(Object label) { String msg = resources.getString("usageOption"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1806,9 +1806,9 @@ public class Messages { */ public static String usageTemplate(Object label) { String msg = resources.getString("usageTemplate"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1816,9 +1816,9 @@ public class Messages { */ public static String usageCheck1(Object label) { String msg = resources.getString("usageCheck1"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1826,9 +1826,9 @@ public class Messages { */ public static String usageCheck2(Object label) { String msg = resources.getString("usageCheck2"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1836,9 +1836,9 @@ public class Messages { */ public static String usageReload(Object label) { String msg = resources.getString("usageReload"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1846,9 +1846,9 @@ public class Messages { */ public static String usageHelp(Object label) { String msg = resources.getString("usageHelp"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1856,9 +1856,9 @@ public class Messages { */ public static String usageSet1(Object label) { String msg = resources.getString("usageSet1"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1866,9 +1866,9 @@ public class Messages { */ public static String usageMessage(Object label) { String msg = resources.getString("usageMessage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1876,9 +1876,9 @@ public class Messages { */ public static String usageReply(Object label) { String msg = resources.getString("usageReply"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1886,9 +1886,9 @@ public class Messages { */ public static String usageJapanize(Object label) { String msg = resources.getString("usageJapanize"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1896,9 +1896,9 @@ public class Messages { */ public static String usageJapanizeOther(Object label) { String msg = resources.getString("usageJapanizeOther"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%label%", label.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1906,11 +1906,11 @@ public class Messages { */ public static String usageTop(Object type, Object num, Object max) { String msg = resources.getString("usageTop"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%type%", type.toString()); msg = msg.replace("%num%", num.toString()); msg = msg.replace("%max%", max.toString()); - return msg; + return Utility.replaceColorCode(msg); } /** @@ -1918,8 +1918,8 @@ public class Messages { */ public static String usageFoot() { String msg = resources.getString("usageFoot"); - if ( msg == null || msg.equals("") ) return ""; - return msg; + if ( msg == null ) return ""; + return Utility.replaceColorCode(msg); } /** @@ -1927,9 +1927,9 @@ public class Messages { */ public static String usageNoticeNextPage(Object type, Object next) { String msg = resources.getString("usageNoticeNextPage"); - if ( msg == null || msg.equals("") ) return ""; + if ( msg == null ) return ""; msg = msg.replace("%type%", type.toString()); msg = msg.replace("%next%", next.toString()); - return msg; + return Utility.replaceColorCode(msg); } } 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 780ea17..0d95e53 100644 --- a/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java +++ b/src/main/java/com/github/ucchyocean/lc3/bukkit/BukkitEventListener.java @@ -14,7 +14,6 @@ import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.ChatColor; -import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -208,7 +207,7 @@ public class BukkitEventListener implements Listener { ChannelMember.getChannelMember(event.getPlayer()); if ( !channel.getMembers().contains(player) ) { // 指定されたチャンネルに参加していないなら、エラーを表示して何も発言せずに終了する。 - sendResourceMessage(event.getPlayer(), PREERR, "errmsgNomember"); + event.getPlayer().sendMessage(Messages.errmsgNomember()); event.setCancelled(true); return; } @@ -509,7 +508,7 @@ public class BukkitEventListener implements Listener { } ArrayList items = new ArrayList(); - items.add(MOTD_FIRSTLINE); + items.add(Messages.motdFirstLine()); for ( Channel channel : api.getChannels() ) { // BANされているチャンネルは表示しない @@ -535,11 +534,10 @@ public class BukkitEventListener implements Listener { String desc = channel.getDescription(); int onlineNum = channel.getOnlineNum(); int memberNum = channel.getTotalNum(); - String item = String.format( - LIST_FORMAT, disp, onlineNum, memberNum, desc); + String item = Messages.listFormat(disp, onlineNum, memberNum, desc); items.add(item); } - items.add(LIST_ENDLINE); + items.add(Messages.listEndLine()); return items; } @@ -581,24 +579,6 @@ public class BukkitEventListener implements Listener { LunaChat.getNormalChatLogger().log(message, player); } - /** - * メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する - * @param sender メッセージの送り先 - * @param pre プレフィックス - * @param key リソースキー - * @param args リソース内の置き換え対象キーワード - */ - private void sendResourceMessage( - CommandSender sender, String pre, String key, Object... args) { - - String org = Messages.get(key); - if ( org == null || org.equals("") ) { - return; - } - String msg = String.format(pre + org, args); - sender.sendMessage(msg); - } - /** * 指定されたEventPriorityが、LunaChatConfigで指定されているEventPriorityと一致するかどうかを調べる * @param priority 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 8f0fcf8..169c364 100644 --- a/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java +++ b/src/main/java/com/github/ucchyocean/lc3/bungee/BungeeEventListener.java @@ -41,11 +41,6 @@ import net.md_5.bungee.event.EventPriority; */ public class BungeeEventListener implements Listener { - private static final String MOTD_FIRSTLINE = Messages.get("motdFirstLine"); - private static final String LIST_ENDLINE = Messages.get("listEndLine"); - private static final String LIST_FORMAT = Messages.get("listFormat"); - private static final String PREERR = Messages.get("errorPrefix"); - private static final String DATE_FORMAT_PATTERN = "yyyy/MM/dd"; private static final String TIME_FORMAT_PATTERN = "HH:mm:ss"; @@ -230,7 +225,8 @@ public class BungeeEventListener implements Listener { ChannelMember.getChannelMember(event.getSender()); if ( !channel.getMembers().contains(player) ) { // 指定されたチャンネルに参加していないなら、エラーを表示して何も発言せずに終了する。 - sendResourceMessage((ProxiedPlayer)event.getSender(), PREERR, "errmsgNomember"); + ((ProxiedPlayer)event.getSender()).sendMessage( + TextComponent.fromLegacyText(Messages.errmsgNomember())); event.setCancelled(true); return; } @@ -480,7 +476,7 @@ public class BungeeEventListener implements Listener { } ArrayList items = new ArrayList(); - items.add(MOTD_FIRSTLINE); + items.add(Messages.motdFirstLine()); for ( Channel channel : api.getChannels() ) { // BANされているチャンネルは表示しない @@ -506,11 +502,10 @@ public class BungeeEventListener implements Listener { String desc = channel.getDescription(); int onlineNum = channel.getOnlineNum(); int memberNum = channel.getTotalNum(); - String item = String.format( - LIST_FORMAT, disp, onlineNum, memberNum, desc); + String item = Messages.listFormat(disp, onlineNum, memberNum, desc); items.add(item); } - items.add(LIST_ENDLINE); + items.add(Messages.listEndLine()); return items; } @@ -525,24 +520,6 @@ public class BungeeEventListener implements Listener { reciever.sendMessage(TextComponent.fromLegacyText(message)); } - /** - * メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する - * @param sender メッセージの送り先 - * @param pre プレフィックス - * @param key リソースキー - * @param args リソース内の置き換え対象キーワード - */ - private void sendResourceMessage( - CommandSender sender, String pre, String key, Object... args) { - - String org = Messages.get(key); - if ( org == null || org.equals("") ) { - return; - } - String msg = String.format(pre + org, args); - sender.sendMessage(TextComponent.fromLegacyText(msg)); - } - /** * 指定されたEventPriorityが、LunaChatConfigで指定されているEventPriorityと一致するかどうかを調べる * @param priority 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 ba60745..7563ebd 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/BukkitChannel.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/BukkitChannel.java @@ -41,16 +41,6 @@ public class BukkitChannel extends Channel { private static final String PERMISSION_SPEAK_PREFIX = "lunachat.speak"; - private static final String MSG_BAN_NGWORD = Messages.get("banNGWordMessage"); - private static final String MSG_KICK_NGWORD = Messages.get("kickNGWordMessage"); - private static final String MSG_MUTE_NGWORD = Messages.get("muteNGWordMessage"); - - private static final String PREERR = Messages.get("errorPrefix"); - - private static final String MSG_NO_RECIPIENT = Messages.get("noRecipientMessage"); - - private static final String ERRMSG_MUTED = Messages.get("errmsgMuted"); - private SimpleDateFormat dateFormat; private SimpleDateFormat timeFormat; @@ -75,8 +65,7 @@ public class BukkitChannel extends Channel { // 発言権限を確認する String node = PERMISSION_SPEAK_PREFIX + "." + getName(); if ( player.isPermissionSet(node) && !player.hasPermission(node) ) { - sendResourceMessage(player, PREERR, "errmsgPermission", - PERMISSION_SPEAK_PREFIX + "." + getName()); + player.sendMessage(Messages.errmsgPermission(node)); return; } @@ -85,7 +74,7 @@ public class BukkitChannel extends Channel { // Muteされているかどうかを確認する if ( getMuted().contains(player) ) { - player.sendMessage( PREERR + ERRMSG_MUTED ); + player.sendMessage(Messages.errmsgMuted()); return; } @@ -183,9 +172,8 @@ public class BukkitChannel extends Channel { if ( !isGlobalChannel() ) { getBanned().add(player); removeMember(player); - if ( !MSG_BAN_NGWORD.equals("") ) { - String m = replaceKeywordsForSystemMessages( - MSG_BAN_NGWORD, player.getName()); + if ( !Messages.banNGWordMessage("", "", "").isEmpty() ) { + String m = Messages.banNGWordMessage(getColorCode(), getName(), player.getName()); player.sendMessage(m); sendMessage(null, m, null, true, "system"); } @@ -196,9 +184,8 @@ public class BukkitChannel extends Channel { if ( !isGlobalChannel() ) { removeMember(player); - if ( !MSG_KICK_NGWORD.equals("") ) { - String m = replaceKeywordsForSystemMessages( - MSG_KICK_NGWORD, player.getName()); + if ( !Messages.kickNGWordMessage("", "", "").isEmpty() ) { + String m = Messages.kickNGWordMessage(getColorCode(), getName(), player.getName()); player.sendMessage(m); sendMessage(null, m, null, true, "system"); } @@ -209,9 +196,8 @@ public class BukkitChannel extends Channel { getMuted().add(player); save(); - if ( !MSG_MUTE_NGWORD.equals("") ) { - String m = replaceKeywordsForSystemMessages( - MSG_MUTE_NGWORD, player.getName()); + if ( !Messages.muteNGWordMessage("", "", "").isEmpty() ) { + String m = Messages.muteNGWordMessage(getColorCode(), getName(), player.getName()); player.sendMessage(m); sendMessage(null, m, null, true, "system"); } @@ -258,27 +244,6 @@ public class BukkitChannel extends Channel { sendMessage(null, maskedMessage, msgFormat, sendDynmap, name); } - /** - * プレイヤーに関連する、システムメッセージをチャンネルに流す - * @param key リソースキー - * @param player プレイヤー - */ - @Override - protected void sendSystemMessage(String key, ChannelMember player) { - - // プライベートチャットならシステムメッセージを流さない - if ( isPersonalChat() ) { - return; - } - - String msg = Messages.get(key); - if ( msg == null || msg.equals("") ) { - return; - } - msg = replaceKeywordsForSystemMessages(msg, player.getName()); - sendMessage(null, msg, null, false, "system"); - } - /** * メッセージを表示します。指定したプレイヤーの発言として処理されます。 * @param player プレイヤー(ワールドチャット、範囲チャットの場合は必須です) @@ -335,7 +300,7 @@ public class BukkitChannel extends Channel { } // 受信者が自分以外いない場合は、メッセージを表示する - if ( !MSG_NO_RECIPIENT.equals("") && ( + if ( !Messages.noRecipientMessage("", "").isEmpty() && ( recipients.size() == 0 || (recipients.size() == 1 && recipients.get(0).getName().equals(player.getName()) ) ) ) { @@ -426,8 +391,7 @@ public class BukkitChannel extends Channel { // 受信者が自分以外いない場合は、メッセージを表示する if ( sendNoRecipientMessage ) { - String msg = replaceKeywordsForSystemMessages(MSG_NO_RECIPIENT, ""); - player.sendMessage(msg); + player.sendMessage(Messages.noRecipientMessage(getColorCode(), getName())); } // ロギング 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 28de60a..bef4ee4 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/BungeeChannel.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/BungeeChannel.java @@ -37,14 +37,6 @@ public class BungeeChannel extends Channel { private static final String PERMISSION_SPEAK_PREFIX = "lunachat.speak"; - private static final String MSG_BAN_NGWORD = Messages.get("banNGWordMessage"); - private static final String MSG_KICK_NGWORD = Messages.get("kickNGWordMessage"); - private static final String MSG_MUTE_NGWORD = Messages.get("muteNGWordMessage"); - - private static final String PREERR = Messages.get("errorPrefix"); - - private static final String ERRMSG_MUTED = Messages.get("errmsgMuted"); - private SimpleDateFormat dateFormat; private SimpleDateFormat timeFormat; @@ -75,9 +67,8 @@ public class BungeeChannel extends Channel { // 発言権限を確認する String node = PERMISSION_SPEAK_PREFIX + "." + getName(); if ( player.isPermissionSet(node) && !player.hasPermission(node) ) { - sendResourceMessage(player, PREERR, "errmsgPermission", - PERMISSION_SPEAK_PREFIX + "." + getName()); - return; + player.sendMessage(Messages.errmsgPermission(node)); + return; } LunaChatConfig config = LunaChat.getConfig(); @@ -85,7 +76,7 @@ public class BungeeChannel extends Channel { // Muteされているかどうかを確認する if ( getMuted().contains(player) ) { - player.sendMessage( PREERR + ERRMSG_MUTED ); + player.sendMessage(Messages.errmsgMuted()); return; } @@ -184,9 +175,8 @@ public class BungeeChannel extends Channel { if ( !isGlobalChannel() ) { getBanned().add(player); removeMember(player); - if ( !MSG_BAN_NGWORD.equals("") ) { - String m = replaceKeywordsForSystemMessages( - MSG_BAN_NGWORD, player.getName()); + if ( !Messages.banNGWordMessage("", "", "").isEmpty() ) { + String m = Messages.banNGWordMessage(getColorCode(), getName(), player.getName()); player.sendMessage(m); sendMessage(null, m, null, true, "system"); } @@ -197,9 +187,8 @@ public class BungeeChannel extends Channel { if ( !isGlobalChannel() ) { removeMember(player); - if ( !MSG_KICK_NGWORD.equals("") ) { - String m = replaceKeywordsForSystemMessages( - MSG_KICK_NGWORD, player.getName()); + if ( !Messages.kickNGWordMessage("", "", "").isEmpty() ) { + String m = Messages.kickNGWordMessage(getColorCode(), getName(), player.getName()); player.sendMessage(m); sendMessage(null, m, null, true, "system"); } @@ -210,9 +199,8 @@ public class BungeeChannel extends Channel { getMuted().add(player); save(); - if ( !MSG_MUTE_NGWORD.equals("") ) { - String m = replaceKeywordsForSystemMessages( - MSG_MUTE_NGWORD, player.getName()); + if ( !Messages.muteNGWordMessage("", "", "").isEmpty() ) { + String m = Messages.muteNGWordMessage(getColorCode(), getName(), player.getName()); player.sendMessage(m); sendMessage(null, m, null, true, "system"); } @@ -259,27 +247,6 @@ public class BungeeChannel extends Channel { sendMessage(null, maskedMessage, msgFormat, sendDynmap, name); } - /** - * プレイヤーに関連する、システムメッセージをチャンネルに流す - * @param key リソースキー - * @param player プレイヤー - */ - @Override - protected void sendSystemMessage(String key, ChannelMember player) { - - // プライベートチャットならシステムメッセージを流さない - if ( isPersonalChat() ) { - return; - } - - String msg = Messages.get(key); - if ( msg == null || msg.equals("") ) { - return; - } - msg = replaceKeywordsForSystemMessages(msg, player.getName()); - sendMessage(null, msg, null, false, "system"); - } - /** * メッセージを表示します。指定したプレイヤーの発言として処理されます。 * @param player プレイヤー(ワールドチャット、範囲チャットの場合は必須です) 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 7b8dbe5..3d90810 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/Channel.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/Channel.java @@ -52,29 +52,6 @@ public abstract class Channel { private static final String KEY_ALLOWCC = "allowcc"; private static final String KEY_JAPANIZE = "japanize"; - private static final String INFO_FIRSTLINE = Messages.get("channelInfoFirstLine"); - private static final String INFO_PREFIX = Messages.get("channelInfoPrefix"); - private static final String INFO_ALIAS = Messages.get("channelInfoAlias"); - private static final String INFO_GLOBAL = Messages.get("channelInfoGlobal"); - private static final String INFO_BROADCAST = Messages.get("channelInfoBroadcast"); - private static final String INFO_SECRET = Messages.get("channelInfoSecret"); - private static final String INFO_PASSWORD = Messages.get("channelInfoPassword"); - private static final String INFO_WORLDCHAT = Messages.get("channelInfoWorldChat"); - private static final String INFO_RANGECHAT = Messages.get("channelInfoRangeChat"); - private static final String INFO_FORMAT = Messages.get("channelInfoFormat"); - private static final String INFO_BANNED = Messages.get("channelInfoBanned"); - private static final String INFO_MUTED = Messages.get("channelInfoMuted"); - - private static final String LIST_ENDLINE = Messages.get("listEndLine"); - private static final String LIST_FORMAT = Messages.get("listFormat"); - - private static final String MSG_BAN_EXPIRED = Messages.get("expiredBanMessage"); - private static final String MSG_MUTE_EXPIRED = Messages.get("expiredMuteMessage"); - private static final String MSG_BAN_EXPIRED_PLAYER = Messages.get("cmdmsgPardoned"); - private static final String MSG_MUTE_EXPIRED_PLAYER = Messages.get("cmdmsgUnmuted"); - - private static final String PREINFO = Messages.get("infoPrefix"); - /** 参加者 */ private List members; @@ -270,7 +247,9 @@ public abstract class Channel { } members = after; - sendSystemMessage("joinMessage", player); + if ( !isPersonalChat() ) { + player.sendMessage(Messages.joinMessage(getColorCode(), getName(), player.getName())); + } save(); } @@ -309,7 +288,9 @@ public abstract class Channel { // 実際にメンバーから削除する members.remove(player); - sendSystemMessage("quitMessage", player); + if ( !isPersonalChat() ) { + player.sendMessage(Messages.quitMessage(getColorCode(), getName(), player.getName())); + } // 0人で削除する設定がオンで、0人になったなら、チャンネルを削除する LunaChatConfig config = LunaChat.getConfig(); @@ -346,7 +327,9 @@ public abstract class Channel { moderator.add(player); // メッセージ - sendSystemMessage("addModeratorMessage", player); + if ( !isPersonalChat() ) { + player.sendMessage(Messages.addModeratorMessage(getColorCode(), getName(), player.getName())); + } save(); } @@ -366,18 +349,13 @@ public abstract class Channel { moderator.remove(player); // メッセージ - sendSystemMessage("removeModeratorMessage", player); + if ( !isPersonalChat() ) { + player.sendMessage(Messages.removeModeratorMessage(getColorCode(), getName(), player.getName())); + } save(); } - /** - * プレイヤーに関連する、システムメッセージをチャンネルに流す - * @param key リソースキー - * @param player プレイヤー - */ - protected abstract void sendSystemMessage(String key, ChannelMember player); - /** * メッセージを表示します。指定したプレイヤーの発言として処理されます。 * @param player プレイヤー(ワールドチャット、範囲チャットの場合は必須です) @@ -405,34 +383,33 @@ public abstract class Channel { public List getInfo(boolean forModerator) { ArrayList info = new ArrayList(); - info.add(INFO_FIRSTLINE); + info.add(Messages.channelInfoFirstLine()); // チャンネル名、参加人数、総人数、チャンネル説明文 - info.add( String.format( - LIST_FORMAT, getName(), getOnlineNum(), getTotalNum(), getDescription()) ); + info.add(Messages.listFormat(getName(), getOnlineNum(), getTotalNum(), getDescription())); // チャンネル別名 String alias = getAlias(); if ( alias != null && alias.length() > 0 ) { - info.add(INFO_ALIAS + alias); + info.add(Messages.channelInfoAlias() + alias); } // 参加メンバー一覧 if ( isGlobalChannel() ) { - info.add(INFO_GLOBAL); + info.add(Messages.channelInfoGlobal()); } else if ( isBroadcastChannel() ) { - info.add(INFO_BROADCAST); + info.add(Messages.channelInfoBroadcast()); } else { // メンバーを、5人ごとに表示する StringBuffer buf = new StringBuffer(); - buf.append(INFO_PREFIX); + buf.append(Messages.channelInfoPrefix()); for ( int i=0; i 0 ) { if ( !forModerator ) { - info.add(INFO_PASSWORD); + info.add(Messages.channelInfoPassword()); } else { - info.add(INFO_PASSWORD + " " + getPassword()); + info.add(Messages.channelInfoPassword() + " " + getPassword()); } } // 範囲チャット、ワールドチャット if ( isWorldRange() && getChatRange() > 0 ) { - info.add(String.format(INFO_RANGECHAT, getChatRange())); + info.add(Messages.channelInfoRangeChat(getChatRange())); } else if ( isWorldRange() ) { - info.add(INFO_WORLDCHAT); + info.add(Messages.channelInfoWorldChat()); } if ( forModerator ) { // フォーマット情報 - info.add(INFO_FORMAT); - info.add(INFO_PREFIX + " " + ChatColor.WHITE + getFormat()); + info.add(Messages.channelInfoFormat()); + info.add(Messages.channelInfoPrefix() + " " + ChatColor.WHITE + getFormat()); // Muteリスト情報、5人ごとに表示する if ( getMuted().size() > 0 ) { - info.add(INFO_MUTED); + info.add(Messages.channelInfoMuted()); StringBuffer buf = new StringBuffer(); - buf.append(INFO_PREFIX + ChatColor.WHITE); + buf.append(Messages.channelInfoPrefix() + ChatColor.WHITE); for ( int i=0; i 0 ) { - info.add(INFO_BANNED); + info.add(Messages.channelInfoBanned()); StringBuffer buf = new StringBuffer(); - buf.append(INFO_PREFIX + ChatColor.WHITE); + buf.append(Messages.channelInfoPrefix() + ChatColor.WHITE); for ( int i=0; i)obj; } - - /** - * メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する - * @param player メッセージの送り先 - * @param pre プレフィックス - * @param key リソースキー - * @param args リソース内の置き換え対象キーワード - */ - void sendResourceMessage( - ChannelMember player, String pre, String key, Object... args) { - - String org = Messages.get(key); - if ( org == null || org.equals("") ) { - return; - } - String msg = String.format(pre + org, args); - player.sendMessage(msg); - } } 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 b788277..ad220b0 100644 --- a/src/main/java/com/github/ucchyocean/lc3/channel/ChannelManager.java +++ b/src/main/java/com/github/ucchyocean/lc3/channel/ChannelManager.java @@ -26,8 +26,6 @@ import com.github.ucchyocean.lc3.member.ChannelMember; */ public class ChannelManager implements LunaChatAPI { - private static final String MSG_BREAKUP = Messages.get("breakupMessage"); - private static final String FILE_NAME_DCHANNELS = "defaults.yml"; private static final String FILE_NAME_TEMPLATES = "templates.yml"; private static final String FILE_NAME_JAPANIZE = "japanize.yml"; @@ -435,10 +433,8 @@ public class ChannelManager implements LunaChatAPI { if ( channel != null ) { // 強制解散のメッセージを、残ったメンバーに流す - if ( !channel.isPersonalChat() && !MSG_BREAKUP.equals("") ) { - String message = new String(MSG_BREAKUP); - message = message.replace("%ch", channel.getName()); - message = message.replace("%color", channel.getColorCode()); + String message = Messages.breakupMessage(channel.getColorCode(), channel.getName()); + if ( !channel.isPersonalChat() && !message.equals("") ) { for ( ChannelMember cp : channel.getMembers() ) { cp.sendMessage(message); } diff --git a/src/main/java/com/github/ucchyocean/lc3/command/AcceptCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/AcceptCommand.java index ed45663..e6190e1 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/AcceptCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/AcceptCommand.java @@ -5,6 +5,7 @@ */ package com.github.ucchyocean.lc3.command; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; @@ -12,16 +13,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * acceptコマンドの実行クラス * @author ucchy */ -public class AcceptCommand extends SubCommandAbst { +public class AcceptCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "accept"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageAccept"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -31,7 +31,7 @@ public class AcceptCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -41,7 +41,7 @@ public class AcceptCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -52,12 +52,12 @@ public class AcceptCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageAccept(label)); } /** @@ -66,14 +66,14 @@ public class AcceptCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand(ChannelMember sender, String label, String[] args) { // 招待を受けていないプレイヤーなら、エラーを表示して終了する if (!DataMaps.inviteMap.containsKey(sender.getName())) { - sendResourceMessage(sender, PREERR, "errmsgNotInvited"); + sender.sendMessage(Messages.errmsgNotInvited()); return true; } @@ -85,23 +85,23 @@ public class AcceptCommand extends SubCommandAbst { // 取得できなかったらエラー終了する if (channel == null) { - sendResourceMessage(sender, PREERR, "errmsgNotfoundChannel"); + sender.sendMessage(Messages.errmsgNotfoundChannel()); return true; } // 既に参加しているなら、エラーを表示して終了する if (channel.getMembers().contains(sender)) { - sendResourceMessage(sender, PREERR, "errmsgInvitedAlreadyJoin"); + sender.sendMessage(Messages.errmsgInvitedAlreadyJoin()); return true; } // 参加する channel.addMember(sender); - sendResourceMessage(sender, PREINFO, "cmdmsgJoin", channel.getName()); + sender.sendMessage(Messages.cmdmsgJoin(channel.getName())); // デフォルトの発言先に設定する api.setDefaultChannel(sender.getName(), channelName); - sendResourceMessage(sender, PREINFO, "cmdmsgSet", channelName); + sender.sendMessage(Messages.cmdmsgSet(channel.getName())); return true; } diff --git a/src/main/java/com/github/ucchyocean/lc3/command/BanCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/BanCommand.java index 0aed706..3c3baba 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/BanCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/BanCommand.java @@ -1,172 +1,171 @@ -/* - * @author ucchy - * @license LGPLv3 - * @copyright Copyright ucchy 2020 - */ -package com.github.ucchyocean.lc3.command; - -import com.github.ucchyocean.lc3.channel.Channel; -import com.github.ucchyocean.lc3.member.ChannelMember; - -/** - * banコマンドの実行クラス - * @author ucchy - */ -public class BanCommand extends SubCommandAbst { - - private static final String COMMAND_NAME = "ban"; - private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY1 = "usageBan"; - private static final String USAGE_KEY2 = "usageBan2"; - - /** - * コマンドを取得します。 - * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() - */ - @Override - public String getCommandName() { - return COMMAND_NAME; - } - - /** - * パーミッションノードを取得します。 - * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() - */ - @Override - public String getPermissionNode() { - return PERMISSION_NODE; - } - - /** - * コマンドの種別を取得します。 - * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() - */ - @Override - public CommandType getCommandType() { - return CommandType.MODERATOR; - } - - /** - * 使用方法に関するメッセージをsenderに送信します。 - * @param sender コマンド実行者 - * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() - */ - @Override - public void sendUsageMessage( - ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY1, label); - sendResourceMessage(sender, "", USAGE_KEY2, label); - } - - /** - * コマンドを実行します。 - * @param sender コマンド実行者 - * @param label 実行ラベル - * @param args 実行時の引数 - * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) - */ - @Override - public boolean runCommand( - ChannelMember sender, String label, String[] args) { - - // 実行引数から、BANするユーザーを取得する - String kickedName = ""; - if (args.length >= 2) { - kickedName = args[1]; - } else { - sendResourceMessage(sender, PREERR, "errmsgCommand"); - return true; - } - - // 対象チャンネルを取得、取得できない場合はエラー表示して終了する - Channel channel = null; - boolean isSpecifiedChannel = false; - if (args.length >= 3) { - channel = api.getChannel(args[2]); - isSpecifiedChannel = true; - } else { - channel = api.getDefaultChannel(sender.getName()); - } - if (channel == null) { - sendResourceMessage(sender, PREERR, "errmsgNoJoin"); - return true; - } - - // モデレーターかどうか確認する - if ( !channel.hasModeratorPermission(sender) ) { - sendResourceMessage(sender, PREERR, "errmsgNotModerator"); - return true; - } - - // グローバルチャンネルならBANできない - if ( channel.isGlobalChannel() ) { - sendResourceMessage(sender, PREERR, "errmsgCannotBANGlobal", channel.getName()); - return true; - } - - // BANされるプレイヤーがメンバーかどうかチェックする - ChannelMember kicked = ChannelMember.getChannelMember(kickedName); - if (!channel.getMembers().contains(kicked)) { - sendResourceMessage(sender, PREERR, "errmsgNomemberOther"); - return true; - } - - // 既にBANされているかどうかチェックする - if (channel.getBanned().contains(kicked)) { - sendResourceMessage(sender, PREERR, "errmsgAlreadyBanned"); - return true; - } - - // 期限付きBANの場合、期限の指定が正しいかどうかをチェックする - int expireMinutes = -1; - if (args.length >= 3 && !isSpecifiedChannel) { - if ( !args[2].matches("[0-9]+") ) { - sendResourceMessage(sender, PREERR, "errmsgInvalidBanExpireParameter"); - return true; - } - expireMinutes = Integer.parseInt(args[2]); - if ( expireMinutes < 1 || 43200 < expireMinutes ) { - sendResourceMessage(sender, PREERR, "errmsgInvalidBanExpireParameter"); - return true; - } - } - - // BAN実行 - channel.getBanned().add(kicked); - if ( expireMinutes != -1 ) { - long expire = System.currentTimeMillis() + expireMinutes * 60 * 1000; - channel.getBanExpires().put(kicked, expire); - } - channel.removeMember(kicked); - - // senderに通知メッセージを出す - if ( expireMinutes != -1 ) { - sendResourceMessage(sender, PREINFO, - "cmdmsgBanWithExpire", kickedName, channel.getName(), expireMinutes); - } else { - sendResourceMessage(sender, PREINFO, - "cmdmsgBan", kickedName, channel.getName()); - } - - // チャンネルに通知メッセージを出す - if ( expireMinutes != -1 ) { - sendResourceMessageWithKeyword(channel, - "banWithExpireMessage", kicked, expireMinutes); - } else { - sendResourceMessageWithKeyword(channel, "banMessage", kicked); - } - - // BANされた人に通知メッセージを出す - if ( kicked != null && kicked.isOnline() ) { - sendResourceMessage(kicked, PREINFO, - "cmdmsgBanned", channel.getName()); - } - - return true; - } -} +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.command; + +import com.github.ucchyocean.lc3.Messages; +import com.github.ucchyocean.lc3.channel.Channel; +import com.github.ucchyocean.lc3.member.ChannelMember; + +/** + * banコマンドの実行クラス + * @author ucchy + */ +public class BanCommand extends LunaChatSubCommand { + + private static final String COMMAND_NAME = "ban"; + private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; + + /** + * コマンドを取得します。 + * @return コマンド + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() + */ + @Override + public String getCommandName() { + return COMMAND_NAME; + } + + /** + * パーミッションノードを取得します。 + * @return パーミッションノード + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() + */ + @Override + public String getPermissionNode() { + return PERMISSION_NODE; + } + + /** + * コマンドの種別を取得します。 + * @return コマンド種別 + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() + */ + @Override + public CommandType getCommandType() { + return CommandType.MODERATOR; + } + + /** + * 使用方法に関するメッセージをsenderに送信します。 + * @param sender コマンド実行者 + * @param label 実行ラベル + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() + */ + @Override + public void sendUsageMessage( + ChannelMember sender, String label) { + sender.sendMessage(Messages.usageBan(label)); + sender.sendMessage(Messages.usageBan2(label)); + } + + /** + * コマンドを実行します。 + * @param sender コマンド実行者 + * @param label 実行ラベル + * @param args 実行時の引数 + * @return コマンドが実行されたかどうか + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) + */ + @Override + public boolean runCommand( + ChannelMember sender, String label, String[] args) { + + // 実行引数から、BANするユーザーを取得する + String kickedName = ""; + if (args.length >= 2) { + kickedName = args[1]; + } else { + sender.sendMessage(Messages.errmsgCommand()); + return true; + } + + // 対象チャンネルを取得、取得できない場合はエラー表示して終了する + Channel channel = null; + boolean isSpecifiedChannel = false; + if (args.length >= 3) { + channel = api.getChannel(args[2]); + isSpecifiedChannel = true; + } else { + channel = api.getDefaultChannel(sender.getName()); + } + if (channel == null) { + sender.sendMessage(Messages.errmsgNoJoin()); + return true; + } + + // モデレーターかどうか確認する + if ( !channel.hasModeratorPermission(sender) ) { + sender.sendMessage(Messages.errmsgNotModerator()); + return true; + } + + // グローバルチャンネルならBANできない + if ( channel.isGlobalChannel() ) { + sender.sendMessage(Messages.errmsgCannotBANGlobal(channel.getName())); + return true; + } + + // BANされるプレイヤーがメンバーかどうかチェックする + ChannelMember kicked = ChannelMember.getChannelMember(kickedName); + if (!channel.getMembers().contains(kicked)) { + sender.sendMessage(Messages.errmsgNomemberOther()); + return true; + } + + // 既にBANされているかどうかチェックする + if (channel.getBanned().contains(kicked)) { + sender.sendMessage(Messages.errmsgAlreadyBanned()); + return true; + } + + // 期限付きBANの場合、期限の指定が正しいかどうかをチェックする + int expireMinutes = -1; + if (args.length >= 3 && !isSpecifiedChannel) { + if ( !args[2].matches("[0-9]+") ) { + sender.sendMessage(Messages.errmsgInvalidBanExpireParameter()); + return true; + } + expireMinutes = Integer.parseInt(args[2]); + if ( expireMinutes < 1 || 43200 < expireMinutes ) { + sender.sendMessage(Messages.errmsgInvalidBanExpireParameter()); + return true; + } + } + + // BAN実行 + channel.getBanned().add(kicked); + if ( expireMinutes != -1 ) { + long expire = System.currentTimeMillis() + expireMinutes * 60 * 1000; + channel.getBanExpires().put(kicked, expire); + } + channel.removeMember(kicked); + + // senderに通知メッセージを出す + if ( expireMinutes != -1 ) { + sender.sendMessage(Messages.cmdmsgBanWithExpire( + kickedName, channel.getName(), expireMinutes)); + } else { + sender.sendMessage(Messages.cmdmsgBan( + kickedName, channel.getName())); + } + + // チャンネルに通知メッセージを出す + if ( expireMinutes != -1 ) { + sender.sendMessage(Messages.banWithExpireMessage( + channel.getColorCode(), channel.getName(), kicked.getName(), expireMinutes)); + } else { + sender.sendMessage(Messages.banMessage( + channel.getColorCode(), channel.getName(), kicked.getName())); + } + + // BANされた人に通知メッセージを出す + if ( kicked != null && kicked.isOnline() ) { + sender.sendMessage(Messages.cmdmsgBanned(channel.getName())); + } + + return true; + } +} diff --git a/src/main/java/com/github/ucchyocean/lc3/command/CreateCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/CreateCommand.java index 9268e7a..079a52d 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/CreateCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/CreateCommand.java @@ -5,6 +5,7 @@ */ package com.github.ucchyocean.lc3.command; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; @@ -12,16 +13,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * createコマンドの実行クラス * @author ucchy */ -public class CreateCommand extends SubCommandAbst { +public class CreateCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "create"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageCreate"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -31,7 +31,7 @@ public class CreateCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -41,7 +41,7 @@ public class CreateCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -52,12 +52,12 @@ public class CreateCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageCreate(label)); } /** @@ -66,7 +66,7 @@ public class CreateCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/DenyCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/DenyCommand.java index 0f0fac5..6da2343 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/DenyCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/DenyCommand.java @@ -5,22 +5,22 @@ */ package com.github.ucchyocean.lc3.command; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.member.ChannelMember; /** * denyコマンドの実行クラス * @author ucchy */ -public class DenyCommand extends SubCommandAbst { +public class DenyCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "deny"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageDeny"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -30,7 +30,7 @@ public class DenyCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -40,7 +40,7 @@ public class DenyCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -51,12 +51,12 @@ public class DenyCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageDeny(label)); } /** @@ -65,7 +65,7 @@ public class DenyCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand(ChannelMember sender, String label, String[] args) { diff --git a/src/main/java/com/github/ucchyocean/lc3/command/DicCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/DicCommand.java index dff1a79..1ffb4a4 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/DicCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/DicCommand.java @@ -5,6 +5,7 @@ */ package com.github.ucchyocean.lc3.command; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.member.ChannelMember; /** @@ -19,7 +20,7 @@ public class DicCommand extends DictionaryCommand { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -30,11 +31,11 @@ public class DicCommand extends DictionaryCommand { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageDic(label)); } } 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 c51433e..a04ead2 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/DictionaryCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/DictionaryCommand.java @@ -8,22 +8,22 @@ package com.github.ucchyocean.lc3.command; import java.util.HashMap; import com.github.ucchyocean.lc3.ChatColor; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.member.ChannelMember; /** * dictionaryコマンドの実行クラス * @author ucchy */ -public class DictionaryCommand extends SubCommandAbst { +public class DictionaryCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "dictionary"; private static final String PERMISSION_NODE = "lunachat-admin." + COMMAND_NAME; - private static final String USAGE_KEY = "usageDictionary"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -33,7 +33,7 @@ public class DictionaryCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -43,7 +43,7 @@ public class DictionaryCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -54,12 +54,12 @@ public class DictionaryCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageDictionary(label)); } /** @@ -68,7 +68,7 @@ public class DictionaryCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand(ChannelMember sender, String label, String[] args) { diff --git a/src/main/java/com/github/ucchyocean/lc3/command/FormatCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/FormatCommand.java index d4f2e74..3487152 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/FormatCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/FormatCommand.java @@ -7,6 +7,7 @@ package com.github.ucchyocean.lc3.command; import java.util.List; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; @@ -14,16 +15,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * formatコマンドの実行クラス * @author ucchy */ -public class FormatCommand extends SubCommandAbst { +public class FormatCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "format"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageFormat"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -33,7 +33,7 @@ public class FormatCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -43,7 +43,7 @@ public class FormatCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -54,12 +54,12 @@ public class FormatCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageFormat(label)); } /** @@ -68,7 +68,7 @@ public class FormatCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/HelpCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/HelpCommand.java index cc9f628..1b8507b 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/HelpCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/HelpCommand.java @@ -7,35 +7,35 @@ package com.github.ucchyocean.lc3.command; import java.util.ArrayList; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.member.ChannelMember; /** * helpコマンドの実行クラス * @author ucchy */ -public class HelpCommand extends SubCommandAbst { +public class HelpCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "help"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageHelp"; // 1ページに表示するコマンドヘルプの項目数 private static final int PAGE_ITEM_NUM = 6; - private ArrayList commands; + private ArrayList commands; /** * コンストラクタ * @param commands */ - public HelpCommand(ArrayList commands) { + public HelpCommand(ArrayList commands) { this.commands = commands; } /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -45,7 +45,7 @@ public class HelpCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -55,7 +55,7 @@ public class HelpCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -66,12 +66,12 @@ public class HelpCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageHelp(label)); } /** @@ -80,7 +80,7 @@ public class HelpCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand(ChannelMember sender, String label, String[] args) { @@ -133,8 +133,8 @@ public class HelpCommand extends SubCommandAbst { } // 種別に該当するコマンドを取得 - ArrayList com = new ArrayList(); - for ( SubCommandAbst c : commands ) { + ArrayList com = new ArrayList(); + for ( LunaChatSubCommand c : commands ) { if ( c.getCommandType() == type && sender.hasPermission(c.getPermissionNode()) ) { com.add(c); 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 43fc04f..0c005cc 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/HideCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/HideCommand.java @@ -16,24 +16,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * hideコマンドの実行クラス * @author ucchy */ -public class HideCommand extends SubCommandAbst { +public class HideCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "hide"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY1 = "usageHide"; - private static final String USAGE_KEY2 = "usageHidePlayer"; - - private static final String HIDE_CHANNEL_FIRSTLINE = - Messages.get("hideChannelFirstLine"); - private static final String HIDE_PLAYER_FIRSTLINE = - Messages.get("hidePlayerFirstLine"); - private static final String LIST_ENDLINE = Messages.get("listEndLine"); - private static final String LIST_PREFIX = Messages.get("listPlainPrefix"); /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -43,7 +34,7 @@ public class HideCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -53,7 +44,7 @@ public class HideCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -64,13 +55,13 @@ public class HideCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY1, label); - sendResourceMessage(sender, "", USAGE_KEY2, label); + sender.sendMessage(Messages.usageHide(label)); + sender.sendMessage(Messages.usageHidePlayer(label)); } /** @@ -79,7 +70,7 @@ public class HideCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( @@ -184,15 +175,15 @@ public class HideCommand extends SubCommandAbst { private ArrayList getHideInfoList(ChannelMember player) { ArrayList items = new ArrayList(); - items.add(HIDE_CHANNEL_FIRSTLINE); + items.add(Messages.hideChannelFirstLine()); for ( String channel : getHideChannelNameList(player) ) { - items.add(LIST_PREFIX + channel); + items.add(Messages.listPlainPrefix() + channel); } - items.add(HIDE_PLAYER_FIRSTLINE); + items.add(Messages.hidePlayerFirstLine()); for ( ChannelMember p : api.getHideinfo(player) ) { - items.add(LIST_PREFIX + p.getDisplayName()); + items.add(Messages.listPlainPrefix() + p.getDisplayName()); } - items.add(LIST_ENDLINE); + items.add(Messages.listEndLine()); return items; } diff --git a/src/main/java/com/github/ucchyocean/lc3/command/InfoCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/InfoCommand.java index bb5cff7..906cd60 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/InfoCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/InfoCommand.java @@ -7,6 +7,7 @@ package com.github.ucchyocean.lc3.command; import java.util.List; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; @@ -14,16 +15,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * infoコマンドの実行クラス * @author ucchy */ -public class InfoCommand extends SubCommandAbst { +public class InfoCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "info"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageInfo"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -33,7 +33,7 @@ public class InfoCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -43,7 +43,7 @@ public class InfoCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -54,12 +54,12 @@ public class InfoCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageInfo(label)); } /** @@ -68,7 +68,7 @@ public class InfoCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/InviteCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/InviteCommand.java index d43b74e..bd922b8 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/InviteCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/InviteCommand.java @@ -5,6 +5,7 @@ */ package com.github.ucchyocean.lc3.command; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; @@ -12,11 +13,10 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * inviteコマンドの実行クラス * @author ucchy */ -public class InviteCommand extends SubCommandAbst { +public class InviteCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "invite"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageInvite"; private static final String PERMISSION_NODE_FORCE_INVITE = "lunachat-admin.force-invite"; @@ -24,7 +24,7 @@ public class InviteCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -34,7 +34,7 @@ public class InviteCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -44,7 +44,7 @@ public class InviteCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -55,12 +55,12 @@ public class InviteCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageInvite(label)); } /** @@ -69,7 +69,7 @@ public class InviteCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand(ChannelMember sender, String label, String[] args) { diff --git a/src/main/java/com/github/ucchyocean/lc3/command/JoinCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/JoinCommand.java index 0f0961d..87d8816 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/JoinCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/JoinCommand.java @@ -5,6 +5,7 @@ */ package com.github.ucchyocean.lc3.command; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; @@ -12,17 +13,16 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * joinコマンドの実行クラス * @author ucchy */ -public class JoinCommand extends SubCommandAbst { +public class JoinCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "join"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; private static final String PERMISSION_SPEAK_PREFIX = "lunachat.speak"; - private static final String USAGE_KEY = "usageJoin"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -32,7 +32,7 @@ public class JoinCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -42,7 +42,7 @@ public class JoinCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -53,12 +53,12 @@ public class JoinCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageJoin(label)); } /** @@ -67,7 +67,7 @@ public class JoinCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/KickCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/KickCommand.java index f066862..a60434f 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/KickCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/KickCommand.java @@ -5,6 +5,7 @@ */ package com.github.ucchyocean.lc3.command; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; @@ -12,16 +13,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * kickコマンドの実行クラス * @author ucchy */ -public class KickCommand extends SubCommandAbst { +public class KickCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "kick"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageKick"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -31,7 +31,7 @@ public class KickCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -41,7 +41,7 @@ public class KickCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -52,12 +52,12 @@ public class KickCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageKick(label)); } /** @@ -66,7 +66,7 @@ public class KickCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/LeaveCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/LeaveCommand.java index fe7f789..0d75648 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/LeaveCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/LeaveCommand.java @@ -5,6 +5,7 @@ */ package com.github.ucchyocean.lc3.command; +import com.github.ucchyocean.lc3.Messages; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; @@ -12,16 +13,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * leaveコマンドの実行クラス * @author ucchy */ -public class LeaveCommand extends SubCommandAbst { +public class LeaveCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "leave"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageLeave"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -31,7 +31,7 @@ public class LeaveCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -41,7 +41,7 @@ public class LeaveCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -52,12 +52,12 @@ public class LeaveCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageLeave(label)); } /** @@ -66,7 +66,7 @@ public class LeaveCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( 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 c80ae55..4730479 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/ListCommand.java @@ -18,7 +18,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * listコマンドの実行クラス * @author ucchy */ -public class ListCommand extends SubCommandAbst { +public class ListCommand extends LunaChatSubCommand { private static final String LIST_FIRSTLINE = Messages.get("listFirstLine"); private static final String LIST_FIRSTLINE_PAGING = Messages.get("listFirstLinePaging"); @@ -27,14 +27,13 @@ public class ListCommand extends SubCommandAbst { private static final String COMMAND_NAME = "list"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageList"; private static final int PAGE_SIZE = 8; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -44,7 +43,7 @@ public class ListCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -54,7 +53,7 @@ public class ListCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -65,12 +64,12 @@ public class ListCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageList(label)); } /** @@ -79,7 +78,7 @@ public class ListCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/LogCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/LogCommand.java index 3cee07a..479cad0 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/LogCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/LogCommand.java @@ -17,20 +17,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * logコマンドの実行クラス * @author ucchy */ -public class LogCommand extends SubCommandAbst { - - private static final String LOGDISPLAY_FIRSTLINE = Messages.get("logDisplayFirstLine"); - private static final String LOGDISPLAY_ENDLINE = Messages.get("logDisplayEndLine"); - private static final String LOGDISPLAY_FORMAT = Messages.get("logDisplayFormat"); +public class LogCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "log"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; - private static final String USAGE_KEY = "usageLog"; /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -40,7 +35,7 @@ public class LogCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -50,7 +45,7 @@ public class LogCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -61,12 +56,12 @@ public class LogCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( ChannelMember sender, String label) { - sendResourceMessage(sender, "", USAGE_KEY, label); + sender.sendMessage(Messages.usageLog(label)); } /** @@ -75,7 +70,7 @@ public class LogCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand(ChannelMember sender, String label, String[] args) { @@ -116,8 +111,7 @@ public class LogCommand extends SubCommandAbst { // 参照権限を確認する String node = PERMISSION_NODE + "." + cname; if (sender.isPermissionSet(node) && !sender.hasPermission(node)) { - sendResourceMessage(sender, PREERR, "errmsgPermission", - PERMISSION_NODE + "." + cname); + sender.sendMessage(Messages.errmsgPermission(node)); return true; } @@ -139,19 +133,19 @@ public class LogCommand extends SubCommandAbst { // チャンネルが存在するかどうか確認する Channel channel = api.getChannel(cname); if ( channel == null ) { - sendResourceMessage(sender, PREERR, "errmsgNotExist"); + sender.sendMessage(Messages.errmsgNotExist()); return true; } // BANされていないかどうか確認する if ( sender != null && channel.getBanned().contains(sender) ) { - sendResourceMessage(sender, PREERR, "errmsgBanned"); + sender.sendMessage(Messages.errmsgBanned()); return true; } // チャンネルのメンバーかどうかを確認する if (!channel.getMembers().contains(sender)) { - sendResourceMessage(sender, PREERR, "errmsgNomember"); + sender.sendMessage(Messages.errmsgNomember()); return true; } @@ -159,7 +153,7 @@ public class LogCommand extends SubCommandAbst { } // 整形と表示 - sender.sendMessage(String.format(LOGDISPLAY_FIRSTLINE, cname)); + sender.sendMessage(Messages.logDisplayFirstLine(cname)); for ( String log : logs ) { @@ -170,11 +164,10 @@ public class LogCommand extends SubCommandAbst { if ( temp.length >= 3 ) { playerName = temp[2]; } - sender.sendMessage(String.format( - LOGDISPLAY_FORMAT, date, playerName, message)); + sender.sendMessage(Messages.logDisplayFormat(date, playerName, message)); } - sender.sendMessage(LOGDISPLAY_ENDLINE); + sender.sendMessage(Messages.logDisplayEndLine()); return true; } diff --git a/src/main/java/com/github/ucchyocean/lc3/command/LunaChatCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/LunaChatCommand.java index abc451a..840072a 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/LunaChatCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/LunaChatCommand.java @@ -19,10 +19,8 @@ import com.github.ucchyocean.lc3.member.ChannelMember; */ public abstract class LunaChatCommand { - private static final String PREERR = Messages.get("errorPrefix"); - - private ArrayList commands; - private ArrayList commonCommands; + private ArrayList commands; + private ArrayList commonCommands; private JoinCommand joinCommand; private HelpCommand helpCommand; @@ -31,7 +29,7 @@ public abstract class LunaChatCommand { */ public LunaChatCommand() { - commands = new ArrayList(); + commands = new ArrayList(); joinCommand = new JoinCommand(); commands.add(joinCommand); commands.add(new LeaveCommand()); @@ -57,7 +55,7 @@ public abstract class LunaChatCommand { helpCommand = new HelpCommand(commands); commands.add(helpCommand); - commonCommands = new ArrayList(); + commonCommands = new ArrayList(); commonCommands.add(new HideCommand()); commonCommands.add(new UnhideCommand()); commonCommands.add(new DictionaryCommand()); @@ -77,13 +75,13 @@ public abstract class LunaChatCommand { // チャンネルチャットが無効でも利用できるコマンドはここで処理する // (hide, unhide, dic, dictionary, reload) if ( args.length >= 1 ) { - for ( SubCommandAbst c : commonCommands ) { + for ( LunaChatSubCommand c : commonCommands ) { if ( c.getCommandName().equalsIgnoreCase(args[0]) ) { // パーミッションの確認 String node = c.getPermissionNode(); if ( !sender.hasPermission(node) ) { - sendResourceMessage(sender, PREERR, "errmsgPermission", node); + sender.sendMessage(Messages.errmsgPermission(node)); return true; } @@ -96,7 +94,7 @@ public abstract class LunaChatCommand { // チャンネルチャット機能が無効になっている場合は、メッセージを表示して終了 if ( !LunaChat.getConfig().isEnableChannelChat() && !sender.hasPermission("lunachat-admin") ) { - sendResourceMessage(sender, PREERR, "errmsgChannelChatDisabled"); + sender.sendMessage(Messages.errmsgChannelChatDisabled()); return true; } @@ -107,13 +105,13 @@ public abstract class LunaChatCommand { } // 第1引数に指定されたコマンドを実行する - for ( SubCommandAbst c : commands ) { + for ( LunaChatSubCommand c : commands ) { if ( c.getCommandName().equalsIgnoreCase(args[0]) ) { // パーミッションの確認 String node = c.getPermissionNode(); if ( !sender.hasPermission(node) ) { - sendResourceMessage(sender, PREERR, "errmsgPermission", node); + sender.sendMessage(Messages.errmsgPermission(node)); return true; } @@ -125,7 +123,7 @@ public abstract class LunaChatCommand { // 第1引数がコマンドでないなら、joinが指定されたとみなす String node = joinCommand.getPermissionNode(); if ( !sender.hasPermission(node) ) { - sendResourceMessage(sender, PREERR, "errmsgPermission", node); + sender.sendMessage(Messages.errmsgPermission(node)); return true; } @@ -144,13 +142,13 @@ public abstract class LunaChatCommand { // コマンド名で補完する String arg = args[0].toLowerCase(); ArrayList coms = new ArrayList(); - for ( SubCommandAbst c : commands ) { + for ( LunaChatSubCommand c : commands ) { if ( c.getCommandName().startsWith(arg) && sender.hasPermission(c.getPermissionNode()) ) { coms.add(c.getCommandName()); } } - for ( SubCommandAbst c : commonCommands ) { + for ( LunaChatSubCommand c : commonCommands ) { if ( c.getCommandName().startsWith(arg) && sender.hasPermission(c.getPermissionNode()) ) { coms.add(c.getCommandName()); @@ -306,25 +304,6 @@ public abstract class LunaChatCommand { return new ArrayList(); } - /** - * メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する - * - * @param sender メッセージの送り先 - * @param pre プレフィックス - * @param key リソースキー - * @param args リソース内の置き換え対象キーワード - */ - private void sendResourceMessage(ChannelMember sender, String pre, - String key, Object... args) { - - String org = Messages.get(key); - if ( org == null || org.equals("") ) { - return; - } - String msg = String.format(pre + org, args); - sender.sendMessage(msg); - } - /** * TAB補完用の参加可能チャンネルリストを返す * @param sender コマンド実行者 diff --git a/src/main/java/com/github/ucchyocean/lc3/command/LunaChatSubCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/LunaChatSubCommand.java new file mode 100644 index 0000000..89453f2 --- /dev/null +++ b/src/main/java/com/github/ucchyocean/lc3/command/LunaChatSubCommand.java @@ -0,0 +1,155 @@ +/* + * @author ucchy + * @license LGPLv3 + * @copyright Copyright ucchy 2020 + */ +package com.github.ucchyocean.lc3.command; + +import com.github.ucchyocean.lc3.LunaChat; +import com.github.ucchyocean.lc3.LunaChatAPI; +import com.github.ucchyocean.lc3.LunaChatConfig; +import com.github.ucchyocean.lc3.member.ChannelMember; + +/** + * サブコマンドの抽象クラス + * @author ucchy + */ +public abstract class LunaChatSubCommand { + + /** + * コマンドの種別 + * @author ucchy + */ + protected enum CommandType { + + /** 一般ユーザー向けコマンド */ + USER, + + /** チャンネルモデレーター向けコマンド */ + MODERATOR, + + /** サーバー管理者向けコマンド */ + ADMIN + } + + protected LunaChatAPI api; + protected LunaChatConfig config; + + /** + * コンストラクタ + */ + public LunaChatSubCommand() { + api = LunaChat.getPlugin().getLunaChatAPI(); + config = LunaChat.getPlugin().getLunaChatConfig(); + } + +// /** +// * メッセージリソースのメッセージを、カラーコード置き換えしつつ、Channelに送信する +// * @param channel メッセージの送り先 +// * @param pre プレフィックス +// * @param key リソースキー +// * @param player キーワード置き換えに使用するプレイヤー +// */ +// protected void sendResourceMessageWithKeyword( +// Channel channel, String key, ChannelMember player) { +// +// String msg = Messages.get(key); +// if ( msg == null || msg.equals("") ) { +// return; +// } +// msg = msg.replace("%ch", channel.getName()); +// msg = msg.replace("%color", channel.getColorCode()); +// if ( player != null ) { +// msg = msg.replace("%username", player.getDisplayName()); +// msg = msg.replace("%player", player.getName()); +// } else { +// msg = msg.replace("%username", ""); +// msg = msg.replace("%player", ""); +// } +// msg = Utility.replaceColorCode(msg); +// channel.sendMessage(null, msg, null, true, "system"); +// } +// +// /** +// * メッセージリソースのメッセージを、カラーコード置き換えしつつ、Channelに送信する +// * @param channel メッセージの送り先 +// * @param pre プレフィックス +// * @param key リソースキー +// * @param player キーワード置き換えに使用するプレイヤー +// * @param minutes キーワード置き換えに使用する数値 +// */ +// protected void sendResourceMessageWithKeyword( +// Channel channel, String key, ChannelMember player, int minutes) { +// +// String msg = Messages.get(key); +// if ( msg == null || msg.equals("") ) { +// return; +// } +// msg = msg.replace("%ch", channel.getName()); +// msg = msg.replace("%color", channel.getColorCode()); +// msg = msg.replace("%d", String.valueOf(minutes)); +// if ( player != null ) { +// msg = msg.replace("%username", player.getDisplayName()); +// msg = msg.replace("%player", player.getName()); +// } else { +// msg = msg.replace("%username", ""); +// msg = msg.replace("%player", ""); +// } +// msg = Utility.replaceColorCode(msg); +// channel.sendMessage(null, msg, null, true, "system"); +// } +// +// /** +// * メッセージリソースのメッセージを、カラーコード置き換えしつつ、ChannelMemberに送信する +// * @param sender メッセージの送り先 +// * @param pre プレフィックス +// * @param key リソースキー +// * @param args リソース内の置き換え対象キーワード +// */ +// protected void sendResourceMessage( +// ChannelMember cp, String pre, String key, Object... args) { +// +// String org = Messages.get(key); +// if ( org == null || org.equals("") ) { +// return; +// } +// String msg = String.format(pre + org, args); +// cp.sendMessage(msg); +// } + + /** + * コマンドを取得します。 + * @return コマンド + */ + public abstract String getCommandName(); + + /** + * パーミッションノードを取得します。 + * @return パーミッションノード + */ + public abstract String getPermissionNode(); + + /** + * コマンドの種別を取得します。 + * @return コマンド種別 + */ + public abstract CommandType getCommandType(); + + /** + * 使用方法に関するメッセージをsenderに送信します。 + * @param sender コマンド実行者 + * @param label 実行ラベル + */ + public abstract void sendUsageMessage( + ChannelMember sender, String label); + + /** + * コマンドを実行します。 + * @param sender コマンド実行者 + * @param label 実行ラベル + * @param args 実行時の引数 + * @return コマンドが実行されたかどうか + */ + public abstract boolean runCommand( + ChannelMember sender, String label, String[] args); +} diff --git a/src/main/java/com/github/ucchyocean/lc3/command/ModCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/ModCommand.java index e534539..0a3bc3d 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/ModCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/ModCommand.java @@ -19,7 +19,7 @@ public class ModCommand extends ModeratorCommand { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -30,7 +30,7 @@ public class ModCommand extends ModeratorCommand { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者O * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/ModeratorCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/ModeratorCommand.java index c65992f..a345d2a 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/ModeratorCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/ModeratorCommand.java @@ -14,7 +14,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * moderatorコマンドの実行クラス * @author ucchy */ -public class ModeratorCommand extends SubCommandAbst { +public class ModeratorCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "moderator"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; @@ -23,7 +23,7 @@ public class ModeratorCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -33,7 +33,7 @@ public class ModeratorCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -43,7 +43,7 @@ public class ModeratorCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -54,7 +54,7 @@ public class ModeratorCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -68,7 +68,7 @@ public class ModeratorCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/MuteCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/MuteCommand.java index 5543dfc..48db67b 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/MuteCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/MuteCommand.java @@ -12,7 +12,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * muteコマンドの実行クラス * @author ucchy */ -public class MuteCommand extends SubCommandAbst { +public class MuteCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "mute"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; @@ -22,7 +22,7 @@ public class MuteCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -32,7 +32,7 @@ public class MuteCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -42,7 +42,7 @@ public class MuteCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -53,7 +53,7 @@ public class MuteCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -68,7 +68,7 @@ public class MuteCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( 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 1fa8bdd..30620f3 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/OptionCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/OptionCommand.java @@ -17,7 +17,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * optionコマンドの実行クラス * @author ucchy */ -public class OptionCommand extends SubCommandAbst { +public class OptionCommand extends LunaChatSubCommand { private static final int MAX_LENGTH_DESCRIPTION = 30; private static final int MAX_LENGTH_ALIAS = 15; @@ -30,7 +30,7 @@ public class OptionCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -40,7 +40,7 @@ public class OptionCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -50,7 +50,7 @@ public class OptionCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -61,7 +61,7 @@ public class OptionCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -75,7 +75,7 @@ public class OptionCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/PardonCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/PardonCommand.java index 2951fe7..6728119 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/PardonCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/PardonCommand.java @@ -12,7 +12,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * pardonコマンドの実行クラス * @author ucchy */ -public class PardonCommand extends SubCommandAbst { +public class PardonCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "pardon"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; @@ -21,7 +21,7 @@ public class PardonCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -31,7 +31,7 @@ public class PardonCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -41,7 +41,7 @@ public class PardonCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -52,7 +52,7 @@ public class PardonCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -66,7 +66,7 @@ public class PardonCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/ReloadCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/ReloadCommand.java index 7ffb26f..92864aa 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/ReloadCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/ReloadCommand.java @@ -12,7 +12,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * reloadコマンドの実行クラス * @author ucchy */ -public class ReloadCommand extends SubCommandAbst { +public class ReloadCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "reload"; private static final String PERMISSION_NODE = "lunachat-admin." + COMMAND_NAME; @@ -21,7 +21,7 @@ public class ReloadCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -31,7 +31,7 @@ public class ReloadCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -41,7 +41,7 @@ public class ReloadCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -52,7 +52,7 @@ public class ReloadCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -66,7 +66,7 @@ public class ReloadCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/RemoveCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/RemoveCommand.java index d9671af..e31bef9 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/RemoveCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/RemoveCommand.java @@ -12,7 +12,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * removeコマンドの実行クラス * @author ucchy */ -public class RemoveCommand extends SubCommandAbst { +public class RemoveCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "remove"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; @@ -21,7 +21,7 @@ public class RemoveCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -31,7 +31,7 @@ public class RemoveCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -41,7 +41,7 @@ public class RemoveCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -52,7 +52,7 @@ public class RemoveCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -66,7 +66,7 @@ public class RemoveCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/SetCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/SetCommand.java index 1f730cd..5848ce9 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/SetCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/SetCommand.java @@ -3,7 +3,7 @@ package com.github.ucchyocean.lc3.command; import com.github.ucchyocean.lc3.channel.Channel; import com.github.ucchyocean.lc3.member.ChannelMember; -public class SetCommand extends SubCommandAbst { +public class SetCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "set"; private static final String PERMISSION_NODE = "lunachat-admin." + COMMAND_NAME; @@ -12,7 +12,7 @@ public class SetCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -22,7 +22,7 @@ public class SetCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -32,7 +32,7 @@ public class SetCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -43,7 +43,7 @@ public class SetCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage(ChannelMember sender, String label) { @@ -56,7 +56,7 @@ public class SetCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand(ChannelMember sender, String label, String[] args) { diff --git a/src/main/java/com/github/ucchyocean/lc3/command/SubCommandAbst.java b/src/main/java/com/github/ucchyocean/lc3/command/SubCommandAbst.java deleted file mode 100644 index f345b70..0000000 --- a/src/main/java/com/github/ucchyocean/lc3/command/SubCommandAbst.java +++ /dev/null @@ -1,161 +0,0 @@ -/* - * @author ucchy - * @license LGPLv3 - * @copyright Copyright ucchy 2020 - */ -package com.github.ucchyocean.lc3.command; - -import com.github.ucchyocean.lc3.LunaChat; -import com.github.ucchyocean.lc3.LunaChatAPI; -import com.github.ucchyocean.lc3.LunaChatConfig; -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; - -/** - * サブコマンドの抽象クラス - * @author ucchy - */ -public abstract class SubCommandAbst { - - /** - * コマンドの種別 - * @author ucchy - */ - protected enum CommandType { - - /** 一般ユーザー向けコマンド */ - USER, - - /** チャンネルモデレーター向けコマンド */ - MODERATOR, - - /** サーバー管理者向けコマンド */ - ADMIN - } - - protected static final String PREINFO = Messages.get("infoPrefix"); - protected static final String PREERR = Messages.get("errorPrefix"); - - protected LunaChatAPI api; - protected LunaChatConfig config; - - /** - * コンストラクタ - */ - public SubCommandAbst() { - api = LunaChat.getPlugin().getLunaChatAPI(); - config = LunaChat.getPlugin().getLunaChatConfig(); - } - - /** - * メッセージリソースのメッセージを、カラーコード置き換えしつつ、Channelに送信する - * @param channel メッセージの送り先 - * @param pre プレフィックス - * @param key リソースキー - * @param player キーワード置き換えに使用するプレイヤー - */ - protected void sendResourceMessageWithKeyword( - Channel channel, String key, ChannelMember player) { - - String msg = Messages.get(key); - if ( msg == null || msg.equals("") ) { - return; - } - msg = msg.replace("%ch", channel.getName()); - msg = msg.replace("%color", channel.getColorCode()); - if ( player != null ) { - msg = msg.replace("%username", player.getDisplayName()); - msg = msg.replace("%player", player.getName()); - } else { - msg = msg.replace("%username", ""); - msg = msg.replace("%player", ""); - } - msg = Utility.replaceColorCode(msg); - channel.sendMessage(null, msg, null, true, "system"); - } - - /** - * メッセージリソースのメッセージを、カラーコード置き換えしつつ、Channelに送信する - * @param channel メッセージの送り先 - * @param pre プレフィックス - * @param key リソースキー - * @param player キーワード置き換えに使用するプレイヤー - * @param minutes キーワード置き換えに使用する数値 - */ - protected void sendResourceMessageWithKeyword( - Channel channel, String key, ChannelMember player, int minutes) { - - String msg = Messages.get(key); - if ( msg == null || msg.equals("") ) { - return; - } - msg = msg.replace("%ch", channel.getName()); - msg = msg.replace("%color", channel.getColorCode()); - msg = msg.replace("%d", String.valueOf(minutes)); - if ( player != null ) { - msg = msg.replace("%username", player.getDisplayName()); - msg = msg.replace("%player", player.getName()); - } else { - msg = msg.replace("%username", ""); - msg = msg.replace("%player", ""); - } - msg = Utility.replaceColorCode(msg); - channel.sendMessage(null, msg, null, true, "system"); - } - - /** - * メッセージリソースのメッセージを、カラーコード置き換えしつつ、ChannelMemberに送信する - * @param sender メッセージの送り先 - * @param pre プレフィックス - * @param key リソースキー - * @param args リソース内の置き換え対象キーワード - */ - protected void sendResourceMessage( - ChannelMember cp, String pre, String key, Object... args) { - - String org = Messages.get(key); - if ( org == null || org.equals("") ) { - return; - } - String msg = String.format(pre + org, args); - cp.sendMessage(msg); - } - - /** - * コマンドを取得します。 - * @return コマンド - */ - public abstract String getCommandName(); - - /** - * パーミッションノードを取得します。 - * @return パーミッションノード - */ - public abstract String getPermissionNode(); - - /** - * コマンドの種別を取得します。 - * @return コマンド種別 - */ - public abstract CommandType getCommandType(); - - /** - * 使用方法に関するメッセージをsenderに送信します。 - * @param sender コマンド実行者 - * @param label 実行ラベル - */ - public abstract void sendUsageMessage( - ChannelMember sender, String label); - - /** - * コマンドを実行します。 - * @param sender コマンド実行者 - * @param label 実行ラベル - * @param args 実行時の引数 - * @return コマンドが実行されたかどうか - */ - public abstract boolean runCommand( - ChannelMember sender, String label, String[] args); -} diff --git a/src/main/java/com/github/ucchyocean/lc3/command/TemplateCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/TemplateCommand.java index 8cb8113..7e5d00b 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/TemplateCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/TemplateCommand.java @@ -11,7 +11,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * templateコマンドの実行クラス * @author ucchy */ -public class TemplateCommand extends SubCommandAbst { +public class TemplateCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "template"; private static final String PERMISSION_NODE = "lunachat-admin." + COMMAND_NAME; @@ -20,7 +20,7 @@ public class TemplateCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -30,7 +30,7 @@ public class TemplateCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -40,7 +40,7 @@ public class TemplateCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -51,7 +51,7 @@ public class TemplateCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -65,7 +65,7 @@ public class TemplateCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( 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 7e5a48d..7896049 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/UnhideCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/UnhideCommand.java @@ -13,7 +13,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * unhideコマンドの実行クラス * @author ucchy */ -public class UnhideCommand extends SubCommandAbst { +public class UnhideCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "unhide"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; @@ -23,7 +23,7 @@ public class UnhideCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -33,7 +33,7 @@ public class UnhideCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -43,7 +43,7 @@ public class UnhideCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -54,7 +54,7 @@ public class UnhideCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -69,7 +69,7 @@ public class UnhideCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/command/UnmuteCommand.java b/src/main/java/com/github/ucchyocean/lc3/command/UnmuteCommand.java index face30b..4d82203 100644 --- a/src/main/java/com/github/ucchyocean/lc3/command/UnmuteCommand.java +++ b/src/main/java/com/github/ucchyocean/lc3/command/UnmuteCommand.java @@ -12,7 +12,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember; * unmuteコマンドの実行クラス * @author ucchy */ -public class UnmuteCommand extends SubCommandAbst { +public class UnmuteCommand extends LunaChatSubCommand { private static final String COMMAND_NAME = "unmute"; private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME; @@ -21,7 +21,7 @@ public class UnmuteCommand extends SubCommandAbst { /** * コマンドを取得します。 * @return コマンド - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandName() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandName() */ @Override public String getCommandName() { @@ -31,7 +31,7 @@ public class UnmuteCommand extends SubCommandAbst { /** * パーミッションノードを取得します。 * @return パーミッションノード - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getPermissionNode() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getPermissionNode() */ @Override public String getPermissionNode() { @@ -41,7 +41,7 @@ public class UnmuteCommand extends SubCommandAbst { /** * コマンドの種別を取得します。 * @return コマンド種別 - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#getCommandType() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#getCommandType() */ @Override public CommandType getCommandType() { @@ -52,7 +52,7 @@ public class UnmuteCommand extends SubCommandAbst { * 使用方法に関するメッセージをsenderに送信します。 * @param sender コマンド実行者 * @param label 実行ラベル - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#sendUsageMessage() + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#sendUsageMessage() */ @Override public void sendUsageMessage( @@ -66,7 +66,7 @@ public class UnmuteCommand extends SubCommandAbst { * @param label 実行ラベル * @param args 実行時の引数 * @return コマンドが実行されたかどうか - * @see com.github.ucchyocean.lc3.command.SubCommandAbst#runCommand(java.lang.String[]) + * @see com.github.ucchyocean.lc3.command.LunaChatSubCommand#runCommand(java.lang.String[]) */ @Override public boolean runCommand( diff --git a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberBukkitConsole.java b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberBukkitConsole.java index 4d9a216..631dc1a 100644 --- a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberBukkitConsole.java +++ b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberBukkitConsole.java @@ -83,6 +83,7 @@ public class ChannelMemberBukkitConsole extends ChannelMemberBukkit { */ @Override public void sendMessage(String message) { + if ( message == null || message.isEmpty() ) return; sender.sendMessage(message); } diff --git a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberBungee.java b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberBungee.java index 0ca0842..cfa54d0 100644 --- a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberBungee.java +++ b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberBungee.java @@ -37,6 +37,7 @@ public abstract class ChannelMemberBungee extends ChannelMember { if ( sender instanceof ProxiedPlayer ) { return new ChannelMemberProxiedPlayer(((ProxiedPlayer)sender).getUniqueId()); } else { + // ProxiedPlayer以外のCommandSenderは、ConsoleSenderしかないはず return new ChannelMemberBungeeConsole((CommandSender)sender); } } diff --git a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberPlayer.java b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberPlayer.java index 76891ae..fb610d6 100644 --- a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberPlayer.java +++ b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberPlayer.java @@ -157,6 +157,7 @@ public class ChannelMemberPlayer extends ChannelMemberBukkit { */ @Override public void sendMessage(String message) { + if ( message == null || message.isEmpty() ) return; Player player = getPlayer(); if ( player != null ) { player.sendMessage(message); 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 cc306c9..8df2028 100644 --- a/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberProxiedPlayer.java +++ b/src/main/java/com/github/ucchyocean/lc3/member/ChannelMemberProxiedPlayer.java @@ -44,7 +44,6 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee { * @return ChannelMemberProxiedPlayer */ public static ChannelMemberProxiedPlayer getChannelMember(String nameOrUuid) { - if ( nameOrUuid.startsWith("$") ) { return new ChannelMemberProxiedPlayer(UUID.fromString(nameOrUuid.substring(1))); } else { @@ -128,6 +127,7 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee { */ @Override public void sendMessage(String message) { + if ( message == null || message.isEmpty() ) return; ProxiedPlayer player = getPlayer(); if ( player != null ) { player.sendMessage(TextComponent.fromLegacyText(message)); 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 71dcb85..f7e3a19 100644 --- a/src/main/java/com/github/ucchyocean/lc3/tool/MessageParser.java +++ b/src/main/java/com/github/ucchyocean/lc3/tool/MessageParser.java @@ -51,7 +51,7 @@ public class MessageParser { System.out.println(String.format( " String msg = resources.getString(\"%s\");", key)); System.out.println(String.format( - " if ( msg == null || msg.equals(\"\") ) return \"\";", key)); + " if ( msg == null ) return \"\";", key)); for ( String keyword : keywords ) { System.out.println(String.format( @@ -59,8 +59,10 @@ public class MessageParser { } if ( key.startsWith("errmsg") ) { System.out.println(" return resources.getString(\"errorPrefix\", \"\") + msg;"); + } else if ( key.startsWith("cmdmsg") ) { + System.out.println(" return resources.getString(\"infoPrefix\", \"\") + msg;"); } else { - System.out.println(" return msg;"); + System.out.println(" return Utility.replaceColorCode(msg);"); } System.out.println(" }"); }