LunaChat v3.0.3 : Clickable chat message (WIP)
このコミットが含まれているのは:
1 親
0466653e89
コミット
e2eea8798d
22ファイル変更
+756
-457
検索条件に一致するファイルはありません
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.channel;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class DummyChannel extends Channel {
|
||||
|
||||
public DummyChannel(String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* @param message
|
||||
* @param format
|
||||
* @param sendDynmap
|
||||
* @param displayName
|
||||
* @see com.github.ucchyocean.lc3.channel.Channel#sendMessage(com.github.ucchyocean.lc3.member.ChannelMember, java.lang.String, java.lang.String, boolean, java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
protected void sendMessage(ChannelMember player, String message, String format, boolean sendDynmap,
|
||||
String displayName) {
|
||||
System.out.println("room " + getName() + " message : " + message);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -73,7 +73,10 @@ public class ChannelMemberDummy extends ChannelMember {
|
||||
*/
|
||||
@Override
|
||||
public void sendMessage(BaseComponent[] message) {
|
||||
System.out.println(message);
|
||||
for ( BaseComponent comp : message ) {
|
||||
System.out.print(comp.toLegacyText());
|
||||
}
|
||||
System.out.println();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,47 +0,0 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.util;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ChatFormatterTester extends TestCase {
|
||||
|
||||
public void testChannelChatKeyword() {
|
||||
|
||||
// LunaChatStandalone instance = new LunaChatStandalone();
|
||||
// instance.onEnable();
|
||||
//
|
||||
// String format = "&f[%color%ch&f]%prefix%displayname%suffix&a:&f %msg";
|
||||
// ChannelMember member = new ChannelMemberDummy();
|
||||
// Channel channel = new DummyChannel("r");
|
||||
//
|
||||
// String pre = ChatFormatter.replaceKeywordsForChannel(format, member, channel);
|
||||
//
|
||||
// System.out.println("pre = " + pre);
|
||||
//
|
||||
// BaseComponent[] comps = ChatFormatter.replaceTextComponent(pre);
|
||||
//
|
||||
// System.out.println("post = " + comps.length);
|
||||
}
|
||||
|
||||
public void testEventChatKeyword() {
|
||||
// String format = "&f%prefix%displayname%suffix&a:&f %msg";
|
||||
// ChannelMember member = new ChannelMemberDummy();
|
||||
//
|
||||
// String pre = ChatFormatter.replaceKeywordsForEvent(format, member);
|
||||
//
|
||||
// System.out.println("pre = " + pre);
|
||||
//
|
||||
// BaseComponent[] comps = ChatFormatter.replaceTextComponent(pre);
|
||||
//
|
||||
// System.out.println("post = " + comps.length);
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.util;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import com.github.ucchyocean.lc3.LunaChatStandalone;
|
||||
import com.github.ucchyocean.lc3.Messages;
|
||||
import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.channel.StandaloneChannel;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberDummy;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class ClickableFormatTest extends TestCase {
|
||||
|
||||
public void testChannelChatKeyword() {
|
||||
|
||||
File dataFolder = new File("target\\LunaChatTest");
|
||||
System.out.println("dataFolder : " + dataFolder.getAbsolutePath());
|
||||
if ( !dataFolder.exists() ) {
|
||||
dataFolder.mkdirs();
|
||||
}
|
||||
|
||||
LunaChatStandalone lunachat = new LunaChatStandalone(dataFolder);
|
||||
lunachat.onEnable();
|
||||
|
||||
Messages.initialize(new File("target\\classes"), null, "ja");
|
||||
|
||||
String format = "&f[%color%ch&f]%prefix%displayname%suffix&a:&f %msg";
|
||||
ChannelMember member = new ChannelMemberDummy();
|
||||
Channel channel = new StandaloneChannel("r");
|
||||
|
||||
ClickableFormat f = ClickableFormat.makeFormat(format, member, channel, true);
|
||||
|
||||
System.out.println("pre = " + f.toString() + ", legacy text = " + f.toLegacyText());
|
||||
|
||||
BaseComponent[] comps = f.makeTextComponent();
|
||||
|
||||
System.out.println("post : comps len = " + comps.length + ", legacy text = " + makeLegacyText(comps));
|
||||
for ( BaseComponent comp : comps ) {
|
||||
System.out.println(comp.toString());
|
||||
}
|
||||
|
||||
// assertTrue(f.toLegacyText().equals(makeLegacyText(comps)));
|
||||
}
|
||||
|
||||
public void testEventChatKeyword() {
|
||||
|
||||
String format = "&f%prefix%displayname%suffix&a:&f %msg";
|
||||
ChannelMember member = new ChannelMemberDummy();
|
||||
|
||||
Messages.initialize(new File("target\\classes"), null, "ja");
|
||||
|
||||
ClickableFormat f = ClickableFormat.makeFormat(format, member);
|
||||
|
||||
System.out.println("pre = " + f.toString() + ", legacy text = " + f.toLegacyText());
|
||||
|
||||
BaseComponent[] comps = f.makeTextComponent();
|
||||
|
||||
System.out.println("post : comps len = " + comps.length + ", legacy text = " + makeLegacyText(comps));
|
||||
for ( BaseComponent comp : comps ) {
|
||||
System.out.println(comp.toString());
|
||||
}
|
||||
|
||||
// assertTrue(f.toLegacyText().equals(makeLegacyText(comps)));
|
||||
}
|
||||
|
||||
private static String makeLegacyText(BaseComponent[] comps) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for ( BaseComponent comp : comps ) {
|
||||
builder.append(comp.toLegacyText());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* @author ucchy
|
||||
* @license LGPLv3
|
||||
* @copyright Copyright ucchy 2020
|
||||
*/
|
||||
package com.github.ucchyocean.lc3.util;
|
||||
|
||||
import junit.framework.TestCase;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class KeywordReplacerTest extends TestCase {
|
||||
|
||||
private static final int MAX = 10;
|
||||
|
||||
public void test() {
|
||||
|
||||
String testee = "";
|
||||
for ( int i=1; i<=MAX; i++ ) {
|
||||
testee += String.format("%%test%d%%%d", i, i);
|
||||
}
|
||||
|
||||
|
||||
String test1 = new String(testee);
|
||||
long start = System.currentTimeMillis();
|
||||
for ( int i=1; i<=MAX; i++ ) {
|
||||
test1 = test1.replace("%test" + i + "%", i + "");
|
||||
}
|
||||
long time = System.currentTimeMillis() - start;
|
||||
System.out.println("test1 time = " + time);
|
||||
|
||||
|
||||
KeywordReplacer test2 = new KeywordReplacer(testee);
|
||||
start = System.currentTimeMillis();
|
||||
for ( int i=1; i<=MAX; i++ ) {
|
||||
test2.replace("%test" + i + "%", i + "");
|
||||
}
|
||||
time = System.currentTimeMillis() - start;
|
||||
System.out.println("test2 time = " + time);
|
||||
|
||||
assertTrue(test1.equals(test2.toString()));
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -11,7 +11,7 @@ import junit.framework.TestCase;
|
||||
*
|
||||
* @author ucchy
|
||||
*/
|
||||
public class UtilityTester extends TestCase {
|
||||
public class UtilityTest extends TestCase {
|
||||
|
||||
public void testColorCode() {
|
||||
|
||||
+1
-1
@@ -14,7 +14,7 @@ import junit.framework.TestCase;
|
||||
* YamlConfigのテスト
|
||||
* @author ucchy
|
||||
*/
|
||||
public class YamlConfigTester extends TestCase {
|
||||
public class YamlConfigTest extends TestCase {
|
||||
|
||||
public void testYamlConfig() {
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする