LunaChat v3-k2 : BungeeCord implementation. (WIP)
このコミットが含まれているのは:
1 親
4dc513242c
コミット
db5fad0bb8
16ファイル変更
+153
-75
検索条件に一致するファイルはありません
@@ -8,6 +8,7 @@ package com.github.ucchyocean.lc3;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
@@ -267,10 +268,10 @@ public class LunaChatConfig {
|
||||
if ( globalChannel != null && !globalChannel.equals("") &&
|
||||
!globalChannel.matches("[0-9a-zA-Z\\-_]{1,20}") ) {
|
||||
|
||||
// TODO コンソールに警告を表示する
|
||||
// String msg = String.format(
|
||||
// Resources.get("errmsgCannotUseForGlobal"), globalChannel);
|
||||
// LunaChat.getInstance().getLogger().warning(msg);
|
||||
// コンソールに警告を表示する
|
||||
String msg = String.format(
|
||||
Messages.get("errmsgCannotUseForGlobal"), globalChannel);
|
||||
LunaChat.getPlugin().log(Level.WARNING, msg);
|
||||
globalChannel = "";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,8 @@
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
/**
|
||||
* プラグインインターフェイス
|
||||
@@ -42,4 +44,17 @@ public interface PluginInterface {
|
||||
* @return normalChatLogger
|
||||
*/
|
||||
public LunaChatLogger getNormalChatLogger();
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
public Set<String> getOnlinePlayerNames();
|
||||
|
||||
/**
|
||||
* このプラグインのログを記録する
|
||||
* @param level ログレベル
|
||||
* @param msg ログメッセージ
|
||||
*/
|
||||
public void log(Level level, String msg);
|
||||
}
|
||||
@@ -84,6 +84,16 @@ public class Utility {
|
||||
* @return 置き換え後の文字列
|
||||
*/
|
||||
public static String stripColorCode(String source) {
|
||||
if (source == null) return null;
|
||||
return stripAltColorCode(source).replaceAll("\u00A7([0-9a-fk-or])", "");
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列に含まれているカラーコード候補(&a)を除去して返す
|
||||
* @param source 置き換え元の文字列
|
||||
* @return 置き換え後の文字列
|
||||
*/
|
||||
public static String stripAltColorCode(String source) {
|
||||
if (source == null) return null;
|
||||
return source.replaceAll("&([0-9a-fk-or])", "");
|
||||
}
|
||||
@@ -107,6 +117,45 @@ public class Utility {
|
||||
if (code == null) return false;
|
||||
return code.matches("&[0-9a-fk-orA-FK-OR]");
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatColorで指定可能な色(REDとかGREENとか)かどうかを判断する
|
||||
* @param color カラー表記の文字列
|
||||
* @return 指定可能かどうか
|
||||
*/
|
||||
public static boolean isValidColor(String color) {
|
||||
if ( color == null ) return false;
|
||||
for (ChatColor c : ChatColor.values()) {
|
||||
if (c.name().equals(color.toUpperCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* カラー表記の文字列を、カラーコードに変換する
|
||||
* @param color カラー表記の文字列
|
||||
* @return カラーコード
|
||||
*/
|
||||
public static String changeToColorCode(String color) {
|
||||
|
||||
return "&" + changeToChatColor(color).getChar();
|
||||
}
|
||||
|
||||
/**
|
||||
* カラー表記の文字列を、ChatColorクラスに変換する
|
||||
* @param color カラー表記の文字列
|
||||
* @return ChatColorクラス
|
||||
*/
|
||||
public static ChatColor changeToChatColor(String color) {
|
||||
|
||||
if (isValidColor(color)) {
|
||||
return ChatColor.valueOf(color.toUpperCase());
|
||||
}
|
||||
return ChatColor.WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された文字数のアスタリスクの文字列を返す
|
||||
* @param length アスタリスクの個数
|
||||
|
||||
@@ -8,7 +8,6 @@ package com.github.ucchyocean.lc3;
|
||||
import java.util.Collection;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -34,44 +33,6 @@ public class UtilityBukkit {
|
||||
return getOnlinePlayers().size();
|
||||
}
|
||||
|
||||
/**
|
||||
* ChatColorで指定可能な色かどうかを判断する
|
||||
* @param color カラー表記の文字列
|
||||
* @return 指定可能かどうか
|
||||
*/
|
||||
public static boolean isValidColor(String color) {
|
||||
if ( color == null ) return false;
|
||||
for (ChatColor c : ChatColor.values()) {
|
||||
if (c.name().equals(color.toUpperCase())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* カラー表記の文字列を、カラーコードに変換する
|
||||
* @param color カラー表記の文字列
|
||||
* @return カラーコード
|
||||
*/
|
||||
public static String changeToColorCode(String color) {
|
||||
|
||||
return "&" + changeToChatColor(color).getChar();
|
||||
}
|
||||
|
||||
/**
|
||||
* カラー表記の文字列を、ChatColorクラスに変換する
|
||||
* @param color カラー表記の文字列
|
||||
* @return ChatColorクラス
|
||||
*/
|
||||
public static ChatColor changeToChatColor(String color) {
|
||||
|
||||
if (isValidColor(color)) {
|
||||
return ChatColor.valueOf(color.toUpperCase());
|
||||
}
|
||||
return ChatColor.WHITE;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された名前のオフラインプレイヤーを取得する
|
||||
* @param name プレイヤー名
|
||||
|
||||
@@ -7,10 +7,11 @@ package com.github.ucchyocean.lc3;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.Reader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
@@ -64,7 +65,7 @@ public class YamlConfig {
|
||||
}
|
||||
|
||||
public static YamlConfig load(File file) {
|
||||
try ( FileReader reader = new FileReader(file) ) {
|
||||
try ( InputStreamReader reader = new InputStreamReader(new FileInputStream(file), "UTF-8") ) {
|
||||
return load(reader);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -159,7 +159,6 @@ public class BukkitEventListener implements Listener {
|
||||
if ( channel.isPersonalChat() && cname.contains(pname) ) {
|
||||
boolean isAllOffline = true;
|
||||
for ( ChannelMember cp : channel.getMembers() ) {
|
||||
// TODO
|
||||
if ( cp.isOnline() ) {
|
||||
isAllOffline = false;
|
||||
}
|
||||
|
||||
@@ -6,11 +6,15 @@
|
||||
package com.github.ucchyocean.lc3.bukkit;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
@@ -239,4 +243,27 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
protected void setNormalChatLogger(LunaChatLogger normalChatLogger) {
|
||||
this.normalChatLogger = normalChatLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
Set<String> list = new HashSet<>();
|
||||
for ( Player p : Bukkit.getOnlinePlayers() ) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* このプラグインのログを記録する
|
||||
* @param level ログレベル
|
||||
* @param msg ログメッセージ
|
||||
*/
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
getLogger().log(level, msg);
|
||||
}
|
||||
}
|
||||
@@ -168,7 +168,6 @@ public class BungeeEventListener implements Listener {
|
||||
if ( channel.isPersonalChat() && cname.contains(pname) ) {
|
||||
boolean isAllOffline = true;
|
||||
for ( ChannelMember cp : channel.getMembers() ) {
|
||||
// TODO
|
||||
if ( cp.isOnline() ) {
|
||||
isAllOffline = false;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,9 @@ package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
@@ -17,6 +20,7 @@ import com.github.ucchyocean.lc3.PluginInterface;
|
||||
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;
|
||||
|
||||
/**
|
||||
@@ -143,4 +147,27 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
public LunaChatLogger getNormalChatLogger() {
|
||||
return normalChatLogger;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
Set<String> list = new HashSet<>();
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -55,10 +55,7 @@ public class JapanizeConvertTask {
|
||||
HashMap<String, String> keywordMap = new HashMap<String, String>();
|
||||
ArrayList<String> keywords = new ArrayList<String>();
|
||||
if ( LunaChat.getConfig().isJapanizeIgnorePlayerName() ) {
|
||||
// TODO
|
||||
// for ( Player player : Bukkit.getOnlinePlayers() ) {
|
||||
// keywords.add(player.getName());
|
||||
// }
|
||||
keywords.addAll(LunaChat.getPlugin().getOnlinePlayerNames());
|
||||
}
|
||||
HashMap<String, String> dictionary =
|
||||
LunaChat.getAPI().getAllDictionary();
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
|
||||
import com.github.ucchyocean.lc3.Utility;
|
||||
import com.github.ucchyocean.lc3.UtilityBukkit;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
@@ -205,9 +204,8 @@ public class OptionCommand extends SubCommandAbst {
|
||||
|
||||
String code = options.get("color");
|
||||
|
||||
// TODO Bukkit依存になってしまっているので、実装修正を検討する
|
||||
if ( UtilityBukkit.isValidColor(code) ) {
|
||||
code = UtilityBukkit.changeToColorCode(code);
|
||||
if ( Utility.isValidColor(code) ) {
|
||||
code = Utility.changeToColorCode(code);
|
||||
}
|
||||
if ( Utility.isAltColorCode(code) ) {
|
||||
channel.setColorCode(code);
|
||||
|
||||
@@ -87,11 +87,11 @@ public class SetCommand extends SubCommandAbst {
|
||||
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgSetDefault", targetPlayer, targetChannel.getName());
|
||||
|
||||
// TODO setされる相手のプレイヤーにも通知する
|
||||
// Player target = Utility.getPlayerExact(targetPlayer);
|
||||
// if ( target != null ) {
|
||||
// sendResourceMessage(new CommandSenderBukkit(target), PREINFO, "cmdmsgSet", targetChannel.getName());
|
||||
// }
|
||||
// setされる相手のプレイヤーにも通知する
|
||||
ChannelMember target = ChannelMember.getChannelMember(targetPlayer);
|
||||
if ( target != null ) {
|
||||
sendResourceMessage(target, PREINFO, "cmdmsgSet", targetChannel.getName());
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -9,7 +9,6 @@ import java.util.UUID;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
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;
|
||||
@@ -49,25 +48,13 @@ public class ChannelMemberProxiedPlayer extends ChannelMemberBungee {
|
||||
if ( nameOrUuid.startsWith("$") ) {
|
||||
return new ChannelMemberProxiedPlayer(UUID.fromString(nameOrUuid.substring(1)));
|
||||
} else {
|
||||
// TODO オフラインのプレイヤー取得について検討する
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(nameOrUuid);
|
||||
if ( player != null ) return new ChannelMemberProxiedPlayer(player.getUniqueId());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* CommandSenderから、ChannelMemberProxiedPlayerを作成して返す
|
||||
* @param sender
|
||||
* @return ChannelMemberProxiedPlayer
|
||||
*/
|
||||
public static ChannelMemberProxiedPlayer getChannelPlayer(CommandSender sender) {
|
||||
if ( sender instanceof ProxiedPlayer ) {
|
||||
return new ChannelMemberProxiedPlayer(((ProxiedPlayer)sender).getUniqueId());
|
||||
}
|
||||
// TODO BungeeCordのCommandSenderを実装するクラスは、ProxiedPlayer以外にないはず。コンソールは?
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインかどうか
|
||||
* @return オンラインかどうか
|
||||
|
||||
@@ -7,6 +7,8 @@ package com.github.ucchyocean.lc3.standalone;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
@@ -72,4 +74,18 @@ public class LunaChatStandalone implements PluginInterface {
|
||||
public LunaChatLogger getNormalChatLogger() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインのプレイヤー名一覧を取得する
|
||||
* @return オンラインのプレイヤー名一覧
|
||||
*/
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void log(Level level, String msg) {
|
||||
// TODO 未実装
|
||||
}
|
||||
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする