diff --git a/src/main/java/com/github/ucchyocean/lc/Channel.java b/src/main/java/com/github/ucchyocean/lc/Channel.java index 42ae520..a46b529 100644 --- a/src/main/java/com/github/ucchyocean/lc/Channel.java +++ b/src/main/java/com/github/ucchyocean/lc/Channel.java @@ -8,6 +8,7 @@ package com.github.ucchyocean.lc; import java.util.ArrayList; import java.util.List; +import org.bukkit.ChatColor; import org.bukkit.entity.Player; /** @@ -16,6 +17,11 @@ import org.bukkit.entity.Player; */ public class Channel { + private static final String INFO_FIRSTLINE = Resources.get("channelInfoFirstLine"); + private static final String INFO_PREFIX = Resources.get("channelInfoPrefix"); + private static final String LIST_ENDLINE = Resources.get("listEndLine"); + private static final String LIST_FORMAT = Resources.get("listFormat"); + private static final String DEFAULT_FORMAT = Resources.get("defaultFormat"); private static final String MSG_JOIN = Resources.get("joinMessage"); private static final String MSG_QUIT = Resources.get("quitMessage"); @@ -202,4 +208,65 @@ public class Channel { LunaChat.log(message); } } + + /** + * チャンネル情報を返す + * @return チャンネル情報 + */ + protected ArrayList getInfo() { + + ArrayList info = new ArrayList(); + info.add(Utility.replaceColorCode(INFO_FIRSTLINE)); + + // メンバーの人数を数える + int onlineNum = 0; + for ( String pname : members ) { + if ( isOnline(pname) ) { + onlineNum++; + } + } + int memberNum = members.size(); + + info.add( String.format( + Utility.replaceColorCode(LIST_FORMAT), + name, onlineNum, memberNum, description) ); + + // メンバーを、5人ごとに表示する + StringBuffer buf = new StringBuffer(); + for ( int i=0; i= 2 ) { + cname = args[1]; + } else { + sendResourceMessage(sender, PREERR, "errmsgCommand"); + return true; + } + + // チャンネルが存在するかどうか確認する + Channel channel = LunaChat.manager.getChannel(cname); + if ( channel == null ) { + sendResourceMessage(sender, PREERR, "errmsgNotExist"); + return true; + } + + // BANされていないかどうか確認する + if ( channel.banned.contains(player.getName()) ) { + sendResourceMessage(sender, PREERR, "errmsgBanned"); + return true; + } + + // 情報を取得して表示する + ArrayList list = channel.getInfo(); + for (String msg : list) { + sender.sendMessage(msg); + } + return true; + } + /** * コマンドの使い方を senderに送る * diff --git a/src/main/resources/messages.yml b/src/main/resources/messages.yml index d827a25..c510397 100644 --- a/src/main/resources/messages.yml +++ b/src/main/resources/messages.yml @@ -9,9 +9,10 @@ listFirstLine: '&8---------- &bChannel List &8----------' listEndLine: '&8----------------------------------' listFormat: '&8| &f%s&8(&c%d&8/&c%d&8) &a%s' -membersFirstLine: '&8---------- &bMember List &8----------' +channelInfoFirstLine: '&8---------- &bChannel Info &8----------' +channelInfoPrefix: '&8| ' -infoMotdFirstLine: '&8----- &3あなたが参加中のチャット &8-----' +motdFirstLine: '&8----- &3あなたが参加中のチャット &8-----' infoPrefix: '&7[LC]' errorPrefix: '&4[LC]' @@ -63,6 +64,7 @@ usageDeny: '&7/%s deny - 招待を拒否します。' usageKick: '&7/%s kick (name) - 指定した人をチャンネルチャットからキックします。' usageBan: '&7/%s ban (name) - 指定した人をチャンネルチャットからBANします。' usagePardon: '&7/%s pardon (name) - 指定した人のBANを解除します。' +usageInfo: '&7/%s info [channel] - チャンネルの情報を表示します。' usageReload: '&7/%s reload - config.ymlの再読み込みをします。' usageCreate: '&7/%s create (channel) [description] - チャンネルを作成します。' diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 1271460..7258a41 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -17,6 +17,7 @@ commands: / kick (name) - 指定した人をチャンネルチャットからキックします。 / ban (name) - 指定した人をチャンネルチャットからBANします。 / pardon (name) - 指定した人のBANを解除します。 + / info [channel] - チャンネルの情報を表示します。 permission: lunachat.user permission-message: パーミッション "" が無いため、実行できません。 lunachatadmin: