mirror of
https://github.com/proxiodev/RedisBungee.git
synced 2024-11-23 04:28:01 +00:00
Fix UUIDTranslator bug, add UUID null checking, make plugin messaging asynchronous
This commit is contained in:
parent
c82adc61b0
commit
4aeb762c17
@ -102,7 +102,12 @@ class RedisBungeeCommands {
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.length > 0) {
|
||||
ServerInfo si = RedisBungee.getApi().getServerFor(plugin.getUuidTranslator().getTranslatedUuid(args[0]));
|
||||
UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0]);
|
||||
if (uuid == null) {
|
||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
ServerInfo si = RedisBungee.getApi().getServerFor(uuid);
|
||||
if (si != null) {
|
||||
TextComponent message = new TextComponent();
|
||||
message.setColor(ChatColor.BLUE);
|
||||
@ -133,7 +138,12 @@ class RedisBungeeCommands {
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.length > 0) {
|
||||
long secs = RedisBungee.getApi().getLastOnline(plugin.getUuidTranslator().getTranslatedUuid(args[0]));
|
||||
UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0]);
|
||||
if (uuid == null) {
|
||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
long secs = RedisBungee.getApi().getLastOnline(uuid);
|
||||
TextComponent message = new TextComponent();
|
||||
if (secs == 0) {
|
||||
message.setColor(ChatColor.GREEN);
|
||||
@ -170,7 +180,12 @@ class RedisBungeeCommands {
|
||||
@Override
|
||||
public void run() {
|
||||
if (args.length > 0) {
|
||||
InetAddress ia = RedisBungee.getApi().getPlayerIp(plugin.getUuidTranslator().getTranslatedUuid(args[0]));
|
||||
UUID uuid = plugin.getUuidTranslator().getTranslatedUuid(args[0]);
|
||||
if (uuid == null) {
|
||||
sender.sendMessage(PLAYER_NOT_FOUND);
|
||||
return;
|
||||
}
|
||||
InetAddress ia = RedisBungee.getApi().getPlayerIp(uuid);
|
||||
if (ia != null) {
|
||||
TextComponent message = new TextComponent();
|
||||
message.setColor(ChatColor.GREEN);
|
||||
|
@ -22,10 +22,7 @@ import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
@AllArgsConstructor
|
||||
public class RedisBungeeListener implements Listener {
|
||||
@ -87,9 +84,13 @@ public class RedisBungeeListener implements Listener {
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPluginMessage(PluginMessageEvent event) {
|
||||
public void onPluginMessage(final PluginMessageEvent event) {
|
||||
if (event.getTag().equals("RedisBungee") && event.getSender() instanceof Server) {
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(event.getData());
|
||||
final byte[] data = Arrays.copyOf(event.getData(), event.getData().length);
|
||||
plugin.getProxy().getScheduler().runAsync(plugin, new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
ByteArrayDataInput in = ByteStreams.newDataInput(data);
|
||||
|
||||
String subchannel = in.readUTF();
|
||||
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
||||
@ -142,6 +143,8 @@ public class RedisBungeeListener implements Listener {
|
||||
|
||||
((Server) event.getSender()).sendData("RedisBungee", out.toByteArray());
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
@ -47,7 +47,7 @@ public class UUIDTranslator {
|
||||
if (stored != null && UUID_PATTERN.matcher(stored).find()) {
|
||||
// This is it!
|
||||
uuid = UUID.fromString(stored);
|
||||
uuidMap.put(stored, UUID.fromString(stored));
|
||||
uuidMap.put(player, UUID.fromString(stored));
|
||||
return uuid;
|
||||
}
|
||||
|
||||
@ -55,7 +55,7 @@ public class UUIDTranslator {
|
||||
uuid = UUIDFetcher.getUUIDOf(player);
|
||||
|
||||
if (uuid != null) {
|
||||
uuidMap.put(stored, uuid);
|
||||
uuidMap.put(player, uuid);
|
||||
jedis.hset("uuids", player, uuid.toString());
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user