LunaChat v2.0.0 : Fixed issue #20.
このコミットが含まれているのは:
1 親
7606240170
コミット
b4ef7c0733
4ファイル変更
+99
-2
検索条件に一致するファイルはありません
@@ -59,6 +59,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
private static final String KEY_MODERATOR = "moderator";
|
||||
private static final String KEY_PASSWORD = "password";
|
||||
private static final String KEY_VISIBLE = "visible";
|
||||
private static final String KEY_COLOR = "color";
|
||||
|
||||
/** 参加者 */
|
||||
private List<String> members;
|
||||
@@ -81,13 +82,17 @@ public class Channel implements ConfigurationSerializable {
|
||||
/** チャンネルリストに表示されるかどうか */
|
||||
private boolean visible;
|
||||
|
||||
/** チャンネルのカラー */
|
||||
private String colorCode;
|
||||
|
||||
/** メッセージフォーマット<br>
|
||||
* 指定可能なキーワードは下記のとおり<br>
|
||||
* %ch - チャンネル名<br>
|
||||
* %username - ユーザー名<br>
|
||||
* %msg - メッセージ<br>
|
||||
* %prefix - PermissionsExに設定するprefix<br>
|
||||
* %suffix - PermissionsExに設定するsuffix
|
||||
* %suffix - PermissionsExに設定するsuffix<br>
|
||||
* %chcolor - チャンネルのカラーコード
|
||||
* */
|
||||
private String format;
|
||||
|
||||
@@ -104,6 +109,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
this.moderator = new ArrayList<String>();
|
||||
this.password = "";
|
||||
this.visible = true;
|
||||
this.colorCode = "";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -369,6 +375,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
|
||||
String msg = format.replace("%ch", name);
|
||||
msg = msg.replace("%msg", message);
|
||||
msg = msg.replace("%chcolor", colorCode);
|
||||
|
||||
if ( player != null ) {
|
||||
msg = msg.replace("%username", player.getDisplayName());
|
||||
@@ -442,6 +449,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
map.put(KEY_MODERATOR, moderator);
|
||||
map.put(KEY_PASSWORD, password);
|
||||
map.put(KEY_VISIBLE, visible);
|
||||
map.put(KEY_COLOR, colorCode);
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -470,6 +478,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
channel.moderator = castToStringList(data.get(KEY_MODERATOR));
|
||||
channel.password = castWithDefault(data.get(KEY_PASSWORD), "");
|
||||
channel.visible = castWithDefault(data.get(KEY_VISIBLE), true);
|
||||
channel.colorCode = castWithDefault(data.get(KEY_COLOR), "");
|
||||
return channel;
|
||||
}
|
||||
|
||||
@@ -601,6 +610,22 @@ public class Channel implements ConfigurationSerializable {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのカラーコードを返す
|
||||
* @return チャンネルのカラーコード
|
||||
*/
|
||||
public String getColorCode() {
|
||||
return colorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルのカラーコードを設定する
|
||||
* @param colorCode カラーコード
|
||||
*/
|
||||
public void setColorCode(String colorCode) {
|
||||
this.colorCode = colorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルの情報をファイルに保存する。
|
||||
* @return 保存をしたかどうか。
|
||||
|
||||
@@ -998,11 +998,29 @@ 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;
|
||||
}
|
||||
if ( options.containsKey("color") ) {
|
||||
// チャンネルカラー
|
||||
String code = options.get("color");
|
||||
if ( Utility.isValidColor(code) ) {
|
||||
code = Utility.changeToColorCode(code);
|
||||
}
|
||||
if ( Utility.isValidColorCode(code) ) {
|
||||
channel.setColorCode(code);
|
||||
sendResourceMessage(sender, PREINFO,
|
||||
"cmdmsgOption", "color", options.get("color"));
|
||||
setOption = true;
|
||||
} else {
|
||||
sendResourceMessage(sender, PREERR,
|
||||
"errmsgInvalidColorCode", options.get("color"));
|
||||
}
|
||||
}
|
||||
if ( !LunaChat.config.globalChannel.equals(channel.getName()) ) {
|
||||
if ( options.containsKey("password") ) {
|
||||
channel.setPassword(options.get("password"));
|
||||
|
||||
@@ -17,6 +17,8 @@ import java.io.OutputStreamWriter;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
/**
|
||||
* @author ucchy
|
||||
* ユーティリティクラス
|
||||
@@ -128,4 +130,55 @@ public class Utility {
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* カラー表記の文字列を、ChatColorクラスに変換する
|
||||
* @param color カラー表記の文字列
|
||||
* @return ChatColorクラス
|
||||
*/
|
||||
public static ChatColor changeToChatColor(String color) {
|
||||
|
||||
if ( isValidColor(color) ) {
|
||||
return ChatColor.valueOf(color.toUpperCase());
|
||||
}
|
||||
return ChatColor.WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* カラー表記の文字列を、カラーコードに変換する
|
||||
* @param color カラー表記の文字列
|
||||
* @return カラーコード
|
||||
*/
|
||||
public static String changeToColorCode(String color) {
|
||||
|
||||
return "&" + changeToChatColor(color).getChar();
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatColorで指定可能な色かどうかを判断する
|
||||
* @param color カラー表記の文字列
|
||||
* @return 指定可能かどうか
|
||||
*/
|
||||
public static boolean isValidColor(String color) {
|
||||
|
||||
for ( ChatColor c : ChatColor.values() ) {
|
||||
if ( c.name().equals(color.toUpperCase()) ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* カラーコードかどうかを判断する
|
||||
* @param color カラー表記の文字列
|
||||
* @return 指定可能かどうか
|
||||
*/
|
||||
public static boolean isValidColorCode(String code) {
|
||||
|
||||
if ( code == null ) {
|
||||
return false;
|
||||
}
|
||||
return code.matches("&[0-9a-f]");
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする