コミットを比較

..
2 コミット
作成者 SHA1 メッセージ 日付
ucchy 6cdd8438f7 LunaChat v3.0.11 : Fixed issue #202 2020-08-23 00:35:24 +09:00
ucchy 854abef1b3 LunaChat v3.0.11 : Fixed issue #201 2020-08-16 10:37:19 +09:00
7個のファイルの変更、49行の追加、9行の削除

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

+1 -1
ファイルの表示
@@ -2,7 +2,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.ucchyocean</groupId>
<artifactId>LunaChat</artifactId>
<version>3.0.10</version>
<version>3.0.11</version>
<description>A powerfull chat channel plugin with IME (Kana-Kanji conversion) support</description>
<url>https://github.com/ucchyocean/LunaChat</url>
+1 -2
ファイルの表示
@@ -9,7 +9,6 @@ import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@@ -188,7 +187,7 @@ public class BukkitChannel extends Channel {
// 設定に応じて、コンソールに出力する
if ( config.isDisplayChatOnConsole() ) {
Bukkit.getLogger().info(ChatColor.stripColor(message));
Bukkit.getLogger().info(message);
}
// 受信者が自分以外いない場合は、メッセージを表示する
+7
ファイルの表示
@@ -213,6 +213,13 @@ public class ClickableFormat {
} else { // type.equals("SUGGEST_COMMAND")
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, command));
}
// componentsの最後の要素のカラーコードを、TextComponentにも反映させる。 see issue #202
if ( components.size() > 0 ) {
BaseComponent last = components.get(components.size() - 1);
tc.setColor(last.getColor());
}
components.add(tc);
lastIndex = matcher.end();
+4 -3
ファイルの表示
@@ -29,9 +29,10 @@ public class KeywordReplacer {
* @param value 値
*/
public void replace(String keyword, String value) {
int start;
while ( (start = str.indexOf(keyword)) > -1 ) {
str.replace(start, start + keyword.length(), value);
int index = 0;
while ( (index = str.indexOf(keyword, index)) > -1 ) {
str.replace(index, index + keyword.length(), value);
index += value.length();
}
}
+1 -1
ファイルの表示
@@ -37,7 +37,7 @@ public class ChannelMemberDummy extends ChannelMember {
*/
@Override
public String getDisplayName() {
return "うっちぃ";
return "&aうっちぃ";
}
/**
+6 -1
ファイルの表示
@@ -39,11 +39,16 @@ public class ClickableFormatTest extends TestCase {
Messages.initialize(new File(MESSAGES_FOLDER), null, "ja");
String format = "&f[%color%ch&f]%prefix%displayname%suffix&a:&f %msg";
//String format = "&f[%color%ch&f]%prefix%displayname%suffix&a:&f %msg";
String format = "&7[%color%ch&7]%prefix%username: &f%msg";
String jpFormat = "%japanize&7 $%msg";
ChannelMember member = new ChannelMemberDummy();
Channel channel = new StandaloneChannel("r");
channel.setColorCode(ChatColor.AQUA.toString());
ClickableFormat f = ClickableFormat.makeFormat(format, member, channel, true);
f.replace("%msg", jpFormat);
System.out.println("pre = " + f.toString() + ", legacy text = " + f.toLegacyText());
+29 -1
ファイルの表示
@@ -15,7 +15,7 @@ public class KeywordReplacerTest extends TestCase {
private static final int MAX = 10;
public void test() {
public void testSpeedOfReplacement() {
String testee = "";
for ( int i=1; i<=MAX; i++ ) {
@@ -42,4 +42,32 @@ public class KeywordReplacerTest extends TestCase {
assertTrue(test1.equals(test2.toString()));
}
public void testSafetyOfRecursiveReplacement() {
String testee = "%prefix%username&f: %msg";
String keyword = "%msg";
String val1 = "&f%japanize&7 #%msg";
//String val2 = "発言の内容";
String val2 = "%msg発%msg言%msgの%msg内%msg容%msg";
KeywordReplacer test1 = new KeywordReplacer(testee);
long start = System.currentTimeMillis();
test1.replace(keyword, val1);
test1.replace(keyword, val2);
long time = System.currentTimeMillis() - start;
System.out.println("test1 time = " + time + ", str = " + test1.toString());
String test2 = new String(testee);
start = System.currentTimeMillis();
test2 = test2.replace(keyword, val1);
test2 = test2.replace(keyword, val2);
time = System.currentTimeMillis() - start;
System.out.println("test2 time = " + time + ", str = " + test2);
assertTrue(test1.toString().equals(test2));
}
}