LunaChat v3-k2 : Messaging implementation. (WIP)
このコミットが含まれているのは:
1 親
e82aa534ba
コミット
f5910411f4
7ファイル変更
+2061
-157
検索条件に一致するファイルはありません
@@ -271,9 +271,7 @@ public class LunaChatConfig {
|
||||
!globalChannel.matches("[0-9a-zA-Z\\-_]{1,20}") ) {
|
||||
|
||||
// コンソールに警告を表示する
|
||||
String msg = String.format(
|
||||
Messages.get("errmsgCannotUseForGlobal"), globalChannel);
|
||||
LunaChat.getPlugin().log(Level.WARNING, msg);
|
||||
LunaChat.getPlugin().log(Level.WARNING, Messages.errmsgCannotUseForGlobal(globalChannel));
|
||||
globalChannel = "";
|
||||
}
|
||||
}
|
||||
|
||||
ファイル差分が大きすぎるため表示されません。
差分を読み込み
@@ -42,11 +42,6 @@ import com.github.ucchyocean.lc3.member.ChannelMemberBukkit;
|
||||
*/
|
||||
public class BukkitEventListener implements Listener {
|
||||
|
||||
private static final String MOTD_FIRSTLINE = Messages.get("motdFirstLine");
|
||||
private static final String LIST_ENDLINE = Messages.get("listEndLine");
|
||||
private static final String LIST_FORMAT = Messages.get("listFormat");
|
||||
private static final String PREERR = Messages.get("errorPrefix");
|
||||
|
||||
private SimpleDateFormat dateFormat;
|
||||
private SimpleDateFormat timeFormat;
|
||||
|
||||
|
||||
@@ -106,7 +106,7 @@ public class JoinCommand extends SubCommandAbst {
|
||||
// 発言先を削除して、グローバルチャンネルにする
|
||||
|
||||
api.removeDefaultChannel(sender.getName());
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgSet", "グローバル");
|
||||
sendResourceMessage(sender, PREINFO, "cmdmsgSet", "Global");
|
||||
|
||||
// TODO
|
||||
// Player p = null;
|
||||
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.tool;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import com.github.ucchyocean.lc3.YamlConfig;
|
||||
|
||||
/**
|
||||
* messages_ja.yml を読んで、Messagesクラス用のメソッドを生成するツール
|
||||
* @author ucchy
|
||||
*/
|
||||
public class MessageParser {
|
||||
|
||||
private static final String FILE_PATH = "src/main/resources/messages_ja.yml";
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
YamlConfig yaml = YamlConfig.load(new File(FILE_PATH));
|
||||
for ( String key : yaml.getKeys(false) ) {
|
||||
String value = yaml.getString(key);
|
||||
|
||||
ArrayList<String> keywords = new ArrayList<>();
|
||||
|
||||
Pattern pattern = Pattern.compile("%([^%]*)%");
|
||||
Matcher matcher = pattern.matcher(value);
|
||||
|
||||
while ( matcher.find() ) {
|
||||
keywords.add(matcher.group(1));
|
||||
}
|
||||
|
||||
String arguments = "";
|
||||
for ( String keyword : keywords ) {
|
||||
if ( arguments.length() > 0 ) arguments += ", ";
|
||||
arguments += "Object " + keyword;
|
||||
}
|
||||
|
||||
// 出力
|
||||
System.out.println();
|
||||
System.out.println(" /**");
|
||||
System.out.println(" * " + value);
|
||||
System.out.println(" */");
|
||||
System.out.println(String.format(
|
||||
" public static String %s(%s) {", key, arguments));
|
||||
System.out.println(String.format(
|
||||
" String msg = resources.getString(\"%s\");", key));
|
||||
System.out.println(String.format(
|
||||
" if ( msg == null || msg.equals(\"\") ) return \"\";", key));
|
||||
|
||||
for ( String keyword : keywords ) {
|
||||
System.out.println(String.format(
|
||||
" msg = msg.replace(\"%%%s%%\", %s.toString());", keyword, keyword));
|
||||
}
|
||||
if ( key.startsWith("errmsg") ) {
|
||||
System.out.println(" return resources.getString(\"errorPrefix\", \"\") + msg;");
|
||||
} else {
|
||||
System.out.println(" return msg;");
|
||||
}
|
||||
System.out.println(" }");
|
||||
}
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする