LunaChat v2.7.2 : Fixed issue #131.

このコミットが含まれているのは:
ucchy committed 2015-04-12 01:16:04 +09:00
1 親 e053d72010
コミット 2b0e3a9b97
8ファイル変更
+160 -40

検索条件に一致するファイルはありません

+11 -3
ファイルの表示
@@ -25,7 +25,7 @@ import com.github.ucchyocean.lc.channel.Channel;
import com.github.ucchyocean.lc.channel.ChannelPlayer;
import com.github.ucchyocean.lc.channel.ChannelPlayerName;
import com.github.ucchyocean.lc.channel.ChannelPlayerUUID;
import com.github.ucchyocean.lc.channel.DelayedJapanizeConvertTask;
import com.github.ucchyocean.lc.channel.DelayedJapanizeNormalChatTask;
import com.github.ucchyocean.lc.event.LunaChatPreChatEvent;
import com.github.ucchyocean.lc.japanize.JapanizeType;
@@ -236,6 +236,14 @@ public class PlayerListener implements Listener {
message = Utility.replaceColorCode(message);
}
// hideされているプレイヤーを、recipientから抜く
for ( ChannelPlayer cp : api.getHidelist(player) ) {
Player p = cp.getPlayer();
if ( p != null ) {
event.getRecipients().remove(p);
}
}
// 一時的にJapanizeスキップ設定かどうかを確認する
boolean skipJapanize = false;
@@ -275,8 +283,8 @@ public class PlayerListener implements Listener {
String taskFormat = Utility.replaceColorCode(config.getJapanizeLine2Format());
DelayedJapanizeConvertTask task = new DelayedJapanizeConvertTask(message,
config.getJapanizeType(), null, player, taskFormat, null);
DelayedJapanizeNormalChatTask task = new DelayedJapanizeNormalChatTask(
message, config.getJapanizeType(), player, taskFormat, event);
// 発言処理を必ず先に実施させるため、遅延を入れてタスクを実行する。
int wait = config.getJapanizeWait();
+1 -1
ファイルの表示
@@ -178,7 +178,7 @@ public class ChannelImpl extends Channel {
}
// タスクを作成しておく
delayedTask = new DelayedJapanizeConvertTask(maskedMessage,
delayedTask = new DelayedJapanizeChannelChatTask(maskedMessage,
japanizeType, this, player, jpFormat, messageFormat);
}
+1 -1
ファイルの表示
@@ -645,7 +645,7 @@ public class ChannelManager implements LunaChatAPI {
// Japanize変換タスクを作成して、同期で実行する。
DelayedJapanizeConvertTask task = new DelayedJapanizeConvertTask(
message, type, null, null, "%japanize", null);
message, type, null, null, "%japanize");
if ( task.runSync() ) {
return task.getResult();
}
+48
ファイルの表示
@@ -0,0 +1,48 @@
/*
* @author ucchy
* @license LGPLv3
* @copyright Copyright ucchy 2015
*/
package com.github.ucchyocean.lc.channel;
import com.github.ucchyocean.lc.japanize.JapanizeType;
/**
*
* @author ucchy
*/
public class DelayedJapanizeChannelChatTask extends DelayedJapanizeConvertTask {
private Channel channel;
private ChannelPlayer player;
private String lineFormat;
/**
* コンストラクタ
* @param org 変換前の文字列
* @param type 変換タイプ
* @param channel 変換後に発言する、発言先チャンネル
* @param player 発言したプレイヤー
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
* @param lineFormat
*/
public DelayedJapanizeChannelChatTask(String org, JapanizeType type, Channel channel,
ChannelPlayer player, String japanizeFormat, String lineFormat) {
super(org, type, channel, player, japanizeFormat);
this.channel = channel;
this.player = player;
this.lineFormat = lineFormat;
}
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
if ( runSync() ) {
// チャンネルへ送信
channel.sendMessage(player, getResult(), lineFormat, true);
}
}
}
+2 -26
ファイルの表示
@@ -34,7 +34,6 @@ public class DelayedJapanizeConvertTask extends BukkitRunnable {
private Channel channel;
private ChannelPlayer player;
private String format;
private String lineFormat;
private String result;
/**
@@ -46,40 +45,17 @@ public class DelayedJapanizeConvertTask extends BukkitRunnable {
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
*/
public DelayedJapanizeConvertTask(String org, JapanizeType type, Channel channel,
ChannelPlayer player, String japanizeFormat, String lineFormat) {
ChannelPlayer player, String japanizeFormat) {
this.org = org;
this.type = type;
this.channel = channel;
this.player = player;
this.format = japanizeFormat;
this.lineFormat = lineFormat;
}
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
if ( runSync() ) {
// チャンネルへ送信
if ( channel != null ) {
channel.sendMessage(player, result, lineFormat, true);
} else {
Bukkit.broadcastMessage(result);
// 設定に応じてdynmapへ送信する
if ( LunaChat.getInstance().getLunaChatConfig().
isSendBroadcastChannelChatToDynmap() &&
LunaChat.getInstance().getDynmap() != null ) {
if ( player != null && player.getPlayer() != null )
LunaChat.getInstance().getDynmap().chat(player.getPlayer(), result);
else
LunaChat.getInstance().getDynmap().broadcast(result);
}
}
}
runSync();
}
/**
+66
ファイルの表示
@@ -0,0 +1,66 @@
/*
* @author ucchy
* @license LGPLv3
* @copyright Copyright ucchy 2015
*/
package com.github.ucchyocean.lc.channel;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.player.AsyncPlayerChatEvent;
import com.github.ucchyocean.lc.LunaChat;
import com.github.ucchyocean.lc.japanize.JapanizeType;
/**
*
* @author ucchy
*/
public class DelayedJapanizeNormalChatTask extends DelayedJapanizeConvertTask {
private ChannelPlayer player;
private AsyncPlayerChatEvent event;
/**
* コンストラクタ
* @param org 変換前の文字列
* @param type 変換タイプ
* @param player 発言したプレイヤー
* @param japanizeFormat 変換後に発言するときの、発言フォーマット
* @param event イベント
*/
public DelayedJapanizeNormalChatTask(String org, JapanizeType type,
ChannelPlayer player, String japanizeFormat, final AsyncPlayerChatEvent event) {
super(org, type, null, player, japanizeFormat);
this.player = player;
this.event = event;
}
/**
* @see java.lang.Runnable#run()
*/
@Override
public void run() {
if ( runSync() ) {
String result = getResult();
// 送信
for ( Player p : event.getRecipients() ) {
p.sendMessage(result);
}
Bukkit.getConsoleSender().sendMessage(result);
// 設定に応じてdynmapへ送信する
if ( LunaChat.getInstance().getLunaChatConfig().
isSendBroadcastChannelChatToDynmap() &&
LunaChat.getInstance().getDynmap() != null ) {
if ( player != null && player.getPlayer() != null )
LunaChat.getInstance().getDynmap().chat(player.getPlayer(), result);
else
LunaChat.getInstance().getDynmap().broadcast(result);
}
}
}
}
+27 -5
ファイルの表示
@@ -28,6 +28,7 @@ public class LunaChatCommand implements CommandExecutor {
private static final String PREERR = Resources.get("errorPrefix");
private ArrayList<SubCommandAbst> commands;
private ArrayList<SubCommandAbst> commonCommands;
private JoinCommand joinCommand;
private HelpCommand helpCommand;
@@ -49,8 +50,6 @@ public class LunaChatCommand implements CommandExecutor {
commands.add(new PardonCommand());
commands.add(new MuteCommand());
commands.add(new UnmuteCommand());
commands.add(new HideCommand());
commands.add(new UnhideCommand());
commands.add(new InfoCommand());
commands.add(new LogCommand());
commands.add(new CreateCommand());
@@ -58,14 +57,18 @@ public class LunaChatCommand implements CommandExecutor {
commands.add(new FormatCommand());
commands.add(new ModeratorCommand());
commands.add(new ModCommand());
commands.add(new DictionaryCommand());
commands.add(new DicCommand());
commands.add(new OptionCommand());
commands.add(new TemplateCommand());
commands.add(new CheckCommand());
commands.add(new ReloadCommand());
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());
}
/**
@@ -75,6 +78,25 @@ public class LunaChatCommand implements CommandExecutor {
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(sender, label, args);
}
}
}
// チャンネルチャット機能が無効になっている場合は、メッセージを表示して終了
if ( !LunaChat.getInstance().getLunaChatConfig().isEnableChannelChat()
&& !sender.isOp() ) {