コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
1735ba5386 | ||
|
|
90b0a33c0f | ||
|
|
4cf64c2318 | ||
|
|
9099ac968e | ||
|
|
bdd148f313 | ||
|
|
81b75f3f0f | ||
|
|
ff722c79a1 | ||
|
|
f95cf9da33 | ||
|
|
18c47505c7 | ||
|
|
a7234efe84 | ||
|
|
9d5fd5ceb5 | ||
|
|
9e65f0f63b | ||
|
|
7b73ad1c21 | ||
|
|
167293d5e5 | ||
|
|
d14840f144 | ||
|
|
b3ed3103e4 | ||
|
|
d652fcb39a | ||
|
|
e2eea8798d | ||
|
|
0466653e89 |
検索条件に一致するファイルはありません
@@ -0,0 +1,33 @@
|
||||
---
|
||||
name: Bug report/バグ報告
|
||||
about: Create a report to help us improve/バグ報告をしたい場合はこちらを選択してください
|
||||
title: ''
|
||||
labels: バグ
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug/バグの概要**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**Server and version/サーバーとバージョン**
|
||||
- Server: Spigot / Paper / BungeeCord / Waterfall / etc...
|
||||
- Server version (Minecraft version) : 1.16.1 / 1.15.2 / etc...
|
||||
- Other plugins:
|
||||
- LunaChat version :
|
||||
|
||||
**To Reproduce/再現手順**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior/期待する結果**
|
||||
A clear and concise description of what you expected to happen./上記の再現手順に書いた状態について、何か期待と違っていたのか、どこに問題があったのかを、明確に記載してください。
|
||||
|
||||
**Screenshots/スクリーンショット**
|
||||
If applicable, add screenshots to help explain your problem./スクリーンショットがあれば添付してください。ブラウザに画像ファイルをドラッグアンドドロップしてアップロードできます。
|
||||
|
||||
**Additional context/備考**
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: Feature request/機能追加リクエスト
|
||||
about: Suggest an idea for this project/機能追加要望をしたい場合はこちらを選択してください
|
||||
title: ''
|
||||
labels: 機能追加・要望
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -6,3 +6,4 @@
|
||||
.idea/
|
||||
*.iml
|
||||
/.sts4-cache
|
||||
/LunaChat
|
||||
@@ -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.6</version>
|
||||
<description>A powerfull chat channel plugin with IME (Kana-Kanji conversion) support</description>
|
||||
<url>https://github.com/ucchyocean/LunaChat</url>
|
||||
|
||||
@@ -70,6 +70,7 @@
|
||||
<version>3.2.1</version>
|
||||
<configuration>
|
||||
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||
<minimizeJar>true</minimizeJar>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
@@ -100,6 +101,18 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<configuration>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<encoding>UTF-8</encoding>
|
||||
<inputEncoding>UTF-8</inputEncoding>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
<argLine>-Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -228,7 +241,7 @@
|
||||
<dependency>
|
||||
<groupId>net.alpenblock</groupId>
|
||||
<artifactId>BungeePerms</artifactId>
|
||||
<version>LATEST</version>
|
||||
<version>4.0-dev-106</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -6,9 +6,12 @@
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bstats.bukkit.Metrics;
|
||||
@@ -68,7 +71,17 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
LunaChat.setMode(LunaChatMode.BUKKIT);
|
||||
|
||||
// Metrics
|
||||
new Metrics(this, 7936);
|
||||
Metrics metrics = new Metrics(this, 7936);
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie(
|
||||
"minecraft_server_version", new Callable<Map<String, Map<String, Integer>>>() {
|
||||
public Map<String, Map<String, Integer>> call() throws Exception {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
Map<String, Integer> sub = new HashMap<>();
|
||||
sub.put(Bukkit.getVersion(), 1);
|
||||
map.put(Bukkit.getName(), sub);
|
||||
return map;
|
||||
}
|
||||
}));
|
||||
|
||||
// 変数などの初期化
|
||||
config = new LunaChatConfig(getDataFolder(), getFile());
|
||||
@@ -152,7 +165,7 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
return messageCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
} else if ( command.getName().equals("reply") ) {
|
||||
return replyCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
} else if ( command.getName().equals("lcjapanize") ) {
|
||||
} else if ( command.getName().equals("japanize") ) {
|
||||
return lcjapanizeCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
@@ -55,7 +57,17 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
LunaChat.setMode(LunaChatMode.BUNGEE);
|
||||
|
||||
// Metrics
|
||||
new Metrics(this, 7936);
|
||||
Metrics metrics = new Metrics(this, 7936);
|
||||
metrics.addCustomChart(new Metrics.DrilldownPie(
|
||||
"minecraft_server_version", new Callable<Map<String, Map<String, Integer>>>() {
|
||||
public Map<String, Map<String, Integer>> call() throws Exception {
|
||||
Map<String, Map<String, Integer>> map = new HashMap<>();
|
||||
Map<String, Integer> sub = new HashMap<>();
|
||||
sub.put(getProxy().getVersion(), 1);
|
||||
map.put(getProxy().getName(), sub);
|
||||
return map;
|
||||
}
|
||||
}));
|
||||
|
||||
// 初期化
|
||||
config = new LunaChatConfig(getDataFolder(), getFile());
|
||||
|
||||
@@ -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 文字列
|
||||
|
||||
@@ -21,6 +21,11 @@ public class LunaChatStandalone implements PluginInterface {
|
||||
private LunaChatConfig config;
|
||||
private ChannelManager manager;
|
||||
private UUIDCacheData uuidCacheData;
|
||||
private File dataFolder;
|
||||
|
||||
public LunaChatStandalone(File dataFolder) {
|
||||
this.dataFolder = dataFolder;
|
||||
}
|
||||
|
||||
public void onEnable() {
|
||||
|
||||
@@ -33,7 +38,7 @@ public class LunaChatStandalone implements PluginInterface {
|
||||
// コンフィグ取得
|
||||
config = new LunaChatConfig(getDataFolder(), getPluginJarFile());
|
||||
|
||||
// UUIDキャッシュデータ (これ要る?)
|
||||
// UUIDキャッシュデータ
|
||||
uuidCacheData = new UUIDCacheData(getDataFolder());
|
||||
}
|
||||
|
||||
@@ -60,12 +65,7 @@ public class LunaChatStandalone implements PluginInterface {
|
||||
|
||||
@Override
|
||||
public File getDataFolder() {
|
||||
|
||||
// 現在のフォルダ下にLunaChatフォルダを作成して返す
|
||||
String cd = new File(".").getAbsoluteFile().getParent();
|
||||
File folder = new File(cd, "LunaChat");
|
||||
if ( !folder.exists() ) folder.mkdirs();
|
||||
return folder;
|
||||
return dataFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -83,7 +83,8 @@ public class LunaChatStandalone implements PluginInterface {
|
||||
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
// TODO Standaloneサーバーのログ出力 未実装
|
||||
// 画面に表示する
|
||||
System.out.println(String.format("[%s]%s", level.toString(), msg));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -10,10 +10,13 @@ import java.io.IOException;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
import com.github.ucchyocean.lc3.util.KeywordReplacer;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
import com.github.ucchyocean.lc3.util.YamlConfig;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
/**
|
||||
* プラグインのメッセージリソース管理クラス
|
||||
* @author ucchy
|
||||
@@ -28,7 +31,7 @@ public class Messages {
|
||||
* Jarファイル内から直接 messages_en.yml をdefaultMessagesとしてロードし、
|
||||
* langに対応するメッセージをファイルからロードする。
|
||||
* @param messagesFolder メッセージ格納フォルダ
|
||||
* @param jar jarファイル
|
||||
* @param jar jarファイル(JTestからの実行時はnullを指定可)
|
||||
* @param lang デフォルト言語
|
||||
*/
|
||||
public static void initialize(File messagesFolder, File jar, String lang) {
|
||||
@@ -50,17 +53,19 @@ public class Messages {
|
||||
|
||||
// デフォルトメッセージを、jarファイル内からロードする
|
||||
YamlConfig defaultMessages = null;
|
||||
try (JarFile jarFile = new JarFile(_jar)) {
|
||||
if ( _jar != null ) {
|
||||
try (JarFile jarFile = new JarFile(_jar)) {
|
||||
|
||||
ZipEntry zipEntry = jarFile.getEntry(String.format("messages_%s.yml", lang));
|
||||
if (zipEntry == null) {
|
||||
zipEntry = jarFile.getEntry("messages_en.yml");
|
||||
ZipEntry zipEntry = jarFile.getEntry(String.format("messages_%s.yml", lang));
|
||||
if (zipEntry == null) {
|
||||
zipEntry = jarFile.getEntry("messages_en.yml");
|
||||
}
|
||||
|
||||
defaultMessages = YamlConfig.load(jarFile.getInputStream(zipEntry));
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
defaultMessages = YamlConfig.load(jarFile.getInputStream(zipEntry));
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// 対応する言語のメッセージをロードする
|
||||
@@ -88,27 +93,27 @@ public class Messages {
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんがチャンネルに参加しました。
|
||||
*/
|
||||
public static String joinMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] joinMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("joinMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんがチャンネルから退出しました。
|
||||
*/
|
||||
public static String quitMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] quitMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("quitMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -126,197 +131,197 @@ public class Messages {
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんをチャンネルからBANしました。
|
||||
*/
|
||||
public static String banMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] banMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("banMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんをチャンネルからキックしました。
|
||||
*/
|
||||
public static String kickMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] kickMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("kickMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんをチャンネルからMuteしました。
|
||||
*/
|
||||
public static String muteMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] muteMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("muteMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7NGワード発言により、%player% さんをチャンネルから自動BANしました。
|
||||
*/
|
||||
public static String banNGWordMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] banNGWordMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("banNGWordMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7NGワード発言により、%player% さんをチャンネルから自動キックしました。
|
||||
*/
|
||||
public static String kickNGWordMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] kickNGWordMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("kickNGWordMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7NGワード発言により、%player% さんをチャンネルから自動Muteしました。
|
||||
*/
|
||||
public static String muteNGWordMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] muteNGWordMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("muteNGWordMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんを期限 %minutes% 分でチャンネルからBANしました。
|
||||
*/
|
||||
public static String banWithExpireMessage(Object color, Object channel, Object player, Object minutes) {
|
||||
public static BaseComponent[] banWithExpireMessage(Object color, Object channel, Object player, Object minutes) {
|
||||
String msg = resources.getString("banWithExpireMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
kr.replace("%minutes%", minutes.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
cf.replace("%minutes%", minutes.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんを期限 %minutes% 分でチャンネルからMuteしました。
|
||||
*/
|
||||
public static String muteWithExpireMessage(Object color, Object channel, Object player, Object minutes) {
|
||||
public static BaseComponent[] muteWithExpireMessage(Object color, Object channel, Object player, Object minutes) {
|
||||
String msg = resources.getString("muteWithExpireMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
kr.replace("%minutes%", minutes.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
cf.replace("%minutes%", minutes.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんのBANが解除されました。
|
||||
*/
|
||||
public static String pardonMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] pardonMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("pardonMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんのMuteが解除されました。
|
||||
*/
|
||||
public static String unmuteMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] unmuteMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("unmuteMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんの期限付きBANが解除されました。
|
||||
*/
|
||||
public static String expiredBanMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] expiredBanMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("expiredBanMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんの期限付きMuteが解除されました。
|
||||
*/
|
||||
public static String expiredMuteMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] expiredMuteMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("expiredMuteMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんがチャンネルのモデレーターになりました。
|
||||
*/
|
||||
public static String addModeratorMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] addModeratorMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("addModeratorMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7%player% さんがチャンネルのモデレーターから外れました。
|
||||
*/
|
||||
public static String removeModeratorMessage(Object color, Object channel, Object player) {
|
||||
public static BaseComponent[] removeModeratorMessage(Object color, Object channel, Object player) {
|
||||
String msg = resources.getString("removeModeratorMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%player%", player.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%player%", player.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
* &f[%color%%channel%&f]&7あなたの発言は、誰にも届きませんでした。
|
||||
*/
|
||||
public static String noRecipientMessage(Object color, Object channel) {
|
||||
public static BaseComponent[] noRecipientMessage(Object color, Object channel) {
|
||||
String msg = resources.getString("noRecipientMessage");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%color%", color.toString());
|
||||
kr.replace("%channel%", channel.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%color%", color.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -354,15 +359,15 @@ public class Messages {
|
||||
/**
|
||||
* &7| &f%channel%&7(&c%online%&7/&c%total%&7) &a%topic%
|
||||
*/
|
||||
public static String listFormat(Object channel, Object online, Object total, Object topic) {
|
||||
public static BaseComponent[] listFormat(Object channel, Object online, Object total, Object topic) {
|
||||
String msg = resources.getString("listFormat");
|
||||
if ( msg == null ) return "";
|
||||
KeywordReplacer kr = new KeywordReplacer(msg);
|
||||
kr.replace("%channel%", channel.toString());
|
||||
kr.replace("%online%", online.toString());
|
||||
kr.replace("%total%", total.toString());
|
||||
kr.replace("%topic%", topic.toString());
|
||||
return Utility.replaceColorCode(kr.toString());
|
||||
if ( msg == null ) return new BaseComponent[0];
|
||||
ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());
|
||||
cf.replace("%channel%", channel.toString());
|
||||
cf.replace("%online%", online.toString());
|
||||
cf.replace("%total%", total.toString());
|
||||
cf.replace("%topic%", topic.toString());
|
||||
return cf.makeTextComponent();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2124,5 +2129,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. ===
|
||||
}
|
||||
@@ -6,9 +6,9 @@
|
||||
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.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -27,31 +27,24 @@ 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.ClickableFormat;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* 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");
|
||||
}
|
||||
private static final int MAX_LIST_ITEMS = 8;
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
@@ -132,9 +125,8 @@ public class BukkitEventListener implements Listener {
|
||||
|
||||
// チャンネルチャット情報を表示する
|
||||
if ( config.isShowListOnJoin() ) {
|
||||
ArrayList<String> list = getListForMotd(player);
|
||||
for ( String msg : list ) {
|
||||
player.sendMessage(msg);
|
||||
for ( BaseComponent[] msg : getListForMotd(player) ) {
|
||||
ChannelMember.getChannelMember(player).sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -309,13 +301,6 @@ public class BukkitEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// チャットフォーマット装飾の適用
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
String format = config.getNormalChatMessageFormat();
|
||||
format = replaceNormalChatFormatKeywords(format, event.getPlayer());
|
||||
event.setFormat(format);
|
||||
}
|
||||
|
||||
// カラーコード置き換え
|
||||
// 置き換え設定になっていて、発言者がパーミッションを持っているなら、置き換えする
|
||||
if ( config.isEnableNormalChatColorCode() &&
|
||||
@@ -378,8 +363,48 @@ public class BukkitEventListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
// 発言内容の設定
|
||||
event.setMessage(message);
|
||||
if ( config.isEnableNormalChatClickable() ) {
|
||||
// クリック可能チャットで発言
|
||||
|
||||
// チャットフォーマット装飾の適用
|
||||
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()));
|
||||
}
|
||||
|
||||
// 発言内容の送信
|
||||
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());
|
||||
@@ -440,7 +465,7 @@ public class BukkitEventListener implements Listener {
|
||||
channel.addMember(cp);
|
||||
}
|
||||
|
||||
// デフォルト発言先が無いなら、グローバルチャンネルに設定する
|
||||
// デフォルト発言先が無いなら、デフォルトチャンネルに設定する
|
||||
Channel dchannel = api.getDefaultChannel(player.getName());
|
||||
if ( dchannel == null ) {
|
||||
api.setDefaultChannel(player.getName(), cname);
|
||||
@@ -448,62 +473,12 @@ 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 プレイヤー
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getListForMotd(Player player) {
|
||||
private ArrayList<BaseComponent[]> getListForMotd(Player player) {
|
||||
|
||||
ChannelMember cp = ChannelMember.getChannelMember(player);
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
@@ -513,9 +488,19 @@ public class BukkitEventListener implements Listener {
|
||||
dchannel = dc.getName().toLowerCase();
|
||||
}
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
items.add(Messages.motdFirstLine());
|
||||
for ( Channel channel : api.getChannels() ) {
|
||||
// チャンネル一覧を取得して、参加人数でソートする
|
||||
ArrayList<Channel> channels = new ArrayList<>(api.getChannels());
|
||||
Collections.sort(channels, new Comparator<Channel>() {
|
||||
public int compare(Channel c1, Channel c2) {
|
||||
if ( c1.getOnlineNum() == c2.getOnlineNum() ) return c1.getName().compareTo(c2.getName());
|
||||
return c2.getOnlineNum() - c1.getOnlineNum();
|
||||
}
|
||||
});
|
||||
|
||||
int count = 0;
|
||||
ArrayList<BaseComponent[]> items = new ArrayList<>();
|
||||
items.add(TextComponent.fromLegacyText(Messages.motdFirstLine()));
|
||||
for ( Channel channel : channels ) {
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
if ( channel.getBanned().contains(cp) ) {
|
||||
@@ -540,10 +525,14 @@ public class BukkitEventListener implements Listener {
|
||||
String desc = channel.getDescription();
|
||||
int onlineNum = channel.getOnlineNum();
|
||||
int memberNum = channel.getTotalNum();
|
||||
String item = Messages.listFormat(disp, onlineNum, memberNum, desc);
|
||||
items.add(item);
|
||||
items.add(Messages.listFormat(disp, onlineNum, memberNum, desc));
|
||||
count++;
|
||||
|
||||
if ( count > MAX_LIST_ITEMS ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
items.add(Messages.listEndLine());
|
||||
items.add(TextComponent.fromLegacyText(Messages.listEndLine()));
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
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.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -19,17 +19,16 @@ 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.ClickableFormat;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
@@ -46,11 +45,8 @@ 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 static final int MAX_LIST_ITEMS = 8;
|
||||
|
||||
private SimpleDateFormat dateFormat;
|
||||
private SimpleDateFormat timeFormat;
|
||||
private LunaChatBungee parent;
|
||||
private LunaChatConfig config;
|
||||
private LunaChatAPI api;
|
||||
@@ -63,8 +59,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);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,9 +140,8 @@ public class BungeeEventListener implements Listener {
|
||||
|
||||
// チャンネルチャット情報を表示する
|
||||
if ( config.isShowListOnJoin() ) {
|
||||
ArrayList<String> list = getListForMotd(player);
|
||||
for ( String msg : list ) {
|
||||
player.sendMessage(TextComponent.fromLegacyText(msg));
|
||||
for ( BaseComponent[] msg : getListForMotd(player) ) {
|
||||
player.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -286,8 +279,9 @@ public class BungeeEventListener implements Listener {
|
||||
boolean skipJapanize = !LunaChat.getAPI().isPlayerJapanize(sender.getName());
|
||||
|
||||
// 一時的なJapanizeスキップが指定されているか確認する
|
||||
if ( message.startsWith(config.getNoneJapanizeMarker()) ) {
|
||||
message = message.substring(config.getNoneJapanizeMarker().length());
|
||||
String marker = config.getNoneJapanizeMarker();
|
||||
if ( !marker.equals("") && message.startsWith(marker) ) {
|
||||
message = message.substring(marker.length());
|
||||
skipJapanize = true;
|
||||
}
|
||||
|
||||
@@ -320,27 +314,33 @@ public class BungeeEventListener implements Listener {
|
||||
}
|
||||
|
||||
String result;
|
||||
|
||||
if ( config.isEnableNormalChatMessageFormat() ) {
|
||||
// チャットフォーマット装飾を適用する場合
|
||||
String format = config.getNormalChatMessageFormat();
|
||||
result = replaceNormalChatFormatKeywords(format, sender, message);
|
||||
String f = config.getNormalChatMessageFormat();
|
||||
ClickableFormat format = ClickableFormat.makeFormat(f, ChannelMember.getChannelMember(sender));
|
||||
format.replace("%msg", message);
|
||||
|
||||
// イベントをキャンセルする
|
||||
event.setCancelled(true);
|
||||
|
||||
// hideされているプレイヤーを除くすべてのプレイヤーに、
|
||||
// 発言内容を送信する。
|
||||
BaseComponent[] msg = format.makeTextComponent();
|
||||
List<ChannelMember> hidelist = api.getHidelist(ChannelMember.getChannelMember(sender));
|
||||
|
||||
for ( String server : parent.getProxy().getServers().keySet() ) {
|
||||
|
||||
ServerInfo info = parent.getProxy().getServerInfo(server);
|
||||
for ( ProxiedPlayer player : info.getPlayers() ) {
|
||||
if ( !containsHideList(player, hidelist) ) {
|
||||
sendMessage(player, result);
|
||||
sendMessage(player, msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
result = format.toLegacyText();
|
||||
|
||||
} else {
|
||||
// チャットフォーマットを適用しない場合
|
||||
// NOTE: ChatEvent経由で送信する都合上、hideは適用しない(できない)仕様とする。
|
||||
@@ -393,56 +393,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 プレイヤー
|
||||
@@ -552,7 +502,7 @@ public class BungeeEventListener implements Listener {
|
||||
* @param player プレイヤー
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getListForMotd(ProxiedPlayer player) {
|
||||
private ArrayList<BaseComponent[]> getListForMotd(ProxiedPlayer player) {
|
||||
|
||||
ChannelMember cp = ChannelMember.getChannelMember(player);
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
@@ -562,9 +512,19 @@ public class BungeeEventListener implements Listener {
|
||||
dchannel = dc.getName().toLowerCase();
|
||||
}
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
items.add(Messages.motdFirstLine());
|
||||
for ( Channel channel : api.getChannels() ) {
|
||||
// チャンネル一覧を取得して、参加人数でソートする
|
||||
ArrayList<Channel> channels = new ArrayList<>(api.getChannels());
|
||||
Collections.sort(channels, new Comparator<Channel>() {
|
||||
public int compare(Channel c1, Channel c2) {
|
||||
if ( c1.getOnlineNum() == c2.getOnlineNum() ) return c1.getName().compareTo(c2.getName());
|
||||
return c2.getOnlineNum() - c1.getOnlineNum();
|
||||
}
|
||||
});
|
||||
|
||||
int count = 0;
|
||||
ArrayList<BaseComponent[]> items = new ArrayList<>();
|
||||
items.add(TextComponent.fromLegacyText(Messages.motdFirstLine()));
|
||||
for ( Channel channel : channels ) {
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
if ( channel.getBanned().contains(cp) ) {
|
||||
@@ -589,10 +549,14 @@ public class BungeeEventListener implements Listener {
|
||||
String desc = channel.getDescription();
|
||||
int onlineNum = channel.getOnlineNum();
|
||||
int memberNum = channel.getTotalNum();
|
||||
String item = Messages.listFormat(disp, onlineNum, memberNum, desc);
|
||||
items.add(item);
|
||||
items.add(Messages.listFormat(disp, onlineNum, memberNum, desc));
|
||||
count++;
|
||||
|
||||
if ( count > MAX_LIST_ITEMS ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
items.add(Messages.listEndLine());
|
||||
items.add(TextComponent.fromLegacyText(Messages.listEndLine()));
|
||||
|
||||
return items;
|
||||
}
|
||||
@@ -604,7 +568,23 @@ 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(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定した対象にメッセージを送信する
|
||||
* @param reciever 送信先
|
||||
* @param message メッセージ
|
||||
*/
|
||||
private void sendMessage(CommandSender reciever, BaseComponent[] message) {
|
||||
if ( message == null ) return;
|
||||
ChannelMember cm = ChannelMember.getChannelMember(reciever);
|
||||
if ( cm != null ) {
|
||||
cm.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
@@ -15,6 +13,7 @@ import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
@@ -25,29 +24,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.ClickableFormat;
|
||||
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");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,11 +49,11 @@ public class BukkitChannel extends Channel {
|
||||
* @param message メッセージ
|
||||
* @param format フォーマット
|
||||
* @param sendDynmap dynmapへ送信するかどうか
|
||||
* @param name 発言者名
|
||||
*/
|
||||
@Override
|
||||
protected void sendMessage(ChannelMember player, String message,
|
||||
String format, boolean sendDynmap, String name) {
|
||||
protected void sendMessage(
|
||||
ChannelMember player, String message,
|
||||
@Nullable ClickableFormat format, boolean sendDynmap) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
@@ -106,7 +99,7 @@ public class BukkitChannel extends Channel {
|
||||
}
|
||||
|
||||
// 受信者が自分以外いない場合は、メッセージを表示する
|
||||
if ( !Messages.noRecipientMessage("", "").isEmpty() && (
|
||||
if ( Messages.noRecipientMessage("", "").length > 0 && (
|
||||
recipients.size() == 0 ||
|
||||
(recipients.size() == 1 &&
|
||||
recipients.get(0).getName().equals(player.getName()) ) ) ) {
|
||||
@@ -155,12 +148,8 @@ public class BukkitChannel extends Channel {
|
||||
}
|
||||
}
|
||||
|
||||
// フォーマットがある場合は置き換える
|
||||
if ( format != null ) {
|
||||
message = format.replace("%msg", message);
|
||||
}
|
||||
|
||||
// LunaChatChannelMessageEvent イベントコール
|
||||
String name = (player != null) ? player.getDisplayName() : "<null>";
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatChannelMessageEvent(
|
||||
getName(), player, message, recipients, name, originalMessage);
|
||||
message = result.getMessage();
|
||||
@@ -184,8 +173,16 @@ public class BukkitChannel extends Channel {
|
||||
}
|
||||
|
||||
// 送信する
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
if ( format != null ) {
|
||||
format.replace("%msg", message);
|
||||
BaseComponent[] comps = format.makeTextComponent();
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(comps);
|
||||
}
|
||||
} else {
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 設定に応じて、コンソールに出力する
|
||||
@@ -199,7 +196,7 @@ public class BukkitChannel extends Channel {
|
||||
}
|
||||
|
||||
// ロギング
|
||||
log(originalMessage, name, player);
|
||||
log(originalMessage, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,89 +252,13 @@ 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 発言者
|
||||
* @param message 記録するメッセージ
|
||||
* @param player プレイヤー
|
||||
*/
|
||||
private void log(String message, String name, ChannelMember player) {
|
||||
@Override
|
||||
protected void log(String message, String name) {
|
||||
|
||||
// LunaChatのチャットログへ記録
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
@@ -5,22 +5,21 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
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.ClickableFormat;
|
||||
|
||||
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 +28,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");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -50,11 +42,10 @@ public class BungeeChannel extends Channel {
|
||||
* @param message メッセージ
|
||||
* @param format フォーマット
|
||||
* @param sendDynmap dynmapへ送信するかどうか
|
||||
* @param name 発言者名
|
||||
*/
|
||||
@Override
|
||||
protected void sendMessage(ChannelMember player, String message,
|
||||
String format, boolean sendDynmap, String name) {
|
||||
@Nullable ClickableFormat format, boolean sendDynmap) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
@@ -108,19 +99,25 @@ public class BungeeChannel extends Channel {
|
||||
}
|
||||
|
||||
// フォーマットがある場合は置き換える
|
||||
if ( format != null ) {
|
||||
message = format.replace("%msg", message);
|
||||
}
|
||||
|
||||
// LunaChatChannelMessageEvent イベントコール
|
||||
String name = (player != null) ? player.getDisplayName() : "<null>";
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatChannelMessageEvent(
|
||||
getName(), player, message, recipients, name, originalMessage);
|
||||
message = result.getMessage();
|
||||
recipients = result.getRecipients();
|
||||
|
||||
// 送信する
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
if ( format != null ) {
|
||||
format.replace("%msg", message);
|
||||
BaseComponent[] comps = format.makeTextComponent();
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(comps);
|
||||
}
|
||||
} else {
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
// 設定に応じて、コンソールに出力する
|
||||
@@ -129,7 +126,7 @@ public class BungeeChannel extends Channel {
|
||||
}
|
||||
|
||||
// ロギング
|
||||
log(originalMessage, name, player);
|
||||
log(originalMessage, name);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -185,91 +182,13 @@ 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 発言者
|
||||
* @param message 記録するメッセージ
|
||||
* @param player プレイヤー
|
||||
*/
|
||||
private void log(String message, String name, ChannelMember player) {
|
||||
@Override
|
||||
protected void log(String message, String name) {
|
||||
|
||||
// LunaChatのチャットログへ記録
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
@@ -13,23 +13,33 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.LunaChatLogger;
|
||||
import com.github.ucchyocean.lc3.LunaChatMode;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.NGWordAction;
|
||||
import com.github.ucchyocean.lc3.bridge.DynmapBridge;
|
||||
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.ChannelMemberOther;
|
||||
import com.github.ucchyocean.lc3.util.ChatColor;
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
import com.github.ucchyocean.lc3.util.YamlConfig;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* チャンネル
|
||||
* @author ucchy
|
||||
@@ -256,7 +266,7 @@ public abstract class Channel {
|
||||
}
|
||||
|
||||
// キーワード置き換え
|
||||
String msgFormat = replaceKeywords(getFormat(), player);
|
||||
ClickableFormat cf = ClickableFormat.makeFormat(getFormat(), player, this, true);
|
||||
|
||||
// カラーコード置き換え
|
||||
// チャンネルで許可されていて、発言者がパーミッションを持っている場合に置き換える
|
||||
@@ -266,11 +276,11 @@ public abstract class Channel {
|
||||
|
||||
// LunaChatChannelChatEvent イベントコール
|
||||
EventResult result = LunaChat.getEventSender().sendLunaChatChannelChatEvent(
|
||||
getName(), player, message, maskedMessage, msgFormat);
|
||||
getName(), player, message, maskedMessage, cf.toLegacyText());
|
||||
if ( result.isCancelled() ) {
|
||||
return;
|
||||
}
|
||||
msgFormat = result.getMessageFormat();
|
||||
// msgFormat = result.getMessageFormat();
|
||||
maskedMessage = result.getNgMaskedMessage();
|
||||
|
||||
// 2byteコードを含むか、半角カタカナのみなら、Japanize変換は行わない
|
||||
@@ -294,10 +304,10 @@ public abstract class Channel {
|
||||
|
||||
int lineType = config.getJapanizeDisplayLine();
|
||||
String jpFormat;
|
||||
String messageFormat = null;
|
||||
ClickableFormat messageFormat = null;
|
||||
if ( lineType == 1 ) {
|
||||
jpFormat = Utility.replaceColorCode(config.getJapanizeLine1Format());
|
||||
messageFormat = msgFormat;
|
||||
messageFormat = cf;
|
||||
isIncludeSyncChat = false;
|
||||
} else {
|
||||
jpFormat = Utility.replaceColorCode(config.getJapanizeLine2Format());
|
||||
@@ -310,7 +320,7 @@ public abstract class Channel {
|
||||
|
||||
if ( isIncludeSyncChat ) {
|
||||
// メッセージの送信
|
||||
sendMessage(player, maskedMessage, msgFormat, true, player.getDisplayName());
|
||||
sendMessage(player, maskedMessage, cf, true);
|
||||
}
|
||||
|
||||
// 非同期実行タスクがある場合、追加で実行する
|
||||
@@ -326,10 +336,10 @@ public abstract class Channel {
|
||||
if ( !isGlobalChannel() ) {
|
||||
getBanned().add(player);
|
||||
removeMember(player);
|
||||
if ( !Messages.banNGWordMessage("", "", "").isEmpty() ) {
|
||||
String m = Messages.banNGWordMessage(getColorCode(), getName(), player.getName());
|
||||
if ( Messages.banNGWordMessage("", "", "").length > 0 ) {
|
||||
BaseComponent[] m = Messages.banNGWordMessage(getColorCode(), getName(), player.getName());
|
||||
player.sendMessage(m);
|
||||
sendMessage(null, m, null, true, "system");
|
||||
sendSystemMessage(m, true, "system");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -338,10 +348,10 @@ public abstract class Channel {
|
||||
|
||||
if ( !isGlobalChannel() ) {
|
||||
removeMember(player);
|
||||
if ( !Messages.kickNGWordMessage("", "", "").isEmpty() ) {
|
||||
String m = Messages.kickNGWordMessage(getColorCode(), getName(), player.getName());
|
||||
if ( Messages.kickNGWordMessage("", "", "").length > 0 ) {
|
||||
BaseComponent[] m = Messages.kickNGWordMessage(getColorCode(), getName(), player.getName());
|
||||
player.sendMessage(m);
|
||||
sendMessage(null, m, null, true, "system");
|
||||
sendSystemMessage(m, true, "system");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -350,10 +360,10 @@ public abstract class Channel {
|
||||
|
||||
getMuted().add(player);
|
||||
save();
|
||||
if ( !Messages.muteNGWordMessage("", "", "").isEmpty() ) {
|
||||
String m = Messages.muteNGWordMessage(getColorCode(), getName(), player.getName());
|
||||
if ( Messages.muteNGWordMessage("", "", "").length > 0 ) {
|
||||
BaseComponent[] m = Messages.muteNGWordMessage(getColorCode(), getName(), player.getName());
|
||||
player.sendMessage(m);
|
||||
sendMessage(null, m, null, true, "system");
|
||||
sendSystemMessage(m, true, "system");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -365,7 +375,7 @@ public abstract class Channel {
|
||||
* @param source 連携元を判別する文字列
|
||||
* @param message メッセージ
|
||||
*/
|
||||
public void chatFromOtherSource(String player, String source, String message) {
|
||||
public void chatFromOtherSource(String player, @Nullable String source, String message) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
@@ -388,9 +398,7 @@ public abstract class Channel {
|
||||
}
|
||||
|
||||
// キーワード置き換え
|
||||
String msgFormat = replaceKeywordsForSystemMessages(getFormat(), name);
|
||||
msgFormat = msgFormat.replace("%prefix", "");
|
||||
msgFormat = msgFormat.replace("%suffix", "");
|
||||
ClickableFormat msgFormat = ClickableFormat.makeFormat(getFormat(), new ChannelMemberOther(name), this, false);
|
||||
|
||||
// カラーコード置き換え チャンネルで許可されている場合に置き換える。
|
||||
if ( isAllowCC() ) {
|
||||
@@ -399,7 +407,7 @@ public abstract class Channel {
|
||||
|
||||
// メッセージの送信
|
||||
boolean sendDynmap = source == null || !source.equals("web");
|
||||
sendMessage(null, maskedMessage, msgFormat, sendDynmap, name);
|
||||
sendMessage(new ChannelMemberOther(name), maskedMessage, msgFormat, sendDynmap);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -409,12 +417,69 @@ public abstract class Channel {
|
||||
* @param name 発言者の表示名
|
||||
*/
|
||||
public void sendSystemMessage(String message, boolean sendDynmap, String name) {
|
||||
sendMessage(null, message, null, sendDynmap, name);
|
||||
sendSystemMessage(TextComponent.fromLegacyText(message), sendDynmap, name);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルにシステムメッセージを送信する。
|
||||
* @param message メッセージ
|
||||
* @param sendDynmap Dynmapにも表示するかどうか
|
||||
* @param name 発言者の表示名
|
||||
*/
|
||||
public void sendSystemMessage(BaseComponent[] message, boolean sendDynmap, String name) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getConfig();
|
||||
|
||||
// 受信者(=メンバー全員からhideしているプレイヤーを除く)
|
||||
List<ChannelMember> recipients = new ArrayList<>(getMembers());
|
||||
for ( ChannelMember cp : getHided() ) {
|
||||
if ( recipients.contains(cp) ) {
|
||||
recipients.remove(cp);
|
||||
}
|
||||
}
|
||||
|
||||
// opListenAllChannel 設定がある場合は、
|
||||
// パーミッション lunachat-admin.listen-all-channels を持つプレイヤーを
|
||||
// 受信者に加える。
|
||||
if ( config.isOpListenAllChannel() ) {
|
||||
for ( String playerName : LunaChat.getPlugin().getOnlinePlayerNames() ) {
|
||||
ChannelMember cp = ChannelMember.getChannelMember(playerName);
|
||||
if ( cp != null
|
||||
&& cp.hasPermission("lunachat-admin.listen-all-channels")
|
||||
&& !recipients.contains(cp) ) {
|
||||
recipients.add(cp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 通常ブロードキャストなら、設定に応じてdynmapへ送信する
|
||||
DynmapBridge dynmap = LunaChatBukkit.getInstance().getDynmap();
|
||||
if ( config.isSendBroadcastChannelChatToDynmap() &&
|
||||
sendDynmap &&
|
||||
dynmap != null &&
|
||||
isBroadcastChannel() &&
|
||||
!isWorldRange() ) {
|
||||
|
||||
dynmap.broadcast(makeLegacyText(message));
|
||||
}
|
||||
|
||||
// 送信する
|
||||
for ( ChannelMember p : recipients ) {
|
||||
p.sendMessage(message);
|
||||
}
|
||||
|
||||
// 設定に応じて、コンソールに出力する
|
||||
if ( config.isDisplayChatOnConsole() ) {
|
||||
LunaChat.getPlugin().log(Level.INFO, makePlainText(message));
|
||||
}
|
||||
|
||||
// ロギング
|
||||
log(makePlainText(message), name);
|
||||
}
|
||||
|
||||
/**
|
||||
* メンバーを追加する
|
||||
* @param name 追加するプレイヤー
|
||||
* @param player 追加するプレイヤー
|
||||
*/
|
||||
public void addMember(ChannelMember player) {
|
||||
|
||||
@@ -448,7 +513,7 @@ public abstract class Channel {
|
||||
|
||||
/**
|
||||
* メンバーを削除する
|
||||
* @param name 削除するプレイヤー
|
||||
* @param player 削除するプレイヤー
|
||||
*/
|
||||
public void removeMember(ChannelMember player) {
|
||||
|
||||
@@ -548,22 +613,30 @@ public abstract class Channel {
|
||||
|
||||
/**
|
||||
* メッセージを表示します。指定したプレイヤーの発言として処理されます。
|
||||
* @param player プレイヤー(ワールドチャット、範囲チャットの場合は必須です)
|
||||
* @param member 発言者(ワールドチャット、範囲チャットの場合は必須です)
|
||||
* @param message メッセージ
|
||||
* @param format フォーマット
|
||||
* @param sendDynmap dynmapへ送信するかどうか
|
||||
* @param displayName 発言者の表示名(APIに使用されます)
|
||||
*/
|
||||
protected abstract void sendMessage(
|
||||
ChannelMember player, String message, String format, boolean sendDynmap, String displayName);
|
||||
ChannelMember member, String message, @Nullable ClickableFormat format, boolean sendDynmap);
|
||||
|
||||
/**
|
||||
* ログを記録する
|
||||
* @param name 発言者
|
||||
* @param message 記録するメッセージ
|
||||
*/
|
||||
protected abstract void log(String message, String name);
|
||||
|
||||
/**
|
||||
* チャットフォーマット内のキーワードを置き換えする
|
||||
* @param format チャットフォーマット
|
||||
* @param player プレイヤー
|
||||
* @param member プレイヤー
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
protected abstract String replaceKeywords(String format, ChannelMember player);
|
||||
protected ClickableFormat replaceKeywords(String format, ChannelMember member) {
|
||||
return ClickableFormat.makeFormat(format, member, this, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネル情報を返す
|
||||
@@ -576,7 +649,7 @@ public abstract class Channel {
|
||||
info.add(Messages.channelInfoFirstLine());
|
||||
|
||||
// チャンネル名、参加人数、総人数、チャンネル説明文
|
||||
info.add(Messages.listFormat(getName(), getOnlineNum(), getTotalNum(), getDescription()));
|
||||
info.add(makeLegacyText(Messages.listFormat(getName(), getOnlineNum(), getTotalNum(), getDescription())));
|
||||
|
||||
// チャンネル別名
|
||||
String alias = getAlias();
|
||||
@@ -709,14 +782,14 @@ public abstract class Channel {
|
||||
save();
|
||||
|
||||
// メッセージ通知を流す
|
||||
String msg = Messages.expiredBanMessage(getColorCode(), getName(), cp.getName());
|
||||
if ( !msg.isEmpty() ) {
|
||||
sendMessage(null, msg, null, false, "system");
|
||||
BaseComponent[] msg = Messages.expiredBanMessage(getColorCode(), getName(), cp.getName());
|
||||
if ( msg.length > 0 ) {
|
||||
sendSystemMessage(msg, true, "system");
|
||||
}
|
||||
|
||||
msg = Messages.cmdmsgPardoned(getName());
|
||||
if ( cp.isOnline() && !msg.isEmpty() ) {
|
||||
cp.sendMessage(msg);
|
||||
String pardonedMsg = Messages.cmdmsgPardoned(getName());
|
||||
if ( cp.isOnline() && !pardonedMsg.isEmpty() ) {
|
||||
cp.sendMessage(pardonedMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -733,14 +806,14 @@ public abstract class Channel {
|
||||
save();
|
||||
|
||||
// メッセージ通知を流す
|
||||
String msg = Messages.expiredMuteMessage(getColorCode(), getName(), cp.getName());
|
||||
if ( !msg.isEmpty() ) {
|
||||
sendMessage(null, msg, null, false, "system");
|
||||
BaseComponent[] msg = Messages.expiredMuteMessage(getColorCode(), getName(), cp.getName());
|
||||
if ( msg.length > 0 ) {
|
||||
sendSystemMessage(msg, true, "system");
|
||||
}
|
||||
|
||||
msg = Messages.cmdmsgUnmuted(getName());
|
||||
if ( cp.isOnline() && !msg.isEmpty() ) {
|
||||
cp.sendMessage(msg);
|
||||
String unmutedMsg = Messages.cmdmsgUnmuted(getName());
|
||||
if ( cp.isOnline() && !unmutedMsg.isEmpty() ) {
|
||||
cp.sendMessage(unmutedMsg);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1051,7 +1124,7 @@ public abstract class Channel {
|
||||
|
||||
/**
|
||||
* 1:1チャットのときに、会話の相手先を設定する
|
||||
* @param name 会話の相手のプレイヤー名
|
||||
* @param to 会話の相手のプレイヤー名
|
||||
*/
|
||||
public void setPrivateMessageTo(ChannelMember to) {
|
||||
this.privateMessageTo = to;
|
||||
@@ -1196,23 +1269,6 @@ public abstract class Channel {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットフォーマット内のキーワードを置き換えする
|
||||
* @param format チャットフォーマット
|
||||
* @param playerName プレイヤー名
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
private String replaceKeywordsForSystemMessages(String format, String playerName) {
|
||||
|
||||
String msg = format;
|
||||
msg = msg.replace("%ch", getName());
|
||||
msg = msg.replace("%color", getColorCode());
|
||||
msg = msg.replace("%username", playerName);
|
||||
msg = msg.replace("%player", playerName);
|
||||
|
||||
return Utility.replaceColorCode(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* List<ChannelMember>を、List<String>に変換する。
|
||||
* @param org 変換元
|
||||
@@ -1324,4 +1380,20 @@ public abstract class Channel {
|
||||
}
|
||||
return (Map<String, Long>)obj;
|
||||
}
|
||||
|
||||
private static String makeLegacyText(BaseComponent[] comps) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for ( BaseComponent comp : comps ) {
|
||||
builder.append(comp.toLegacyText());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private static String makePlainText(BaseComponent[] comps) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for ( BaseComponent comp : comps ) {
|
||||
builder.append(comp.toPlainText());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
|
||||
/**
|
||||
* Japanize2行表示のときに、変換結果を遅延してチャンネルに表示するためのタスク
|
||||
@@ -16,7 +17,7 @@ public class ChannelChatJapanizeTask implements Runnable {
|
||||
|
||||
private Channel channel;
|
||||
private ChannelMember player;
|
||||
private String lineFormat;
|
||||
private ClickableFormat lineFormat;
|
||||
|
||||
private JapanizeConvertTask task;
|
||||
|
||||
@@ -27,10 +28,10 @@ public class ChannelChatJapanizeTask implements Runnable {
|
||||
* @param channel 変換後に発言する、発言先チャンネル
|
||||
* @param player 発言したプレイヤー
|
||||
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
|
||||
* @param lineFormat
|
||||
* @param lineFormat チャンネルのフォーマット
|
||||
*/
|
||||
public ChannelChatJapanizeTask(String org, JapanizeType type, Channel channel,
|
||||
ChannelMember player, String japanizeFormat, String lineFormat) {
|
||||
ChannelMember player, String japanizeFormat, ClickableFormat lineFormat) {
|
||||
|
||||
task = new JapanizeConvertTask(org, type, japanizeFormat, channel, player);
|
||||
this.channel = channel;
|
||||
@@ -45,8 +46,7 @@ public class ChannelChatJapanizeTask implements Runnable {
|
||||
public void run() {
|
||||
if ( task.runSync() ) {
|
||||
// チャンネルへ送信
|
||||
String name = (player != null) ? player.getDisplayName() : "";
|
||||
channel.sendMessage(player, task.getResult(), lineFormat, true, name);
|
||||
channel.sendMessage(player, task.getResult(), lineFormat, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -412,8 +412,9 @@ public class ChannelManager implements LunaChatAPI {
|
||||
channel = new BukkitChannel(name);
|
||||
} else if ( LunaChat.getMode() == LunaChatMode.BUNGEE ) {
|
||||
channel = new BungeeChannel(name);
|
||||
} else {
|
||||
channel = new StandaloneChannel(name);
|
||||
}
|
||||
// TODO Standalone のチャンネル作成
|
||||
|
||||
channels.put(name.toLowerCase(), channel);
|
||||
channel.save();
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class StandaloneChannel extends Channel {
|
||||
|
||||
public StandaloneChannel(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void sendMessage(ChannelMember member, String message,
|
||||
@Nullable ClickableFormat format, boolean sendDynmap) {
|
||||
|
||||
// デバッグ表示メッセージ
|
||||
System.out.println(String.format("room=%s, member=%s, format=%s, message=%s",
|
||||
getName(), member.toString(), format, message));
|
||||
|
||||
// TODO チャンネルのメンバーに送信
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void log(String message, String name) {
|
||||
|
||||
// デバッグ表示メッセージ
|
||||
System.out.println(String.format("room=%s, name=%s, message=%s",
|
||||
getName(), name, message));
|
||||
|
||||
// TODO ログファイルを出力
|
||||
}
|
||||
}
|
||||
@@ -14,6 +14,9 @@ import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.util.ChatColor;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
/**
|
||||
* listコマンドの実行クラス
|
||||
* @author ucchy
|
||||
@@ -79,14 +82,13 @@ public class ListCommand extends LunaChatSubCommand {
|
||||
public boolean runCommand(
|
||||
ChannelMember sender, String label, String[] args) {
|
||||
|
||||
int page = 0;
|
||||
int page = 1;
|
||||
if ( args.length >= 2 && args[1].matches("[0-9]") ) {
|
||||
page = Integer.parseInt(args[1]);
|
||||
}
|
||||
|
||||
// リストを取得して表示する
|
||||
ArrayList<String> list = getList(sender, page);
|
||||
for (String msg : list) {
|
||||
for (BaseComponent[] msg : getList(sender, page)) {
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
return true;
|
||||
@@ -98,25 +100,25 @@ public class ListCommand extends LunaChatSubCommand {
|
||||
* @param page 表示するページ、0を指定した場合は全表示
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getList(ChannelMember player, int page) {
|
||||
private ArrayList<BaseComponent[]> getList(ChannelMember player, int page) {
|
||||
|
||||
ArrayList<String> list = getPlayerList(player);
|
||||
ArrayList<BaseComponent[]> list = getPlayerList(player);
|
||||
int size = list.size();
|
||||
int maxPage = (int)(size / PAGE_SIZE) + 1;
|
||||
|
||||
if ( page < 0 ) page = 0;
|
||||
if ( page > maxPage ) page = maxPage;
|
||||
|
||||
ArrayList<String> items = new ArrayList<>();
|
||||
ArrayList<BaseComponent[]> items = new ArrayList<>();
|
||||
if ( page == 0 ) { // 全表示
|
||||
items.add(Messages.listFirstLine());
|
||||
items.add(TextComponent.fromLegacyText(Messages.listFirstLine()));
|
||||
items.addAll(list);
|
||||
items.add(Messages.listEndLine());
|
||||
items.add(TextComponent.fromLegacyText(Messages.listEndLine()));
|
||||
} else { // ページ表示
|
||||
items.add(Messages.listFirstLinePaging(page, maxPage));
|
||||
items.add(TextComponent.fromLegacyText(Messages.listFirstLinePaging(page, maxPage)));
|
||||
int endIndex = (page * PAGE_SIZE > size) ? size : page * PAGE_SIZE;
|
||||
items.addAll(list.subList((page - 1) * PAGE_SIZE, endIndex));
|
||||
items.add(Messages.listEndLine());
|
||||
items.add(TextComponent.fromLegacyText(Messages.listEndLine()));
|
||||
}
|
||||
|
||||
return items;
|
||||
@@ -127,9 +129,8 @@ public class ListCommand extends LunaChatSubCommand {
|
||||
* @param player プレイヤー
|
||||
* @return チャンネルリスト
|
||||
*/
|
||||
private ArrayList<String> getPlayerList(ChannelMember player) {
|
||||
private ArrayList<BaseComponent[]> getPlayerList(ChannelMember player) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
String dchannel = "";
|
||||
String playerName = "";
|
||||
if ( player != null ) {
|
||||
@@ -142,15 +143,17 @@ public class ListCommand extends LunaChatSubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
// チャンネルを取得して、チャンネル名でソートする
|
||||
// チャンネルを取得して、参加人数でソートする
|
||||
ArrayList<Channel> channels = new ArrayList<>(api.getChannels());
|
||||
Collections.sort(channels, new Comparator<Channel>() {
|
||||
public int compare(Channel c1, Channel c2) {
|
||||
return c1.getName().compareTo(c2.getName());
|
||||
if ( c1.getOnlineNum() == c2.getOnlineNum() ) return c1.getName().compareTo(c2.getName());
|
||||
return c2.getOnlineNum() - c1.getOnlineNum();
|
||||
}
|
||||
});
|
||||
|
||||
// 指定されたプレイヤー名に合うように、フィルタ&表示用整形する。
|
||||
ArrayList<BaseComponent[]> items = new ArrayList<>();
|
||||
for ( Channel channel : channels ) {
|
||||
|
||||
// BANされているチャンネルは表示しない
|
||||
@@ -183,8 +186,7 @@ public class ListCommand extends LunaChatSubCommand {
|
||||
String desc = channel.getDescription();
|
||||
int onlineNum = channel.getOnlineNum();
|
||||
int memberNum = channel.getTotalNum();
|
||||
String item = Messages.listFormat(disp, onlineNum, memberNum, desc);
|
||||
items.add(item);
|
||||
items.add(Messages.listFormat(disp, onlineNum, memberNum, desc));
|
||||
}
|
||||
|
||||
return items;
|
||||
|
||||
@@ -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 パーミッションノード
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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が返される
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.github.ucchyocean.lc3.member;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
public class ChannelMemberOther extends ChannelMember {
|
||||
|
||||
private String name;
|
||||
private String displayName;
|
||||
|
||||
public ChannelMemberOther(String name) {
|
||||
this.name = name;
|
||||
this.displayName = name;
|
||||
}
|
||||
|
||||
public ChannelMemberOther(String name, String displayName) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent[] message) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s:{name=%s, displayName=%s}",
|
||||
this.getClass().toString(), name, displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chat(String message) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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));
|
||||
|
||||
@@ -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;
|
||||
@@ -128,11 +129,11 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee {
|
||||
|
||||
LuckPermsBridge luckperms = LunaChatBungee.getInstance().getLuckPerms();
|
||||
if ( luckperms != null ) {
|
||||
return luckperms.getPlayerPrefix(id);
|
||||
return luckperms.getPlayerSuffix(id);
|
||||
}
|
||||
BungeePermsBridge bungeeperms = LunaChatBungee.getInstance().getBungeePerms();
|
||||
if ( bungeeperms != null ) {
|
||||
return bungeeperms.userPrefix(id.toString(), null, null);
|
||||
return bungeeperms.userSuffix(id.toString(), null, null);
|
||||
}
|
||||
return "";
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
package com.github.ucchyocean.lc3.member;
|
||||
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
public class ChannelMemberSystem extends ChannelMember {
|
||||
|
||||
private static final String NAME = "system";
|
||||
private static final ChannelMember instance = new ChannelMemberSystem();
|
||||
|
||||
@Override
|
||||
public boolean isOnline() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String message) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(BaseComponent[] message) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(String node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return NAME;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPermissionSet(String node) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chat(String message) {
|
||||
// do nothing.
|
||||
}
|
||||
|
||||
public static ChannelMember getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
@@ -30,6 +30,18 @@ public class MessageParser {
|
||||
private static final String START_MARKER = " // === Auto-generated methods area start. ===";
|
||||
private static final String END_MARKER = " // === Auto-generated methods area end. ===";
|
||||
|
||||
private static final List<String> CLICKABLE_MESSAGES;
|
||||
static {
|
||||
CLICKABLE_MESSAGES = new ArrayList<>();
|
||||
for ( String s : new String[] {
|
||||
"joinMessage", "quitMessage", "banMessage", "kickMessage",
|
||||
"muteMessage", "banNGWordMessage", "kickNGWordMessage", "muteNGWordMessage", "banWithExpireMessage",
|
||||
"muteWithExpireMessage", "pardonMessage", "unmuteMessage", "expiredBanMessage", "expiredMuteMessage",
|
||||
"addModeratorMessage", "removeModeratorMessage", "noRecipientMessage", "listFormat", } ) {
|
||||
CLICKABLE_MESSAGES.add(s);
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
// 自動生成メソッドを作成する
|
||||
@@ -99,30 +111,53 @@ public class MessageParser {
|
||||
}
|
||||
|
||||
// 出力
|
||||
result.add("");
|
||||
result.add(" /**");
|
||||
result.add(" * " + value);
|
||||
result.add(" */");
|
||||
result.add(String.format(
|
||||
" public static String %s(%s) {", key, arguments));
|
||||
result.add(String.format(
|
||||
" String msg = resources.getString(\"%s\");", key));
|
||||
result.add(String.format(
|
||||
" if ( msg == null ) return \"\";", key));
|
||||
result.add(" KeywordReplacer kr = new KeywordReplacer(msg);");
|
||||
|
||||
for ( String keyword : keywords ) {
|
||||
if ( !CLICKABLE_MESSAGES.contains(key) ) {
|
||||
result.add("");
|
||||
result.add(" /**");
|
||||
result.add(" * " + value);
|
||||
result.add(" */");
|
||||
result.add(String.format(
|
||||
" kr.replace(\"%%%s%%\", %s.toString());", keyword, keyword));
|
||||
}
|
||||
if ( key.startsWith("errmsg") ) {
|
||||
result.add(" return Utility.replaceColorCode(resources.getString(\"errorPrefix\", \"\") + kr.toString());");
|
||||
} else if ( key.startsWith("cmdmsg") ) {
|
||||
result.add(" return Utility.replaceColorCode(resources.getString(\"infoPrefix\", \"\") + kr.toString());");
|
||||
" public static String %s(%s) {", key, arguments));
|
||||
result.add(String.format(
|
||||
" String msg = resources.getString(\"%s\");", key));
|
||||
result.add(String.format(
|
||||
" if ( msg == null ) return \"\";", key));
|
||||
result.add(" KeywordReplacer kr = new KeywordReplacer(msg);");
|
||||
|
||||
for ( String keyword : keywords ) {
|
||||
result.add(String.format(
|
||||
" kr.replace(\"%%%s%%\", %s.toString());", keyword, keyword));
|
||||
}
|
||||
if ( key.startsWith("errmsg") ) {
|
||||
result.add(" return Utility.replaceColorCode(resources.getString(\"errorPrefix\", \"\") + kr.toString());");
|
||||
} else if ( key.startsWith("cmdmsg") ) {
|
||||
result.add(" return Utility.replaceColorCode(resources.getString(\"infoPrefix\", \"\") + kr.toString());");
|
||||
} else {
|
||||
result.add(" return Utility.replaceColorCode(kr.toString());");
|
||||
}
|
||||
result.add(" }");
|
||||
} else {
|
||||
result.add(" return Utility.replaceColorCode(kr.toString());");
|
||||
result.add("");
|
||||
result.add(" /**");
|
||||
result.add(" * " + value);
|
||||
result.add(" */");
|
||||
result.add(String.format(
|
||||
" public static BaseComponent[] %s(%s) {", key, arguments));
|
||||
result.add(String.format(
|
||||
" String msg = resources.getString(\"%s\");", key));
|
||||
result.add(String.format(
|
||||
" if ( msg == null ) return new BaseComponent[0];", key));
|
||||
result.add(" ClickableFormat cf = ClickableFormat.makeChannelClickableMessage(msg, channel.toString());");
|
||||
|
||||
for ( String keyword : keywords ) {
|
||||
if ( keyword.equals("%channel%") ) continue;
|
||||
result.add(String.format(
|
||||
" cf.replace(\"%%%s%%\", %s.toString());", keyword, keyword));
|
||||
}
|
||||
result.add(" return cf.makeTextComponent();");
|
||||
result.add(" }");
|
||||
|
||||
}
|
||||
result.add(" }");
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -0,0 +1,254 @@
|
||||
/*
|
||||
* @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.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 ClickableFormat {
|
||||
|
||||
private static final String JOIN_COMMAND_TEMPLATE = "/lunachat join %s";
|
||||
private static final String TELL_COMMAND_TEMPLATE = "/tell %s";
|
||||
|
||||
private static final String PLACEHOLDER_RUN_COMMAND =
|
||||
"<type=RUN_COMMAND text=\"%s\" hover=\"%s\" command=\"%s\">";
|
||||
private static final String PLACEHOLDER_SUGGEST_COMMAND =
|
||||
"<type=SUGGEST_COMMAND text=\"%s\" hover=\"%s\" command=\"%s\">";
|
||||
private static final String PLACEHOLDER_PATTERN =
|
||||
"<type=(SUGGEST_COMMAND|RUN_COMMAND) text=\"([^\"]*)\" hover=\"([^\"]*)\" command=\"([^\"]*)\">";
|
||||
|
||||
private KeywordReplacer message;
|
||||
|
||||
private ClickableFormat(KeywordReplacer message) {
|
||||
this.message = message;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットフォーマット内のキーワードを置き換えする
|
||||
* @param format チャットフォーマット
|
||||
* @param member 発言者
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
public static ClickableFormat makeFormat(String format, @Nullable ChannelMember member) {
|
||||
return makeFormat(format, member, null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットフォーマット内のキーワードを置き換えする
|
||||
* @param format チャットフォーマット
|
||||
* @param member 発言者
|
||||
* @param channel チャンネル
|
||||
* @param withPlayerLink プレイヤー名の箇所にクリック可能なプレースホルダーを挿入するか
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
public static ClickableFormat makeFormat(String format,
|
||||
@Nullable ChannelMember member, @Nullable Channel channel, boolean withPlayerLink) {
|
||||
|
||||
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd");
|
||||
SimpleDateFormat timeFormat = new SimpleDateFormat("HH:mm:ss");
|
||||
|
||||
LunaChatAPI api = LunaChat.getAPI();
|
||||
|
||||
KeywordReplacer msg = new KeywordReplacer(format);
|
||||
|
||||
//msg.replace("%msg", message);
|
||||
|
||||
if ( channel != null ) {
|
||||
|
||||
// テンプレートのキーワードを、まず最初に置き換える
|
||||
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(
|
||||
PLACEHOLDER_RUN_COMMAND,
|
||||
channel.getName(),
|
||||
Messages.hoverChannelName(channel.getName()),
|
||||
String.format(JOIN_COMMAND_TEMPLATE, channel.getName())));
|
||||
msg.replace("%color", channel.getColorCode());
|
||||
if ( channel.getPrivateMessageTo() != null ) {
|
||||
msg.replace("%to", String.format(
|
||||
PLACEHOLDER_SUGGEST_COMMAND,
|
||||
channel.getPrivateMessageTo().getDisplayName(),
|
||||
Messages.hoverPlayerName(channel.getPrivateMessageTo().getName()),
|
||||
String.format(TELL_COMMAND_TEMPLATE, channel.getPrivateMessageTo().getName())));
|
||||
msg.replace("%recieverserver", channel.getPrivateMessageTo().getServerName());
|
||||
}
|
||||
}
|
||||
|
||||
if ( msg.contains("%date") ) {
|
||||
msg.replace("%date", dateFormat.format(new Date()));
|
||||
}
|
||||
if ( msg.contains("%time") ) {
|
||||
msg.replace("%time", timeFormat.format(new Date()));
|
||||
}
|
||||
|
||||
if ( member != null ) {
|
||||
|
||||
// ChannelMember関連のキーワード置き換え
|
||||
if ( withPlayerLink ) {
|
||||
String playerPMPlaceHolder = String.format(
|
||||
PLACEHOLDER_SUGGEST_COMMAND,
|
||||
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(
|
||||
PLACEHOLDER_SUGGEST_COMMAND,
|
||||
member.getName(),
|
||||
Messages.hoverPlayerName(member.getName()),
|
||||
String.format(TELL_COMMAND_TEMPLATE, member.getName())));
|
||||
} else {
|
||||
msg.replace("%displayname", member.getDisplayName());
|
||||
msg.replace("%username", member.getDisplayName());
|
||||
msg.replace("%player", 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());
|
||||
}
|
||||
|
||||
return new ClickableFormat(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットのメッセージ用のフォーマットを置き換えする
|
||||
* @param format フォーマット
|
||||
* @param channelName チャンネル名
|
||||
* @return 置き換え結果
|
||||
*/
|
||||
public static ClickableFormat makeChannelClickableMessage(String format, String channelName) {
|
||||
|
||||
KeywordReplacer msg = new KeywordReplacer(format);
|
||||
String stripped = Utility.stripColorCode(channelName);
|
||||
msg.replace("%channel%", String.format(
|
||||
PLACEHOLDER_RUN_COMMAND,
|
||||
channelName,
|
||||
Messages.hoverChannelName(stripped),
|
||||
String.format(JOIN_COMMAND_TEMPLATE, stripped)));
|
||||
|
||||
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() {
|
||||
|
||||
message.translateColorCode();
|
||||
|
||||
List<BaseComponent> components = new ArrayList<>();
|
||||
Matcher matcher = Pattern.compile(PLACEHOLDER_PATTERN).matcher(message.getStringBuilder());
|
||||
int lastIndex = 0;
|
||||
|
||||
while ( matcher.find() ) {
|
||||
|
||||
// マッチする箇所までの文字列を取得する
|
||||
if ( lastIndex < matcher.start() ) {
|
||||
for ( BaseComponent c : TextComponent.fromLegacyText(message.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 { // type.equals("SUGGEST_COMMAND")
|
||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
|
||||
}
|
||||
components.add(tc);
|
||||
|
||||
lastIndex = matcher.end();
|
||||
}
|
||||
|
||||
if ( lastIndex < message.length() - 1 ) {
|
||||
// 残りの部分の文字列を取得する
|
||||
for ( BaseComponent c : TextComponent.fromLegacyText(message.substring(lastIndex)) ) {
|
||||
components.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
BaseComponent[] result = new BaseComponent[components.size()];
|
||||
components.toArray(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
public String toLegacyText() {
|
||||
|
||||
StringBuilder msg = new StringBuilder(message.toString());
|
||||
Matcher matcher = Pattern.compile(PLACEHOLDER_PATTERN).matcher(msg);
|
||||
|
||||
while ( matcher.find(0) ) {
|
||||
String text = matcher.group(2);
|
||||
msg.replace(matcher.start(), matcher.end(), text);
|
||||
}
|
||||
|
||||
return msg.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return message.toString();
|
||||
}
|
||||
|
||||
public void replace(String keyword, String value) {
|
||||
message.replace(keyword, value);
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,8 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.util;
|
||||
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 文字列のキーワード置き換えを行うユーティリティクラス
|
||||
* @author ucchy
|
||||
@@ -22,7 +24,7 @@ public class KeywordReplacer {
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列keywordえを、文字列valueに置き替える
|
||||
* 文字列keywordを、文字列valueに置き換える
|
||||
* @param keyword キーワード
|
||||
* @param value 値
|
||||
*/
|
||||
@@ -33,6 +35,22 @@ public class KeywordReplacer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 正規表現regexに一致する箇所を、文字列valueに置き換える
|
||||
* @param regex 正規表現
|
||||
* @param value 値
|
||||
*/
|
||||
public void replaceRegex(String regex, String value) {
|
||||
str = new StringBuilder(Pattern.compile(regex).matcher(str).replaceAll(value));
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列内のカラーコード候補(&a)を、カラーコード(§a)に置き換えする
|
||||
*/
|
||||
public void translateColorCode() {
|
||||
str = new StringBuilder(Utility.replaceColorCode(str.toString()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された文字列が含まれているかどうかを判定する
|
||||
* @param keyword キーワード
|
||||
@@ -51,4 +69,24 @@ public class KeywordReplacer {
|
||||
public String toString() {
|
||||
return str.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列をStringBuilderのまま取得する
|
||||
* @return StringBuilder
|
||||
*/
|
||||
public StringBuilder getStringBuilder() {
|
||||
return str;
|
||||
}
|
||||
|
||||
public String substring(int start) {
|
||||
return str.substring(start);
|
||||
}
|
||||
|
||||
public String substring(int start, int end) {
|
||||
return str.substring(start, end);
|
||||
}
|
||||
|
||||
public int length() {
|
||||
return str.length();
|
||||
}
|
||||
}
|
||||
@@ -19,6 +19,7 @@ import java.util.zip.ZipEntry;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatMode;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
/**
|
||||
* ユーティリティクラス
|
||||
@@ -41,34 +42,46 @@ public class Utility {
|
||||
parent.mkdirs();
|
||||
}
|
||||
|
||||
try ( JarFile jar = new JarFile(jarFile) ) {
|
||||
ZipEntry zipEntry = jar.getEntry(sourceFilePath);
|
||||
InputStream is = jar.getInputStream(zipEntry);
|
||||
if ( jarFile.isDirectory() ) {
|
||||
File file = new File(jarFile, sourceFilePath);
|
||||
|
||||
try ( FileOutputStream fos = new FileOutputStream(targetFile) ) {
|
||||
try {
|
||||
Files.copy(file, targetFile);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (isBinary) {
|
||||
byte[] buf = new byte[8192];
|
||||
int len;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
fos.write(buf, 0, len);
|
||||
}
|
||||
} else {
|
||||
|
||||
} else {
|
||||
try ( JarFile jar = new JarFile(jarFile) ) {
|
||||
ZipEntry zipEntry = jar.getEntry(sourceFilePath);
|
||||
InputStream is = jar.getInputStream(zipEntry);
|
||||
|
||||
try ( BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8")) ) {
|
||||
try ( FileOutputStream fos = new FileOutputStream(targetFile) ) {
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
writer.write(line);
|
||||
writer.newLine();
|
||||
if (isBinary) {
|
||||
byte[] buf = new byte[8192];
|
||||
int len;
|
||||
while ((len = is.read(buf)) != -1) {
|
||||
fos.write(buf, 0, len);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
try ( BufferedReader reader = new BufferedReader(new InputStreamReader(is, "UTF-8"));
|
||||
BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(fos, "UTF-8")) ) {
|
||||
|
||||
String line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
writer.write(line);
|
||||
writer.newLine();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -109,7 +122,7 @@ public class Utility {
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列に含まれているカラーコード候補(&a)を除去して返す
|
||||
* 文字列に含まれているカラーコード候補(&aや#99AABB)を除去して返す
|
||||
* @param source 置き換え元の文字列
|
||||
* @return 置き換え後の文字列
|
||||
*/
|
||||
@@ -130,7 +143,7 @@ public class Utility {
|
||||
}
|
||||
|
||||
/**
|
||||
* カラーコード候補(&a)かどうかを判断する
|
||||
* カラーコード候補(&aや#99AABB)かどうかを判断する
|
||||
* @param color カラーコード候補
|
||||
* @return カラーコード候補かどうか
|
||||
*/
|
||||
|
||||
@@ -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 --------------------
|
||||
@@ -147,14 +147,14 @@ ngword: []
|
||||
ngwordAction: mask
|
||||
|
||||
|
||||
# -------------------- Chat decoration settings --------------------
|
||||
# -------------------- Normal chat settings --------------------
|
||||
|
||||
# Whether to decorate normal chat (non-channel chat) from LunaChat.
|
||||
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,13 +163,19 @@ 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.
|
||||
enableNormalChatColorCode: true
|
||||
|
||||
# Whether normal chat (non-channel chat) is clickable.
|
||||
# If it is clickable, you can click the player name to send a private message,
|
||||
# but plugin will cancel the normal chat and send another clickable message,
|
||||
# so you may not use other chat related plugins.
|
||||
# Note that channel chats are always clickable, regardless of this setting.
|
||||
enableNormalChatClickable: false
|
||||
|
||||
|
||||
# -------------------- Japanize conversion settings --------------------
|
||||
|
||||
@@ -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
|
||||
@@ -152,14 +152,14 @@ ngwordAction: mask
|
||||
|
||||
|
||||
|
||||
# -------------------- チャット装飾設定 --------------------
|
||||
# -------------------- 通常チャット設定 --------------------
|
||||
|
||||
# 通常チャット(非チャンネルチャット)の装飾を、LunaChatから行うかどうか。
|
||||
enableNormalChatMessageFormat: true
|
||||
|
||||
# チャット装飾のフォーマット設定。
|
||||
# フォーマット設定には、下記のキーワードが使用できます。
|
||||
# %username : 発言者表示名
|
||||
# %displayname : 発言者表示名
|
||||
# %player : 発言者ID
|
||||
# %world : 発言したワールド名(spigot側に導入したときに有効です。MultiVerseが導入されている場合は、ワールドの表示名を取得して使用します。)
|
||||
# %server : 発言者の接続サーバー名(BungeeCord側に導入したときに有効です。)
|
||||
@@ -168,13 +168,19 @@ 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に設定すると、カラーコードは変換されません。
|
||||
enableNormalChatColorCode: true
|
||||
|
||||
# 通常チャット(非チャンネルチャット)をクリック可能にするかどうか。
|
||||
# クリック可能にすると、プレイヤー名をクリックしてプライベートメッセージを送ることができるようになりますが、
|
||||
# 通常チャットをキャンセルしてクリック可能な別のメッセージを流すので、他のチャット関連プラグインとの連携が
|
||||
# うまくいかなくなる可能性があります。
|
||||
# なお、この設定に関係なく、チャンネルチャットは常にクリック可能です。
|
||||
enableNormalChatClickable: false
|
||||
|
||||
|
||||
# -------------------- Japanize変換設定 --------------------
|
||||
|
||||
@@ -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%'
|
||||
@@ -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%にプライベートメッセージを送る'
|
||||
@@ -0,0 +1,138 @@
|
||||
/*
|
||||
* @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) {
|
||||
for ( BaseComponent comp : message ) {
|
||||
System.out.print(comp.toLegacyText());
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
/**
|
||||
* @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.
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChatStandalone;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.channel.StandaloneChannel;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberDummy;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ClickableFormatTest extends TestCase {
|
||||
|
||||
private static final String DATA_FOLDER = "target" + File.separator + "LunaChatTest";
|
||||
private static final String MESSAGES_FOLDER = "target" + File.separator + "classes";
|
||||
|
||||
public void testChannelChatKeyword() {
|
||||
|
||||
File dataFolder = new File(DATA_FOLDER);
|
||||
System.out.println("dataFolder : " + dataFolder.getAbsolutePath());
|
||||
if ( !dataFolder.exists() ) {
|
||||
dataFolder.mkdirs();
|
||||
}
|
||||
|
||||
LunaChatStandalone lunachat = new LunaChatStandalone(dataFolder);
|
||||
lunachat.onEnable();
|
||||
|
||||
Messages.initialize(new File(MESSAGES_FOLDER), null, "ja");
|
||||
|
||||
String format = "&f[%color%ch&f]%prefix%displayname%suffix&a:&f %msg";
|
||||
ChannelMember member = new ChannelMemberDummy();
|
||||
Channel channel = new StandaloneChannel("r");
|
||||
|
||||
ClickableFormat f = ClickableFormat.makeFormat(format, member, channel, true);
|
||||
|
||||
System.out.println("pre = " + f.toString() + ", legacy text = " + f.toLegacyText());
|
||||
|
||||
BaseComponent[] comps = f.makeTextComponent();
|
||||
|
||||
System.out.println("post : comps len = " + comps.length + ", legacy text = " + makeLegacyText(comps));
|
||||
for ( BaseComponent comp : comps ) {
|
||||
System.out.println(comp.toString());
|
||||
}
|
||||
|
||||
// assertTrue(f.toLegacyText().equals(makeLegacyText(comps)));
|
||||
}
|
||||
|
||||
public void testEventChatKeyword() {
|
||||
|
||||
String format = "&f%prefix%displayname%suffix&a:&f %msg";
|
||||
ChannelMember member = new ChannelMemberDummy();
|
||||
|
||||
Messages.initialize(new File(MESSAGES_FOLDER), null, "ja");
|
||||
|
||||
ClickableFormat f = ClickableFormat.makeFormat(format, member);
|
||||
|
||||
System.out.println("pre = " + f.toString() + ", legacy text = " + f.toLegacyText());
|
||||
|
||||
BaseComponent[] comps = f.makeTextComponent();
|
||||
|
||||
System.out.println("post : comps len = " + comps.length + ", legacy text = " + makeLegacyText(comps));
|
||||
for ( BaseComponent comp : comps ) {
|
||||
System.out.println(comp.toString());
|
||||
}
|
||||
|
||||
// assertTrue(f.toLegacyText().equals(makeLegacyText(comps)));
|
||||
}
|
||||
|
||||
private static String makeLegacyText(BaseComponent[] comps) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for ( BaseComponent comp : comps ) {
|
||||
builder.append(comp.toLegacyText());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.util;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class KeywordReplacerTest extends TestCase {
|
||||
|
||||
private static final int MAX = 10;
|
||||
|
||||
public void test() {
|
||||
|
||||
String testee = "";
|
||||
for ( int i=1; i<=MAX; i++ ) {
|
||||
testee += String.format("%%test%d%%%d", i, i);
|
||||
}
|
||||
|
||||
|
||||
String test1 = new String(testee);
|
||||
long start = System.currentTimeMillis();
|
||||
for ( int i=1; i<=MAX; i++ ) {
|
||||
test1 = test1.replace("%test" + i + "%", i + "");
|
||||
}
|
||||
long time = System.currentTimeMillis() - start;
|
||||
System.out.println("test1 time = " + time);
|
||||
|
||||
|
||||
KeywordReplacer test2 = new KeywordReplacer(testee);
|
||||
start = System.currentTimeMillis();
|
||||
for ( int i=1; i<=MAX; i++ ) {
|
||||
test2.replace("%test" + i + "%", i + "");
|
||||
}
|
||||
time = System.currentTimeMillis() - start;
|
||||
System.out.println("test2 time = " + time);
|
||||
|
||||
assertTrue(test1.equals(test2.toString()));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -11,7 +11,7 @@ import junit.framework.TestCase;
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class UtilityTester extends TestCase {
|
||||
public class UtilityTest extends TestCase {
|
||||
|
||||
public void testColorCode() {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import junit.framework.TestCase;
|
||||
* YamlConfigのテスト
|
||||
* @author ucchy
|
||||
*/
|
||||
public class YamlConfigTester extends TestCase {
|
||||
public class YamlConfigTest extends TestCase {
|
||||
|
||||
public void testYamlConfig() {
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする