LunaChat v3-k2 : BungeeCord implementation. (WIP)
このコミットが含まれているのは:
1 親
730d221442
コミット
e8b61c5a64
23ファイル変更
+780
-1183
検索条件に一致するファイルはありません
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* プラグインのメッセージリソース管理クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class Messages {
|
||||
|
||||
private static final String BASE_NAME = "messages";
|
||||
private static final String FILE_NAME = BASE_NAME + ".yml";
|
||||
|
||||
private static YamlConfig resources;
|
||||
|
||||
/**
|
||||
* 初期化する
|
||||
*/
|
||||
protected static void initialize() {
|
||||
|
||||
File file = new File(
|
||||
LunaChat.getDataFolder() +
|
||||
File.separator + FILE_NAME);
|
||||
|
||||
if ( !file.exists() ) {
|
||||
Utility.copyFileFromJar(LunaChat.getPluginJarFile(),
|
||||
file, FILE_NAME, false);
|
||||
}
|
||||
|
||||
resources = YamlConfig.load(file);
|
||||
resources.addDefaults(loadDefaultMessages());
|
||||
}
|
||||
|
||||
/**
|
||||
* リソースを取得する
|
||||
* @param key リソースキー
|
||||
* @return リソース
|
||||
*/
|
||||
public static String get(String key) {
|
||||
|
||||
if ( resources == null ) {
|
||||
initialize();
|
||||
}
|
||||
return Utility.replaceColorCode(resources.getString(key));
|
||||
}
|
||||
|
||||
/**
|
||||
* Jarファイル内から直接 messages.yml を読み込み、YamlConfigにして返すメソッド
|
||||
* @return
|
||||
*/
|
||||
private static YamlConfig loadDefaultMessages() {
|
||||
try {
|
||||
return YamlConfig.load(getResourceInputStream());
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Jarファイル内を検索して、現在のlanguageやcountryになるべく一致するリソースを見つけて、InputStreamで返す
|
||||
* @return InputStream
|
||||
*/
|
||||
private static InputStream getResourceInputStream() {
|
||||
|
||||
String baseName = BASE_NAME;
|
||||
Locale locale = Locale.getDefault();
|
||||
|
||||
ArrayList<String> candidates = new ArrayList<String>();
|
||||
candidates.add(String.format("/%s_%s_%s.yaml", baseName, locale.getLanguage(), locale.getCountry()));
|
||||
candidates.add(String.format("/%s_%s_%s.yml", baseName, locale.getLanguage(), locale.getCountry()));
|
||||
candidates.add(String.format("/%s_%s.yaml", baseName, locale.getLanguage()));
|
||||
candidates.add(String.format("/%s_%s.yml", baseName, locale.getLanguage()));
|
||||
candidates.add("/" + baseName + ".yaml");
|
||||
candidates.add("/" + baseName + ".yml");
|
||||
|
||||
for ( String name : candidates ) {
|
||||
InputStream stream = Messages.class.getResourceAsStream(name);
|
||||
if ( stream != null ) return stream;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
|
||||
/**
|
||||
* プラグインのリソース管理クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class Resources {
|
||||
|
||||
private static final String FILE_NAME = "messages.yml";
|
||||
|
||||
private static YamlConfiguration defaultMessages;
|
||||
private static YamlConfiguration resources;
|
||||
|
||||
/**
|
||||
* 初期化する
|
||||
*/
|
||||
protected static void initialize() {
|
||||
|
||||
File file = new File(
|
||||
LunaChat.getDataFolder() +
|
||||
File.separator + FILE_NAME);
|
||||
|
||||
if ( !file.exists() ) {
|
||||
Utility.copyFileFromJar(LunaChat.getPluginJarFile(),
|
||||
file, FILE_NAME, false);
|
||||
}
|
||||
|
||||
defaultMessages = loadDefaultMessages();
|
||||
resources = YamlConfiguration.loadConfiguration(file);
|
||||
}
|
||||
|
||||
/**
|
||||
* リソースを取得する
|
||||
* @param key リソースキー
|
||||
* @return リソース
|
||||
*/
|
||||
public static String get(String key) {
|
||||
|
||||
if ( resources == null ) {
|
||||
initialize();
|
||||
}
|
||||
String def = defaultMessages.getString(key);
|
||||
return Utility.replaceColorCode(resources.getString(key, def));
|
||||
}
|
||||
|
||||
/**
|
||||
* Jarファイル内から直接 messages.yml を読み込み、YamlConfigurationにして返すメソッド
|
||||
* @return
|
||||
*/
|
||||
private static YamlConfiguration loadDefaultMessages() {
|
||||
|
||||
YamlConfiguration messages = new YamlConfiguration();
|
||||
JarFile jarFile = null;
|
||||
BufferedReader reader = null;
|
||||
try {
|
||||
jarFile = new JarFile(LunaChat.getPluginJarFile());
|
||||
ZipEntry zipEntry = jarFile.getEntry(FILE_NAME);
|
||||
InputStream inputStream = jarFile.getInputStream(zipEntry);
|
||||
reader = new BufferedReader(new InputStreamReader(inputStream, "UTF-8"));
|
||||
String line;
|
||||
while ( (line = reader.readLine()) != null ) {
|
||||
if ( line.contains(":") && !line.startsWith("#") ) {
|
||||
String key = line.substring(0, line.indexOf(":")).trim();
|
||||
String value = line.substring(line.indexOf(":") + 1).trim();
|
||||
if ( value.startsWith("'") && value.endsWith("'") )
|
||||
value = value.substring(1, value.length()-1);
|
||||
messages.set(key, value);
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
if ( reader != null ) {
|
||||
try {
|
||||
reader.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
if ( jarFile != null ) {
|
||||
try {
|
||||
jarFile.close();
|
||||
} catch (IOException e) {
|
||||
// do nothing.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return messages;
|
||||
}
|
||||
}
|
||||
@@ -26,7 +26,7 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.bridge.VaultChatBridge;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
@@ -42,10 +42,10 @@ import com.github.ucchyocean.lc.member.ChannelMemberBukkit;
|
||||
*/
|
||||
public class BukkitEventListener implements Listener {
|
||||
|
||||
private static final String MOTD_FIRSTLINE = Resources.get("motdFirstLine");
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Resources.get("listFormat");
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
private static final String MOTD_FIRSTLINE = Messages.get("motdFirstLine");
|
||||
private static final String LIST_ENDLINE = Messages.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Messages.get("listFormat");
|
||||
private static final String PREERR = Messages.get("errorPrefix");
|
||||
|
||||
private SimpleDateFormat dateFormat;
|
||||
private SimpleDateFormat timeFormat;
|
||||
@@ -597,7 +597,7 @@ public class BukkitEventListener implements Listener {
|
||||
private void sendResourceMessage(
|
||||
CommandSender sender, String pre, String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
String org = Messages.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import com.github.ucchyocean.lc.bridge.McMMOBridge;
|
||||
import com.github.ucchyocean.lc.bridge.MultiverseCoreBridge;
|
||||
import com.github.ucchyocean.lc.bridge.VaultChatBridge;
|
||||
import com.github.ucchyocean.lc.channel.ChannelManager;
|
||||
import com.github.ucchyocean.lc.command.BukkitLunaChatCommand;
|
||||
import com.github.ucchyocean.lc.command.LunaChatCommandBukkit;
|
||||
import com.github.ucchyocean.lc.command.LunaChatJapanizeCommand;
|
||||
import com.github.ucchyocean.lc.command.LunaChatMessageCommand;
|
||||
import com.github.ucchyocean.lc.command.LunaChatReplyCommand;
|
||||
@@ -48,7 +48,7 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
private ExpireCheckTask expireCheckerTask;
|
||||
private LunaChatLogger normalChatLogger;
|
||||
|
||||
private BukkitLunaChatCommand lunachatCommand;
|
||||
private LunaChatCommandBukkit lunachatCommand;
|
||||
private LunaChatMessageCommand messageCommand;
|
||||
private LunaChatReplyCommand replyCommand;
|
||||
private LunaChatJapanizeCommand lcjapanizeCommand;
|
||||
@@ -103,7 +103,7 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
getServer().getPluginManager().registerEvents(new BukkitEventListener(), this);
|
||||
|
||||
// コマンドの登録
|
||||
lunachatCommand = new BukkitLunaChatCommand();
|
||||
lunachatCommand = new LunaChatCommandBukkit();
|
||||
messageCommand = new LunaChatMessageCommand();
|
||||
replyCommand = new LunaChatReplyCommand();
|
||||
lcjapanizeCommand = new LunaChatJapanizeCommand();
|
||||
|
||||
@@ -15,7 +15,7 @@ import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* BungeeJapanizeMessengerのdictionaryコマンド実装クラス
|
||||
* LunaChatのdictionaryコマンド実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class DictionaryCommand extends Command {
|
||||
@@ -26,9 +26,11 @@ public class DictionaryCommand extends Command {
|
||||
* コンストラクタ
|
||||
* @param parent
|
||||
* @param name コマンド
|
||||
* @param permission パーミッション
|
||||
* @param aliases エイリアス
|
||||
*/
|
||||
public DictionaryCommand(LunaChatBungee parent, String name) {
|
||||
super(name);
|
||||
public DictionaryCommand(LunaChatBungee parent, String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,95 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.YamlConfig;
|
||||
|
||||
/**
|
||||
* Japanize変換に使用するユーザー辞書
|
||||
* @author ucchy
|
||||
*/
|
||||
public class JapanizeDictionary {
|
||||
|
||||
private HashMap<String, String> dictionary;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*/
|
||||
public JapanizeDictionary() {
|
||||
reload();
|
||||
}
|
||||
|
||||
/**
|
||||
* ファイルから設定を読み直す
|
||||
*/
|
||||
public void reload() {
|
||||
|
||||
dictionary = new HashMap<String, String>();
|
||||
|
||||
// Fileを取得
|
||||
File file = new File(LunaChat.getDataFolder(), "dictionary.yml");
|
||||
if ( !file.exists() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
YamlConfig config = YamlConfig.load(file);
|
||||
|
||||
for ( String key : config.getKeys(false) ) {
|
||||
dictionary.put(key, config.getString(key));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* ファイルに保存する
|
||||
*/
|
||||
public void save() {
|
||||
|
||||
YamlConfig config = new YamlConfig();
|
||||
|
||||
for ( String key : dictionary.keySet() ) {
|
||||
config.set(key, dictionary.get(key));
|
||||
}
|
||||
|
||||
try {
|
||||
config.save(new File(LunaChat.getDataFolder(), "dictionary.yml"));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 辞書に単語を登録する
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
public void put(String key, String value) {
|
||||
dictionary.put(key, value);
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 辞書から単語を消去する
|
||||
* @param key
|
||||
*/
|
||||
public void remove(String key) {
|
||||
dictionary.remove(key);
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* 全てのデータを返す
|
||||
* @return dictionary
|
||||
*/
|
||||
public HashMap<String, String> getDictionary() {
|
||||
return dictionary;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,6 +43,7 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
LunaChat.setMode(LunaChatMode.BUNGEE);
|
||||
|
||||
// 初期化
|
||||
config = new LunaChatConfig(getDataFolder(), getFile());
|
||||
history = new HashMap<String, String>();
|
||||
|
||||
manager = new ChannelManager();
|
||||
@@ -54,22 +55,14 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
}
|
||||
|
||||
// コマンド登録
|
||||
for ( String command : new String[]{
|
||||
"tell", "msg", "message", "m", "w", "t"}) {
|
||||
getProxy().getPluginManager().registerCommand(
|
||||
this, new TellCommand(this, command));
|
||||
}
|
||||
for ( String command : new String[]{"reply", "r"}) {
|
||||
getProxy().getPluginManager().registerCommand(
|
||||
this, new ReplyCommand(this, command));
|
||||
}
|
||||
for ( String command : new String[]{"dictionary", "dic"}) {
|
||||
getProxy().getPluginManager().registerCommand(
|
||||
this, new DictionaryCommand(this, command));
|
||||
}
|
||||
|
||||
// コンフィグ取得
|
||||
config = new LunaChatConfig(getDataFolder(), getFile());
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new LunaChatCommand("lunachat", "lunachat.command", "lc", "ch"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new TellCommand(this, "tell", "lunachat.message", "msg", "message", "m", "w", "t"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new ReplyCommand(this, "reply", "lunachat.reply", "r"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new DictionaryCommand(this, "dictionary", "lunachat.dictionary", "dic"));
|
||||
|
||||
// リスナー登録
|
||||
getProxy().getPluginManager().registerListener(this, new BungeeEventListener(this));
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc.command.LunaChatCommandBungee;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
/**
|
||||
* LunaChatのlunachatコマンド実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatCommand extends Command implements TabExecutor {
|
||||
|
||||
private LunaChatCommandBungee com = new LunaChatCommandBungee();
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name コマンド
|
||||
* @param permission パーミッション
|
||||
* @param aliases エイリアス
|
||||
*/
|
||||
public LunaChatCommand(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
com.execute(sender, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
* @see net.md_5.bungee.api.plugin.TabExecutor#onTabComplete(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
return com.onTabComplete(sender, args);
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@ import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
/**
|
||||
* BungeeJapanizeMessengerのreplyコマンド実装クラス
|
||||
* LunaChatのreplyコマンド実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ReplyCommand extends TellCommand {
|
||||
@@ -21,9 +21,11 @@ public class ReplyCommand extends TellCommand {
|
||||
* コンストラクタ
|
||||
* @param BungeeJapanizeMessenger
|
||||
* @param name コマンド
|
||||
* @param permission パーミッション
|
||||
* @param aliases エイリアス
|
||||
*/
|
||||
public ReplyCommand(LunaChatBungee parent, String name) {
|
||||
super(parent, name);
|
||||
public ReplyCommand(LunaChatBungee parent, String name, String permission, String... aliases) {
|
||||
super(parent, name, permission, aliases);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* BungeeJapanizeMessengerのtellコマンド実装クラス
|
||||
* LunaChatのtellコマンド実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class TellCommand extends Command {
|
||||
@@ -32,9 +32,11 @@ public class TellCommand extends Command {
|
||||
* コンストラクタ
|
||||
* @param parent
|
||||
* @param name コマンド
|
||||
* @param permission パーミッション
|
||||
* @param aliases エイリアス
|
||||
*/
|
||||
public TellCommand(LunaChatBungee parent, String name) {
|
||||
super(name);
|
||||
public TellCommand(LunaChatBungee parent, String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc.LunaChatLogger;
|
||||
import com.github.ucchyocean.lc.NGWordAction;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.UtilityBukkit;
|
||||
import com.github.ucchyocean.lc.bridge.DynmapBridge;
|
||||
@@ -42,37 +42,37 @@ public class BukkitChannel extends Channel {
|
||||
|
||||
private static final String PERMISSION_SPEAK_PREFIX = "lunachat.speak";
|
||||
|
||||
private static final String INFO_FIRSTLINE = Resources.get("channelInfoFirstLine");
|
||||
private static final String INFO_PREFIX = Resources.get("channelInfoPrefix");
|
||||
private static final String INFO_ALIAS = Resources.get("channelInfoAlias");
|
||||
private static final String INFO_GLOBAL = Resources.get("channelInfoGlobal");
|
||||
private static final String INFO_BROADCAST = Resources.get("channelInfoBroadcast");
|
||||
private static final String INFO_SECRET = Resources.get("channelInfoSecret");
|
||||
private static final String INFO_PASSWORD = Resources.get("channelInfoPassword");
|
||||
private static final String INFO_WORLDCHAT = Resources.get("channelInfoWorldChat");
|
||||
private static final String INFO_RANGECHAT = Resources.get("channelInfoRangeChat");
|
||||
private static final String INFO_FORMAT = Resources.get("channelInfoFormat");
|
||||
private static final String INFO_BANNED = Resources.get("channelInfoBanned");
|
||||
private static final String INFO_MUTED = Resources.get("channelInfoMuted");
|
||||
private static final String INFO_FIRSTLINE = Messages.get("channelInfoFirstLine");
|
||||
private static final String INFO_PREFIX = Messages.get("channelInfoPrefix");
|
||||
private static final String INFO_ALIAS = Messages.get("channelInfoAlias");
|
||||
private static final String INFO_GLOBAL = Messages.get("channelInfoGlobal");
|
||||
private static final String INFO_BROADCAST = Messages.get("channelInfoBroadcast");
|
||||
private static final String INFO_SECRET = Messages.get("channelInfoSecret");
|
||||
private static final String INFO_PASSWORD = Messages.get("channelInfoPassword");
|
||||
private static final String INFO_WORLDCHAT = Messages.get("channelInfoWorldChat");
|
||||
private static final String INFO_RANGECHAT = Messages.get("channelInfoRangeChat");
|
||||
private static final String INFO_FORMAT = Messages.get("channelInfoFormat");
|
||||
private static final String INFO_BANNED = Messages.get("channelInfoBanned");
|
||||
private static final String INFO_MUTED = Messages.get("channelInfoMuted");
|
||||
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Resources.get("listFormat");
|
||||
private static final String LIST_ENDLINE = Messages.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Messages.get("listFormat");
|
||||
|
||||
private static final String MSG_BAN_NGWORD = Resources.get("banNGWordMessage");
|
||||
private static final String MSG_KICK_NGWORD = Resources.get("kickNGWordMessage");
|
||||
private static final String MSG_MUTE_NGWORD = Resources.get("muteNGWordMessage");
|
||||
private static final String MSG_BAN_NGWORD = Messages.get("banNGWordMessage");
|
||||
private static final String MSG_KICK_NGWORD = Messages.get("kickNGWordMessage");
|
||||
private static final String MSG_MUTE_NGWORD = Messages.get("muteNGWordMessage");
|
||||
|
||||
private static final String MSG_BAN_EXPIRED = Resources.get("expiredBanMessage");
|
||||
private static final String MSG_MUTE_EXPIRED = Resources.get("expiredMuteMessage");
|
||||
private static final String MSG_BAN_EXPIRED_PLAYER = Resources.get("cmdmsgPardoned");
|
||||
private static final String MSG_MUTE_EXPIRED_PLAYER = Resources.get("cmdmsgUnmuted");
|
||||
private static final String MSG_BAN_EXPIRED = Messages.get("expiredBanMessage");
|
||||
private static final String MSG_MUTE_EXPIRED = Messages.get("expiredMuteMessage");
|
||||
private static final String MSG_BAN_EXPIRED_PLAYER = Messages.get("cmdmsgPardoned");
|
||||
private static final String MSG_MUTE_EXPIRED_PLAYER = Messages.get("cmdmsgUnmuted");
|
||||
|
||||
private static final String PREINFO = Resources.get("infoPrefix");
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
private static final String PREINFO = Messages.get("infoPrefix");
|
||||
private static final String PREERR = Messages.get("errorPrefix");
|
||||
|
||||
private static final String MSG_NO_RECIPIENT = Resources.get("noRecipientMessage");
|
||||
private static final String MSG_NO_RECIPIENT = Messages.get("noRecipientMessage");
|
||||
|
||||
private static final String ERRMSG_MUTED = Resources.get("errmsgMuted");
|
||||
private static final String ERRMSG_MUTED = Messages.get("errmsgMuted");
|
||||
|
||||
private SimpleDateFormat dateFormat;
|
||||
private SimpleDateFormat timeFormat;
|
||||
@@ -300,7 +300,7 @@ public class BukkitChannel extends Channel {
|
||||
return;
|
||||
}
|
||||
|
||||
String msg = Resources.get(key);
|
||||
String msg = Messages.get(key);
|
||||
if ( msg == null || msg.equals("") ) {
|
||||
return;
|
||||
}
|
||||
@@ -839,7 +839,7 @@ public class BukkitChannel extends Channel {
|
||||
private void sendResourceMessage(
|
||||
ChannelMember player, String pre, String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
String org = Messages.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.YamlConfig;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
@@ -25,7 +25,7 @@ import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
*/
|
||||
public class ChannelManager implements LunaChatAPI {
|
||||
|
||||
private static final String MSG_BREAKUP = Resources.get("breakupMessage");
|
||||
private static final String MSG_BREAKUP = Messages.get("breakupMessage");
|
||||
|
||||
private static final String FILE_NAME_DCHANNELS = "defaults.yml";
|
||||
private static final String FILE_NAME_TEMPLATES = "templates.yml";
|
||||
@@ -623,8 +623,15 @@ public class ChannelManager implements LunaChatAPI {
|
||||
* @param file 出力先
|
||||
*/
|
||||
private void makeEmptyFile(File file) {
|
||||
// try {
|
||||
// file.createNewFile();
|
||||
// } catch (IOException e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
|
||||
YamlConfig config = new YamlConfig();
|
||||
try {
|
||||
file.createNewFile();
|
||||
config.save(file);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@@ -1,435 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.bukkit.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
/**
|
||||
* Lunachatコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BungeeLunaChatCommand extends Command implements TabExecutor {
|
||||
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
private ArrayList<SubCommandAbst> commands;
|
||||
private ArrayList<SubCommandAbst> commonCommands;
|
||||
private JoinCommand joinCommand;
|
||||
private HelpCommand helpCommand;
|
||||
|
||||
public BungeeLunaChatCommand(String name) {
|
||||
super(name);
|
||||
|
||||
commands = new ArrayList<SubCommandAbst>();
|
||||
joinCommand = new JoinCommand();
|
||||
commands.add(joinCommand);
|
||||
commands.add(new LeaveCommand());
|
||||
commands.add(new ListCommand());
|
||||
commands.add(new InviteCommand());
|
||||
commands.add(new AcceptCommand());
|
||||
commands.add(new DenyCommand());
|
||||
commands.add(new KickCommand());
|
||||
commands.add(new BanCommand());
|
||||
commands.add(new PardonCommand());
|
||||
commands.add(new MuteCommand());
|
||||
commands.add(new UnmuteCommand());
|
||||
commands.add(new InfoCommand());
|
||||
commands.add(new LogCommand());
|
||||
commands.add(new CreateCommand());
|
||||
commands.add(new RemoveCommand());
|
||||
commands.add(new FormatCommand());
|
||||
commands.add(new ModeratorCommand());
|
||||
commands.add(new ModCommand());
|
||||
commands.add(new OptionCommand());
|
||||
commands.add(new TemplateCommand());
|
||||
commands.add(new SetCommand());
|
||||
helpCommand = new HelpCommand(commands);
|
||||
commands.add(helpCommand);
|
||||
|
||||
commonCommands = new ArrayList<SubCommandAbst>();
|
||||
commonCommands.add(new HideCommand());
|
||||
commonCommands.add(new UnhideCommand());
|
||||
commonCommands.add(new DictionaryCommand());
|
||||
commonCommands.add(new DicCommand());
|
||||
commonCommands.add(new ReloadCommand());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
// チャンネルチャットが無効でも利用できるコマンドはここで処理する
|
||||
// (hide, unhide, dic, dictionary, reload)
|
||||
if ( args.length >= 1 ) {
|
||||
for ( SubCommandAbst c : commonCommands ) {
|
||||
if ( c.getCommandName().equalsIgnoreCase(args[0]) ) {
|
||||
|
||||
// パーミッションの確認
|
||||
String node = c.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return;
|
||||
}
|
||||
|
||||
// 実行
|
||||
c.runCommand(ChannelMember.getChannelMember(sender), getName(), args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// チャンネルチャット機能が無効になっている場合は、メッセージを表示して終了
|
||||
if ( !LunaChatBukkit.getInstance().getLunaChatConfig().isEnableChannelChat()
|
||||
&& !sender.hasPermission("lunachat-admin") ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgChannelChatDisabled");
|
||||
return;
|
||||
}
|
||||
|
||||
// 引数なしは、ヘルプを表示
|
||||
if (args.length == 0) {
|
||||
helpCommand.runCommand(ChannelMember.getChannelMember(sender), getName(), args);
|
||||
return;
|
||||
}
|
||||
|
||||
// 第1引数に指定されたコマンドを実行する
|
||||
for ( SubCommandAbst c : commands ) {
|
||||
if ( c.getCommandName().equalsIgnoreCase(args[0]) ) {
|
||||
|
||||
// パーミッションの確認
|
||||
String node = c.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return;
|
||||
}
|
||||
|
||||
// 実行
|
||||
c.runCommand(ChannelMember.getChannelMember(sender), getName(), args);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 第1引数がコマンドでないなら、joinが指定されたとみなす
|
||||
String node = joinCommand.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return;
|
||||
}
|
||||
|
||||
joinCommand.runCommand(ChannelMember.getChannelMember(sender), getName(), args);
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @param sender TABキー補完の実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
*/
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
if ( args.length == 1 ) {
|
||||
// コマンド名で補完する
|
||||
String arg = args[0].toLowerCase();
|
||||
ArrayList<String> coms = new ArrayList<String>();
|
||||
for ( SubCommandAbst c : commands ) {
|
||||
if ( c.getCommandName().startsWith(arg) &&
|
||||
sender.hasPermission(c.getPermissionNode()) ) {
|
||||
coms.add(c.getCommandName());
|
||||
}
|
||||
}
|
||||
for ( SubCommandAbst c : commonCommands ) {
|
||||
if ( c.getCommandName().startsWith(arg) &&
|
||||
sender.hasPermission(c.getPermissionNode()) ) {
|
||||
coms.add(c.getCommandName());
|
||||
}
|
||||
}
|
||||
return coms;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("join") ||
|
||||
args[0].equalsIgnoreCase("info") ) ) {
|
||||
// 参加可能チャンネル名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(ChannelMember.getChannelMember(sender)) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("ban") ||
|
||||
args[0].equalsIgnoreCase("pardon") ||
|
||||
args[0].equalsIgnoreCase("kick") ||
|
||||
args[0].equalsIgnoreCase("mute") ||
|
||||
args[0].equalsIgnoreCase("unmute") ) ) {
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( ProxiedPlayer player : getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
pname = pname == null ? "" : pname.toLowerCase();
|
||||
if ( pname.startsWith(arg) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 && (
|
||||
args[0].equalsIgnoreCase("ban") ||
|
||||
args[0].equalsIgnoreCase("pardon") ||
|
||||
args[0].equalsIgnoreCase("kick") ||
|
||||
args[0].equalsIgnoreCase("mute") ||
|
||||
args[0].equalsIgnoreCase("unmute") ) ) {
|
||||
// チャンネル名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(ChannelMember.getChannelMember(sender)) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) ) {
|
||||
|
||||
// 参加可能チャンネル名とプレイヤー名と
|
||||
// 文字列"player", "channel"で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(ChannelMember.getChannelMember(sender)) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
for ( ProxiedPlayer player : getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
pname = pname == null ? "" : pname.toLowerCase();
|
||||
if ( pname.startsWith(arg) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
if ( "player".startsWith(arg) ) {
|
||||
items.add("player");
|
||||
}
|
||||
if ( "channel".startsWith(arg) ) {
|
||||
items.add("channel");
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) &&
|
||||
args[1].equalsIgnoreCase("player") ) {
|
||||
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( ProxiedPlayer player : getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
pname = pname == null ? "" : pname.toLowerCase();
|
||||
if ( pname.startsWith(arg) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) &&
|
||||
args[1].equalsIgnoreCase("channel") ) {
|
||||
|
||||
// チャンネル名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(ChannelMember.getChannelMember(sender)) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 && args[0].equalsIgnoreCase("remove") ) {
|
||||
// 削除可能チャンネル名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanRemove(ChannelMember.getChannelMember(sender)) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 &&
|
||||
(args[0].equalsIgnoreCase("dic") || args[0].equalsIgnoreCase("dictionary")) ) {
|
||||
// add、remove、viewで補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : new String[]{"add", "remove", "view"} ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("dic") || args[0].equalsIgnoreCase("dictionary")) &&
|
||||
args[1].equalsIgnoreCase("remove") ) {
|
||||
// 辞書に登録されているワードで補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name :
|
||||
LunaChatBukkit.getInstance().getLunaChatAPI().getAllDictionary().keySet() ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 &&
|
||||
args[0].equalsIgnoreCase("set") ) {
|
||||
// "default" で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
if ( "default".startsWith(arg) ) {
|
||||
items.add("default");
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
args[0].equalsIgnoreCase("set") && args[1].equalsIgnoreCase("default") ) {
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( ProxiedPlayer player : getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
pname = pname == null ? "" : pname.toLowerCase();
|
||||
if ( pname.startsWith(arg) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 4 &&
|
||||
args[0].equalsIgnoreCase("set") && args[1].equalsIgnoreCase("default") ) {
|
||||
// チャンネル名で補完する
|
||||
String arg = args[3].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(ChannelMember.getChannelMember(sender)) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
private void sendResourceMessage(CommandSender sender, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
sender.sendMessage(TextComponent.fromLegacyText(msg));
|
||||
}
|
||||
|
||||
/**
|
||||
* TAB補完用の参加可能チャンネルリストを返す
|
||||
* @param sender コマンド実行者
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getListCanJoin(ChannelMember sender) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
ChannelMember cp = ChannelMember.getChannelMember(sender);
|
||||
|
||||
for ( Channel channel : LunaChatBukkit.getInstance().getLunaChatAPI().getChannels() ) {
|
||||
|
||||
// BANされているチャンネルは対象外
|
||||
if ( channel.getBanned().contains(cp) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットは対象外
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 未参加で visible=false のチャンネルは対象外
|
||||
if ( sender instanceof ProxiedPlayer &&
|
||||
!channel.getMembers().contains(cp) &&
|
||||
!channel.isGlobalChannel() &&
|
||||
!channel.isVisible() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.add(channel.getName());
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* TAB補完用の削除可能チャンネルリストを返す
|
||||
* @param sender コマンド実行者
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getListCanRemove(ChannelMember sender) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
|
||||
for ( Channel channel : LunaChatBukkit.getInstance().getLunaChatAPI().getChannels() ) {
|
||||
|
||||
// 実行者がチャンネルモデレーターでない場合は対象外
|
||||
if ( !channel.hasModeratorPermission(sender) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットは対象外
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// グローバルチャンネルは対象外
|
||||
if ( channel.isGlobalChannel() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.add(channel.getName());
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
private Collection<ProxiedPlayer> getOnlinePlayers() {
|
||||
return ProxyServer.getInstance().getPlayers();
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@ package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
@@ -24,11 +24,11 @@ public class HideCommand extends SubCommandAbst {
|
||||
private static final String USAGE_KEY2 = "usageHidePlayer";
|
||||
|
||||
private static final String HIDE_CHANNEL_FIRSTLINE =
|
||||
Resources.get("hideChannelFirstLine");
|
||||
Messages.get("hideChannelFirstLine");
|
||||
private static final String HIDE_PLAYER_FIRSTLINE =
|
||||
Resources.get("hidePlayerFirstLine");
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_PREFIX = Resources.get("listPlainPrefix");
|
||||
Messages.get("hidePlayerFirstLine");
|
||||
private static final String LIST_ENDLINE = Messages.get("listEndLine");
|
||||
private static final String LIST_PREFIX = Messages.get("listPlainPrefix");
|
||||
|
||||
/**
|
||||
* コマンドを取得します。
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.Comparator;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
|
||||
@@ -21,10 +21,10 @@ import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
*/
|
||||
public class ListCommand extends SubCommandAbst {
|
||||
|
||||
private static final String LIST_FIRSTLINE = Resources.get("listFirstLine");
|
||||
private static final String LIST_FIRSTLINE_PAGING = Resources.get("listFirstLinePaging");
|
||||
private static final String LIST_ENDLINE = Resources.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Resources.get("listFormat");
|
||||
private static final String LIST_FIRSTLINE = Messages.get("listFirstLine");
|
||||
private static final String LIST_FIRSTLINE_PAGING = Messages.get("listFirstLinePaging");
|
||||
private static final String LIST_ENDLINE = Messages.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Messages.get("listFormat");
|
||||
|
||||
private static final String COMMAND_NAME = "list";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
|
||||
@@ -8,7 +8,7 @@ package com.github.ucchyocean.lc.command;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChatLogger;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.bukkit.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
@@ -19,9 +19,9 @@ import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
*/
|
||||
public class LogCommand extends SubCommandAbst {
|
||||
|
||||
private static final String LOGDISPLAY_FIRSTLINE = Resources.get("logDisplayFirstLine");
|
||||
private static final String LOGDISPLAY_ENDLINE = Resources.get("logDisplayEndLine");
|
||||
private static final String LOGDISPLAY_FORMAT = Resources.get("logDisplayFormat");
|
||||
private static final String LOGDISPLAY_FIRSTLINE = Messages.get("logDisplayFirstLine");
|
||||
private static final String LOGDISPLAY_ENDLINE = Messages.get("logDisplayEndLine");
|
||||
private static final String LOGDISPLAY_FORMAT = Messages.get("logDisplayFormat");
|
||||
|
||||
private static final String COMMAND_NAME = "log";
|
||||
private static final String PERMISSION_NODE = "lunachat." + COMMAND_NAME;
|
||||
|
||||
+399
-450
@@ -1,450 +1,399 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.bukkit.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* Lunachatコマンドの処理クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BukkitLunaChatCommand implements CommandExecutor {
|
||||
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
|
||||
private ArrayList<SubCommandAbst> commands;
|
||||
private ArrayList<SubCommandAbst> commonCommands;
|
||||
private JoinCommand joinCommand;
|
||||
private HelpCommand helpCommand;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*/
|
||||
public BukkitLunaChatCommand() {
|
||||
|
||||
commands = new ArrayList<SubCommandAbst>();
|
||||
joinCommand = new JoinCommand();
|
||||
commands.add(joinCommand);
|
||||
commands.add(new LeaveCommand());
|
||||
commands.add(new ListCommand());
|
||||
commands.add(new InviteCommand());
|
||||
commands.add(new AcceptCommand());
|
||||
commands.add(new DenyCommand());
|
||||
commands.add(new KickCommand());
|
||||
commands.add(new BanCommand());
|
||||
commands.add(new PardonCommand());
|
||||
commands.add(new MuteCommand());
|
||||
commands.add(new UnmuteCommand());
|
||||
commands.add(new InfoCommand());
|
||||
commands.add(new LogCommand());
|
||||
commands.add(new CreateCommand());
|
||||
commands.add(new RemoveCommand());
|
||||
commands.add(new FormatCommand());
|
||||
commands.add(new ModeratorCommand());
|
||||
commands.add(new ModCommand());
|
||||
commands.add(new OptionCommand());
|
||||
commands.add(new TemplateCommand());
|
||||
commands.add(new SetCommand());
|
||||
helpCommand = new HelpCommand(commands);
|
||||
commands.add(helpCommand);
|
||||
|
||||
commonCommands = new ArrayList<SubCommandAbst>();
|
||||
commonCommands.add(new HideCommand());
|
||||
commonCommands.add(new UnhideCommand());
|
||||
commonCommands.add(new DictionaryCommand());
|
||||
commonCommands.add(new DicCommand());
|
||||
commonCommands.add(new ReloadCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command,
|
||||
String label, String[] args) {
|
||||
|
||||
// チャンネルチャットが無効でも利用できるコマンドはここで処理する
|
||||
// (hide, unhide, dic, dictionary, reload)
|
||||
if ( args.length >= 1 ) {
|
||||
for ( SubCommandAbst c : commonCommands ) {
|
||||
if ( c.getCommandName().equalsIgnoreCase(args[0]) ) {
|
||||
|
||||
// パーミッションの確認
|
||||
String node = c.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行
|
||||
return c.runCommand(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// チャンネルチャット機能が無効になっている場合は、メッセージを表示して終了
|
||||
if ( !LunaChatBukkit.getInstance().getLunaChatConfig().isEnableChannelChat()
|
||||
&& !sender.isOp() ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgChannelChatDisabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 引数なしは、ヘルプを表示
|
||||
if (args.length == 0) {
|
||||
helpCommand.runCommand(ChannelMember.getChannelMember(sender), label, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 第1引数に指定されたコマンドを実行する
|
||||
for ( SubCommandAbst c : commands ) {
|
||||
if ( c.getCommandName().equalsIgnoreCase(args[0]) ) {
|
||||
|
||||
// パーミッションの確認
|
||||
String node = c.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行
|
||||
return c.runCommand(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
}
|
||||
|
||||
// 第1引数がコマンドでないなら、joinが指定されたとみなす
|
||||
String node = joinCommand.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return true;
|
||||
}
|
||||
|
||||
return joinCommand.runCommand(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @param sender TABキー補完の実行者
|
||||
* @param command 実行されたコマンド
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
*/
|
||||
public List<String> onTabComplete(
|
||||
CommandSender sender, Command command, String label, String[] args) {
|
||||
return onTabComplete(ChannelMember.getChannelMember(sender), command, label, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @param sender TABキー補完の実行者
|
||||
* @param command 実行されたコマンド
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
*/
|
||||
public List<String> onTabComplete(
|
||||
ChannelMember sender, Command command, String label, String[] args) {
|
||||
if ( args.length == 1 ) {
|
||||
// コマンド名で補完する
|
||||
String arg = args[0].toLowerCase();
|
||||
ArrayList<String> coms = new ArrayList<String>();
|
||||
for ( SubCommandAbst c : commands ) {
|
||||
if ( c.getCommandName().startsWith(arg) &&
|
||||
sender.hasPermission(c.getPermissionNode()) ) {
|
||||
coms.add(c.getCommandName());
|
||||
}
|
||||
}
|
||||
for ( SubCommandAbst c : commonCommands ) {
|
||||
if ( c.getCommandName().startsWith(arg) &&
|
||||
sender.hasPermission(c.getPermissionNode()) ) {
|
||||
coms.add(c.getCommandName());
|
||||
}
|
||||
}
|
||||
return coms;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("join") ||
|
||||
args[0].equalsIgnoreCase("info") ) ) {
|
||||
// 参加可能チャンネル名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("ban") ||
|
||||
args[0].equalsIgnoreCase("pardon") ||
|
||||
args[0].equalsIgnoreCase("kick") ||
|
||||
args[0].equalsIgnoreCase("mute") ||
|
||||
args[0].equalsIgnoreCase("unmute") ) ) {
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( Player player : Bukkit.getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
pname = pname == null ? "" : pname.toLowerCase();
|
||||
if ( pname.startsWith(arg) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 && (
|
||||
args[0].equalsIgnoreCase("ban") ||
|
||||
args[0].equalsIgnoreCase("pardon") ||
|
||||
args[0].equalsIgnoreCase("kick") ||
|
||||
args[0].equalsIgnoreCase("mute") ||
|
||||
args[0].equalsIgnoreCase("unmute") ) ) {
|
||||
// チャンネル名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) ) {
|
||||
|
||||
// 参加可能チャンネル名とプレイヤー名と
|
||||
// 文字列"player", "channel"で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
for ( Player player : Bukkit.getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
pname = pname == null ? "" : pname.toLowerCase();
|
||||
if ( pname.startsWith(arg) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
if ( "player".startsWith(arg) ) {
|
||||
items.add("player");
|
||||
}
|
||||
if ( "channel".startsWith(arg) ) {
|
||||
items.add("channel");
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) &&
|
||||
args[1].equalsIgnoreCase("player") ) {
|
||||
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( Player player : Bukkit.getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
pname = pname == null ? "" : pname.toLowerCase();
|
||||
if ( pname.startsWith(arg) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) &&
|
||||
args[1].equalsIgnoreCase("channel") ) {
|
||||
|
||||
// チャンネル名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 && args[0].equalsIgnoreCase("remove") ) {
|
||||
// 削除可能チャンネル名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanRemove(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 &&
|
||||
(args[0].equalsIgnoreCase("dic") || args[0].equalsIgnoreCase("dictionary")) ) {
|
||||
// add、remove、viewで補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : new String[]{"add", "remove", "view"} ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("dic") || args[0].equalsIgnoreCase("dictionary")) &&
|
||||
args[1].equalsIgnoreCase("remove") ) {
|
||||
// 辞書に登録されているワードで補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name :
|
||||
LunaChatBukkit.getInstance().getLunaChatAPI().getAllDictionary().keySet() ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 &&
|
||||
args[0].equalsIgnoreCase("set") ) {
|
||||
// "default" で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
if ( "default".startsWith(arg) ) {
|
||||
items.add("default");
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
args[0].equalsIgnoreCase("set") && args[1].equalsIgnoreCase("default") ) {
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( Player player : Bukkit.getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
pname = pname == null ? "" : pname.toLowerCase();
|
||||
if ( pname.startsWith(arg) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 4 &&
|
||||
args[0].equalsIgnoreCase("set") && args[1].equalsIgnoreCase("default") ) {
|
||||
// チャンネル名で補完する
|
||||
String arg = args[3].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
*
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
private void sendResourceMessage(CommandSender sender, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* TAB補完用の参加可能チャンネルリストを返す
|
||||
* @param sender コマンド実行者
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getListCanJoin(ChannelMember sender) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
ChannelMember cp = ChannelMember.getChannelMember(sender);
|
||||
|
||||
for ( Channel channel : LunaChatBukkit.getInstance().getLunaChatAPI().getChannels() ) {
|
||||
|
||||
// BANされているチャンネルは対象外
|
||||
if ( channel.getBanned().contains(cp) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットは対象外
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 未参加で visible=false のチャンネルは対象外
|
||||
if ( sender instanceof Player &&
|
||||
!channel.getMembers().contains(cp) &&
|
||||
!channel.isGlobalChannel() &&
|
||||
!channel.isVisible() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.add(channel.getName());
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* TAB補完用の削除可能チャンネルリストを返す
|
||||
* @param sender コマンド実行者
|
||||
* @return リスト
|
||||
*/
|
||||
private ArrayList<String> getListCanRemove(ChannelMember sender) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
|
||||
for ( Channel channel : LunaChatBukkit.getInstance().getLunaChatAPI().getChannels() ) {
|
||||
|
||||
// 実行者がチャンネルモデレーターでない場合は対象外
|
||||
if ( !channel.hasModeratorPermission(sender) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットは対象外
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// グローバルチャンネルは対象外
|
||||
if ( channel.isGlobalChannel() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.add(channel.getName());
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.bukkit.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* Lunachatコマンドの処理クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public abstract class LunaChatCommand {
|
||||
|
||||
private static final String PREERR = Messages.get("errorPrefix");
|
||||
|
||||
private ArrayList<SubCommandAbst> commands;
|
||||
private ArrayList<SubCommandAbst> commonCommands;
|
||||
private JoinCommand joinCommand;
|
||||
private HelpCommand helpCommand;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*/
|
||||
public LunaChatCommand() {
|
||||
|
||||
commands = new ArrayList<SubCommandAbst>();
|
||||
joinCommand = new JoinCommand();
|
||||
commands.add(joinCommand);
|
||||
commands.add(new LeaveCommand());
|
||||
commands.add(new ListCommand());
|
||||
commands.add(new InviteCommand());
|
||||
commands.add(new AcceptCommand());
|
||||
commands.add(new DenyCommand());
|
||||
commands.add(new KickCommand());
|
||||
commands.add(new BanCommand());
|
||||
commands.add(new PardonCommand());
|
||||
commands.add(new MuteCommand());
|
||||
commands.add(new UnmuteCommand());
|
||||
commands.add(new InfoCommand());
|
||||
commands.add(new LogCommand());
|
||||
commands.add(new CreateCommand());
|
||||
commands.add(new RemoveCommand());
|
||||
commands.add(new FormatCommand());
|
||||
commands.add(new ModeratorCommand());
|
||||
commands.add(new ModCommand());
|
||||
commands.add(new OptionCommand());
|
||||
commands.add(new TemplateCommand());
|
||||
commands.add(new SetCommand());
|
||||
helpCommand = new HelpCommand(commands);
|
||||
commands.add(helpCommand);
|
||||
|
||||
commonCommands = new ArrayList<SubCommandAbst>();
|
||||
commonCommands.add(new HideCommand());
|
||||
commonCommands.add(new UnhideCommand());
|
||||
commonCommands.add(new DictionaryCommand());
|
||||
commonCommands.add(new DicCommand());
|
||||
commonCommands.add(new ReloadCommand());
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 実行したかどうか(falseを返した場合、サーバーがUsageを表示する)
|
||||
*/
|
||||
protected boolean execute(ChannelMember sender, String label, String[] args) {
|
||||
|
||||
// チャンネルチャットが無効でも利用できるコマンドはここで処理する
|
||||
// (hide, unhide, dic, dictionary, reload)
|
||||
if ( args.length >= 1 ) {
|
||||
for ( SubCommandAbst c : commonCommands ) {
|
||||
if ( c.getCommandName().equalsIgnoreCase(args[0]) ) {
|
||||
|
||||
// パーミッションの確認
|
||||
String node = c.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行
|
||||
return c.runCommand(sender, label, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// チャンネルチャット機能が無効になっている場合は、メッセージを表示して終了
|
||||
if ( !LunaChatBukkit.getInstance().getLunaChatConfig().isEnableChannelChat()
|
||||
&& !sender.hasPermission("lunachat-admin") ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgChannelChatDisabled");
|
||||
return true;
|
||||
}
|
||||
|
||||
// 引数なしは、ヘルプを表示
|
||||
if (args.length == 0) {
|
||||
helpCommand.runCommand(sender, label, args);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 第1引数に指定されたコマンドを実行する
|
||||
for ( SubCommandAbst c : commands ) {
|
||||
if ( c.getCommandName().equalsIgnoreCase(args[0]) ) {
|
||||
|
||||
// パーミッションの確認
|
||||
String node = c.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 実行
|
||||
return c.runCommand(sender, label, args);
|
||||
}
|
||||
}
|
||||
|
||||
// 第1引数がコマンドでないなら、joinが指定されたとみなす
|
||||
String node = joinCommand.getPermissionNode();
|
||||
if ( !sender.hasPermission(node) ) {
|
||||
sendResourceMessage(sender, PREERR, "errmsgPermission", node);
|
||||
return true;
|
||||
}
|
||||
|
||||
return joinCommand.runCommand(sender, label, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @param sender TABキー補完の実行者
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
*/
|
||||
protected List<String> onTabComplete(ChannelMember sender, String label, String[] args) {
|
||||
if ( args.length == 1 ) {
|
||||
// コマンド名で補完する
|
||||
String arg = args[0].toLowerCase();
|
||||
ArrayList<String> coms = new ArrayList<String>();
|
||||
for ( SubCommandAbst c : commands ) {
|
||||
if ( c.getCommandName().startsWith(arg) &&
|
||||
sender.hasPermission(c.getPermissionNode()) ) {
|
||||
coms.add(c.getCommandName());
|
||||
}
|
||||
}
|
||||
for ( SubCommandAbst c : commonCommands ) {
|
||||
if ( c.getCommandName().startsWith(arg) &&
|
||||
sender.hasPermission(c.getPermissionNode()) ) {
|
||||
coms.add(c.getCommandName());
|
||||
}
|
||||
}
|
||||
return coms;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("join") ||
|
||||
args[0].equalsIgnoreCase("info") ) ) {
|
||||
// 参加可能チャンネル名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("ban") ||
|
||||
args[0].equalsIgnoreCase("pardon") ||
|
||||
args[0].equalsIgnoreCase("kick") ||
|
||||
args[0].equalsIgnoreCase("mute") ||
|
||||
args[0].equalsIgnoreCase("unmute") ) ) {
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
return getListPlayerNames(arg);
|
||||
|
||||
} else if ( args.length == 3 && (
|
||||
args[0].equalsIgnoreCase("ban") ||
|
||||
args[0].equalsIgnoreCase("pardon") ||
|
||||
args[0].equalsIgnoreCase("kick") ||
|
||||
args[0].equalsIgnoreCase("mute") ||
|
||||
args[0].equalsIgnoreCase("unmute") ) ) {
|
||||
// チャンネル名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 && (
|
||||
args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) ) {
|
||||
|
||||
// 参加可能チャンネル名とプレイヤー名と
|
||||
// 文字列"player", "channel"で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
items.addAll(getListPlayerNames(arg));
|
||||
if ( "player".startsWith(arg) ) {
|
||||
items.add("player");
|
||||
}
|
||||
if ( "channel".startsWith(arg) ) {
|
||||
items.add("channel");
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) &&
|
||||
args[1].equalsIgnoreCase("player") ) {
|
||||
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
return getListPlayerNames(arg);
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("hide") ||
|
||||
args[0].equalsIgnoreCase("unhide") ) &&
|
||||
args[1].equalsIgnoreCase("channel") ) {
|
||||
|
||||
// チャンネル名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
return getListPlayerNames(arg);
|
||||
|
||||
} else if ( args.length == 2 && args[0].equalsIgnoreCase("remove") ) {
|
||||
// 削除可能チャンネル名で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanRemove(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 &&
|
||||
(args[0].equalsIgnoreCase("dic") || args[0].equalsIgnoreCase("dictionary")) ) {
|
||||
// add、remove、viewで補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : new String[]{"add", "remove", "view"} ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
(args[0].equalsIgnoreCase("dic") || args[0].equalsIgnoreCase("dictionary")) &&
|
||||
args[1].equalsIgnoreCase("remove") ) {
|
||||
// 辞書に登録されているワードで補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name :
|
||||
LunaChatBukkit.getInstance().getLunaChatAPI().getAllDictionary().keySet() ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 2 &&
|
||||
args[0].equalsIgnoreCase("set") ) {
|
||||
// "default" で補完する
|
||||
String arg = args[1].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
if ( "default".startsWith(arg) ) {
|
||||
items.add("default");
|
||||
}
|
||||
return items;
|
||||
|
||||
} else if ( args.length == 3 &&
|
||||
args[0].equalsIgnoreCase("set") && args[1].equalsIgnoreCase("default") ) {
|
||||
// プレイヤー名で補完する
|
||||
String arg = args[2].toLowerCase();
|
||||
return getListPlayerNames(arg);
|
||||
|
||||
} else if ( args.length == 4 &&
|
||||
args[0].equalsIgnoreCase("set") && args[1].equalsIgnoreCase("default") ) {
|
||||
// チャンネル名で補完する
|
||||
String arg = args[3].toLowerCase();
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
for ( String name : getListCanJoin(sender) ) {
|
||||
if ( name.toLowerCase().startsWith(arg) ) {
|
||||
items.add(name);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* メッセージリソースのメッセージを、カラーコード置き換えしつつ、senderに送信する
|
||||
*
|
||||
* @param sender メッセージの送り先
|
||||
* @param pre プレフィックス
|
||||
* @param key リソースキー
|
||||
* @param args リソース内の置き換え対象キーワード
|
||||
*/
|
||||
private void sendResourceMessage(ChannelMember sender, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Messages.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
String msg = String.format(pre + org, args);
|
||||
sender.sendMessage(msg);
|
||||
}
|
||||
|
||||
/**
|
||||
* TAB補完用の参加可能チャンネルリストを返す
|
||||
* @param sender コマンド実行者
|
||||
* @return リスト
|
||||
*/
|
||||
protected ArrayList<String> getListCanJoin(ChannelMember sender) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
|
||||
for ( Channel channel : LunaChatBukkit.getInstance().getLunaChatAPI().getChannels() ) {
|
||||
|
||||
// BANされているチャンネルは対象外
|
||||
if ( channel.getBanned().contains(sender) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットは対象外
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 未参加で visible=false のチャンネルは対象外
|
||||
if ( !channel.getMembers().contains(sender) &&
|
||||
!channel.isGlobalChannel() && !channel.isVisible() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.add(channel.getName());
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* TAB補完用の削除可能チャンネルリストを返す
|
||||
* @param sender コマンド実行者
|
||||
* @return リスト
|
||||
*/
|
||||
protected ArrayList<String> getListCanRemove(ChannelMember sender) {
|
||||
|
||||
ArrayList<String> items = new ArrayList<String>();
|
||||
|
||||
for ( Channel channel : LunaChatBukkit.getInstance().getLunaChatAPI().getChannels() ) {
|
||||
|
||||
// 実行者がチャンネルモデレーターでない場合は対象外
|
||||
if ( !channel.hasModeratorPermission(sender) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// 個人チャットは対象外
|
||||
if ( channel.isPersonalChat() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// グローバルチャンネルは対象外
|
||||
if ( channel.isGlobalChannel() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
items.add(channel.getName());
|
||||
}
|
||||
|
||||
return items;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインプレイヤーのうち、プレイヤー名が指定された文字列と前方一致するものをリストにして返す
|
||||
* @param pre 検索キー
|
||||
* @return プレイヤー名リスト
|
||||
*/
|
||||
protected abstract List<String> getListPlayerNames(String pre);
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* Lunachatコマンドの処理クラス(Bukkit実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatCommandBukkit extends LunaChatCommand implements CommandExecutor {
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param command 実行されたコマンド
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 実行したかどうか(falseを返した場合、サーバーがUsageを表示する)
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
return execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @param sender TABキー補完の実行者
|
||||
* @param command 実行されたコマンド
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
*/
|
||||
public List<String> onTabComplete(CommandSender sender, Command command, String label, String[] args) {
|
||||
return onTabComplete(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインプレイヤーのうち、プレイヤー名が指定された文字列と前方一致するものをリストにして返す
|
||||
* @param pre 検索キー
|
||||
* @return プレイヤー名リスト
|
||||
* @see com.github.ucchyocean.lc.command.LunaChatCommand#getListPlayerNames(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected List<String> getListPlayerNames(String pre) {
|
||||
|
||||
List<String> items = new ArrayList<String>();
|
||||
for ( Player player : Bukkit.getOnlinePlayers() ) {
|
||||
String pname = player.getName();
|
||||
if ( pname == null ) continue;
|
||||
if ( pname.toLowerCase().startsWith(pre) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
/**
|
||||
* Lunachatコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatCommandBungee extends LunaChatCommand {
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
execute(ChannelMember.getChannelMember(sender), "", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* TABキー補完が実行されたときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
* @see net.md_5.bungee.api.plugin.TabExecutor#onTabComplete(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
return onTabComplete(ChannelMember.getChannelMember(sender), "", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインプレイヤーのうち、プレイヤー名が指定された文字列と前方一致するものをリストにして返す
|
||||
* @param pre 検索キー
|
||||
* @return プレイヤー名リスト
|
||||
* @see com.github.ucchyocean.lc.command.LunaChatCommand#getListPlayerNames(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected List<String> getListPlayerNames(String pre) {
|
||||
|
||||
List<String> items = new ArrayList<String>();
|
||||
for ( ProxiedPlayer player : ProxyServer.getInstance().getPlayers() ) {
|
||||
String pname = player.getName();
|
||||
if ( pname == null ) continue;
|
||||
if ( pname.toLowerCase().startsWith(pre) ) {
|
||||
items.add(player.getName());
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.bukkit.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
|
||||
@@ -23,8 +23,8 @@ public class LunaChatJapanizeCommand implements CommandExecutor {
|
||||
|
||||
private static final String PERM_JAPANIZE_OTHER = "lunachat-admin.japanize-other";
|
||||
|
||||
private static final String PREINFO = Resources.get("infoPrefix");
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
private static final String PREINFO = Messages.get("infoPrefix");
|
||||
private static final String PREERR = Messages.get("errorPrefix");
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
@@ -111,7 +111,7 @@ public class LunaChatJapanizeCommand implements CommandExecutor {
|
||||
protected void sendResourceMessage(CommandSender sender, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
String org = Messages.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ public class LunaChatJapanizeCommand implements CommandExecutor {
|
||||
protected void sendResourceMessage(ChannelMember cp, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
String org = Messages.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.bukkit.LunaChatBukkit;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
@@ -21,7 +21,7 @@ import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
*/
|
||||
public class LunaChatMessageCommand implements CommandExecutor {
|
||||
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
private static final String PREERR = Messages.get("errorPrefix");
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
@@ -129,7 +129,7 @@ public class LunaChatMessageCommand implements CommandExecutor {
|
||||
protected void sendResourceMessage(CommandSender sender, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
String org = Messages.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
@@ -147,7 +147,7 @@ public class LunaChatMessageCommand implements CommandExecutor {
|
||||
protected void sendResourceMessage(ChannelMember cp, String pre,
|
||||
String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
String org = Messages.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ package com.github.ucchyocean.lc.command;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
|
||||
/**
|
||||
@@ -17,8 +17,8 @@ import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
*/
|
||||
public class LunaChatReplyCommand extends LunaChatMessageCommand {
|
||||
|
||||
private static final String PREINFO = Resources.get("infoPrefix");
|
||||
private static final String PREERR = Resources.get("errorPrefix");
|
||||
private static final String PREINFO = Messages.get("infoPrefix");
|
||||
private static final String PREERR = Messages.get("errorPrefix");
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
|
||||
@@ -8,7 +8,7 @@ package com.github.ucchyocean.lc.command;
|
||||
import com.github.ucchyocean.lc.LunaChat;
|
||||
import com.github.ucchyocean.lc.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc.Resources;
|
||||
import com.github.ucchyocean.lc.Messages;
|
||||
import com.github.ucchyocean.lc.Utility;
|
||||
import com.github.ucchyocean.lc.channel.Channel;
|
||||
import com.github.ucchyocean.lc.member.ChannelMember;
|
||||
@@ -35,8 +35,8 @@ public abstract class SubCommandAbst {
|
||||
ADMIN
|
||||
}
|
||||
|
||||
protected static final String PREINFO = Resources.get("infoPrefix");
|
||||
protected static final String PREERR = Resources.get("errorPrefix");
|
||||
protected static final String PREINFO = Messages.get("infoPrefix");
|
||||
protected static final String PREERR = Messages.get("errorPrefix");
|
||||
|
||||
protected LunaChatAPI api;
|
||||
protected LunaChatConfig config;
|
||||
@@ -59,7 +59,7 @@ public abstract class SubCommandAbst {
|
||||
protected void sendResourceMessageWithKeyword(
|
||||
Channel channel, String key, ChannelMember player) {
|
||||
|
||||
String msg = Resources.get(key);
|
||||
String msg = Messages.get(key);
|
||||
if ( msg == null || msg.equals("") ) {
|
||||
return;
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public abstract class SubCommandAbst {
|
||||
protected void sendResourceMessageWithKeyword(
|
||||
Channel channel, String key, ChannelMember player, int minutes) {
|
||||
|
||||
String msg = Resources.get(key);
|
||||
String msg = Messages.get(key);
|
||||
if ( msg == null || msg.equals("") ) {
|
||||
return;
|
||||
}
|
||||
@@ -115,7 +115,7 @@ public abstract class SubCommandAbst {
|
||||
protected void sendResourceMessage(
|
||||
ChannelMember cp, String pre, String key, Object... args) {
|
||||
|
||||
String org = Resources.get(key);
|
||||
String org = Messages.get(key);
|
||||
if ( org == null || org.equals("") ) {
|
||||
return;
|
||||
}
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする