LunaChat v1.1.0 : refactored.

このコミットが含まれているのは:
ucchyocean committed 2013-04-23 01:22:25 +09:00
1 親 506a5c5ac1
コミット e24b1bb85e
3ファイル変更
+63 -58

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

+56 -57
ファイルの表示
@@ -5,67 +5,66 @@
*/
package com.github.ucchyocean.lc;
import java.util.HashMap;
/**
* @author ucchy
* ローマ字からかな文字へ変換するクラス
*/
public class KanaConverter {
private static final String[][] TABLE = {
{ "", "あ","い","う","え","お" },
{ "k", "か","き","く","け","こ" },
{ "s", "さ","し","す","せ","そ" },
{ "t", "た","ち","つ","て","と" },
{ "n", "な","に","ぬ","ね","の" },
{ "h", "は","ひ","ふ","へ","ほ" },
{ "m", "ま","み","む","め","も" },
{ "y", "や","い","ゆ","いぇ","よ" },
{ "r", "ら","り","る","れ","ろ" },
{ "w", "わ","うぃ","う","うぇ","を" },
{ "g", "が","ぎ","ぐ","げ","ご" },
{ "z", "ざ","じ","ず","ぜ","ぞ" },
{ "j", "じゃ","じ","じゅ","じぇ","じょ" },
{ "d", "だ","ぢ","づ","で","ど" },
{ "b", "ば","び","ぶ","べ","ぼ" },
{ "p", "ぱ","ぴ","ぷ","ぺ","ぽ" },
{ "gy", "ぎゃ","ぎぃ","ぎゅ","ぎぇ","ぎょ" },
{ "zy", "じゃ","じぃ","じゅ","じぇ","じょ" },
{ "jy", "じゃ","じぃ","じゅ","じぇ","じょ" },
{ "dy", "ぢゃ","ぢぃ","ぢゅ","ぢぇ","ぢょ" },
{ "by", "びゃ","びぃ","びゅ","びぇ","びょ" },
{ "py", "ぴゃ","ぴぃ","ぴゅ","ぴぇ","ぴょ" },
{ "l", "ぁ","ぃ","ぅ","ぇ","ぉ" },
{ "v", "ヴぁ","ヴぃ","ヴ","ヴぇ","ヴぉ" },
{ "sh", "しゃ","し","しゅ","しぇ","しょ" },
{ "sy", "しゃ","し","しゅ","しぇ","しょ" },
{ "ch", "ちゃ","ち","ちゅ","ちぇ","ちょ" },
{ "cy", "ちゃ","ち","ちゅ","ちぇ","ちょ" },
{ "f", "ふぁ","ふぃ","ふ","ふぇ","ふぉ" },
{ "q", "くぁ","くぃ","く","くぇ","くぉ" },
{ "ky", "きゃ","きぃ","きゅ","きぇ","きょ" },
{ "ty", "ちゃ","ちぃ","ちゅ","ちぇ","ちょ" },
{ "ny", "にゃ","にぃ","にゅ","にぇ","にょ" },
{ "hy", "ひゃ","ひぃ","ひゅ","ひぇ","ひょ" },
{ "my", "みゃ","みぃ","みゅ","みぇ","みょ" },
{ "ry", "りゃ","りぃ","りゅ","りぇ","りょ" },
{ "ly", "ゃ","ぃ","ゅ","ぇ","ょ" },
{ "lt", "た","ち","っ","て","と" },
{ "xy", "ゃ","ぃ","ゅ","ぇ","ょ" },
{ "xt", "た","ち","っ","て","と" },
{ "x", "ぁ","ぃ","ぅ","ぇ","ぉ" },
private static final HashMap<String, String[]> TABLE;
static {
TABLE = new HashMap<String, String[]>();
TABLE.put( "", new String[]{"あ","い","う","え","お"});
TABLE.put( "k", new String[]{"か","き","く","け","こ"});
TABLE.put( "s", new String[]{"さ","し","す","せ","そ"});
TABLE.put( "t", new String[]{"た","ち","つ","て","と"});
TABLE.put( "n", new String[]{"な","に","ぬ","ね","の"});
TABLE.put( "h", new String[]{"は","ひ","ふ","へ","ほ"});
TABLE.put( "m", new String[]{"ま","み","む","め","も"});
TABLE.put( "y", new String[]{"や","い","ゆ","いぇ","よ"});
TABLE.put( "r", new String[]{"ら","り","る","れ","ろ"});
TABLE.put( "w", new String[]{"わ","うぃ","う","うぇ","を"});
TABLE.put( "g", new String[]{"が","ぎ","ぐ","げ","ご"});
TABLE.put( "z", new String[]{"ざ","じ","ず","ぜ","ぞ"});
TABLE.put( "j", new String[]{"じゃ","じ","じゅ","じぇ","じょ"});
TABLE.put( "d", new String[]{"だ","ぢ","づ","で","ど"});
TABLE.put( "b", new String[]{"ば","び","ぶ","べ","ぼ"});
TABLE.put( "p", new String[]{"ぱ","ぴ","ぷ","ぺ","ぽ"});
TABLE.put("gy", new String[]{"ぎゃ","ぎぃ","ぎゅ","ぎぇ","ぎょ"});
TABLE.put("zy", new String[]{"じゃ","じぃ","じゅ","じぇ","じょ"});
TABLE.put("jy", new String[]{"じゃ","じぃ","じゅ","じぇ","じょ"});
TABLE.put("dy", new String[]{"ぢゃ","ぢぃ","ぢゅ","ぢぇ","ぢょ"});
TABLE.put("by", new String[]{"びゃ","びぃ","びゅ","びぇ","びょ"});
TABLE.put("py", new String[]{"ぴゃ","ぴぃ","ぴゅ","ぴぇ","ぴょ"});
TABLE.put( "l", new String[]{"ぁ","ぃ","ぅ","ぇ","ぉ"});
TABLE.put( "v", new String[]{"ヴぁ","ヴぃ","ヴ","ヴぇ","ヴぉ"});
TABLE.put("sh", new String[]{"しゃ","し","しゅ","しぇ","しょ"});
TABLE.put("sy", new String[]{"しゃ","し","しゅ","しぇ","しょ"});
TABLE.put("ch", new String[]{"ちゃ","ち","ちゅ","ちぇ","ちょ"});
TABLE.put("cy", new String[]{"ちゃ","ち","ちゅ","ちぇ","ちょ"});
TABLE.put( "f", new String[]{"ふぁ","ふぃ","ふ","ふぇ","ふぉ"});
TABLE.put( "q", new String[]{"くぁ","くぃ","く","くぇ","くぉ"});
TABLE.put("ky", new String[]{"きゃ","きぃ","きゅ","きぇ","きょ"});
TABLE.put("ty", new String[]{"ちゃ","ちぃ","ちゅ","ちぇ","ちょ"});
TABLE.put("ny", new String[]{"にゃ","にぃ","にゅ","にぇ","にょ"});
TABLE.put("hy", new String[]{"ひゃ","ひぃ","ひゅ","ひぇ","ひょ"});
TABLE.put("my", new String[]{"みゃ","みぃ","みゅ","みぇ","みょ"});
TABLE.put("ry", new String[]{"りゃ","りぃ","りゅ","りぇ","りょ"});
TABLE.put("ly", new String[]{"ゃ","ぃ","ゅ","ぇ","ょ"});
TABLE.put("lt", new String[]{"た","ち","っ","て","と"});
TABLE.put("xy", new String[]{"ゃ","ぃ","ゅ","ぇ","ょ"});
TABLE.put("xt", new String[]{"た","ち","っ","て","と"});
TABLE.put( "x", new String[]{"ぁ","ぃ","ぅ","ぇ","ぉ"});
};
private static String getKanaFromTable(String s, int n) {
private static String R2K(String s, int n) {
for ( int i=0; i<TABLE.length; i++ ) {
if ( s.equals(TABLE[i][0]) ) {
return TABLE[i][n+1];
}
if ( TABLE.containsKey(s) ) {
return TABLE.get(s)[n];
}
return s + TABLE[0][n+1];
return s + TABLE.get("")[n];
}
/**
@@ -82,19 +81,19 @@ public class KanaConverter {
String tmp = org.substring(i,i+1);
if ( tmp.equals("a") ) {
line.append( R2K(last, 0) );
line.append( getKanaFromTable(last, 0) );
last = "";
} else if ( tmp.equals("i") ) {
line.append( R2K(last, 1) );
line.append( getKanaFromTable(last, 1) );
last = "";
} else if ( tmp.equals("u") ) {
line.append( R2K(last, 2) );
line.append( getKanaFromTable(last, 2) );
last = "";
} else if ( tmp.equals("e") ) {
line.append( R2K(last, 3) );
line.append( getKanaFromTable(last, 3) );
last = "";
} else if ( tmp.equals("o") ) {
line.append( R2K(last, 4) );
line.append( getKanaFromTable(last, 4) );
last = "";
} else {
if ( last.equals("n") && !(tmp.equals("y")) ) {
+3 -1
ファイルの表示
@@ -27,7 +27,9 @@ public class PlayerListener implements Listener {
public void onChat(AsyncPlayerChatEvent event) {
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
if ( event.getMessage().startsWith(LunaChat.config.globalMarker) ) {
if ( LunaChat.config.globalMarker != null &&
!LunaChat.config.globalMarker.equals("") &&
event.getMessage().startsWith(LunaChat.config.globalMarker) ) {
int offset = LunaChat.config.globalMarker.length();
event.setMessage(event.getMessage().substring(offset));
return;