LunaChat v3.0.6 : Added enableNormalChatClickable config.
このコミットが含まれているのは:
1 親
bdd148f313
コミット
9099ac968e
5ファイル変更
+84
-27
検索条件に一致するファイルはありません
@@ -116,6 +116,9 @@ public class LunaChatConfig {
|
||||
/** 通常チャットで、カラーコードを使用可能にするかどうか */
|
||||
private boolean enableNormalChatColorCode;
|
||||
|
||||
/** 通常チャットを、クリック可能にするかどうか */
|
||||
private boolean enableNormalChatClickable;
|
||||
|
||||
/** Japanize変換のタイプ<br/>
|
||||
* none = 日本語変換をしない<br/>
|
||||
* kana = カナ変換のみする<br/>
|
||||
@@ -241,6 +244,8 @@ public class LunaChatConfig {
|
||||
config.getString("normalChatMessageFormat", "&f%prefix%username%suffix&a:&f %msg");
|
||||
enableNormalChatColorCode =
|
||||
config.getBoolean("enableNormalChatColorCode", true);
|
||||
enableNormalChatClickable =
|
||||
config.getBoolean("enableNormalChatClickable", false);
|
||||
|
||||
japanizeType = JapanizeType.fromID(config.getString("japanizeType"), null);
|
||||
japanizeDisplayLine = config.getInt("japanizeDisplayLine", 2);
|
||||
@@ -564,6 +569,14 @@ public class LunaChatConfig {
|
||||
return enableNormalChatColorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャットを、クリック可能にするかどうか
|
||||
* @return enableNormalChatClickable
|
||||
*/
|
||||
public boolean isEnableNormalChatClickable() {
|
||||
return enableNormalChatClickable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された文字列から、対応するEventPriorityを返す。
|
||||
* @param value 文字列
|
||||
|
||||
@@ -301,19 +301,6 @@ public class BukkitEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// チャットフォーマット装飾の適用
|
||||
ClickableFormat format;
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
// event.setFormat(format);
|
||||
} else {
|
||||
String f = event.getFormat()
|
||||
.replace("%1$s", "%displayName")
|
||||
.replace("%2$s", "%msg");
|
||||
format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
}
|
||||
|
||||
// カラーコード置き換え
|
||||
// 置き換え設定になっていて、発言者がパーミッションを持っているなら、置き換えする
|
||||
if ( config.isEnableNormalChatColorCode() &&
|
||||
@@ -376,21 +363,48 @@ public class BukkitEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// 発言内容の設定
|
||||
// event.setMessage(message);
|
||||
if ( config.isEnableNormalChatClickable() ) {
|
||||
// クリック可能チャットで発言
|
||||
|
||||
// 発言内容の送信
|
||||
format.replace("%msg", message);
|
||||
BaseComponent[] comps = format.makeTextComponent();
|
||||
for ( Player recipient : event.getRecipients() ) {
|
||||
ChannelMember cm = ChannelMember.getChannelMember(recipient);
|
||||
if ( cm != null ) {
|
||||
cm.sendMessage(comps);
|
||||
// チャットフォーマット装飾の適用
|
||||
ClickableFormat format;
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
} else {
|
||||
String f = event.getFormat()
|
||||
.replace("%1$s", "%displayName")
|
||||
.replace("%2$s", "%msg");
|
||||
format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
}
|
||||
}
|
||||
|
||||
// イベントのキャンセル
|
||||
event.setCancelled(true);
|
||||
// 発言内容の送信
|
||||
format.replace("%msg", message);
|
||||
BaseComponent[] comps = format.makeTextComponent();
|
||||
for ( Player recipient : event.getRecipients() ) {
|
||||
ChannelMember cm = ChannelMember.getChannelMember(recipient);
|
||||
if ( cm != null ) {
|
||||
cm.sendMessage(comps);
|
||||
}
|
||||
}
|
||||
|
||||
// イベントのキャンセル
|
||||
event.setCancelled(true);
|
||||
|
||||
} else {
|
||||
// 通常チャットイベントで発言
|
||||
|
||||
// チャットフォーマット装飾の適用
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
f = ClickableFormat.replaceForNormalChatFormat(
|
||||
f, ChannelMember.getChannelMember(event.getPlayer()));
|
||||
event.setFormat(Utility.replaceColorCode(f));
|
||||
}
|
||||
|
||||
// 発言内容の設定
|
||||
event.setMessage(message);
|
||||
}
|
||||
|
||||
// ロギング
|
||||
logNormalChat(message, player.getName());
|
||||
|
||||
@@ -149,6 +149,12 @@ public class ClickableFormat {
|
||||
return new ClickableFormat(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットのメッセージ用のフォーマットを置き換えする
|
||||
* @param format フォーマット
|
||||
* @param channelName チャンネル名
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
public static ClickableFormat makeChannelClickableMessage(String format, String channelName) {
|
||||
|
||||
KeywordReplacer msg = new KeywordReplacer(format);
|
||||
@@ -162,6 +168,18 @@ public class ClickableFormat {
|
||||
return new ClickableFormat(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットフォーマット内のキーワードをBukkitの通常チャットイベント用に置き換えする
|
||||
* @param format 置き換え元のチャットフォーマット
|
||||
* @param member 発言者
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
public static String replaceForNormalChatFormat(String format, ChannelMember member) {
|
||||
format = format.replace("%displayName", "%1$s");
|
||||
format = format.replace("%username", "%1$s");
|
||||
format = format.replace("%msg", "%2$s");
|
||||
return makeFormat(format, member, null, false).toLegacyText();
|
||||
}
|
||||
|
||||
public BaseComponent[] makeTextComponent() {
|
||||
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする