コミットを比較
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
0866722243 | ||
|
|
a58830f314 | ||
|
|
6cdd8438f7 | ||
|
|
854abef1b3 | ||
|
|
0c8212e979 |
検索条件に一致するファイルはありません
@@ -2,7 +2,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>com.github.ucchyocean</groupId>
|
||||
<artifactId>LunaChat</artifactId>
|
||||
<version>3.0.9</version>
|
||||
<version>3.0.12</version>
|
||||
<description>A powerfull chat channel plugin with IME (Kana-Kanji conversion) support</description>
|
||||
<url>https://github.com/ucchyocean/LunaChat</url>
|
||||
|
||||
@@ -101,18 +101,23 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<configuration>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<encoding>UTF-8</encoding>
|
||||
<inputEncoding>UTF-8</inputEncoding>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
<argLine>-Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.12.4</version>
|
||||
<configuration>
|
||||
<junitArtifactName>junit:junit</junitArtifactName>
|
||||
<encoding>UTF-8</encoding>
|
||||
<inputEncoding>UTF-8</inputEncoding>
|
||||
<outputEncoding>UTF-8</outputEncoding>
|
||||
<argLine>-Dfile.encoding=UTF-8</argLine>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>versions-maven-plugin</artifactId>
|
||||
<version>1.3.1</version>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
@@ -158,7 +163,7 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.16.1-R0.1-SNAPSHOT</version>
|
||||
<version>1.16.2-R0.1-SNAPSHOT</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
@@ -172,7 +177,7 @@
|
||||
<dependency>
|
||||
<groupId>net.md-5</groupId>
|
||||
<artifactId>bungeecord-chat</artifactId>
|
||||
<version>1.16-R0.1</version>
|
||||
<version>1.16-R0.3</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
@@ -212,7 +217,7 @@
|
||||
<dependency>
|
||||
<groupId>com.gmail.nossr50.mcMMO</groupId>
|
||||
<artifactId>mcMMO</artifactId>
|
||||
<version>2.1.128</version>
|
||||
<version>2.1.145</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
<exclusions>
|
||||
@@ -241,7 +246,7 @@
|
||||
<dependency>
|
||||
<groupId>net.alpenblock</groupId>
|
||||
<artifactId>BungeePerms</artifactId>
|
||||
<version>4.0-dev-106</version>
|
||||
<version>4.0-dev-112</version>
|
||||
<optional>true</optional>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
@@ -267,22 +272,22 @@
|
||||
<dependency>
|
||||
<groupId>com.google.code.gson</groupId>
|
||||
<artifactId>gson</artifactId>
|
||||
<version>2.8.5</version>
|
||||
<version>2.8.6</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.9</version>
|
||||
<version>3.11</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>16.0.2</version>
|
||||
<version>20.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<version>4.12</version>
|
||||
<version>4.13</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -119,6 +119,9 @@ public class LunaChatConfig {
|
||||
/** 通常チャットを、クリック可能にするかどうか */
|
||||
private boolean enableNormalChatClickable;
|
||||
|
||||
/** 通常チャットを、コンソールに表示するかどうか */
|
||||
private boolean displayNormalChatOnConsole;
|
||||
|
||||
/** Japanize変換のタイプ<br/>
|
||||
* none = 日本語変換をしない<br/>
|
||||
* kana = カナ変換のみする<br/>
|
||||
@@ -249,6 +252,8 @@ public class LunaChatConfig {
|
||||
config.getBoolean("enableNormalChatColorCode", true);
|
||||
enableNormalChatClickable =
|
||||
config.getBoolean("enableNormalChatClickable", false);
|
||||
displayNormalChatOnConsole =
|
||||
config.getBoolean("displayNormalChatOnConsole", true);
|
||||
|
||||
japanizeType = JapanizeType.fromID(config.getString("japanizeType"), null);
|
||||
japanizeDisplayLine = config.getInt("japanizeDisplayLine", 2);
|
||||
@@ -582,6 +587,14 @@ public class LunaChatConfig {
|
||||
return enableNormalChatClickable;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通常チャットを、コンソールに表示するかどうか
|
||||
* @return displayNormalChatOnConsole
|
||||
*/
|
||||
public boolean isDisplayNormalChatOnConsole() {
|
||||
return displayNormalChatOnConsole;
|
||||
}
|
||||
|
||||
/**
|
||||
* Bungeeパススルーモードかどうかを返す
|
||||
* @return bungeePassThroughMode
|
||||
|
||||
@@ -10,6 +10,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@@ -179,14 +180,26 @@ public class BukkitEventListener implements Listener {
|
||||
|
||||
// Bungeeパススルーモードなら、メッセージを返送して終了する
|
||||
if ( config.isBungeePassThroughMode() ) {
|
||||
ChannelMember player = ChannelMember.getChannelMember(event.getPlayer());
|
||||
if ( player instanceof ChannelMemberPlayer ) {
|
||||
ChannelMemberOther other = ((ChannelMemberPlayer)player).toChannelMemberOther();
|
||||
|
||||
// メッセージの返送
|
||||
ChannelMember member = ChannelMember.getChannelMember(event.getPlayer());
|
||||
if ( member instanceof ChannelMemberPlayer ) {
|
||||
ChannelMemberOther other = ((ChannelMemberPlayer)member).toChannelMemberOther();
|
||||
BukkitChatMessage msg = new BukkitChatMessage(other, event.getMessage());
|
||||
LunaChatBukkit.getInstance().sendPluginMessage(msg.toByteArray());
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
|
||||
// 設定が有効ならコンソールに表示する
|
||||
if ( config.isDisplayNormalChatOnConsole() ) {
|
||||
String logmsg = event.getFormat()
|
||||
.replace("%1$s", member.getDisplayName())
|
||||
.replace("%2$s", event.getMessage());
|
||||
LunaChat.getPlugin().log(Level.INFO, logmsg);
|
||||
}
|
||||
}
|
||||
|
||||
// イベントをキャンセルして終了する
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 頭にglobalMarkerが付いている場合は、グローバル発言にする
|
||||
@@ -395,6 +408,11 @@ public class BukkitEventListener implements Listener {
|
||||
// イベントのキャンセル
|
||||
event.setCancelled(true);
|
||||
|
||||
// 設定が有効ならコンソールに表示する
|
||||
if ( config.isDisplayNormalChatOnConsole() ) {
|
||||
LunaChat.getPlugin().log(Level.INFO, makeLegacyText(comps));
|
||||
}
|
||||
|
||||
} else {
|
||||
// 通常チャットイベントで発言
|
||||
|
||||
@@ -586,4 +604,17 @@ public class BukkitEventListener implements Listener {
|
||||
String c = LunaChat.getConfig().getPlayerChatEventListenerPriority().name();
|
||||
return c.equals(priority.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* BaseComponent配列を、カラーコードを含むStringに変換する
|
||||
* @param comps BaseComponentの配列
|
||||
* @return カラーコードを含むString
|
||||
*/
|
||||
private static String makeLegacyText(BaseComponent[] comps) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
for ( BaseComponent comp : comps ) {
|
||||
builder.append(comp.toLegacyText());
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
}
|
||||
@@ -399,7 +399,7 @@ public class BungeeEventListener implements Listener {
|
||||
result = format.toLegacyText();
|
||||
|
||||
// コンソールに表示設定なら、コンソールに表示する
|
||||
if ( config.isDisplayChatOnConsole() ) {
|
||||
if ( config.isDisplayNormalChatOnConsole() ) {
|
||||
parent.getLogger().info(result);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
// 受信者が自分以外いない場合は、メッセージを表示する
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ListCommand extends LunaChatSubCommand {
|
||||
ChannelMember sender, String label, String[] args) {
|
||||
|
||||
int page = 1;
|
||||
if ( args.length >= 2 && args[1].matches("[0-9]") ) {
|
||||
if ( args.length >= 2 && args[1].matches("[0-9]+") ) {
|
||||
page = Integer.parseInt(args[1]);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -178,6 +178,10 @@ enableNormalChatColorCode: true
|
||||
# Note that channel chats are always clickable, regardless of this setting.
|
||||
enableNormalChatClickable: false
|
||||
|
||||
# Whether to log normal chat (non-channel chat) to console.
|
||||
# Even if this item is set to false, it may be recorded in the console.
|
||||
displayNormalChatOnConsole: true
|
||||
|
||||
|
||||
# -------------------- Japanize conversion settings --------------------
|
||||
|
||||
|
||||
@@ -182,6 +182,10 @@ enableNormalChatColorCode: true
|
||||
# なお、この設定に関係なく、チャンネルチャットは常にクリック可能です。
|
||||
enableNormalChatClickable: false
|
||||
|
||||
# 通常チャット(非チャンネルチャット)をコンソールにログ出力するかどうか。
|
||||
# 本項目をfalseにしても、コンソールに記録される場合があります。
|
||||
displayNormalChatOnConsole: true
|
||||
|
||||
|
||||
# -------------------- Japanize変換設定 --------------------
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ChannelMemberDummy extends ChannelMember {
|
||||
*/
|
||||
@Override
|
||||
public String getDisplayName() {
|
||||
return "うっちぃ";
|
||||
return "&aうっちぃ";
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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());
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
新しいイシューから参照
ユーザーをブロックする