LunaChat v3-k2 : Messaging implementation. (WIP)

このコミットが含まれているのは:
ucchy committed 2020-06-03 00:19:39 +09:00
1 親 f5910411f4
コミット 1513dd8197
42ファイル変更
+924 -1120

検索条件に一致するファイルはありません

ファイル差分が大きすぎるため表示されません。 差分を読み込み
+4 -24
ファイルの表示
@@ -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<String> items = new ArrayList<String>();
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
+5 -28
ファイルの表示
@@ -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<String> items = new ArrayList<String>();
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
+10 -46
ファイルの表示
@@ -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()));
}
// ロギング
+9 -42
ファイルの表示
@@ -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 プレイヤー(ワールドチャット、範囲チャットの場合は必須です)
+41 -82
ファイルの表示
@@ -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<ChannelMember> 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<String> getInfo(boolean forModerator) {
ArrayList<String> info = new ArrayList<String>();
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<getMembers().size(); i++ ) {
if ( i%5 == 0 && i != 0 ) {
info.add(buf.toString());
buf = new StringBuffer();
buf.append(INFO_PREFIX);
buf.append(Messages.channelInfoPrefix());
}
ChannelMember cp = getMembers().get(i);
@@ -457,42 +434,42 @@ public abstract class Channel {
// シークレットチャンネルかどうか
if ( !isVisible() ) {
info.add(INFO_SECRET);
info.add(Messages.channelInfoSecret());
}
// パスワード設定があるかどうか
if ( getPassword().length() > 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<getMuted().size(); i++ ) {
if ( i%5 == 0 && i != 0 ) {
info.add(buf.toString());
buf = new StringBuffer();
buf.append(INFO_PREFIX + ChatColor.WHITE);
buf.append(Messages.channelInfoPrefix() + ChatColor.WHITE);
}
buf.append(getMuted().get(i).getName() + ",");
}
@@ -502,15 +479,15 @@ public abstract class Channel {
// BANリスト情報、5人ごとに表示する
if ( getBanned().size() > 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<getBanned().size(); i++ ) {
if ( i%5 == 0 && i != 0 ) {
info.add(buf.toString());
buf = new StringBuffer();
buf.append(INFO_PREFIX + ChatColor.WHITE);
buf.append(Messages.channelInfoPrefix() + ChatColor.WHITE);
}
buf.append(getBanned().get(i).getName() + ",");
}
@@ -519,7 +496,7 @@ public abstract class Channel {
}
}
info.add(LIST_ENDLINE);
info.add(Messages.listEndLine());
return info;
}
@@ -542,13 +519,13 @@ public abstract class Channel {
save();
// メッセージ通知を流す
if ( !MSG_BAN_EXPIRED.equals("") ) {
String msg = replaceKeywords(MSG_BAN_EXPIRED, cp);
String msg = Messages.expiredBanMessage(getColorCode(), getName(), cp.getName());
if ( !msg.isEmpty() ) {
sendMessage(null, msg, null, false, "system");
}
if ( cp.isOnline() && !MSG_BAN_EXPIRED_PLAYER.equals("") ) {
String msg = PREINFO + String.format(MSG_BAN_EXPIRED_PLAYER, getName());
msg = Messages.cmdmsgPardoned(getName());
if ( cp.isOnline() && !msg.isEmpty() ) {
cp.sendMessage(msg);
}
}
@@ -566,13 +543,13 @@ public abstract class Channel {
save();
// メッセージ通知を流す
if ( !MSG_MUTE_EXPIRED.equals("") ) {
String msg = replaceKeywords(MSG_MUTE_EXPIRED, cp);
String msg = Messages.expiredMuteMessage(getColorCode(), getName(), cp.getName());
if ( !msg.isEmpty() ) {
sendMessage(null, msg, null, false, "system");
}
if ( cp.isOnline() && !MSG_MUTE_EXPIRED_PLAYER.equals("") ) {
String msg = PREINFO + String.format(MSG_MUTE_EXPIRED_PLAYER, getName());
msg = Messages.cmdmsgUnmuted(getName());
if ( cp.isOnline() && !msg.isEmpty() ) {
cp.sendMessage(msg);
}
}
@@ -1140,22 +1117,4 @@ public abstract class Channel {
}
return (Map<String, Long>)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);
}
}
+2 -6
ファイルの表示
@@ -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);
}
+13 -13
ファイルの表示
@@ -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;
}
+171 -172
ファイルの表示
@@ -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;
}
}
+8 -8
ファイルの表示
@@ -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(
+8 -8
ファイルの表示
@@ -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) {
+4 -3
ファイルの表示
@@ -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));
}
}
+8 -8
ファイルの表示
@@ -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) {
+8 -8
ファイルの表示
@@ -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(
+12 -12
ファイルの表示
@@ -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<SubCommandAbst> commands;
private ArrayList<LunaChatSubCommand> commands;
/**
* コンストラクタ
* @param commands
*/
public HelpCommand(ArrayList<SubCommandAbst> commands) {
public HelpCommand(ArrayList<LunaChatSubCommand> 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<SubCommandAbst> com = new ArrayList<SubCommandAbst>();
for ( SubCommandAbst c : commands ) {
ArrayList<LunaChatSubCommand> com = new ArrayList<LunaChatSubCommand>();
for ( LunaChatSubCommand c : commands ) {
if ( c.getCommandType() == type
&& sender.hasPermission(c.getPermissionNode()) ) {
com.add(c);
+13 -22
ファイルの表示
@@ -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<String> getHideInfoList(ChannelMember player) {
ArrayList<String> items = new ArrayList<String>();
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;
}
+8 -8
ファイルの表示
@@ -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(
+8 -8
ファイルの表示
@@ -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) {
+8 -8
ファイルの表示
@@ -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(
+8 -8
ファイルの表示
@@ -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(
+8 -8
ファイルの表示
@@ -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(
+7 -8
ファイルの表示
@@ -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(
+14 -21
ファイルの表示
@@ -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;
}
+12 -33
ファイルの表示
@@ -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<SubCommandAbst> commands;
private ArrayList<SubCommandAbst> commonCommands;
private ArrayList<LunaChatSubCommand> commands;
private ArrayList<LunaChatSubCommand> commonCommands;
private JoinCommand joinCommand;
private HelpCommand helpCommand;
@@ -31,7 +29,7 @@ public abstract class LunaChatCommand {
*/
public LunaChatCommand() {
commands = new ArrayList<SubCommandAbst>();
commands = new ArrayList<LunaChatSubCommand>();
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<SubCommandAbst>();
commonCommands = new ArrayList<LunaChatSubCommand>();
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<String> coms = new ArrayList<String>();
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<String>();
}
/**
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、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 コマンド実行者
+155
ファイルの表示
@@ -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);
}
+2 -2
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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) {
-161
ファイルの表示
@@ -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);
}
+6 -6
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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(
+6 -6
ファイルの表示
@@ -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(
+1
ファイルの表示
@@ -83,6 +83,7 @@ public class ChannelMemberBukkitConsole extends ChannelMemberBukkit {
*/
@Override
public void sendMessage(String message) {
if ( message == null || message.isEmpty() ) return;
sender.sendMessage(message);
}
+1
ファイルの表示
@@ -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);
}
}
+1
ファイルの表示
@@ -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);
+1 -1
ファイルの表示
@@ -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));
+4 -2
ファイルの表示
@@ -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(" }");
}