Skip to content

Commit

Permalink
LunaChat v2.7.4 : Fixed issue #133
Browse files Browse the repository at this point in the history
  • Loading branch information
ucchyocean committed Jul 19, 2015
1 parent c9e4d01 commit f7f741d
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 19 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>2.7.3</version>
<version>2.7.4</version>
<description>チャンネルチャットプラグイン</description>

<licenses>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ public void onDynmapWebChat(DynmapWebChatEvent event) {
channel.chatFromOtherSource(
event.getName(), event.getSource(), event.getMessage());
event.setProcessed();
dynmap.sendBroadcastToWeb(null, event.getMessage());
}
}
}
3 changes: 2 additions & 1 deletion src/main/java/com/github/ucchyocean/lc/channel/Channel.java
Original file line number Diff line number Diff line change
Expand Up @@ -364,9 +364,10 @@ public void removeModerator(ChannelPlayer player) {
* @param message メッセージ
* @param format フォーマット
* @param sendDynmap dynmapへ送信するかどうか
* @param displayName 発言者の表示名(APIに使用されます)
*/
public abstract void sendMessage(
ChannelPlayer player, String message, String format, boolean sendDynmap);
ChannelPlayer player, String message, String format, boolean sendDynmap, String displayName);

/**
* チャンネル情報を返す
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/com/github/ucchyocean/lc/channel/ChannelImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ public void chat(ChannelPlayer player, String message) {
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();

// Muteされているかどうかを確認する
if ( player != null && getMuted().contains(player) ) {
if ( getMuted().contains(player) ) {
player.sendMessage( PREERR + ERRMSG_MUTED );
return;
}
Expand Down Expand Up @@ -184,7 +184,7 @@ public void chat(ChannelPlayer player, String message) {

if ( isIncludeSyncChat ) {
// メッセージの送信
sendMessage(player, maskedMessage, msgFormat, true);
sendMessage(player, maskedMessage, msgFormat, true, player.getDisplayName());
}

// 非同期実行タスクがある場合、追加で実行する
Expand All @@ -204,7 +204,7 @@ public void chat(ChannelPlayer player, String message) {
String m = replaceKeywordsForSystemMessages(
MSG_BAN_NGWORD, player.getName());
player.sendMessage(m);
sendMessage(null, m, null, true);
sendMessage(null, m, null, true, "system");
}
}

Expand All @@ -217,7 +217,7 @@ public void chat(ChannelPlayer player, String message) {
String m = replaceKeywordsForSystemMessages(
MSG_KICK_NGWORD, player.getName());
player.sendMessage(m);
sendMessage(null, m, null, true);
sendMessage(null, m, null, true, "system");
}
}

Expand All @@ -230,7 +230,7 @@ public void chat(ChannelPlayer player, String message) {
String m = replaceKeywordsForSystemMessages(
MSG_MUTE_NGWORD, player.getName());
player.sendMessage(m);
sendMessage(null, m, null, true);
sendMessage(null, m, null, true, "system");
}
}
}
Expand Down Expand Up @@ -271,7 +271,8 @@ public void chatFromOtherSource(String player, String source, String message) {
}

// メッセージの送信
sendMessage(null, maskedMessage, msgFormat, false);
boolean sendDynmap = source == null || !source.equals("web");
sendMessage(null, maskedMessage, msgFormat, sendDynmap, name);
}

/**
Expand All @@ -292,7 +293,7 @@ protected void sendSystemMessage(String key, ChannelPlayer player) {
return;
}
msg = replaceKeywordsForSystemMessages(msg, player.getName());
sendMessage(null, msg, null, false);
sendMessage(null, msg, null, false, "system");
}

/**
Expand All @@ -301,10 +302,11 @@ protected void sendSystemMessage(String key, ChannelPlayer player) {
* @param message メッセージ
* @param format フォーマット
* @param sendDynmap dynmapへ送信するかどうか
* @param name 発言者名
*/
@Override
public void sendMessage(ChannelPlayer player, String message,
String format, boolean sendDynmap) {
String format, boolean sendDynmap, String name) {

LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();

Expand Down Expand Up @@ -404,7 +406,7 @@ public void sendMessage(ChannelPlayer player, String message,
// イベントコール
LunaChatChannelMessageEvent event =
new LunaChatChannelMessageEvent(
getName(), player, message, recipients);
getName(), player, message, recipients, name, originalMessage);
Bukkit.getPluginManager().callEvent(event);
message = event.getMessage();
recipients = event.getRecipients();
Expand Down Expand Up @@ -448,8 +450,7 @@ public void sendMessage(ChannelPlayer player, String message,
}

// ロギング
String p = (player != null) ? player.getName() : "";
log(originalMessage, p);
log(originalMessage, name);
}

/**
Expand Down Expand Up @@ -615,7 +616,7 @@ public void checkExpires() {
// メッセージ通知を流す
if ( !MSG_BAN_EXPIRED.equals("") ) {
String msg = replaceKeywords(MSG_BAN_EXPIRED, cp);
sendMessage(null, msg, null, false);
sendMessage(null, msg, null, false, "system");
}

if ( cp.isOnline() && !MSG_BAN_EXPIRED_PLAYER.equals("") ) {
Expand All @@ -639,7 +640,7 @@ public void checkExpires() {
// メッセージ通知を流す
if ( !MSG_MUTE_EXPIRED.equals("") ) {
String msg = replaceKeywords(MSG_MUTE_EXPIRED, cp);
sendMessage(null, msg, null, false);
sendMessage(null, msg, null, false, "system");
}

if ( cp.isOnline() && !MSG_MUTE_EXPIRED_PLAYER.equals("") ) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public DelayedJapanizeChannelChatTask(String org, JapanizeType type, Channel cha
public void run() {
if ( runSync() ) {
// チャンネルへ送信
channel.sendMessage(player, getResult(), lineFormat, true);
String name = (player != null) ? player.getDisplayName() : "";
channel.sendMessage(player, getResult(), lineFormat, true, name);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ protected void sendResourceMessageWithKeyword(
msg = msg.replace("%player", "");
}
msg = Utility.replaceColorCode(msg);
channel.sendMessage(null, msg, null, true);
channel.sendMessage(null, msg, null, true, "system");
}

/**
Expand Down Expand Up @@ -104,7 +104,7 @@ protected void sendResourceMessageWithKeyword(
msg = msg.replace("%player", "");
}
msg = Utility.replaceColorCode(msg);
channel.sendMessage(null, msg, null, true);
channel.sendMessage(null, msg, null, true, "system");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ public class LunaChatChannelMessageEvent extends LunaChatBaseEvent {
private ChannelPlayer player;
private String message;
private ArrayList<ChannelPlayer> recipients;
private String displayName;
private String originalMessage;

public LunaChatChannelMessageEvent(String channelName,
ChannelPlayer player, String message, ArrayList<ChannelPlayer> recipients) {
ChannelPlayer player, String message, ArrayList<ChannelPlayer> recipients,
String displayName, String originalMessage) {
super(channelName);
this.player = player;
this.message = message;
this.recipients = recipients;
this.displayName = displayName;
this.originalMessage = originalMessage;
}

/**
Expand All @@ -52,6 +57,22 @@ public ArrayList<ChannelPlayer> getRecipients() {
return recipients;
}

/**
* 発言者の表示名を取得する
* @return 発言者の表示名
*/
public String getDisplayName() {
return displayName;
}

/**
* オリジナルメッセージ(チャットフォーマットを適用していない状態のメッセージ)を取得する
* @return オリジナルメッセージ
*/
public String getOriginalMessage() {
return originalMessage;
}

/**
* メッセージを上書き設定する
* @param message メッセージ
Expand Down

0 comments on commit f7f741d

Please sign in to comment.