LunaChat v3.0.3 : Clickable chat message (WIP)
このコミットが含まれているのは:
1 親
74a2e4de8c
コミット
0466653e89
24ファイル変更
+667
-355
検索条件に一致するファイルはありません
@@ -5,9 +5,7 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
@@ -16,11 +14,10 @@ import com.github.ucchyocean.lc3.LunaChatBungee;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.event.EventResult;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberProxiedPlayer;
|
||||
import com.github.ucchyocean.lc3.util.KeywordReplacer;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
import com.github.ucchyocean.lc3.util.ChatFormatter;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
/**
|
||||
@@ -29,19 +26,12 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
*/
|
||||
public class BungeeChannel extends Channel {
|
||||
|
||||
private SimpleDateFormat dateFormat;
|
||||
private SimpleDateFormat timeFormat;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name チャンネル名
|
||||
*/
|
||||
protected BungeeChannel(String name) {
|
||||
|
||||
super(name);
|
||||
|
||||
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||||
timeFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -113,14 +103,16 @@ public class BungeeChannel extends Channel {
|
||||
}
|
||||
|
||||
// LunaChatChannelMessageEvent イベントコール
|
||||
// TODO messageがクリックイベント用のプレースホルダ―入りになっているが、問題ないか
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatChannelMessageEvent(
|
||||
getName(), player, message, recipients, name, originalMessage);
|
||||
message = result.getMessage();
|
||||
recipients = result.getRecipients();
|
||||
|
||||
// 送信する
|
||||
BaseComponent[] comps = ChatFormatter.replaceTextComponent(message);
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
p.sendMessage(comps);
|
||||
}
|
||||
|
||||
// 設定に応じて、コンソールに出力する
|
||||
@@ -185,84 +177,6 @@ public class BungeeChannel extends Channel {
|
||||
return super.getMembers();
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットフォーマット内のキーワードを置き換えする
|
||||
* @param format チャットフォーマット
|
||||
* @param player プレイヤー
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
@Override
|
||||
protected String replaceKeywords(String format, ChannelMember player) {
|
||||
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
KeywordReplacer msg = new KeywordReplacer(format);
|
||||
|
||||
// テンプレートのキーワードを、まず最初に置き換える
|
||||
for ( int i=0; i<=9; i++ ) {
|
||||
String key = "%" + i;
|
||||
if ( msg.contains(key) ) {
|
||||
if ( api.getTemplate("" + i) != null ) {
|
||||
msg.replace(key, api.getTemplate("" + i));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
msg.replace("%ch", getName());
|
||||
//msg.replace("%msg", message);
|
||||
msg.replace("%color", getColorCode());
|
||||
if ( getPrivateMessageTo() != null ) {
|
||||
msg.replace("%to", getPrivateMessageTo().getDisplayName());
|
||||
if ( getPrivateMessageTo() instanceof ChannelMemberProxiedPlayer ) {
|
||||
ChannelMemberProxiedPlayer cm = (ChannelMemberProxiedPlayer)getPrivateMessageTo();
|
||||
msg.replace("%recieverserver", cm.getServer().getInfo().getName());
|
||||
} else {
|
||||
msg.replace("%recieverserver", "");
|
||||
}
|
||||
} else {
|
||||
msg.replace("%to", "");
|
||||
msg.replace("%recieverserver", "");
|
||||
}
|
||||
|
||||
if ( msg.contains("%date") ) {
|
||||
msg.replace("%date", dateFormat.format(new Date()));
|
||||
}
|
||||
if ( msg.contains("%time") ) {
|
||||
msg.replace("%time", timeFormat.format(new Date()));
|
||||
}
|
||||
|
||||
if ( player != null ) {
|
||||
msg.replace("%username", player.getDisplayName());
|
||||
msg.replace("%player", player.getName());
|
||||
|
||||
if ( msg.contains("%prefix") || msg.contains("%suffix") ) {
|
||||
msg.replace("%prefix", player.getPrefix());
|
||||
msg.replace("%suffix", player.getSuffix());
|
||||
}
|
||||
|
||||
msg.replace("%world", "");
|
||||
|
||||
if ( msg.contains("%server") ) {
|
||||
if ( player instanceof ChannelMemberProxiedPlayer ) {
|
||||
String serverName = ((ChannelMemberProxiedPlayer)player).getServer().getInfo().getName();
|
||||
msg.replace("%server", serverName);
|
||||
}
|
||||
msg.replace("%server", "");
|
||||
}
|
||||
|
||||
} else {
|
||||
msg.replace("%username", "");
|
||||
msg.replace("%player", "");
|
||||
msg.replace("%prefix", "");
|
||||
msg.replace("%suffix", "");
|
||||
msg.replace("%world", "");
|
||||
msg.replace("%server", "");
|
||||
}
|
||||
|
||||
return Utility.replaceColorCode(msg.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* ログを記録する
|
||||
* @param name 発言者
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする