Skip to content

Commit

Permalink
LunaChat v3.0.10 : Fixed issue #200
Browse files Browse the repository at this point in the history
  • Loading branch information
ucchyocean committed Aug 4, 2020
1 parent 55810cf commit 0c8212e
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ucchyocean</groupId>
<artifactId>LunaChat</artifactId>
<version>3.0.9</version>
<version>3.0.10</version>
<description>A powerfull chat channel plugin with IME (Kana-Kanji conversion) support</description>
<url>https://github.com/ucchyocean/LunaChat</url>

Expand Down
13 changes: 13 additions & 0 deletions src/main/java/com/github/ucchyocean/lc3/LunaChatConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ public class LunaChatConfig {
/** 通常チャットを、クリック可能にするかどうか */
private boolean enableNormalChatClickable;

/** 通常チャットを、コンソールに表示するかどうか */
private boolean displayNormalChatOnConsole;

/** Japanize変換のタイプ<br/>
* none = 日本語変換をしない<br/>
* kana = カナ変換のみする<br/>
Expand Down Expand Up @@ -249,6 +252,8 @@ public void reloadConfig(File dataFolder, File jarFile) {
config.getBoolean("enableNormalChatColorCode", true);
enableNormalChatClickable =
config.getBoolean("enableNormalChatClickable", false);
displayNormalChatOnConsole =
config.getBoolean("displayNormalChatOnConsole", true);

japanizeType = JapanizeType.fromID(config.getString("japanizeType"), null);
japanizeDisplayLine = config.getInt("japanizeDisplayLine", 2);
Expand Down Expand Up @@ -582,6 +587,14 @@ public boolean isEnableNormalChatClickable() {
return enableNormalChatClickable;
}

/**
* 通常チャットを、コンソールに表示するかどうか
* @return displayNormalChatOnConsole
*/
public boolean isDisplayNormalChatOnConsole() {
return displayNormalChatOnConsole;
}

/**
* Bungeeパススルーモードかどうかを返す
* @return bungeePassThroughMode
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.logging.Level;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand Down Expand Up @@ -179,14 +180,26 @@ private void processChatEvent(AsyncPlayerChatEvent event) {

// Bungeeパススルーモードなら、メッセージを返送して終了する
if ( config.isBungeePassThroughMode() ) {
ChannelMember player = ChannelMember.getChannelMember(event.getPlayer());
if ( player instanceof ChannelMemberPlayer ) {
ChannelMemberOther other = ((ChannelMemberPlayer)player).toChannelMemberOther();

// メッセージの返送
ChannelMember member = ChannelMember.getChannelMember(event.getPlayer());
if ( member instanceof ChannelMemberPlayer ) {
ChannelMemberOther other = ((ChannelMemberPlayer)member).toChannelMemberOther();
BukkitChatMessage msg = new BukkitChatMessage(other, event.getMessage());
LunaChatBukkit.getInstance().sendPluginMessage(msg.toByteArray());
event.setCancelled(true);
return;

// 設定が有効ならコンソールに表示する
if ( config.isDisplayNormalChatOnConsole() ) {
String logmsg = event.getFormat()
.replace("%1$s", member.getDisplayName())
.replace("%2$s", event.getMessage());
LunaChat.getPlugin().log(Level.INFO, logmsg);
}
}

// イベントをキャンセルして終了する
event.setCancelled(true);
return;
}

// 頭にglobalMarkerが付いている場合は、グローバル発言にする
Expand Down Expand Up @@ -395,6 +408,11 @@ private void chatGlobal(AsyncPlayerChatEvent event) {
// イベントのキャンセル
event.setCancelled(true);

// 設定が有効ならコンソールに表示する
if ( config.isDisplayNormalChatOnConsole() ) {
LunaChat.getPlugin().log(Level.INFO, makeLegacyText(comps));
}

} else {
// 通常チャットイベントで発言

Expand Down Expand Up @@ -586,4 +604,17 @@ private boolean matchesEventPriority(EventPriority priority) {
String c = LunaChat.getConfig().getPlayerChatEventListenerPriority().name();
return c.equals(priority.name());
}

/**
* BaseComponent配列を、カラーコードを含むStringに変換する
* @param comps BaseComponentの配列
* @return カラーコードを含むString
*/
private static String makeLegacyText(BaseComponent[] comps) {
StringBuilder builder = new StringBuilder();
for ( BaseComponent comp : comps ) {
builder.append(comp.toLegacyText());
}
return builder.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ private void chatGlobal(ChannelMember member, String message) {
result = format.toLegacyText();

// コンソールに表示設定なら、コンソールに表示する
if ( config.isDisplayChatOnConsole() ) {
if ( config.isDisplayNormalChatOnConsole() ) {
parent.getLogger().info(result);
}

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ enableNormalChatColorCode: true
# Note that channel chats are always clickable, regardless of this setting.
enableNormalChatClickable: false

# Whether to log normal chat (non-channel chat) to console.
# Even if this item is set to false, it may be recorded in the console.
displayNormalChatOnConsole: true


# -------------------- Japanize conversion settings --------------------

Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/config_ja.yml
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,10 @@ enableNormalChatColorCode: true
# なお、この設定に関係なく、チャンネルチャットは常にクリック可能です。
enableNormalChatClickable: false

# 通常チャット(非チャンネルチャット)をコンソールにログ出力するかどうか。
# 本項目をfalseにしても、コンソールに記録される場合があります。
displayNormalChatOnConsole: true


# -------------------- Japanize変換設定 --------------------

Expand Down

0 comments on commit 0c8212e

Please sign in to comment.