LunaChat v3-k2 : tidied up command classes.
このコミットが含まれているのは:
1 親
a127034d91
コミット
adfc7db64b
16ファイル変更
+207
-454
検索条件に一致するファイルはありません
+2
-5
@@ -3,18 +3,15 @@
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bukkit;
|
||||
package com.github.ucchyocean.lc3;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
|
||||
/**
|
||||
* 各チャンネルの期限付きBANや期限付きMuteを、1分間隔で確認しに行くタスク
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ExpireCheckTask extends BukkitRunnable {
|
||||
public class ExpireCheckTask implements Runnable {
|
||||
|
||||
/**
|
||||
* 1分ごとに呼び出されるメソッド
|
||||
@@ -6,9 +6,9 @@
|
||||
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.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -17,7 +17,9 @@ import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
|
||||
import com.github.ucchyocean.lc3.ExpireCheckTask;
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
@@ -30,10 +32,11 @@ import com.github.ucchyocean.lc3.bridge.McMMOBridge;
|
||||
import com.github.ucchyocean.lc3.bridge.MultiverseCoreBridge;
|
||||
import com.github.ucchyocean.lc3.bridge.VaultChatBridge;
|
||||
import com.github.ucchyocean.lc3.channel.ChannelManager;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatCommandBukkit;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatCommand;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatJapanizeCommand;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatMessageCommand;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatReplyCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
* LunaChatのBukkit実装
|
||||
@@ -50,10 +53,10 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
private DynmapBridge dynmap;
|
||||
private MultiverseCoreBridge multiverse;
|
||||
|
||||
private ExpireCheckTask expireCheckerTask;
|
||||
private BukkitTask expireCheckerTask;
|
||||
private LunaChatLogger normalChatLogger;
|
||||
|
||||
private LunaChatCommandBukkit lunachatCommand;
|
||||
private LunaChatCommand lunachatCommand;
|
||||
private LunaChatMessageCommand messageCommand;
|
||||
private LunaChatReplyCommand replyCommand;
|
||||
private LunaChatJapanizeCommand lcjapanizeCommand;
|
||||
@@ -109,14 +112,14 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
getServer().getPluginManager().registerEvents(new BukkitEventListener(), this);
|
||||
|
||||
// コマンドの登録
|
||||
lunachatCommand = new LunaChatCommandBukkit();
|
||||
lunachatCommand = new LunaChatCommand();
|
||||
messageCommand = new LunaChatMessageCommand();
|
||||
replyCommand = new LunaChatReplyCommand();
|
||||
lcjapanizeCommand = new LunaChatJapanizeCommand();
|
||||
|
||||
// 期限チェッカータスクの起動
|
||||
expireCheckerTask = new ExpireCheckTask();
|
||||
expireCheckerTask.runTaskTimerAsynchronously(this, 100, 600);
|
||||
expireCheckerTask = Bukkit.getScheduler().runTaskTimerAsynchronously(
|
||||
this, new ExpireCheckTask(), 100, 600);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -141,13 +144,13 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
CommandSender sender, Command command, String label, String[] args) {
|
||||
|
||||
if ( command.getName().equals("lunachat") ) {
|
||||
return lunachatCommand.onCommand(sender, command, label, args);
|
||||
return lunachatCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
} else if ( command.getName().equals("tell") ) {
|
||||
return messageCommand.onCommand(sender, command, label, args);
|
||||
return messageCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
} else if ( command.getName().equals("reply") ) {
|
||||
return replyCommand.onCommand(sender, command, label, args);
|
||||
return replyCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
} else if ( command.getName().equals("lcjapanize") ) {
|
||||
return lcjapanizeCommand.onCommand(sender, command, label, args);
|
||||
return lcjapanizeCommand.execute(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
|
||||
return false;
|
||||
@@ -163,7 +166,7 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
|
||||
List<String> completeList = null;
|
||||
if ( command.getName().equals("lunachat") ) {
|
||||
completeList = lunachatCommand.onTabComplete(sender, command, label, args);
|
||||
completeList = lunachatCommand.onTabComplete(ChannelMember.getChannelMember(sender), label, args);
|
||||
}
|
||||
if ( completeList != null ) {
|
||||
return completeList;
|
||||
@@ -252,7 +255,7 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
Set<String> list = new HashSet<>();
|
||||
Set<String> list = new TreeSet<>();
|
||||
for ( Player p : Bukkit.getOnlinePlayers() ) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc3.command.LunaChatJapanizeCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* Japanizeコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class JapanizeCommandBungee extends Command {
|
||||
|
||||
private LunaChatJapanizeCommand command;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name
|
||||
* @param permission
|
||||
* @param aliases
|
||||
*/
|
||||
public JapanizeCommandBungee(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
command = new LunaChatJapanizeCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
command.execute(ChannelMember.getChannelMember(sender), "jp", args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,8 +7,8 @@ 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.TreeSet;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
@@ -62,11 +62,13 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
|
||||
// コマンド登録
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new LunaChatCommandImpl("lunachat", "", "lc", "ch"));
|
||||
new LunaChatCommandBungee("lunachat", "", "lc", "ch"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new TellCommand(this, "tell", "", "msg", "message", "m", "t"));
|
||||
new MessageCommandBungee("tell", "", "msg", "message", "m", "t"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new ReplyCommand(this, "reply", "", "r"));
|
||||
new ReplyCommandBungee("reply", "", "r"));
|
||||
getProxy().getPluginManager().registerCommand(this,
|
||||
new JapanizeCommandBungee("japanize", "", "jp"));
|
||||
|
||||
// リスナー登録
|
||||
getProxy().getPluginManager().registerListener(this, new BungeeEventListener(this));
|
||||
@@ -154,7 +156,7 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
*/
|
||||
@Override
|
||||
public Set<String> getOnlinePlayerNames() {
|
||||
Set<String> list = new HashSet<>();
|
||||
Set<String> list = new TreeSet<>();
|
||||
for ( ProxiedPlayer p : ProxyServer.getInstance().getPlayers() ) {
|
||||
list.add(p.getName());
|
||||
}
|
||||
|
||||
+13
-10
@@ -5,28 +5,30 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc3.command.LunaChatCommandBungee;
|
||||
import com.github.ucchyocean.lc3.command.LunaChatCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
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コマンド実装クラス
|
||||
* Lunachatコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatCommandImpl extends Command implements TabExecutor {
|
||||
public class LunaChatCommandBungee extends Command implements TabExecutor {
|
||||
|
||||
private LunaChatCommandBungee com = new LunaChatCommandBungee();
|
||||
private LunaChatCommand command;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name コマンド
|
||||
* @param permission パーミッション
|
||||
* @param aliases エイリアス
|
||||
* @param name
|
||||
* @param permission
|
||||
* @param aliases
|
||||
*/
|
||||
public LunaChatCommandImpl(String name, String permission, String... aliases) {
|
||||
public LunaChatCommandBungee(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
command = new LunaChatCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,8 +37,9 @@ public class LunaChatCommandImpl extends Command implements TabExecutor {
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
com.execute(sender, args);
|
||||
command.execute(ChannelMember.getChannelMember(sender), "ch", args);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -48,6 +51,6 @@ public class LunaChatCommandImpl extends Command implements TabExecutor {
|
||||
*/
|
||||
@Override
|
||||
public Iterable<String> onTabComplete(CommandSender sender, String[] args) {
|
||||
return com.onTabComplete(sender, args);
|
||||
return command.onTabComplete(ChannelMember.getChannelMember(sender), "ch", args);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc3.command.LunaChatMessageCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* Tellコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class MessageCommandBungee extends Command {
|
||||
|
||||
private LunaChatMessageCommand command;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name
|
||||
* @param permission
|
||||
* @param aliases
|
||||
*/
|
||||
public MessageCommandBungee(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
command = new LunaChatMessageCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
command.execute(ChannelMember.getChannelMember(sender), "m", args);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,79 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
/**
|
||||
* LunaChatのreplyコマンド実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ReplyCommand extends TellCommand {
|
||||
|
||||
private LunaChatBungee parent;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param BungeeJapanizeMessenger
|
||||
* @param name コマンド
|
||||
* @param permission パーミッション
|
||||
* @param aliases エイリアス
|
||||
*/
|
||||
public ReplyCommand(LunaChatBungee parent, String name, String permission, String... aliases) {
|
||||
super(parent, name, permission, aliases);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドが実行された時に呼び出されるメソッド
|
||||
* @param sender コマンド実行者
|
||||
* @param args コマンド引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
String recieverName = parent.getHistory(sender.getName());
|
||||
|
||||
// 引数が無いときは、現在の会話相手を表示して終了する。
|
||||
if ( args.length == 0 ) {
|
||||
if ( recieverName != null ) {
|
||||
sendMessage(sender, ChatColor.LIGHT_PURPLE +
|
||||
"現在の会話相手: " + recieverName);
|
||||
} else {
|
||||
sendMessage(sender, ChatColor.LIGHT_PURPLE +
|
||||
"現在の会話相手は設定されていません。");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
// 送信先プレイヤーの取得。取得できないならエラーを表示して終了する。
|
||||
if ( recieverName == null ) {
|
||||
sendMessage(sender, ChatColor.RED +
|
||||
"メッセージ送信先が見つかりません。");
|
||||
return;
|
||||
}
|
||||
ProxiedPlayer reciever = parent.getProxy().getPlayer(
|
||||
parent.getHistory(sender.getName()));
|
||||
if ( reciever == null ) {
|
||||
sendMessage(sender, ChatColor.RED +
|
||||
"メッセージ送信先" + recieverName + "が見つかりません。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 送信メッセージの作成
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (int i = 0; i < args.length; i++) {
|
||||
str.append(args[i] + " ");
|
||||
}
|
||||
String message = str.toString().trim();
|
||||
|
||||
// 送信
|
||||
sendPrivateMessage(sender, reciever, message);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import com.github.ucchyocean.lc3.command.LunaChatReplyCommand;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* Replyコマンドの処理クラス(Bungee実装)
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ReplyCommandBungee extends Command {
|
||||
|
||||
private LunaChatReplyCommand command;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param name
|
||||
* @param permission
|
||||
* @param aliases
|
||||
*/
|
||||
public ReplyCommandBungee(String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
command = new LunaChatReplyCommand();
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
command.execute(ChannelMember.getChannelMember(sender), "r", args);
|
||||
}
|
||||
}
|
||||
@@ -1,177 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.bungee;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChat;
|
||||
import com.github.ucchyocean.lc3.LunaChatConfig;
|
||||
import com.github.ucchyocean.lc3.Utility;
|
||||
import com.github.ucchyocean.lc3.japanize.Japanizer;
|
||||
|
||||
import net.md_5.bungee.api.ChatColor;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
|
||||
/**
|
||||
* LunaChatのtellコマンド実装クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class TellCommand extends Command {
|
||||
|
||||
private LunaChatBungee parent;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param parent
|
||||
* @param name コマンド
|
||||
* @param permission パーミッション
|
||||
* @param aliases エイリアス
|
||||
*/
|
||||
public TellCommand(LunaChatBungee parent, String name, String permission, String... aliases) {
|
||||
super(name, permission, aliases);
|
||||
this.parent = parent;
|
||||
}
|
||||
|
||||
/**
|
||||
* コマンドが実行された時に呼び出されるメソッド
|
||||
* @param sender コマンド実行者
|
||||
* @param args コマンド引数
|
||||
* @see net.md_5.bungee.api.plugin.Command#execute(net.md_5.bungee.api.CommandSender, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
|
||||
// 引数が足らないので、Usageを表示して終了する。
|
||||
if ( args.length <= 1 ) {
|
||||
sendMessage(sender, ChatColor.RED +
|
||||
"実行例: /" + this.getName() + " <player> <message>");
|
||||
return;
|
||||
}
|
||||
|
||||
// 自分自身には送信できない。
|
||||
if ( args[0].equals(sender.getName()) ) {
|
||||
sendMessage(sender, ChatColor.RED +
|
||||
"自分自身にはプライベートメッセージを送信することができません。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 送信先プレイヤーの取得。取得できないならエラーを表示して終了する。
|
||||
ProxiedPlayer reciever = parent.getProxy().getPlayer(args[0]);
|
||||
if ( reciever == null ) {
|
||||
sendMessage(sender, ChatColor.RED +
|
||||
"メッセージ送信先 " + args[0] + " が見つかりません。");
|
||||
return;
|
||||
}
|
||||
|
||||
// 送信メッセージの作成
|
||||
StringBuilder str = new StringBuilder();
|
||||
for (int i = 1; i < args.length; i++) {
|
||||
str.append(args[i] + " ");
|
||||
}
|
||||
String message = str.toString().trim();
|
||||
|
||||
// 送信
|
||||
sendPrivateMessage(sender, reciever, message);
|
||||
}
|
||||
|
||||
/**
|
||||
* プライベートメッセージを送信する
|
||||
* @param sender 送信者
|
||||
* @param receiver 受信者名
|
||||
* @param message メッセージ
|
||||
*/
|
||||
protected void sendPrivateMessage(CommandSender sender, ProxiedPlayer reciever, String message) {
|
||||
|
||||
LunaChatConfig config = parent.getConfig();
|
||||
|
||||
// NGワードのマスク
|
||||
message = maskNGWord(message, config.getNgwordCompiled());
|
||||
|
||||
// Japanizeの付加
|
||||
if ( message.startsWith(config.getNoneJapanizeMarker()) ) {
|
||||
|
||||
message = message.substring(config.getNoneJapanizeMarker().length());
|
||||
|
||||
} else {
|
||||
|
||||
String japanize = Japanizer.japanize(message, config.getJapanizeType(),
|
||||
LunaChat.getAPI().getAllDictionary());
|
||||
if ( japanize.length() > 0 ) {
|
||||
|
||||
// NGワードのマスク
|
||||
japanize = maskNGWord(japanize, config.getNgwordCompiled());
|
||||
|
||||
// フォーマット化してメッセージを上書きする
|
||||
String japanizeFormat = config.getJapanizeDisplayLine() == 1 ?
|
||||
config.getJapanizeLine1Format() :
|
||||
"%msg\n" + config.getJapanizeLine2Format();
|
||||
String preMessage = new String(message);
|
||||
message = japanizeFormat.replace("%msg", preMessage).replace("%japanize", japanize);
|
||||
}
|
||||
}
|
||||
|
||||
// フォーマットの適用
|
||||
String senderServer = "";
|
||||
if ( sender instanceof ProxiedPlayer ) {
|
||||
senderServer = ((ProxiedPlayer)sender).getServer().getInfo().getName();
|
||||
}
|
||||
String result = new String(
|
||||
parent.getConfig().getDefaultFormatForPrivateMessage());
|
||||
result = result.replace("%senderserver", senderServer);
|
||||
result = result.replace("%sender", sender.getName());
|
||||
result = result.replace("%recieverserver",
|
||||
reciever.getServer().getInfo().getName());
|
||||
result = result.replace("%reciever", reciever.getName());
|
||||
result = result.replace("%msg", message);
|
||||
|
||||
// カラーコードの置き換え
|
||||
result = Utility.replaceColorCode(result);
|
||||
|
||||
// メッセージ送信
|
||||
sendMessage(sender, result);
|
||||
sendMessage(reciever, result);
|
||||
|
||||
// 送信履歴を記録
|
||||
parent.putHistory(reciever.getName(), sender.getName());
|
||||
|
||||
// コンソールに表示設定なら、コンソールに表示する
|
||||
if ( config.isDisplayChatOnConsole() ) {
|
||||
parent.getLogger().info(result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* NGワードをマスクする
|
||||
* @param message メッセージ
|
||||
* @param ngwords NGワード
|
||||
* @return マスクされたメッセージ
|
||||
*/
|
||||
private String maskNGWord(String message, List<Pattern> ngwords) {
|
||||
for ( Pattern pattern : ngwords ) {
|
||||
Matcher matcher = pattern.matcher(message);
|
||||
if ( matcher.find() ) {
|
||||
message = matcher.replaceAll(
|
||||
Utility.getAstariskString(matcher.group(0).length()));
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定した対象にメッセージを送信する
|
||||
* @param reciever 送信先
|
||||
* @param message メッセージ
|
||||
*/
|
||||
protected void sendMessage(CommandSender reciever, String message) {
|
||||
if ( message == null ) return;
|
||||
reciever.sendMessage(TextComponent.fromLegacyText(message));
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
* Lunachatコマンドの処理クラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public abstract class LunaChatCommand {
|
||||
public class LunaChatCommand {
|
||||
|
||||
private ArrayList<LunaChatSubCommand> commands;
|
||||
private ArrayList<LunaChatSubCommand> commonCommands;
|
||||
@@ -70,7 +70,7 @@ public abstract class LunaChatCommand {
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 実行したかどうか(falseを返した場合、サーバーがUsageを表示する)
|
||||
*/
|
||||
protected boolean execute(ChannelMember sender, String label, String[] args) {
|
||||
public boolean execute(ChannelMember sender, String label, String[] args) {
|
||||
|
||||
// チャンネルチャットが無効でも利用できるコマンドはここで処理する
|
||||
// (hide, unhide, dic, dictionary, reload)
|
||||
@@ -137,7 +137,7 @@ public abstract class LunaChatCommand {
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 補完候補
|
||||
*/
|
||||
protected List<String> onTabComplete(ChannelMember sender, String label, String[] args) {
|
||||
public List<String> onTabComplete(ChannelMember sender, String label, String[] args) {
|
||||
if ( args.length == 1 ) {
|
||||
// コマンド名で補完する
|
||||
String arg = args[0].toLowerCase();
|
||||
@@ -374,5 +374,14 @@ public abstract class LunaChatCommand {
|
||||
* @param pre 検索キー
|
||||
* @return プレイヤー名リスト
|
||||
*/
|
||||
protected abstract List<String> getListPlayerNames(String pre);
|
||||
private List<String> getListPlayerNames(String pre) {
|
||||
String prefix = pre.toLowerCase();
|
||||
List<String> items = new ArrayList<String>();
|
||||
for ( String pname : LunaChat.getPlugin().getOnlinePlayerNames() ) {
|
||||
if ( pname.toLowerCase().startsWith(prefix) ) {
|
||||
items.add(pname);
|
||||
}
|
||||
}
|
||||
return items;
|
||||
}
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.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.lc3.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.lc3.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;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import com.github.ucchyocean.lc3.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), "ch", 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), "ch", args);
|
||||
}
|
||||
|
||||
/**
|
||||
* オンラインプレイヤーのうち、プレイヤー名が指定された文字列と前方一致するものをリストにして返す
|
||||
* @param pre 検索キー
|
||||
* @return プレイヤー名リスト
|
||||
* @see com.github.ucchyocean.lc3.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;
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,6 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.bukkit.LunaChatBukkit;
|
||||
@@ -18,16 +14,18 @@ import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
* Japanize変換設定コマンド
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatJapanizeCommand implements CommandExecutor {
|
||||
public class LunaChatJapanizeCommand {
|
||||
|
||||
private static final String PERM_JAPANIZE_OTHER = "lunachat-admin.japanize-other";
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 実行したかどうか(falseを返した場合、サーバーがUsageを表示する)
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command,
|
||||
String label, String[] args) {
|
||||
public boolean execute(ChannelMember sender, String label, String[] args) {
|
||||
|
||||
if ( args.length == 1 &&
|
||||
(args[0].equalsIgnoreCase("on") || args[0].equalsIgnoreCase("off")) ) {
|
||||
@@ -85,7 +83,7 @@ public class LunaChatJapanizeCommand implements CommandExecutor {
|
||||
* @param sender
|
||||
* @param label
|
||||
*/
|
||||
private void printUsage(CommandSender sender, String label) {
|
||||
private void printUsage(ChannelMember sender, String label) {
|
||||
sender.sendMessage(Messages.usageJapanize(label));
|
||||
if ( sender.hasPermission(PERM_JAPANIZE_OTHER) ) {
|
||||
sender.sendMessage(Messages.usageJapanizeOther(label));
|
||||
|
||||
@@ -5,10 +5,6 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChatAPI;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.bukkit.LunaChatBukkit;
|
||||
@@ -19,14 +15,16 @@ import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
* 1:1チャット送信コマンド
|
||||
* @author ucchy
|
||||
*/
|
||||
public class LunaChatMessageCommand implements CommandExecutor {
|
||||
public class LunaChatMessageCommand {
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 実行したかどうか(falseを返した場合、サーバーがUsageを表示する)
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command,
|
||||
String label, String[] args) {
|
||||
public boolean execute(ChannelMember sender, String label, String[] args) {
|
||||
|
||||
// senderからChannelMemberを作成する
|
||||
ChannelMember inviter = ChannelMember.getChannelMember(sender);
|
||||
@@ -111,7 +109,7 @@ public class LunaChatMessageCommand implements CommandExecutor {
|
||||
* @param sender
|
||||
* @param label
|
||||
*/
|
||||
private void printUsage(CommandSender sender, String label) {
|
||||
private void printUsage(ChannelMember sender, String label) {
|
||||
sender.sendMessage(Messages.usageMessage(label));
|
||||
}
|
||||
}
|
||||
@@ -5,9 +5,6 @@
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.command;
|
||||
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
@@ -18,11 +15,15 @@ import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
public class LunaChatReplyCommand extends LunaChatMessageCommand {
|
||||
|
||||
/**
|
||||
* @see org.bukkit.command.CommandExecutor#onCommand(org.bukkit.command.CommandSender, org.bukkit.command.Command, java.lang.String, java.lang.String[])
|
||||
* コマンドを実行したときに呼び出されるメソッド
|
||||
* @param sender 実行者
|
||||
* @param label 実行されたコマンドのラベル
|
||||
* @param args 実行されたコマンドの引数
|
||||
* @return 実行したかどうか(falseを返した場合、サーバーがUsageを表示する)
|
||||
* @see com.github.ucchyocean.lc3.command.LunaChatMessageCommand#execute(com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.lang.String[])
|
||||
*/
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command,
|
||||
String label, String[] args) {
|
||||
public boolean execute(ChannelMember sender, String label, String[] args) {
|
||||
|
||||
// senderからChannelMemberを作成する
|
||||
ChannelMember inviter = ChannelMember.getChannelMember(sender);
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする