LunaChat v3.0.7 : Fixed issue #182
このコミットが含まれているのは:
1 親
978100ab02
コミット
7874d47b33
8ファイル変更
+103
-37
検索条件に一致するファイルはありません
@@ -15,6 +15,15 @@ import com.github.ucchyocean.lc3.event.EventSenderInterface;
|
||||
*/
|
||||
public class LunaChat {
|
||||
|
||||
/** Bukkit->BungeeCord チャット発言内容の転送に使用するプラグインメッセージチャンネル名 */
|
||||
public static final String PMC_MESSAGE = "lunachat:message";
|
||||
|
||||
/** Bukkit->BungeeCord API実行処理の転送に使用するプラグインメッセージチャンネル名 */
|
||||
public static final String PMC_API = "lunachat:api";
|
||||
|
||||
/** BungeeCord->Bukkit イベント通知の転送に使用するプラグインメッセージチャンネル名 */
|
||||
public static final String PMC_EVENT = "lunachat:event";
|
||||
|
||||
private static PluginInterface instance;
|
||||
private static LunaChatMode mode;
|
||||
private static EventSenderInterface esender;
|
||||
|
||||
@@ -42,9 +42,6 @@ import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
*/
|
||||
public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
|
||||
/** Bukkit-BungeeCord間の送受信に使用するチャンネル名 */
|
||||
private static final String CHANNEL = "lunachat:message";
|
||||
|
||||
private static LunaChatBukkit instance;
|
||||
|
||||
private LunaChatConfig config;
|
||||
@@ -141,7 +138,7 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
LunaChat.setEventSender(new BukkitEventSender());
|
||||
|
||||
// プラグインチャンネル登録
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, CHANNEL);
|
||||
getServer().getMessenger().registerOutgoingPluginChannel(this, LunaChat.PMC_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -319,6 +316,6 @@ public class LunaChatBukkit extends JavaPlugin implements PluginInterface {
|
||||
* @param bytes 送信内容
|
||||
*/
|
||||
public void sendPluginMessage(byte[] bytes) {
|
||||
getServer().sendPluginMessage(this, CHANNEL, bytes);
|
||||
getServer().sendPluginMessage(this, LunaChat.PMC_MESSAGE, bytes);
|
||||
}
|
||||
}
|
||||
@@ -35,9 +35,6 @@ import net.md_5.bungee.api.plugin.Plugin;
|
||||
*/
|
||||
public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
|
||||
/** Bukkit-BungeeCord間の送受信に使用するチャンネル名 */
|
||||
private static final String CHANNEL = "lunachat:message";
|
||||
|
||||
private static LunaChatBungee instance;
|
||||
|
||||
private HashMap<String, String> history;
|
||||
@@ -115,7 +112,7 @@ public class LunaChatBungee extends Plugin implements PluginInterface {
|
||||
LunaChat.setEventSender(new BungeeEventSender());
|
||||
|
||||
// プラグインチャンネル登録
|
||||
getProxy().registerChannel(CHANNEL);
|
||||
getProxy().registerChannel(LunaChat.PMC_MESSAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -22,12 +22,14 @@ import com.github.ucchyocean.lc3.channel.Channel;
|
||||
import com.github.ucchyocean.lc3.event.EventResult;
|
||||
import com.github.ucchyocean.lc3.japanize.Japanizer;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberOther;
|
||||
import com.github.ucchyocean.lc3.messaging.BukkitChatMessage;
|
||||
import com.github.ucchyocean.lc3.util.ChatColor;
|
||||
import com.github.ucchyocean.lc3.util.ClickableFormat;
|
||||
import com.github.ucchyocean.lc3.util.Utility;
|
||||
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.BaseComponent;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
@@ -46,9 +48,6 @@ import net.md_5.bungee.event.EventPriority;
|
||||
*/
|
||||
public class BungeeEventListener implements Listener {
|
||||
|
||||
/** Bukkit-BungeeCord間の送受信に使用するチャンネル名 */
|
||||
private static final String CHANNEL = "lunachat:message";
|
||||
|
||||
private static final int MAX_LIST_ITEMS = 8;
|
||||
|
||||
private LunaChatBungee parent;
|
||||
@@ -192,7 +191,7 @@ public class BungeeEventListener implements Listener {
|
||||
public void onPluginMessageReceived(PluginMessageEvent event) {
|
||||
|
||||
// 自分のチャンネルメッセージでない場合は無視する
|
||||
if ( !event.getTag().equals(CHANNEL) ) {
|
||||
if ( !event.getTag().equals(LunaChat.PMC_MESSAGE) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -210,9 +209,15 @@ public class BungeeEventListener implements Listener {
|
||||
return;
|
||||
}
|
||||
|
||||
// 発言者を取得する サーバー名を設定できる場合は設定する
|
||||
ChannelMemberOther member = msg.getMember();
|
||||
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(member.getName());
|
||||
if ( player != null ) {
|
||||
member.setServerName(player.getServer().getInfo().getName());
|
||||
}
|
||||
|
||||
// 発言先チャンネルを取得して発言する
|
||||
processChat(msg.getMember(), msg.getMessage());
|
||||
// 発言処理する
|
||||
processChat(member, msg.getMessage());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.github.ucchyocean.lc3.member;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.github.ucchyocean.lc3.util.BlockLocation;
|
||||
@@ -18,27 +19,31 @@ public class ChannelMemberOther extends ChannelMember {
|
||||
private String prefix;
|
||||
private String suffix;
|
||||
private BlockLocation location;
|
||||
private String serverName;
|
||||
private String worldName;
|
||||
|
||||
public ChannelMemberOther(String name) {
|
||||
public ChannelMemberOther(@NotNull String name) {
|
||||
this(name, name);
|
||||
}
|
||||
|
||||
public ChannelMemberOther(String name, String displayName) {
|
||||
public ChannelMemberOther(@NotNull String name, @NotNull String displayName) {
|
||||
this(name, displayName, "", "");
|
||||
}
|
||||
|
||||
public ChannelMemberOther(String name, String displayName,
|
||||
String prefix, String suffix) {
|
||||
public ChannelMemberOther(@NotNull String name, @NotNull String displayName,
|
||||
@NotNull String prefix, @NotNull String suffix) {
|
||||
this(name, displayName, prefix, suffix, null);
|
||||
}
|
||||
|
||||
public ChannelMemberOther(String name, String displayName,
|
||||
String prefix, String suffix, BlockLocation location) {
|
||||
public ChannelMemberOther(@NotNull String name, @NotNull String displayName,
|
||||
@NotNull String prefix, @NotNull String suffix,
|
||||
@Nullable BlockLocation location) {
|
||||
this(name, displayName, prefix, suffix, location, null);
|
||||
}
|
||||
|
||||
public ChannelMemberOther(String name, String displayName,
|
||||
String prefix, String suffix, BlockLocation location, String id) {
|
||||
public ChannelMemberOther(@NotNull String name, @NotNull String displayName,
|
||||
@NotNull String prefix, @NotNull String suffix,
|
||||
@Nullable BlockLocation location, @Nullable String id) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.prefix = prefix;
|
||||
@@ -84,19 +89,29 @@ public class ChannelMemberOther extends ChannelMember {
|
||||
|
||||
@Override
|
||||
public String getWorldName() {
|
||||
if ( location != null ) {
|
||||
return location.getWorldName();
|
||||
}
|
||||
if ( worldName != null ) return worldName;
|
||||
if ( location != null ) return location.getWorldName();
|
||||
return "";
|
||||
}
|
||||
|
||||
public void setWorldName(String worldName) {
|
||||
this.worldName = worldName;
|
||||
}
|
||||
|
||||
public @Nullable BlockLocation getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getServerName() {
|
||||
return "";
|
||||
return serverName;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param serverName serverName
|
||||
*/
|
||||
public void setServerName(String serverName) {
|
||||
this.serverName = serverName;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -106,8 +121,9 @@ public class ChannelMemberOther extends ChannelMember {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return String.format("%s:{name=%s, displayName=%s}",
|
||||
this.getClass().toString(), name, displayName);
|
||||
return String.format(
|
||||
"%s:{id=%s, name=%s, displayName=%s, prefix=%s, suffix=%s, location={%s}, server=%s}",
|
||||
this.getClass().toString(), id, name, displayName, prefix, suffix, location, serverName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,5 +142,4 @@ public class ChannelMemberOther extends ChannelMember {
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -302,8 +302,10 @@ public class ChannelMemberPlayer extends ChannelMemberBukkit {
|
||||
}
|
||||
|
||||
public ChannelMemberOther toChannelMemberOther() {
|
||||
return new ChannelMemberOther(getName(), getDisplayName(), getPrefix(), getSuffix(),
|
||||
getBlockLocation(), id.toString());
|
||||
ChannelMemberOther other = new ChannelMemberOther(getName(), getDisplayName(),
|
||||
getPrefix(), getSuffix(), getBlockLocation(), id.toString());
|
||||
other.setWorldName(getWorldName());
|
||||
return other;
|
||||
}
|
||||
|
||||
private BlockLocation getBlockLocation() {
|
||||
|
||||
@@ -13,12 +13,11 @@ import java.io.IOException;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import com.github.ucchyocean.lc3.member.ChannelMember;
|
||||
import com.github.ucchyocean.lc3.member.ChannelMemberOther;
|
||||
import com.github.ucchyocean.lc3.util.BlockLocation;
|
||||
|
||||
/**
|
||||
* BukkitからBungeeCordへプレイヤーの発言を送信するためのメッセージクラス
|
||||
* Bukkitで発生したプレイヤーのチャットイベントを、BungeeCordへ転送するためのメッセージクラス
|
||||
* @author ucchy
|
||||
*/
|
||||
public class BukkitChatMessage {
|
||||
@@ -40,7 +39,7 @@ public class BukkitChatMessage {
|
||||
* 発言者を取得する
|
||||
* @return member
|
||||
*/
|
||||
public ChannelMember getMember() {
|
||||
public ChannelMemberOther getMember() {
|
||||
return member;
|
||||
}
|
||||
|
||||
@@ -63,7 +62,8 @@ public class BukkitChatMessage {
|
||||
out.writeUTF(member.getDisplayName());
|
||||
out.writeUTF(member.getPrefix());
|
||||
out.writeUTF(member.getSuffix());
|
||||
out.writeUTF(member.getLocation() == null ? "null" : member.getLocation().toString());
|
||||
out.writeUTF(member.getLocation() == null ? "<null>" : member.getLocation().toString());
|
||||
out.writeUTF(member.getId() == null ? "<null>" : member.getId());
|
||||
out.writeUTF(message);
|
||||
return baos.toByteArray();
|
||||
} catch (IOException e) {
|
||||
@@ -84,7 +84,9 @@ public class BukkitChatMessage {
|
||||
String prefix = in.readUTF();
|
||||
String suffix = in.readUTF();
|
||||
BlockLocation location = BlockLocation.fromString(in.readUTF());
|
||||
ChannelMemberOther member = new ChannelMemberOther(name, displayName, prefix, suffix, location);
|
||||
String id = in.readUTF();
|
||||
if ( id.equals("<null>") ) id = null;
|
||||
ChannelMemberOther member = new ChannelMemberOther(name, displayName, prefix, suffix, location, id);
|
||||
String message = in.readUTF();
|
||||
return new BukkitChatMessage(member, message);
|
||||
} catch (IOException e) {
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする