feat(bungee): profile plugin message
This commit is contained in:
parent
e81d45c2f5
commit
1edfac5537
2 changed files with 25 additions and 7 deletions
|
@ -51,6 +51,10 @@ public class NickoBungee extends Plugin {
|
|||
}
|
||||
}
|
||||
|
||||
public Nicko getNicko() {
|
||||
return nicko;
|
||||
}
|
||||
|
||||
public static NickoBungee getInstance() {
|
||||
return plugin;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.artelnatif.nicko.bungee.event;
|
|||
|
||||
import net.artelnatif.nicko.bungee.NickoBungee;
|
||||
import net.artelnatif.nicko.bungee.message.PluginMessageSender;
|
||||
import net.artelnatif.nicko.disguise.NickoProfile;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
@ -13,6 +14,7 @@ import java.io.ByteArrayInputStream;
|
|||
import java.io.DataInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
public class FetchMessageListener implements Listener {
|
||||
|
@ -21,17 +23,29 @@ public class FetchMessageListener implements Listener {
|
|||
if (!event.getTag().equals(NickoBungee.PROXY_FETCH)) { return; }
|
||||
|
||||
try (DataInputStream input = new DataInputStream(new ByteArrayInputStream(event.getData()))) {
|
||||
final ProxyServer proxy = NickoBungee.getInstance().getProxy();
|
||||
final NickoBungee instance = NickoBungee.getInstance();
|
||||
final ProxyServer proxy = instance.getProxy();
|
||||
|
||||
final String uuid = input.readUTF();
|
||||
final ProxiedPlayer player = proxy.getPlayer(UUID.fromString(uuid));
|
||||
final String stringUuid = input.readUTF();
|
||||
final UUID uuid = UUID.fromString(stringUuid);
|
||||
final ProxiedPlayer player = proxy.getPlayer(uuid);
|
||||
final ServerInfo serverInfo = player.getServer().getInfo();
|
||||
|
||||
// TODO: 1/28/23 FETCH PROFILE
|
||||
final Optional<NickoProfile> optionalProfile = instance.getNicko().getDataStore().getData(uuid);
|
||||
if (optionalProfile.isPresent()) {
|
||||
final NickoProfile profile = optionalProfile.get();
|
||||
final ArrayList<String> payload = new ArrayList<>();
|
||||
payload.add(player.getUniqueId().toString());
|
||||
payload.add(profile.getName());
|
||||
payload.add(profile.getSkin());
|
||||
payload.add(String.valueOf(profile.isBungeecordTransfer()));
|
||||
payload.add(profile.getLocale().getCode());
|
||||
|
||||
PluginMessageSender.send(serverInfo, NickoBungee.SERVER_DATA, payload);
|
||||
return;
|
||||
}
|
||||
|
||||
instance.getNicko().getLogger().warning("Unable to send profile to distant server!");
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue