コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
6951eb77fc | ||
|
|
82fa7a73f8 |
検索条件に一致するファイルはありません
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.ucchyocean</groupId>
|
||||
<artifactId>LunaChat</artifactId>
|
||||
<version>2.7.7</version>
|
||||
<version>2.7.8</version>
|
||||
<description>チャンネルチャットプラグイン</description>
|
||||
|
||||
<licenses>
|
||||
|
||||
@@ -11,6 +11,7 @@ import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
|
||||
@@ -23,6 +24,9 @@ public class LunaChatConfig {
|
||||
/** チャンネルチャット機能を利用可能にするかどうか */
|
||||
private boolean enableChannelChat;
|
||||
|
||||
/** チャットイベントの処理優先度 */
|
||||
private EventPriority playerChatEventListenerPriority;
|
||||
|
||||
/** チャンネルチャットに入っていない人の発言を、グローバルとして扱うかどうか */
|
||||
private boolean noJoinAsGlobal;
|
||||
|
||||
@@ -157,6 +161,8 @@ public class LunaChatConfig {
|
||||
FileConfiguration config = LunaChat.getInstance().getConfig();
|
||||
|
||||
enableChannelChat = config.getBoolean("enableChannelChat", true);
|
||||
playerChatEventListenerPriority
|
||||
= getEventPriority(config.getString("playerChatEventListenerPriority"), EventPriority.HIGH);
|
||||
noJoinAsGlobal = config.getBoolean("noJoinAsGlobal", true);
|
||||
loggingChat = config.getBoolean("loggingChat", true);
|
||||
loggingChatToHawkEye = config.getBoolean("loggingChatToHawkEye", true);
|
||||
@@ -250,6 +256,14 @@ public class LunaChatConfig {
|
||||
return enableChannelChat;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャットイベントの処理優先度
|
||||
* @return playerChatEventListenerPriorityを返す
|
||||
*/
|
||||
public EventPriority getPlayerChatEventListenerPriority() {
|
||||
return playerChatEventListenerPriority;
|
||||
}
|
||||
|
||||
/**
|
||||
* チャンネルチャットに入っていない人の発言を、グローバルとして扱うかどうか
|
||||
* @return noJoinAsGlobalを返す
|
||||
@@ -519,4 +533,29 @@ public class LunaChatConfig {
|
||||
public boolean isEnableNormalChatColorCode() {
|
||||
return enableNormalChatColorCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* 指定された文字列から、対応するEventPriorityを返す。
|
||||
* @param value 文字列
|
||||
* @param def デフォルト
|
||||
* @return EventPriority
|
||||
*/
|
||||
private static EventPriority getEventPriority(String value, EventPriority def) {
|
||||
|
||||
if ( value == null ) return def;
|
||||
|
||||
if ( value.equalsIgnoreCase("LOWEST") ) {
|
||||
return EventPriority.LOWEST;
|
||||
} else if ( value.equalsIgnoreCase("LOW") ) {
|
||||
return EventPriority.LOW;
|
||||
} else if ( value.equalsIgnoreCase("NORMAL") ) {
|
||||
return EventPriority.NORMAL;
|
||||
} else if ( value.equalsIgnoreCase("HIGH") ) {
|
||||
return EventPriority.HIGH;
|
||||
} else if ( value.equalsIgnoreCase("HIGHEST") ) {
|
||||
return EventPriority.HIGHEST;
|
||||
}
|
||||
|
||||
return def;
|
||||
}
|
||||
}
|
||||
@@ -53,64 +53,58 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのチャットごとに呼び出されるメソッド
|
||||
* @param event チャットイベント
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.LOWEST, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatLowest(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.LOWEST ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.LOW, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatLow(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.LOW ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.NORMAL, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatNormal(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.NORMAL ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.HIGH, ignoreCancelled=true)
|
||||
public void onChat(AsyncPlayerChatEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
|
||||
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
|
||||
if ( config.getGlobalMarker() != null &&
|
||||
!config.getGlobalMarker().equals("") &&
|
||||
event.getMessage().startsWith(config.getGlobalMarker()) &&
|
||||
event.getMessage().length() > config.getGlobalMarker().length() ) {
|
||||
|
||||
int offset = config.getGlobalMarker().length();
|
||||
event.setMessage( event.getMessage().substring(offset) );
|
||||
chatGlobal(event);
|
||||
return;
|
||||
public void onAsyncPlayerChatHigh(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.HIGH ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
}
|
||||
|
||||
ChannelPlayer player =
|
||||
ChannelPlayer.getChannelPlayer(event.getPlayer());
|
||||
Channel channel = api.getDefaultChannel(player.getName());
|
||||
|
||||
// デフォルトの発言先が無い場合
|
||||
if ( channel == null ) {
|
||||
if ( config.isNoJoinAsGlobal() ) {
|
||||
// グローバル発言にする
|
||||
chatGlobal(event);
|
||||
return;
|
||||
|
||||
} else {
|
||||
// 発言をキャンセルして終了する
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* プレイヤーがチャット発言したときに呼び出されるメソッド
|
||||
* @param event
|
||||
*/
|
||||
@EventHandler(priority=EventPriority.HIGHEST, ignoreCancelled=true)
|
||||
public void onAsyncPlayerChatHighest(AsyncPlayerChatEvent event) {
|
||||
if ( LunaChat.getInstance().getLunaChatConfig().getPlayerChatEventListenerPriority() == EventPriority.HIGHEST ) {
|
||||
processChatEvent(event);
|
||||
}
|
||||
|
||||
// LunaChatPreChatEvent イベントコール
|
||||
LunaChatPreChatEvent preChatEvent = new LunaChatPreChatEvent(
|
||||
channel.getName(), player, event.getMessage());
|
||||
Bukkit.getPluginManager().callEvent(preChatEvent);
|
||||
if ( preChatEvent.isCancelled() ) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Channel alt = preChatEvent.getChannel();
|
||||
if ( alt != null ) {
|
||||
channel = alt;
|
||||
}
|
||||
String message = preChatEvent.getMessage();
|
||||
|
||||
// チャンネルチャット発言
|
||||
channel.chat(player, message);
|
||||
|
||||
// もとのイベントをキャンセル
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -174,6 +168,66 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* プレイヤーのチャットごとに呼び出されるメソッド
|
||||
* @param event チャットイベント
|
||||
*/
|
||||
private void processChatEvent(AsyncPlayerChatEvent event) {
|
||||
|
||||
LunaChatConfig config = LunaChat.getInstance().getLunaChatConfig();
|
||||
LunaChatAPI api = LunaChat.getInstance().getLunaChatAPI();
|
||||
|
||||
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
|
||||
if ( config.getGlobalMarker() != null &&
|
||||
!config.getGlobalMarker().equals("") &&
|
||||
event.getMessage().startsWith(config.getGlobalMarker()) &&
|
||||
event.getMessage().length() > config.getGlobalMarker().length() ) {
|
||||
|
||||
int offset = config.getGlobalMarker().length();
|
||||
event.setMessage( event.getMessage().substring(offset) );
|
||||
chatGlobal(event);
|
||||
return;
|
||||
}
|
||||
|
||||
ChannelPlayer player =
|
||||
ChannelPlayer.getChannelPlayer(event.getPlayer());
|
||||
Channel channel = api.getDefaultChannel(player.getName());
|
||||
|
||||
// デフォルトの発言先が無い場合
|
||||
if ( channel == null ) {
|
||||
if ( config.isNoJoinAsGlobal() ) {
|
||||
// グローバル発言にする
|
||||
chatGlobal(event);
|
||||
return;
|
||||
|
||||
} else {
|
||||
// 発言をキャンセルして終了する
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// LunaChatPreChatEvent イベントコール
|
||||
LunaChatPreChatEvent preChatEvent = new LunaChatPreChatEvent(
|
||||
channel.getName(), player, event.getMessage());
|
||||
Bukkit.getPluginManager().callEvent(preChatEvent);
|
||||
if ( preChatEvent.isCancelled() ) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
Channel alt = preChatEvent.getChannel();
|
||||
if ( alt != null ) {
|
||||
channel = alt;
|
||||
}
|
||||
String message = preChatEvent.getMessage();
|
||||
|
||||
// チャンネルチャット発言
|
||||
channel.chat(player, message);
|
||||
|
||||
// もとのイベントをキャンセル
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* イベントをグローバルチャット発言として処理する
|
||||
* @param event 処理するイベント
|
||||
|
||||
@@ -703,7 +703,7 @@ public class ChannelImpl extends Channel {
|
||||
msg = msg.replace("%suffix", player.getSuffix());
|
||||
}
|
||||
|
||||
if ( format.contains("%world") ) {
|
||||
if ( msg.contains("%world") ) {
|
||||
|
||||
String worldname = null;
|
||||
if ( LunaChat.getInstance().getMultiverseCore() != null ) {
|
||||
@@ -712,7 +712,7 @@ public class ChannelImpl extends Channel {
|
||||
if ( worldname == null || worldname.equals("") ) {
|
||||
worldname = player.getWorldName();
|
||||
}
|
||||
format = format.replace("%world", worldname);
|
||||
msg = msg.replace("%world", worldname);
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
@@ -4,10 +4,19 @@
|
||||
# @copyright Copyright ucchy 2013
|
||||
|
||||
|
||||
# -------------------- 全般設定 --------------------
|
||||
|
||||
# チャンネルチャット機能を利用可能にするかどうか
|
||||
# Japanize機能のみを利用したい場合は、falseにしてください。
|
||||
enableChannelChat: true
|
||||
|
||||
# イベント処理の優先度を設定できます。
|
||||
# 他のプラグインとの組み合わせでうまく動かないときに使用してください。
|
||||
# LOWEST, LOW, NORMAL, HIGH, HIGHEST のどれかを指定できます。
|
||||
# よくわからない場合は、デフォルトのHIGHのままにしてください。
|
||||
playerChatEventListenerPriority: 'HIGH'
|
||||
|
||||
|
||||
# -------------------- チャンネルチャット設定 --------------------
|
||||
|
||||
# チャンネルチャットに入っていない人の発言を、グローバルとして扱うかどうか
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする