LunaChat v2.1.0 : issue #31 (wip...)
このコミットが含まれているのは:
1 親
20d7f94754
コミット
8503f47424
3ファイル変更
+143
-18
検索条件に一致するファイルはありません
@@ -67,6 +67,9 @@ public class Channel implements ConfigurationSerializable {
|
||||
private static final String KEY_PASSWORD = "password";
|
||||
private static final String KEY_VISIBLE = "visible";
|
||||
private static final String KEY_COLOR = "color";
|
||||
private static final String KEY_BROADCAST = "broadcast";
|
||||
private static final String KEY_WORLD = "world";
|
||||
private static final String KEY_RANGE = "range";
|
||||
|
||||
private static final SimpleDateFormat dformat =
|
||||
new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
@@ -106,6 +109,15 @@ public class Channel implements ConfigurationSerializable {
|
||||
* */
|
||||
private String format;
|
||||
|
||||
/** ブロードキャストチャンネルかどうか */
|
||||
private boolean broadcastChannel;
|
||||
|
||||
/** ワールドチャットかどうか */
|
||||
private boolean isWorldRange;
|
||||
|
||||
/** チャットの可聴範囲 0は無制限 */
|
||||
private int chatRange;
|
||||
|
||||
/** ロガー */
|
||||
private Logger logger;
|
||||
|
||||
@@ -122,6 +134,9 @@ public class Channel implements ConfigurationSerializable {
|
||||
this.password = "";
|
||||
this.visible = true;
|
||||
this.colorCode = "";
|
||||
this.broadcastChannel = false;
|
||||
this.isWorldRange = false;
|
||||
this.chatRange = 0;
|
||||
|
||||
if ( isPersonalChat() ) {
|
||||
this.format = DEFAULT_FORMAT_FOR_PERSONAL;
|
||||
@@ -138,11 +153,18 @@ public class Channel implements ConfigurationSerializable {
|
||||
return name.contains(">");
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @return グローバルチャットチャンネルかどうか
|
||||
// */
|
||||
// private boolean isGlobalChat() {
|
||||
// return name.equals(LunaChat.config.globalChannel);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @return グローバルチャットチャンネルかどうか
|
||||
* @return ブロードキャストチャンネルかどうか
|
||||
*/
|
||||
private boolean isGlobalChat() {
|
||||
return name.equals(LunaChat.config.globalChannel);
|
||||
private boolean isBroadcastChannel() {
|
||||
return (name.equals(LunaChat.config.globalChannel) || broadcastChannel);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -332,12 +354,13 @@ public class Channel implements ConfigurationSerializable {
|
||||
*/
|
||||
public void sendInformation(String message) {
|
||||
|
||||
if ( isGlobalChat() ) {
|
||||
if ( isBroadcastChannel() ) {
|
||||
// ブロードキャストチャンネル
|
||||
|
||||
// グローバルチャンネルは、そのままブロードキャスト
|
||||
Bukkit.broadcastMessage(message);
|
||||
|
||||
} else {
|
||||
// 通常チャンネル
|
||||
|
||||
// オンラインのプレイヤーに送信する
|
||||
for ( String member : members ) {
|
||||
@@ -365,7 +388,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
Utility.replaceColorCode(LIST_FORMAT),
|
||||
name, getOnlineNum(), getTotalNum(), description) );
|
||||
|
||||
if ( !isGlobalChat() ) {
|
||||
if ( !isBroadcastChannel() ) {
|
||||
// メンバーを、5人ごとに表示する
|
||||
StringBuffer buf = new StringBuffer();
|
||||
for ( int i=0; i<members.size(); i++ ) {
|
||||
@@ -463,7 +486,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
public int getOnlineNum() {
|
||||
|
||||
// グローバルチャンネルならサーバー接続人数を返す
|
||||
if ( isGlobalChat() ) {
|
||||
if ( isBroadcastChannel() ) {
|
||||
return Bukkit.getOnlinePlayers().length;
|
||||
}
|
||||
|
||||
@@ -484,7 +507,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
public int getTotalNum() {
|
||||
|
||||
// グローバルチャンネルならサーバー接続人数を返す
|
||||
if ( isGlobalChat() ) {
|
||||
if ( isBroadcastChannel() ) {
|
||||
return Bukkit.getOnlinePlayers().length;
|
||||
}
|
||||
|
||||
@@ -509,6 +532,9 @@ public class Channel implements ConfigurationSerializable {
|
||||
map.put(KEY_PASSWORD, password);
|
||||
map.put(KEY_VISIBLE, visible);
|
||||
map.put(KEY_COLOR, colorCode);
|
||||
map.put(KEY_BROADCAST, broadcastChannel);
|
||||
map.put(KEY_WORLD, isWorldRange);
|
||||
map.put(KEY_RANGE, chatRange);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -533,6 +559,9 @@ public class Channel implements ConfigurationSerializable {
|
||||
channel.password = castWithDefault(data.get(KEY_PASSWORD), "");
|
||||
channel.visible = castWithDefault(data.get(KEY_VISIBLE), true);
|
||||
channel.colorCode = castWithDefault(data.get(KEY_COLOR), "");
|
||||
channel.broadcastChannel = castWithDefault(data.get(KEY_BROADCAST), false);
|
||||
channel.isWorldRange = castWithDefault(data.get(KEY_WORLD), false);
|
||||
channel.chatRange = castWithDefault(data.get(KEY_RANGE), 0);
|
||||
return channel;
|
||||
}
|
||||
|
||||
@@ -680,6 +709,30 @@ public class Channel implements ConfigurationSerializable {
|
||||
this.colorCode = colorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* ブロードキャストチャンネルを設定する
|
||||
* @param broadcast ブロードキャストチャンネルにするかどうか
|
||||
*/
|
||||
public void setBroadcast(boolean broadcast) {
|
||||
this.broadcastChannel = broadcast;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットを同ワールド内に制限するかどうかを設定する
|
||||
* @param isWorldRange 同ワールド制限するかどうか
|
||||
*/
|
||||
public void setWorldRange(boolean isWorldRange) {
|
||||
this.isWorldRange = isWorldRange;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットの可聴範囲を設定する
|
||||
* @param range 可聴範囲
|
||||
*/
|
||||
public void setRange(int range) {
|
||||
this.chatRange = range;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの情報をファイルに保存する。
|
||||
* @return 保存をしたかどうか。
|
||||
|
||||
@@ -24,6 +24,9 @@ import com.github.ucchyocean.lc.event.LunaChatChannelOptionChangedEvent;
|
||||
*/
|
||||
public class LunaChatCommand implements CommandExecutor {
|
||||
|
||||
private static final int MAX_LENGTH_DESCRIPTION = 30;
|
||||
private static final int MAX_LENGTH_PASSWORD = 15;
|
||||
|
||||
private static final String PREINFO = Resources.get("infoPrefix");
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
@@ -1000,14 +1003,22 @@ public class LunaChatCommand implements CommandExecutor {
|
||||
|
||||
// 設定する
|
||||
boolean setOption = false;
|
||||
|
||||
if ( options.containsKey("description") ) {
|
||||
// チャンネル説明文
|
||||
// TODO: チャンネル説明文は30文字制限をした方がいい。
|
||||
channel.setDescription(options.get("description"));
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "description", options.get("description"));
|
||||
setOption = true;
|
||||
String desc = options.get("description");
|
||||
// チャンネル説明文は最大文字長を超えていないか確認
|
||||
if ( desc.length() > MAX_LENGTH_DESCRIPTION ) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgToolongDescription", MAX_LENGTH_DESCRIPTION);
|
||||
} else {
|
||||
channel.setDescription(desc);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "description", desc);
|
||||
setOption = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.containsKey("color") ) {
|
||||
// チャンネルカラー
|
||||
String code = options.get("color");
|
||||
@@ -1024,15 +1035,72 @@ public class LunaChatCommand implements CommandExecutor {
|
||||
"errmsgInvalidColorCode", options.get("color"));
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.containsKey("broadcast") ) {
|
||||
// ブロードキャストチャンネル
|
||||
String value = options.get("broadcast");
|
||||
|
||||
if ( value.equals("") || value.equalsIgnoreCase("false") ) {
|
||||
channel.setBroadcast(false);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "broadcast", "false");
|
||||
setOption = true;
|
||||
} else if ( value.equalsIgnoreCase("true") ) {
|
||||
channel.setBroadcast(true);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "broadcast", "true");
|
||||
setOption = true;
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgInvalidBooleanOption", "broadcast");
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.containsKey("range") ) {
|
||||
// レンジ
|
||||
String value = options.get("range");
|
||||
|
||||
if ( value.equals("") ) {
|
||||
channel.setWorldRange(false);
|
||||
channel.setRange(0);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "range", "無効");
|
||||
setOption = true;
|
||||
} else if ( value.equalsIgnoreCase("world") ) {
|
||||
channel.setWorldRange(true);
|
||||
channel.setRange(0);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "range", "world");
|
||||
setOption = true;
|
||||
} else if ( value.matches("[0-9]+") ) {
|
||||
channel.setWorldRange(true);
|
||||
channel.setRange(Integer.parseInt(value));
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "range", value);
|
||||
setOption = true;
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgInvalidRangeOption");
|
||||
}
|
||||
}
|
||||
|
||||
if ( !LunaChat.config.globalChannel.equals(channel.getName()) ) {
|
||||
|
||||
if ( options.containsKey("password") ) {
|
||||
// パスワード
|
||||
// TODO: パスワードは10文字制限をした方がいい。
|
||||
channel.setPassword(options.get("password"));
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "password", options.get("password"));
|
||||
setOption = true;
|
||||
String password = options.get("password");
|
||||
// パスワードは10文字制限をした方がいい。
|
||||
if ( password.length() > MAX_LENGTH_PASSWORD ) {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgToolongPassword", MAX_LENGTH_PASSWORD);
|
||||
} else {
|
||||
channel.setPassword(password);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "password", password);
|
||||
setOption = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ( options.containsKey("visible") ) {
|
||||
String temp = options.get("visible");
|
||||
if ( temp.equalsIgnoreCase("false") ) {
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする