39 lines
1.4 KiB
Java
39 lines
1.4 KiB
Java
package com.sekwah.advancedportals.bungee.listener;
|
|
|
|
import com.google.common.io.ByteArrayDataOutput;
|
|
import com.google.common.io.ByteStreams;
|
|
import com.sekwah.advancedportals.bungee.AdvancedPortalsPlugin;
|
|
import com.sekwah.advancedportals.bungee.BungeeMessages;
|
|
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
|
import net.md_5.bungee.api.plugin.Listener;
|
|
import net.md_5.bungee.event.EventHandler;
|
|
|
|
public class EventListener implements Listener {
|
|
private AdvancedPortalsPlugin plugin;
|
|
|
|
public EventListener(AdvancedPortalsPlugin plugin) { this.plugin = plugin; }
|
|
|
|
@EventHandler
|
|
public void onServerConnected(ServerConnectedEvent event) {
|
|
String uuid = event.getPlayer().getUniqueId().toString();
|
|
|
|
if (plugin.PlayerDestiMap.containsKey(uuid)) {
|
|
String[] val = plugin.PlayerDestiMap.get(uuid);
|
|
|
|
// key: UUID (string)
|
|
// value: [0] targetServer, [1] targetDestination, [2] onlineUUID
|
|
|
|
if (event.getPlayer().getServer().getInfo().getName().equalsIgnoreCase(val[0])) {
|
|
|
|
ByteArrayDataOutput out = ByteStreams.newDataOutput();
|
|
|
|
out.writeUTF(BungeeMessages.SERVER_DESTI);
|
|
out.writeUTF(val[1]);
|
|
out.writeUTF(val[2]);
|
|
|
|
event.getPlayer().getServer().sendData(plugin.channelName, out.toByteArray());
|
|
}
|
|
}
|
|
}
|
|
}
|