LunaChat v3-k2 : Added event mocks. (WIP)
このコミットが含まれているのは:
1 親
7abc57f9ac
コミット
75fe8a98ec
40ファイル変更
+3127
-2031
検索条件に一致するファイルはありません
@@ -0,0 +1,189 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.github.ucchyocean.lc3.bungee.BungeeEventListener;
|
||||
import com.github.ucchyocean.lc3.bungee.BungeeEventSender;
|
||||
import com.github.ucchyocean.lc3.bungee.JapanizeCommandBungee;
|
||||
import com.github.ucchyocean.lc3.bungee.LunaChatCommandBungee;
|
||||
import com.github.ucchyocean.lc3.bungee.MessageCommandBungee;
|
||||
import com.github.ucchyocean.lc3.bungee.ReplyCommandBungee;
|
||||
import com.github.ucchyocean.lc3.channel.ChannelManager;
|
||||
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
|
||||
/**
|
||||
* LunaChatのBungeeCord実装
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
|
||||
private static LunaChatBungee instance;
|
||||
|
||||
private HashMap<String, String> history;
|
||||
private LunaChatConfig config;
|
||||
private ChannelManager manager;
|
||||
private UUIDCacheData uuidCacheData;
|
||||
private LunaChatLogger normalChatLogger;
|
||||
|
||||
/**
|
||||
* プラグインが有効化されたときに呼び出されるメソッド
|
||||
* @see net.md_5.bungee.api.plugin.Plugin#onEnable()
|
||||
*/
|
||||
@Override
|
||||
public void onEnable() {
|
||||
|
||||
LunaChat.setPlugin(this);
|
||||
LunaChat.setMode(LunaChatMode.BUNGEE);
|
||||
|
||||
// 初期化
|
||||
config = new LunaChatConfig(getDataFolder(), getFile());
|
||||
uuidCacheData = new UUIDCacheData(getDataFolder());
|
||||
Messages.initialize(new File(getDataFolder(), "messages"), getFile(), config.getLang());
|
||||
history = new HashMap<String, String>();
|
||||
|
||||
manager = new ChannelManager();
|
||||
normalChatLogger = new LunaChatLogger("==normalchat");
|
||||
|
||||
// チャンネルチャット無効なら、デフォルト発言先をクリアする
|
||||
if ( !config.isEnableChannelChat() ) {
|
||||
manager.removeAllDefaultChannels();
|
||||
}
|
||||
|
||||
// コマンド登録
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new LunaChatCommandBungee("lunachat", "", "lc", "ch"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new MessageCommandBungee("tell", "", "msg", "message", "m", "t"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new ReplyCommandBungee("reply", "", "r"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new JapanizeCommandBungee("japanize", "", "jp"));
|
||||
|
||||
// リスナー登録
|
||||
getProxy().getPluginManager().registerListener(this, new BungeeEventListener(this));
|
||||
|
||||
// イベント実行クラスの登録
|
||||
LunaChat.setEventSender(new BungeeEventSender());
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatのインスタンスを返す
|
||||
* @return LunaChat
|
||||
*/
|
||||
public static LunaChatBungee getInstance() {
|
||||
if ( instance == null ) {
|
||||
instance = (LunaChatBungee)ProxyServer.getInstance().getPluginManager().getPlugin("LunaChat");
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* コンフィグを返す
|
||||
* @return コンフィグ
|
||||
*/
|
||||
public LunaChatConfig getConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* プライベートメッセージの受信履歴を記録する
|
||||
* @param reciever 受信者
|
||||
* @param sender 送信者
|
||||
*/
|
||||
protected void putHistory(String reciever, String sender) {
|
||||
history.put(reciever, sender);
|
||||
}
|
||||
|
||||
/**
|
||||
* プライベートメッセージの受信履歴を取得する
|
||||
* @param reciever 受信者
|
||||
* @return 送信者
|
||||
*/
|
||||
protected String getHistory(String reciever) {
|
||||
return history.get(reciever);
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのJarファイル自身を示すFileクラスを返す。
|
||||
* @return Jarファイル
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getPluginJarFile()
|
||||
*/
|
||||
@Override
|
||||
public File getPluginJarFile() {
|
||||
return getFile();
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatConfigを取得する
|
||||
* @return LunaChatConfig
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getLunaChatConfig()
|
||||
*/
|
||||
@Override
|
||||
public LunaChatConfig getLunaChatConfig() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/**
|
||||
* LunaChatAPIを取得する
|
||||
* @return LunaChatAPI
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getLunaChatAPI()
|
||||
*/
|
||||
@Override
|
||||
public LunaChatAPI getLunaChatAPI() {
|
||||
return manager;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャット用のロガーを返す
|
||||
* @return normalChatLogger
|
||||
*/
|
||||
@Override
|
||||
public LunaChatLogger getNormalChatLogger() {
|
||||
return normalChatLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
Set<String> list = new TreeSet<>();
|
||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() ) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのログを記録する
|
||||
* @param level ログレベル
|
||||
* @param msg ログメッセージ
|
||||
*/
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
getLogger().log(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* UUIDキャッシュデータを取得する
|
||||
* @return UUIDキャッシュデータ
|
||||
* @see com.github.ucchyocean.lc3.PluginInterface#getUUIDCacheData()
|
||||
*/
|
||||
@Override
|
||||
public UUIDCacheData getUUIDCacheData() {
|
||||
return uuidCacheData;
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする