2
0
mirror of https://github.com/proxiodev/RedisBungee.git synced 2024-11-22 20:28:00 +00:00

code clean up and lambda etc

This commit is contained in:
mohammed jasem alaajel 2021-05-21 16:51:44 +04:00
parent 39b3c03604
commit 96793e81c5
2 changed files with 90 additions and 92 deletions

View File

@ -6,7 +6,7 @@
<groupId>com.imaginarycode.minecraft</groupId>
<artifactId>RedisBungee</artifactId>
<version>0.6.3</version>
<version>0.6.4-SNAPSHOT</version>
<repositories>

View File

@ -14,7 +14,6 @@ import net.md_5.bungee.api.AbstractReconnectHandler;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.connection.Server;
@ -62,7 +61,7 @@ public class RedisBungeeListener implements Listener {
if (player != null) {
event.setCancelled(true);
// TODO: Make it accept a BaseComponent[] like everything else.
event.setCancelReason(TextComponent.toLegacyText(ONLINE_MODE_RECONNECT));
event.setCancelReason(ONLINE_MODE_RECONNECT);
return null;
}
}
@ -71,7 +70,7 @@ public class RedisBungeeListener implements Listener {
if (jedis.sismember("proxy:" + s + ":usersOnline", event.getConnection().getUniqueId().toString())) {
event.setCancelled(true);
// TODO: Make it accept a BaseComponent[] like everything else.
event.setCancelReason(TextComponent.toLegacyText(ALREADY_LOGGED_IN));
event.setCancelReason(ALREADY_LOGGED_IN);
return null;
}
}
@ -146,14 +145,13 @@ public class RedisBungeeListener implements Listener {
event.getResponse().getPlayers().setOnline(plugin.getCount());
}
@SuppressWarnings("UnstableApiUsage")
@EventHandler
public void onPluginMessage(final PluginMessageEvent event) {
if ((event.getTag().equals("legacy:redisbungee") || event.getTag().equals("RedisBungee")) && event.getSender() instanceof Server) {
final String currentChannel = event.getTag();
final byte[] data = Arrays.copyOf(event.getData(), event.getData().length);
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
@Override
public void run() {
plugin.getProxy().getScheduler().runAsync(plugin, () -> {
ByteArrayDataInput in = ByteStreams.newDataInput(data);
String subchannel = in.readUTF();
@ -246,7 +244,6 @@ public class RedisBungeeListener implements Listener {
}
((Server) event.getSender()).sendData(currentChannel, out.toByteArray());
}
});
}
}
@ -259,6 +256,7 @@ public class RedisBungeeListener implements Listener {
}
}
@SuppressWarnings("SameParameterValue")
private void serializeMultimap(Multimap<String, String> collection, boolean includeNames, ByteArrayDataOutput output) {
output.writeInt(collection.keySet().size());
for (Map.Entry<String, Collection<String>> entry : collection.asMap().entrySet()) {