LunaChat v3.0.3 : Clickable chat message (WIP)

このコミットが含まれているのは:
ucchy committed 2020-06-29 01:47:26 +09:00
1 親 74a2e4de8c
コミット 0466653e89
24ファイル変更
+667 -355

検索条件に一致するファイルはありません

+1
ファイルの表示
@@ -6,3 +6,4 @@
.idea/
*.iml
/.sts4-cache
/LunaChat
+1 -1
ファイルの表示
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ucchyocean</groupId>
<artifactId>LunaChat</artifactId>
<version>3.0.2</version>
<version>3.0.3</version>
<description>A powerfull chat channel plugin with IME (Kana-Kanji conversion) support</description>
<url>https://github.com/ucchyocean/LunaChat</url>
+22
ファイルの表示
@@ -2124,5 +2124,27 @@ public class Messages {
kr.replace("%next%", next.toString());
return Utility.replaceColorCode(kr.toString());
}
/**
* 発言先を%channel%にする
*/
public static String hoverChannelName(Object channel) {
String msg = resources.getString("hoverChannelName");
if ( msg == null ) return "";
KeywordReplacer kr = new KeywordReplacer(msg);
kr.replace("%channel%", channel.toString());
return Utility.replaceColorCode(kr.toString());
}
/**
* %player%にプライベートメッセージを送る
*/
public static String hoverPlayerName(Object player) {
String msg = resources.getString("hoverPlayerName");
if ( msg == null ) return "";
KeywordReplacer kr = new KeywordReplacer(msg);
kr.replace("%player%", player.toString());
return Utility.replaceColorCode(kr.toString());
}
// === Auto-generated methods area end. ===
}
+27 -70
ファイルの表示
@@ -6,9 +6,7 @@
package com.github.ucchyocean.lc3.bukkit;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@@ -27,32 +25,22 @@ import com.github.ucchyocean.lc3.LunaChatAPI;
import com.github.ucchyocean.lc3.LunaChatBukkit;
import com.github.ucchyocean.lc3.LunaChatConfig;
import com.github.ucchyocean.lc3.Messages;
import com.github.ucchyocean.lc3.bridge.VaultChatBridge;
import com.github.ucchyocean.lc3.channel.Channel;
import com.github.ucchyocean.lc3.event.EventResult;
import com.github.ucchyocean.lc3.japanize.JapanizeType;
import com.github.ucchyocean.lc3.member.ChannelMember;
import com.github.ucchyocean.lc3.member.ChannelMemberBukkit;
import com.github.ucchyocean.lc3.util.KeywordReplacer;
import com.github.ucchyocean.lc3.util.ChatFormatter;
import com.github.ucchyocean.lc3.util.Utility;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* Bukkit関連のイベントを監視するリスナ
* @author ucchy
*/
public class BukkitEventListener implements Listener {
private SimpleDateFormat dateFormat;
private SimpleDateFormat timeFormat;
/**
* コンストラクタ
*/
public BukkitEventListener() {
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
timeFormat = new SimpleDateFormat("HH:mm:ss");
}
/**
* プレイヤーがチャット発言したときに呼び出されるメソッド
* @param event
@@ -310,10 +298,17 @@ public class BukkitEventListener implements Listener {
}
// チャットフォーマット装飾の適用
String format;
if ( config.isEnableNormalChatMessageFormat() ) {
String format = config.getNormalChatMessageFormat();
format = replaceNormalChatFormatKeywords(format, event.getPlayer());
event.setFormat(format);
format = config.getNormalChatMessageFormat();
// format = replaceNormalChatFormatKeywords(format, event.getPlayer());
format = ChatFormatter.replaceKeywordsForEvent(
format, ChannelMember.getChannelMember(event.getPlayer()));
// event.setFormat(format);
} else {
format = event.getFormat()
.replace("%1$s", event.getPlayer().getDisplayName())
.replace("%2$s", "%msg");
}
// カラーコード置き換え
@@ -379,7 +374,19 @@ public class BukkitEventListener implements Listener {
}
// 発言内容の設定
event.setMessage(message);
// event.setMessage(message);
// 発言内容の送信
BaseComponent[] comps = ChatFormatter.replaceTextComponent(format.replace("%msg", message));
for ( Player recipient : event.getRecipients() ) {
ChannelMember cm = ChannelMember.getChannelMember(recipient);
if ( cm != null ) {
cm.sendMessage(comps);
}
}
// イベントのキャンセル
event.setCancelled(true); // TODO いろいろテストが必要
// ロギング
logNormalChat(message, player.getName());
@@ -440,7 +447,7 @@ public class BukkitEventListener implements Listener {
channel.addMember(cp);
}
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
// デフォルト発言先が無いなら、デフォルトチャンネルに設定する
Channel dchannel = api.getDefaultChannel(player.getName());
if ( dchannel == null ) {
api.setDefaultChannel(player.getName(), cname);
@@ -448,56 +455,6 @@ public class BukkitEventListener implements Listener {
}
}
/**
* 通常チャットのフォーマット設定のキーワードを置き換えして返す
* @param org フォーマット設定
* @param player 発言プレイヤー
* @return キーワード置き換え済みの文字列
*/
private String replaceNormalChatFormatKeywords(String org, Player player) {
KeywordReplacer format = new KeywordReplacer(org);
format.replace("%username", "%1$s");
format.replace("%msg", "%2$s");
format.replace("%player", player.getName());
if ( format.contains("%date") ) {
format.replace("%date", dateFormat.format(new Date()));
}
if ( format.contains("%time") ) {
format.replace("%time", timeFormat.format(new Date()));
}
if ( format.contains("%prefix") || format.contains("%suffix") ) {
String prefix = "";
String suffix = "";
VaultChatBridge vaultchat = LunaChatBukkit.getInstance().getVaultChat();
if ( vaultchat != null ) {
prefix = vaultchat.getPlayerPrefix(player);
suffix = vaultchat.getPlayerSuffix(player);
}
format.replace("%prefix", prefix);
format.replace("%suffix", suffix);
}
if ( format.contains("%world") ) {
String worldname = null;
if ( LunaChatBukkit.getInstance().getMultiverseCore() != null ) {
worldname = LunaChatBukkit.getInstance().getMultiverseCore().getWorldAlias(player.getWorld());
}
if ( worldname == null || worldname.equals("") ) {
worldname = player.getWorld().getName();
}
format.replace("%world", worldname);
}
format.replace("%server", "");
return Utility.replaceColorCode(format.toString());
}
/**
* プレイヤーのサーバー参加時用の参加チャンネルリストを返す
* @param player プレイヤー
+8 -64
ファイルの表示
@@ -6,9 +6,7 @@
package com.github.ucchyocean.lc3.bungee;
import java.nio.charset.StandardCharsets;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.regex.Matcher;
@@ -19,14 +17,12 @@ import com.github.ucchyocean.lc3.LunaChatAPI;
import com.github.ucchyocean.lc3.LunaChatBungee;
import com.github.ucchyocean.lc3.LunaChatConfig;
import com.github.ucchyocean.lc3.Messages;
import com.github.ucchyocean.lc3.bridge.BungeePermsBridge;
import com.github.ucchyocean.lc3.bridge.LuckPermsBridge;
import com.github.ucchyocean.lc3.channel.Channel;
import com.github.ucchyocean.lc3.event.EventResult;
import com.github.ucchyocean.lc3.japanize.Japanizer;
import com.github.ucchyocean.lc3.member.ChannelMember;
import com.github.ucchyocean.lc3.util.ChatColor;
import com.github.ucchyocean.lc3.util.KeywordReplacer;
import com.github.ucchyocean.lc3.util.ChatFormatter;
import com.github.ucchyocean.lc3.util.Utility;
import net.md_5.bungee.api.CommandSender;
@@ -46,11 +42,6 @@ import net.md_5.bungee.event.EventPriority;
*/
public class BungeeEventListener implements Listener {
private static final String DATE_FORMAT_PATTERN = "yyyy/MM/dd";
private static final String TIME_FORMAT_PATTERN = "HH:mm:ss";
private SimpleDateFormat dateFormat;
private SimpleDateFormat timeFormat;
private LunaChatBungee parent;
private LunaChatConfig config;
private LunaChatAPI api;
@@ -63,8 +54,6 @@ public class BungeeEventListener implements Listener {
this.parent = parent;
config = parent.getConfig();
api = parent.getLunaChatAPI();
dateFormat = new SimpleDateFormat(DATE_FORMAT_PATTERN);
timeFormat = new SimpleDateFormat(TIME_FORMAT_PATTERN);
}
/**
@@ -323,7 +312,9 @@ public class BungeeEventListener implements Listener {
if ( config.isEnableNormalChatMessageFormat() ) {
// チャットフォーマット装飾を適用する場合
String format = config.getNormalChatMessageFormat();
result = replaceNormalChatFormatKeywords(format, sender, message);
// result = replaceNormalChatFormatKeywords(format, sender, message);
result = ChatFormatter.replaceKeywordsForEvent(format, ChannelMember.getChannelMember(sender));
result = result.replace("%msg", message);
// イベントをキャンセルする
event.setCancelled(true);
@@ -393,56 +384,6 @@ public class BungeeEventListener implements Listener {
LunaChat.getNormalChatLogger().log(Utility.stripColorCode(result), sender.getName());
}
/**
* 通常チャットのフォーマット設定のキーワードを置き換えして返す
* @param org フォーマット設定
* @param player 発言プレイヤー
* @param msg 発言内容
* @return キーワード置き換え済みの文字列
*/
private String replaceNormalChatFormatKeywords(String org, ProxiedPlayer player, String msg) {
KeywordReplacer format = new KeywordReplacer(org);
format.replace("%username", player.getDisplayName());
format.replace("%msg", msg);
format.replace("%player", player.getName());
if ( format.contains("%date") ) {
format.replace("%date", dateFormat.format(new Date()));
}
if ( format.contains("%time") ) {
format.replace("%time", timeFormat.format(new Date()));
}
if ( format.contains("%prefix") || format.contains("%suffix") ) {
String prefix = "";
String suffix = "";
LuckPermsBridge luckperms = LunaChatBungee.getInstance().getLuckPerms();
if ( luckperms != null ) {
prefix = luckperms.getPlayerPrefix(player.getUniqueId());
suffix = luckperms.getPlayerSuffix(player.getUniqueId());
}
BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms();
if ( bungeeperms != null ) {
prefix = bungeeperms.userPrefix(player.getUniqueId().toString(), null, null);
suffix = bungeeperms.userSuffix(player.getUniqueId().toString(), null, null);
}
format.replace("%prefix", prefix);
format.replace("%suffix", suffix);
}
if ( format.contains("%world") ) {
format.replace("%world", "");
}
if ( format.contains("%server") ) {
format.replace("%server", player.getServer().getInfo().getName());
}
return Utility.replaceColorCode(format.toString());
}
/**
* チャンネルに発言処理を行う
* @param player プレイヤー
@@ -604,7 +545,10 @@ public class BungeeEventListener implements Listener {
*/
private void sendMessage(CommandSender reciever, String message) {
if ( message == null ) return;
reciever.sendMessage(TextComponent.fromLegacyText(message));
ChannelMember cm = ChannelMember.getChannelMember(reciever);
if ( cm != null ) {
cm.sendMessage(ChatFormatter.replaceTextComponent(message));
}
}
/**
+6 -88
ファイルの表示
@@ -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 org.bukkit.Bukkit;
@@ -25,29 +23,23 @@ import com.github.ucchyocean.lc3.bridge.DynmapBridge;
import com.github.ucchyocean.lc3.event.EventResult;
import com.github.ucchyocean.lc3.member.ChannelMember;
import com.github.ucchyocean.lc3.member.ChannelMemberBukkit;
import com.github.ucchyocean.lc3.util.KeywordReplacer;
import com.github.ucchyocean.lc3.util.Utility;
import com.github.ucchyocean.lc3.util.ChatFormatter;
import com.github.ucchyocean.lc3.util.UtilityBukkit;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* チャンネルの実装クラス
* @author ucchy
*/
public class BukkitChannel extends Channel {
private SimpleDateFormat dateFormat;
private SimpleDateFormat timeFormat;
/**
* コンストラクタ
* @param name チャンネル名
*/
protected BukkitChannel(String name) {
super(name);
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
timeFormat = new SimpleDateFormat("HH:mm:ss");
}
/**
@@ -161,6 +153,7 @@ public class BukkitChannel extends Channel {
}
// LunaChatChannelMessageEvent イベントコール
// TODO messageがクリックイベント用のプレースホルダ―入りになっているが、問題ないか
EventResult result = LunaChat.getEventSender().sendLunaChatChannelMessageEvent(
getName(), player, message, recipients, name, originalMessage);
message = result.getMessage();
@@ -184,8 +177,9 @@ public class BukkitChannel extends Channel {
}
// 送信する
BaseComponent[] comps = ChatFormatter.replaceTextComponent(message);
for ( ChannelMember p : recipients ) {
p.sendMessage(message);
p.sendMessage(comps);
}
// 設定に応じて、コンソールに出力する
@@ -255,82 +249,6 @@ public class BukkitChannel 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());
} 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());
}
if ( msg.contains("%world") ) {
String worldname = null;
if ( LunaChatBukkit.getInstance().getMultiverseCore() != null ) {
worldname = LunaChatBukkit.getInstance().getMultiverseCore().getWorldAlias(player.getWorldName());
}
if ( worldname == null || worldname.equals("") ) {
worldname = player.getWorldName();
}
msg.replace("%world", worldname);
}
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 発言者
+5 -91
ファイルの表示
@@ -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 発言者
+4 -1
ファイルの表示
@@ -27,6 +27,7 @@ import com.github.ucchyocean.lc3.event.EventResult;
import com.github.ucchyocean.lc3.japanize.JapanizeType;
import com.github.ucchyocean.lc3.member.ChannelMember;
import com.github.ucchyocean.lc3.util.ChatColor;
import com.github.ucchyocean.lc3.util.ChatFormatter;
import com.github.ucchyocean.lc3.util.Utility;
import com.github.ucchyocean.lc3.util.YamlConfig;
@@ -563,7 +564,9 @@ public abstract class Channel {
* @param player プレイヤー
* @return 置き換え結果
*/
protected abstract String replaceKeywords(String format, ChannelMember player);
protected String replaceKeywords(String format, ChannelMember player) {
return ChatFormatter.replaceKeywordsForChannel(format, player, this);
}
/**
* チャンネル情報を返す
+14
ファイルの表示
@@ -8,6 +8,8 @@ package com.github.ucchyocean.lc3.member;
import com.github.ucchyocean.lc3.LunaChat;
import com.github.ucchyocean.lc3.LunaChatMode;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* チャンネルメンバーの抽象クラス
* @author ucchy
@@ -50,12 +52,24 @@ public abstract class ChannelMember implements Comparable<ChannelMember> {
*/
public abstract void sendMessage(String message);
/**
* メッセージを送る
* @param message 送るメッセージ
*/
public abstract void sendMessage(BaseComponent[] message);
/**
* 発言者が今いるワールドのワールド名を取得する
* @return ワールド名
*/
public abstract String getWorldName();
/**
* 発言者が今いるサーバーのサーバー名を取得する
* @return サーバー名
*/
public abstract String getServerName();
/**
* 指定されたパーミッションノードの権限を持っているかどうかを取得する
* @param node パーミッションノード
+14 -3
ファイルの表示
@@ -11,6 +11,8 @@ import org.bukkit.World;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* ChannelMemberのBukkit-BlockCommandSender実装
* @author ucchy
@@ -87,6 +89,15 @@ public class ChannelMemberBlock extends ChannelMemberBukkit {
// do nothing.
}
/**
* メッセージを送る、実際は何もせずにメッセージを捨てる
* @param message 送るメッセージ
* @see com.github.ucchyocean.lc3.member.ChannelMember#sendMessage(net.md_5.bungee.api.chat.BaseComponent[])
*/
public void sendMessage(BaseComponent[] message) {
// do nothing.
}
/**
* BukkitのPlayerを取得する
* @return 常にnullが返される
@@ -99,12 +110,12 @@ public class ChannelMemberBlock extends ChannelMemberBukkit {
/**
* 発言者が今いるワールドのワールド名を取得する
* @return 常に "-" が返される。
* @return 常に空文字列
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getWorldName()
*/
@Override
public String getWorldName() {
return "-";
return "";
}
/**
@@ -148,7 +159,7 @@ public class ChannelMemberBlock extends ChannelMemberBukkit {
* @see com.github.ucchyocean.lc3.member.ChannelMember#chat(java.lang.String)
*/
public void chat(String message) {
Bukkit.broadcastMessage("<" + getName() + ">" + message);
Bukkit.broadcastMessage("<" + getName() + "> " + message);
}
/**
+9 -1
ファイルの表示
@@ -32,10 +32,18 @@ public abstract class ChannelMemberBukkit extends ChannelMember {
/**
* 発言者が今いるワールドを取得する
* @return 発言者の位置
* @return 発言者が今いるワールド
*/
public abstract World getWorld();
/**
* 発言者が今いるサーバーのサーバー名を取得する
* @return サーバー名
*/
public String getServerName() {
return "";
}
/**
* CommandSenderから、ChannelMemberを作成して返す
* @param sender
+12
ファイルの表示
@@ -11,6 +11,8 @@ import org.bukkit.World;
import org.bukkit.command.ConsoleCommandSender;
import org.bukkit.entity.Player;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* ChannelMemberのBukkit-ConsoleCommandSender実装
* @author ucchy
@@ -88,6 +90,16 @@ public class ChannelMemberBukkitConsole extends ChannelMemberBukkit {
sender.sendMessage(message);
}
/**
* メッセージを送る
* @param message 送るメッセージ
* @see com.github.ucchyocean.lc3.member.ChannelMember#sendMessage(net.md_5.bungee.api.chat.BaseComponent[])
*/
public void sendMessage(BaseComponent[] message) {
if ( message == null || message.length == 0 ) return;
sender.spigot().sendMessage(message);
}
/**
* BukkitのPlayerを取得する
* @return 常にnullが返される
+22
ファイルの表示
@@ -27,6 +27,28 @@ public abstract class ChannelMemberBungee extends ChannelMember {
*/
public abstract Server getServer();
/**
* 発言者が今いるサーバーのサーバー名を取得する
* @return サーバー名
*/
public String getServerName() {
Server server = getServer();
if ( server != null ) {
return server.getInfo().getName();
}
return "";
}
/**
* 発言者が今いるワールド名を返す
* @return 常に空文字列が返される
* @see com.github.ucchyocean.lc3.member.ChannelMember#getWorldName()
*/
@Override
public String getWorldName() {
return "";
}
/**
* CommandSenderから、ChannelMemberを作成して返す
* @param sender
+8 -6
ファイルの表示
@@ -7,6 +7,7 @@ package com.github.ucchyocean.lc3.member;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
@@ -104,17 +105,18 @@ public class ChannelMemberBungeeConsole extends ChannelMemberBungee {
*/
@Override
public void sendMessage(String message) {
if ( message == null || message.isEmpty() ) return;
sender.sendMessage(TextComponent.fromLegacyText(message));
}
/**
* 発言者が今いるワールド名を返す
* @return 常に"-"が返される
* @see com.github.ucchyocean.lc3.member.ChannelMember#getWorldName()
* メッセージを送る
* @param message 送るメッセージ
* @see com.github.ucchyocean.lc3.member.ChannelMember#sendMessage(net.md_5.bungee.api.chat.BaseComponent[])
*/
@Override
public String getWorldName() {
return "-";
public void sendMessage(BaseComponent[] message) {
if ( message == null || message.length == 0 ) return;
sender.sendMessage(message);
}
/**
+32 -11
ファイルの表示
@@ -18,6 +18,8 @@ import com.github.ucchyocean.lc3.LunaChat;
import com.github.ucchyocean.lc3.LunaChatBukkit;
import com.github.ucchyocean.lc3.bridge.VaultChatBridge;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* ChannelMemberのBukkitPlayer実装
* @author ucchy
@@ -169,6 +171,19 @@ public class ChannelMemberPlayer extends ChannelMemberBukkit {
}
}
/**
* メッセージを送る
* @param message 送るメッセージ
* @see com.github.ucchyocean.lc3.member.ChannelMember#sendMessage(net.md_5.bungee.api.chat.BaseComponent[])
*/
public void sendMessage(BaseComponent[] message) {
if ( message == null || message.length == 0 ) return;
Player player = getPlayer();
if ( player != null ) {
player.spigot().sendMessage(message);
}
}
/**
* BukkitのPlayerを取得する
* @return Player
@@ -179,6 +194,18 @@ public class ChannelMemberPlayer extends ChannelMemberBukkit {
return Bukkit.getPlayer(id);
}
/**
* 発言者が今いるワールドを取得する
* @return 発言者が今いるワールド
* @see com.github.ucchyocean.lc3.member.ChannelMemberBukkit#getWorld()
*/
@Override
public World getWorld() {
Player player = getPlayer();
if ( player != null ) return player.getWorld();
return null;
}
/**
* 発言者が今いるワールドのワールド名を取得する
* @return ワールド名
@@ -186,11 +213,12 @@ public class ChannelMemberPlayer extends ChannelMemberBukkit {
*/
@Override
public String getWorldName() {
Player player = getPlayer();
if ( player != null ) {
return player.getWorld().getName();
World world = getWorld();
if ( world == null ) return "";
if ( LunaChatBukkit.getInstance().getMultiverseCore() != null ) {
return LunaChatBukkit.getInstance().getMultiverseCore().getWorldAlias(world.getName());
}
return "-";
return world.getName();
}
/**
@@ -261,13 +289,6 @@ public class ChannelMemberPlayer extends ChannelMemberBukkit {
return "$" + id.toString();
}
@Override
public World getWorld() {
Player player = getPlayer();
if ( player != null ) return player.getWorld();
return null;
}
public static ChannelMemberPlayer getChannelMember(String nameOrUuid) {
if ( nameOrUuid.startsWith("$") ) {
return new ChannelMemberPlayer(nameOrUuid.substring(1));
+10 -6
ファイルの表示
@@ -15,6 +15,7 @@ import com.github.ucchyocean.lc3.bridge.BungeePermsBridge;
import com.github.ucchyocean.lc3.bridge.LuckPermsBridge;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
@@ -152,13 +153,16 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee {
}
/**
* 発言者が今いるワールドのワールド名を取得する
* @return ワールド名
* @see com.github.ucchyocean.lc.channel.ChannelPlayer#getWorldName()
* メッセージを送る
* @param message 送るメッセージ
* @see com.github.ucchyocean.lc3.member.ChannelMember#sendMessage(net.md_5.bungee.api.chat.BaseComponent[])
*/
@Override
public String getWorldName() {
return "-";
public void sendMessage(BaseComponent[] message) {
if ( message == null || message.length == 0 ) return;
ProxiedPlayer player = getPlayer();
if ( player != null ) {
player.sendMessage(message);
}
}
/**
+237
ファイルの表示
@@ -0,0 +1,237 @@
/*
* @author ucchy
* @license LGPLv3
* @copyright Copyright ucchy 2020
*/
package com.github.ucchyocean.lc3.util;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import com.github.ucchyocean.lc3.LunaChat;
import com.github.ucchyocean.lc3.LunaChatAPI;
import com.github.ucchyocean.lc3.Messages;
import com.github.ucchyocean.lc3.channel.Channel;
import com.github.ucchyocean.lc3.member.ChannelMember;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
/**
* チャットのフォーマットを作成するユーティリティクラス
* @author ucchy
*/
public class ChatFormatter {
private static ChatFormatter instance;
private SimpleDateFormat dateFormat;
private SimpleDateFormat timeFormat;
private static final String JOIN_COMMAND_TEMPLATE = "/lunachat join %s";
private static final String TELL_COMMAND_TEMPLATE = "/tell %s ";
private ChatFormatter() {
dateFormat = new SimpleDateFormat("yyyy/MM/dd");
timeFormat = new SimpleDateFormat("HH:mm:ss");
}
/**
* チャットフォーマット内のキーワードを置き換えする
* @param format チャットフォーマット
* @param member 発言者
* @param channel チャンネル
* @return 置き換え結果
*/
public static String replaceKeywordsForChannel(String format, @Nullable ChannelMember member, @NotNull Channel channel) {
if ( instance == null ) {
instance = new ChatFormatter();
}
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", String.format(
"<type=RUN_COMMAND text=\"%s\" hover=\"%s\" command=\"%s\">",
channel.getName(),
Messages.hoverChannelName(channel.getName()),
String.format(JOIN_COMMAND_TEMPLATE, channel.getName())));
//msg.replace("%msg", message);
msg.replace("%color", channel.getColorCode());
if ( channel.getPrivateMessageTo() != null ) {
// msg.replace("%to", channel.getPrivateMessageTo().getDisplayName());
msg.replace("%to", String.format(
"<type=SUGGEST_COMMAND text=\"%s\" hover=\"%s\" command=\"%s\">",
channel.getPrivateMessageTo().getDisplayName(),
Messages.hoverPlayerName(channel.getPrivateMessageTo().getName()),
String.format(TELL_COMMAND_TEMPLATE, channel.getPrivateMessageTo().getName())));
msg.replace("%recieverserver", channel.getPrivateMessageTo().getServerName());
} else {
msg.replace("%to", "");
msg.replace("%recieverserver", "");
}
if ( msg.contains("%date") ) {
msg.replace("%date", instance.dateFormat.format(new Date()));
}
if ( msg.contains("%time") ) {
msg.replace("%time", instance.timeFormat.format(new Date()));
}
if ( member != null ) {
String playerPMPlaceHolder = String.format(
"<type=SUGGEST_COMMAND text=\"%s\" hover=\"%s\" command=\"%s\">",
member.getDisplayName(),
Messages.hoverPlayerName(member.getName()),
String.format(TELL_COMMAND_TEMPLATE, member.getName()));
msg.replace("%displayname", playerPMPlaceHolder);
msg.replace("%username", playerPMPlaceHolder);
msg.replace("%player", String.format(
"<type=SUGGEST_COMMAND text=\"%s\" hover=\"%s\" command=\"%s\">",
member.getName(),
Messages.hoverPlayerName(member.getName()),
String.format(TELL_COMMAND_TEMPLATE, member.getName())));
if ( msg.contains("%prefix") || msg.contains("%suffix") ) {
msg.replace("%prefix", member.getPrefix());
msg.replace("%suffix", member.getSuffix());
}
msg.replace("%world", member.getWorldName());
msg.replace("%server", member.getServerName());
} else {
msg.replace("%displayname", "");
msg.replace("%username", "");
msg.replace("%player", "");
msg.replace("%prefix", "");
msg.replace("%suffix", "");
msg.replace("%world", "");
msg.replace("%server", "");
}
return Utility.replaceColorCode(msg.toString());
}
/**
* 通常チャットのフォーマット設定のキーワードを置き換えして返す
* @param format チャットフォーマット
* @param member 発言者
* @return キーワード置き換え済みの文字列
*/
public static String replaceKeywordsForEvent(String format, @NotNull ChannelMember member) {
if ( instance == null ) {
instance = new ChatFormatter();
}
KeywordReplacer msg = new KeywordReplacer(format);
String playerPMPlaceHolder = String.format(
"<type=SUGGEST_COMMAND text=\"%s\" hover=\"%s\" command=\"%s\">",
member.getDisplayName(),
Messages.hoverPlayerName(member.getName()),
String.format(TELL_COMMAND_TEMPLATE, member.getName()));
msg.replace("%displayname", playerPMPlaceHolder);
msg.replace("%username", playerPMPlaceHolder);
msg.replace("%player", String.format(
"<type=SUGGEST_COMMAND text=\"%s\" hover=\"%s\" command=\"%s\">",
member.getName(),
Messages.hoverPlayerName(member.getName()),
String.format(TELL_COMMAND_TEMPLATE, member.getName())));
// msg.replace("%msg", "%2$s");
if ( msg.contains("%date") ) {
msg.replace("%date", instance.dateFormat.format(new Date()));
}
if ( msg.contains("%time") ) {
msg.replace("%time", instance.timeFormat.format(new Date()));
}
if ( msg.contains("%prefix") || msg.contains("%suffix") ) {
msg.replace("%prefix", member.getPrefix());
msg.replace("%suffix", member.getSuffix());
}
msg.replace("%world", member.getWorldName());
msg.replace("%server", member.getServerName());
return Utility.replaceColorCode(msg.toString());
}
public static BaseComponent[] replaceTextComponent(String src) {
List<BaseComponent> components = new ArrayList<>();
Pattern pattern = Pattern.compile(
"<type=(SUGGEST_COMMAND|RUN_COMMAND) text=\"([^\"]*)\" hover=\"([^\"]*)\" command=\"([^\"]*)\">");
Matcher matcher = pattern.matcher(src);
int lastIndex = 0;
while ( matcher.find() ) {
// マッチする箇所までの文字列を取得する
if ( lastIndex < matcher.start() ) {
for ( BaseComponent c : TextComponent.fromLegacyText(src.substring(lastIndex, matcher.start())) ) {
components.add(c);
}
}
// マッチした箇所の文字列を解析して追加する
String type = matcher.group(1);
String text = matcher.group(2);
String hover = matcher.group(3);
String command = matcher.group(4);
TextComponent tc = new TextComponent(text);
if ( !hover.isEmpty() ) {
tc.setHoverEvent(new HoverEvent(
HoverEvent.Action.SHOW_TEXT, new ComponentBuilder(hover).create()));
}
if ( type.equals("RUN_COMMAND") ) {
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, command));
} else {
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
}
components.add(tc);
lastIndex = matcher.end() + 1;
}
if ( lastIndex < src.length() - 1 ) {
// 残りの部分の文字列を取得する
for ( BaseComponent c : TextComponent.fromLegacyText(src.substring(lastIndex)) ) {
components.add(c);
}
}
BaseComponent[] result = new BaseComponent[components.size()];
components.toArray(result);
return result;
}
}
+7 -7
ファイルの表示
@@ -61,7 +61,7 @@ formatConstraint: ['%username','%msg']
# The following keywords can be used for formatting.
# %ch: Channel name
# %color: Channel color
# %username: Speaker display name
# %displayname: Speaker display name
# %player: Speaker ID
# %world: world name
# %prefix: prefix (replaced if Vault and Prefix/Suffix plugin are installed)
@@ -69,7 +69,7 @@ formatConstraint: ['%username','%msg']
# %date: date
# %time: time
# %msg: Content of statement
defaultFormat: '&f[%color%ch&f]%prefix%username%suffix&a:&f %msg'
defaultFormat: '&f[%color%ch&f]%prefix%displayname%suffix&a:&f %msg'
# Setting to display the content of all channels on the OP screen.
opListenAllChannel: false
@@ -98,7 +98,7 @@ quickChannelChatSeparator: ':'
# When sending a private message with the # /tell, /msg or /r command, applied formatting.
# The following keywords can be used for formatting.
# %ch: Channel name (same as "%player>%to")
# %username: Speaker display name
# %displayname: Speaker display name
# %player: Speaker ID
# %server: Speaker's connection server name (valid when installed on BungeeCord side.)
# %to: ID of the person (recipient) who speaks
@@ -110,7 +110,7 @@ quickChannelChatSeparator: ':'
# %time: time
# %msg: Content of statement (When converted to Japanize, the result of Japanize is included.)
defaultFormatForPrivateMessage: '&7[%player -> %to]&f %msg'
#defaultFormatForPrivateMessage: '&7[%player@%server >%to@%recieverserver] %msg'
#defaultFormatForPrivateMessage: '&7[%player@%server > %to@%recieverserver] %msg'
# -------------------- dynmap linkage setting --------------------
@@ -154,7 +154,7 @@ enableNormalChatMessageFormat: true
# Chat decoration formatting.
# The following keywords can be used for formatting.
# %username: Speaker display name
# %displayname: Speaker display name
# %player: Speaker ID
# %world: Name of the world you said (Valid when it is installed on the spigot side. When MultiVerse is installed, the display name of the world is acquired and used.)
# %server: Speaker's connection server name (valid when installed on BungeeCord side.)
@@ -163,8 +163,8 @@ enableNormalChatMessageFormat: true
# %date: date
# %time: time
# %msg: Content of statement (When converted to Japanize, the result of Japanize is included.)
normalChatMessageFormat: '&f%prefix%username%suffix&a:&f %msg'
#normalChatMessageFormat: '&f%username@%server&a:&f %msg'
normalChatMessageFormat: '&f%prefix%displayname%suffix&a:&f %msg'
#normalChatMessageFormat: '&f%displayname@%server&a:&f %msg'
# Color code (&a, &b, etc.) in normal chat (non-channel chat)
# Whether to enable. If set to false, color codes will not be converted.
+6 -6
ファイルの表示
@@ -62,7 +62,7 @@ formatConstraint: ['%username', '%msg']
# フォーマット設定には、下記のキーワードが使用できます。
# %ch : チャンネル名
# %color : チャンネルカラー
# %username : 発言者表示名
# %displayname : 発言者表示名
# %player : 発言者ID
# %world : 発言したワールド名
# %prefix : プレフィックス(VaultとPermissionsExが導入されている場合に置き換えられます)
@@ -70,7 +70,7 @@ formatConstraint: ['%username', '%msg']
# %date : 日付
# %time : 時刻
# %msg : 発言内容(Japanize変換された場合は、Japanize結果を含みます。)
defaultFormat: '&f[%color%ch&f]%prefix%username%suffix&a:&f %msg'
defaultFormat: '&f[%color%ch&f]%prefix%displayname%suffix&a:&f %msg'
# OPの画面に、全チャンネルの発言内容を表示する設定。
opListenAllChannel: false
@@ -100,7 +100,7 @@ quickChannelChatSeparator: ':'
# 適用されるフォーマット設定。
# フォーマット設定には、下記のキーワードが使用できます。
# %ch : チャンネル名(「%player>%to」と同一です。)
# %username : 発言者表示名
# %displayname : 発言者表示名
# %player : 発言者ID
# %server : 発言者の接続サーバー名(BungeeCord側に導入したときに有効です。)
# %to : 発言の相手(受信者)のID
@@ -159,7 +159,7 @@ enableNormalChatMessageFormat: true
# チャット装飾のフォーマット設定。
# フォーマット設定には、下記のキーワードが使用できます。
# %username : 発言者表示名
# %displayname : 発言者表示名
# %player : 発言者ID
# %world : 発言したワールド名(spigot側に導入したときに有効です。MultiVerseが導入されている場合は、ワールドの表示名を取得して使用します。)
# %server : 発言者の接続サーバー名(BungeeCord側に導入したときに有効です。)
@@ -168,8 +168,8 @@ enableNormalChatMessageFormat: true
# %date : 日付
# %time : 時刻
# %msg : 発言内容(Japanize変換された場合は、Japanize結果を含みます。)
normalChatMessageFormat: '&f%prefix%username%suffix&a:&f %msg'
#normalChatMessageFormat: '&f%username@%server&a:&f %msg'
normalChatMessageFormat: '&f%prefix%displayname%suffix&a:&f %msg'
#normalChatMessageFormat: '&f%displayname@%server&a:&f %msg'
# 通常チャット(非チャンネルチャット)で、カラーコード(&aや&bなど)を
# 使用可能にするかどうか。falseに設定すると、カラーコードは変換されません。
+3
ファイルの表示
@@ -206,3 +206,6 @@ usageJapanizeOther: '&6/%label% (player) on|off &7- Turn on/off the Japanize con
usageTop: '&e----- &6LunaChat %type% command (&c%num%&6/&c%max%&6) &e-----'
usageFoot: '&e-----------------------------------------'
usageNoticeNextPage: '&6 To see the next page, run &c/%label% help %type% %next%&6. '
hoverChannelName: 'Set %channel% as your speak channel'
hoverPlayerName: 'Send private message to %player%'
+3
ファイルの表示
@@ -206,3 +206,6 @@ usageJapanizeOther: '&6/%label% (player) on|off &7- Turn on/off the Japanize con
usageTop: '&e----- &6LunaChat %type% command (&c%num%&6/&c%max%&6) &e-----'
usageFoot: '&e-----------------------------------------'
usageNoticeNextPage: '&6次のページを見るには、&c/%label% help %type% %next%&6 と実行してください。'
hoverChannelName: '発言先を%channel%にする'
hoverPlayerName: '%player%にプライベートメッセージを送る'
+34
ファイルの表示
@@ -0,0 +1,34 @@
/*
* @author ucchy
* @license LGPLv3
* @copyright Copyright ucchy 2020
*/
package com.github.ucchyocean.lc3.channel;
import com.github.ucchyocean.lc3.member.ChannelMember;
/**
*
* @author ucchy
*/
public class DummyChannel extends Channel {
public DummyChannel(String name) {
super(name);
}
/**
* @param player
* @param message
* @param format
* @param sendDynmap
* @param displayName
* @see com.github.ucchyocean.lc3.channel.Channel#sendMessage(com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.lang.String, boolean, java.lang.String)
*/
@Override
protected void sendMessage(ChannelMember player, String message, String format, boolean sendDynmap,
String displayName) {
System.out.println("room " + getName() + " message : " + message);
}
}
+135
ファイルの表示
@@ -0,0 +1,135 @@
/*
* @author ucchy
* @license LGPLv3
* @copyright Copyright ucchy 2020
*/
package com.github.ucchyocean.lc3.member;
import net.md_5.bungee.api.chat.BaseComponent;
/**
* テスト用のダミーメンバー
* @author ucchy
*/
public class ChannelMemberDummy extends ChannelMember {
/**
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#isOnline()
*/
@Override
public boolean isOnline() {
return true;
}
/**
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#getName()
*/
@Override
public String getName() {
return "ucchy";
}
/**
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#getDisplayName()
*/
@Override
public String getDisplayName() {
return "うっちぃ";
}
/**
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#getPrefix()
*/
@Override
public String getPrefix() {
return "[P]";
}
/**
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#getSuffix()
*/
@Override
public String getSuffix() {
return "[S]";
}
/**
* @param message
* @see com.github.ucchyocean.lc3.member.ChannelMember#sendMessage(java.lang.String)
*/
@Override
public void sendMessage(String message) {
System.out.println(message);
}
/**
* @param message
* @see com.github.ucchyocean.lc3.member.ChannelMember#sendMessage(net.md_5.bungee.api.chat.BaseComponent[])
*/
@Override
public void sendMessage(BaseComponent[] message) {
System.out.println(message);
}
/**
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#getWorldName()
*/
@Override
public String getWorldName() {
return "w";
}
/**
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#getServerName()
*/
@Override
public String getServerName() {
return "s";
}
/**
* @param node
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#hasPermission(java.lang.String)
*/
@Override
public boolean hasPermission(String node) {
return true;
}
/**
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#toString()
*/
@Override
public String toString() {
return "ChannelMemberDummy{name=ucchy}";
}
/**
* @param node
* @return
* @see com.github.ucchyocean.lc3.member.ChannelMember#isPermissionSet(java.lang.String)
*/
@Override
public boolean isPermissionSet(String node) {
return true;
}
/**
* @param message
* @see com.github.ucchyocean.lc3.member.ChannelMember#chat(java.lang.String)
*/
@Override
public void chat(String message) {
// do nothing.
}
}
+47
ファイルの表示
@@ -0,0 +1,47 @@
/*
* @author ucchy
* @license LGPLv3
* @copyright Copyright ucchy 2020
*/
package com.github.ucchyocean.lc3.util;
import junit.framework.TestCase;
/**
*
* @author ucchy
*/
public class ChatFormatterTester extends TestCase {
public void testChannelChatKeyword() {
// LunaChatStandalone instance = new LunaChatStandalone();
// instance.onEnable();
//
// String format = "&f[%color%ch&f]%prefix%displayname%suffix&a:&f %msg";
// ChannelMember member = new ChannelMemberDummy();
// Channel channel = new DummyChannel("r");
//
// String pre = ChatFormatter.replaceKeywordsForChannel(format, member, channel);
//
// System.out.println("pre = " + pre);
//
// BaseComponent[] comps = ChatFormatter.replaceTextComponent(pre);
//
// System.out.println("post = " + comps.length);
}
public void testEventChatKeyword() {
// String format = "&f%prefix%displayname%suffix&a:&f %msg";
// ChannelMember member = new ChannelMemberDummy();
//
// String pre = ChatFormatter.replaceKeywordsForEvent(format, member);
//
// System.out.println("pre = " + pre);
//
// BaseComponent[] comps = ChatFormatter.replaceTextComponent(pre);
//
// System.out.println("post = " + comps.length);
}
}