Actually fix RedisBungee channel for 1.13+

This commit is contained in:
Drc-DEV 2019-10-16 19:33:42 +02:00 committed by filoghost
parent 8c09806c25
commit 7496bf8d4d

View File

@ -48,19 +48,18 @@ public class BungeeChannel implements PluginMessageListener {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "BungeeCord");
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "BungeeCord", this);
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_13_R1)) {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "legacy:redisbungee");
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "legacy:redisbungee", this);
} else {
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, "RedisBungee");
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, "RedisBungee", this);
}
String targetChannel = "RedisBungee";
if (NMSVersion.isGreaterEqualThan(NMSVersion.v1_13_R1)) targetChannel = "legacy:redisbungee";
Bukkit.getMessenger().registerOutgoingPluginChannel(plugin, targetChannel);
Bukkit.getMessenger().registerIncomingPluginChannel(plugin, targetChannel, this);
}
@Override
public void onPluginMessageReceived(String channel, Player player, byte[] message) {
String targetChannel = Configuration.useRedisBungee ? "RedisBungee" : "BungeeCord";
if (targetChannel.equalsIgnoreCase("RedisBungee") && NMSVersion.isGreaterEqualThan(NMSVersion.v1_13_R1)) targetChannel = "legacy:redisbungee";
if (channel.equals(targetChannel)) {
DataInputStream in = new DataInputStream(new ByteArrayInputStream(message));
@ -103,7 +102,9 @@ public class BungeeChannel implements PluginMessageListener {
// OR, if you don't need to send it to a specific player
Collection<? extends Player> players = Bukkit.getOnlinePlayers();
if (players.size() > 0) {
players.iterator().next().sendPluginMessage(HolographicDisplays.getInstance(), Configuration.useRedisBungee ? "RedisBungee" : "BungeeCord", b.toByteArray());
String targetChannel = Configuration.useRedisBungee ? "RedisBungee" : "BungeeCord";
if (targetChannel.equalsIgnoreCase("RedisBungee") && NMSVersion.isGreaterEqualThan(NMSVersion.v1_13_R1)) targetChannel = "legacy:redisbungee";
players.iterator().next().sendPluginMessage(HolographicDisplays.getInstance(), targetChannel, b.toByteArray());
}
}
}