Skip to content

Commit

Permalink
LunaChat v3.0.11 : Fixed issue #202
Browse files Browse the repository at this point in the history
  • Loading branch information
ucchyocean committed Aug 22, 2020
1 parent 854abef commit 6cdd843
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
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;
Expand Down Expand Up @@ -188,7 +187,7 @@ protected void sendMessage(

// 設定に応じて、コンソールに出力する
if ( config.isDisplayChatOnConsole() ) {
Bukkit.getLogger().info(ChatColor.stripColor(message));
Bukkit.getLogger().info(message);
}

// 受信者が自分以外いない場合は、メッセージを表示する
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,13 @@ public BaseComponent[] makeTextComponent() {
} 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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public String getName() {
*/
@Override
public String getDisplayName() {
return "うっちぃ";
return "&aうっちぃ";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,16 @@ public void testChannelChatKeyword() {

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());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++ ) {
Expand Down Expand Up @@ -43,7 +43,7 @@ public void test() {
assertTrue(test1.equals(test2.toString()));
}

public void testaaa() {
public void testSafetyOfRecursiveReplacement() {

String testee = "%prefix%username&f: %msg";
String keyword = "%msg";
Expand Down

0 comments on commit 6cdd843

Please sign in to comment.