LunaChat v2.6.9 : Fixed issue #108

このコミットが含まれているのは:
ucchy committed 2014-09-29 22:29:35 +09:00
1 親 4438eb4798
コミット 5f4622798a
2ファイル変更
+34 -8

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

+33 -7
ファイルの表示
@@ -108,7 +108,7 @@ public class DelayedJapanizeConvertTask extends BukkitRunnable {
for ( String keyword : keywords ) {
if ( keywordLocked.contains(keyword) ) {
index++;
String key = "<" + index + ">";
String key = "<" + makeMultibytesDigit(index) + ">";
keywordLocked = keywordLocked.replace(keyword, key);
keywordMap.put(key, keyword);
}
@@ -116,7 +116,7 @@ public class DelayedJapanizeConvertTask extends BukkitRunnable {
for ( String dickey : dictionary.keySet() ) {
if ( keywordLocked.contains(dickey) ) {
index++;
String key = "<" + index + ">";
String key = "<" + makeMultibytesDigit(index) + ">";
keywordLocked = keywordLocked.replace(dickey, key);
keywordMap.put(key, dictionary.get(dickey));
}
@@ -125,11 +125,6 @@ public class DelayedJapanizeConvertTask extends BukkitRunnable {
// カナ変換
String japanized = KanaConverter.conv(keywordLocked);
// キーワードのアンロック
for ( String key : keywordMap.keySet() ) {
japanized = japanized.replace(key, keywordMap.get(key));
}
// IME変換
if ( type == JapanizeType.GOOGLE_IME ) {
japanized = IMEConverter.convByGoogleIME(japanized);
@@ -137,6 +132,11 @@ public class DelayedJapanizeConvertTask extends BukkitRunnable {
japanized = IMEConverter.convBySocialIME(japanized);
}
// キーワードのアンロック
for ( String key : keywordMap.keySet() ) {
japanized = japanized.replace(key, keywordMap.get(key));
}
// 変換後の文字列にNGワードが含まれている場合は、マスクする
for ( Pattern pattern :
LunaChat.getInstance().getLunaChatConfig().getNgwordCompiled() ) {
@@ -171,5 +171,31 @@ public class DelayedJapanizeConvertTask extends BukkitRunnable {
public String getResult() {
return result;
}
/**
* 数値を、全角文字の文字列に変換して返す
* @param digit
* @return
*/
private String makeMultibytesDigit(int digit) {
String half = Integer.toString(digit);
StringBuilder result = new StringBuilder();
for ( int index=0; index < half.length(); index++ ) {
switch ( half.charAt(index) ) {
case '0' : result.append("0"); break;
case '1' : result.append("1"); break;
case '2' : result.append("2"); break;
case '3' : result.append("3"); break;
case '4' : result.append("4"); break;
case '5' : result.append("5"); break;
case '6' : result.append("6"); break;
case '7' : result.append("7"); break;
case '8' : result.append("8"); break;
case '9' : result.append("9"); break;
}
}
return result.toString();
}
}