LunaChat v2.0.0 : Issue #23 (wip. There are still compile errors.)
このコミットが含まれているのは:
1 親
7be368ae36
コミット
0b39fbbef7
5ファイル変更
+136
-25
検索条件に一致するファイルはありません
@@ -22,6 +22,7 @@ import org.bukkit.entity.Player;
|
||||
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelChatEvent;
|
||||
import com.github.ucchyocean.lc.event.LunaChatChannelMemberChangedEvent;
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc.japanize.KanaConverter;
|
||||
|
||||
/**
|
||||
@@ -132,7 +133,7 @@ public class Channel implements ConfigurationSerializable {
|
||||
|
||||
// Japanize変換
|
||||
String kana = null;
|
||||
if ( LunaChat.config.displayJapanize ) {
|
||||
if ( LunaChat.config.getJapanizeType() != JapanizeType.NONE ) {
|
||||
// 2byteコードを含まない場合にのみ、処理を行う
|
||||
if ( message.getBytes().length == message.length() ) {
|
||||
kana = KanaConverter.conv(message);
|
||||
|
||||
@@ -10,15 +10,14 @@ import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
|
||||
/**
|
||||
* @author ucchy
|
||||
* LunaChatのコンフィグクラス
|
||||
*/
|
||||
public class LunaChatConfig {
|
||||
|
||||
/** Japanize変換をおこなうかどうか */
|
||||
protected boolean displayJapanize;
|
||||
|
||||
/** チャンネルチャットに入っていない人の発言を、グローバルとして扱うかどうか */
|
||||
protected boolean noJoinAsGlobal;
|
||||
|
||||
@@ -50,6 +49,24 @@ public class LunaChatConfig {
|
||||
* ban = マスクしてチャンネルからBANする */
|
||||
protected NGWordAction ngwordAction;
|
||||
|
||||
/** Japanize変換のタイプ
|
||||
* none = 日本語変換をしない
|
||||
* kana = カナ変換のみする
|
||||
* googleime = カナ変換後、GoogleIMEで漢字変換する
|
||||
* socialime = カナ変換後、SocialIMEで漢字変換する */
|
||||
protected JapanizeType japanizeType;
|
||||
|
||||
/** Japanize変換の1行表示と2行表示の切り替え
|
||||
* 1 = 1行表示
|
||||
* 2 = 2行表示 */
|
||||
protected int japanizeDisplayLine;
|
||||
|
||||
/** Japanize変換の1行表示時のフォーマット */
|
||||
protected String japanizeLine1Format;
|
||||
|
||||
/** Japanize変換の2行表示時の2行目のフォーマット */
|
||||
protected String japanizeLine2Format;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
*/
|
||||
@@ -70,7 +87,6 @@ public class LunaChatConfig {
|
||||
LunaChat.instance.reloadConfig();
|
||||
FileConfiguration config = LunaChat.instance.getConfig();
|
||||
|
||||
displayJapanize = config.getBoolean("displayJapanize", true);
|
||||
noJoinAsGlobal = config.getBoolean("noJoinAsGlobal", true);
|
||||
loggingChat = config.getBoolean("loggingChat", true);
|
||||
globalMarker = config.getString("globalMarker", "!");
|
||||
@@ -81,6 +97,13 @@ public class LunaChatConfig {
|
||||
globalChannel = config.getString("globalChannel", "");
|
||||
ngword = config.getStringList("ngword");
|
||||
ngwordAction = NGWordAction.fromID(config.getString("ngwordAction", "mask"));
|
||||
japanizeType = JapanizeType.fromID(config.getString("japanizeType", "kana"));
|
||||
japanizeDisplayLine = config.getInt("japanizeDisplayLine", 2);
|
||||
if ( japanizeDisplayLine != 1 && japanizeDisplayLine != 2 ) {
|
||||
japanizeDisplayLine = 2;
|
||||
}
|
||||
japanizeLine1Format = config.getString("japanizeLine1Format", "%msg (%japanize)");
|
||||
japanizeLine2Format = config.getString("japanizeLine2Format", "&6[JP] %japanize");
|
||||
|
||||
// globalチャンネルが、使用可能なチャンネル名かどうかを調べる
|
||||
if ( !LunaChat.manager.checkForChannelName(globalChannel) ) {
|
||||
@@ -91,20 +114,6 @@ public class LunaChatConfig {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return displayJapanizeを返す
|
||||
*/
|
||||
public boolean isDisplayJapanize() {
|
||||
return displayJapanize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param displayJapanize displayJapanizeを設定する
|
||||
*/
|
||||
public void setDisplayJapanize(boolean displayJapanize) {
|
||||
this.displayJapanize = displayJapanize;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return noJoinAsGlobalを返す
|
||||
*/
|
||||
@@ -230,4 +239,60 @@ public class LunaChatConfig {
|
||||
public void setNgwordAction(NGWordAction ngwordAction) {
|
||||
this.ngwordAction = ngwordAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return japanizeTypeを返す
|
||||
*/
|
||||
public JapanizeType getJapanizeType() {
|
||||
return japanizeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param japanizeType japanizeTypeを設定する
|
||||
*/
|
||||
public void setJapanizeType(JapanizeType japanizeType) {
|
||||
this.japanizeType = japanizeType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return japanizeDisplayLineを返す
|
||||
*/
|
||||
public int getJapanizeDisplayLine() {
|
||||
return japanizeDisplayLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param japanizeDisplayLine japanizeDisplayLineを設定する
|
||||
*/
|
||||
public void setJapanizeDisplayLine(int japanizeDisplayLine) {
|
||||
this.japanizeDisplayLine = japanizeDisplayLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return japanizeLine1Formatを返す
|
||||
*/
|
||||
public String getJapanizeLine1Format() {
|
||||
return japanizeLine1Format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param japanizeLine1Format japanizeLine1Formatを設定する
|
||||
*/
|
||||
public void setJapanizeLine1Format(String japanizeLine1Format) {
|
||||
this.japanizeLine1Format = japanizeLine1Format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return japanizeLine2Formatを返す
|
||||
*/
|
||||
public String getJapanizeLine2Format() {
|
||||
return japanizeLine2Format;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param japanizeLine2Format japanizeLine2Formatを設定する
|
||||
*/
|
||||
public void setJapanizeLine2Format(String japanizeLine2Format) {
|
||||
this.japanizeLine2Format = japanizeLine2Format;
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import com.github.ucchyocean.lc.japanize.JapanizeType;
|
||||
import com.github.ucchyocean.lc.japanize.KanaConverter;
|
||||
|
||||
/**
|
||||
@@ -161,7 +162,7 @@ public class PlayerListener implements Listener {
|
||||
}
|
||||
|
||||
// Japanize変換
|
||||
if ( LunaChat.config.displayJapanize ) {
|
||||
if ( LunaChat.config.getJapanizeType() != JapanizeType.NONE ) {
|
||||
message = addJapanize(message);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +1,52 @@
|
||||
package com.github.ucchyocean.lc.japanize;
|
||||
|
||||
/**
|
||||
* @author ucchy
|
||||
* 日本語変換タイプ
|
||||
*/
|
||||
public enum JapanizeType {
|
||||
|
||||
NONE,
|
||||
/** 日本語変換をしない */
|
||||
NONE("none"),
|
||||
|
||||
KANA,
|
||||
/** カナ変換のみする */
|
||||
KANA("kana"),
|
||||
|
||||
GOOGLE_IME,
|
||||
/** カナ変換後、GoogleIMEで漢字変換 */
|
||||
GOOGLE_IME("googleime"),
|
||||
|
||||
SOCIAL_IME;
|
||||
/** カナ変換後、SocialIMEで漢字変換 */
|
||||
SOCIAL_IME("socialime");
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* コンストラクタ
|
||||
* @param id
|
||||
*/
|
||||
JapanizeType(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列表記を返す
|
||||
* @see java.lang.Enum#toString()
|
||||
*/
|
||||
public String toString() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 文字列表記からJapanizeTypeを作成して返す
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
public static JapanizeType fromID(String id) {
|
||||
for ( JapanizeType type : values() ) {
|
||||
if ( type.id.equalsIgnoreCase(id) ) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
return NONE;
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする