2017-04-10 05:39:22 +02:00
|
|
|
package net.ME1312.SubServers.Bungee.Network.Packet;
|
|
|
|
|
2019-04-18 16:02:09 +02:00
|
|
|
import net.ME1312.SubData.Server.SubDataClient;
|
2018-08-09 20:54:56 +02:00
|
|
|
import net.ME1312.SubServers.Bungee.Host.Proxy;
|
2019-04-18 16:02:09 +02:00
|
|
|
import net.ME1312.Galaxi.Library.Map.ObjectMap;
|
|
|
|
import net.ME1312.Galaxi.Library.Util;
|
|
|
|
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
|
|
|
|
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
|
2019-08-30 21:44:54 +02:00
|
|
|
import net.ME1312.SubServers.Bungee.SubProxy;
|
2017-04-10 05:39:22 +02:00
|
|
|
|
2019-04-18 16:02:09 +02:00
|
|
|
import java.util.UUID;
|
2018-05-24 04:27:20 +02:00
|
|
|
|
2017-04-10 05:39:22 +02:00
|
|
|
/**
|
|
|
|
* Download Proxy Info Packet
|
|
|
|
*/
|
2019-04-18 16:02:09 +02:00
|
|
|
public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
|
2019-08-30 21:44:54 +02:00
|
|
|
private SubProxy plugin;
|
2018-08-09 20:54:56 +02:00
|
|
|
private String proxy;
|
2019-04-18 16:02:09 +02:00
|
|
|
private UUID tracker;
|
2017-04-10 05:39:22 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* New PacketDownloadProxyInfo (In)
|
|
|
|
*
|
|
|
|
* @param plugin SubPlugin
|
|
|
|
*/
|
2019-08-30 21:44:54 +02:00
|
|
|
public PacketDownloadProxyInfo(SubProxy plugin) {
|
2018-08-09 20:54:56 +02:00
|
|
|
if (Util.isNull(plugin)) throw new NullPointerException();
|
2017-04-10 05:39:22 +02:00
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* New PacketDownloadProxyInfo (Out)
|
|
|
|
*
|
|
|
|
* @param plugin SubPlugin
|
2018-08-09 20:54:56 +02:00
|
|
|
* @param proxy Proxy (or null for all)
|
2019-04-18 16:02:09 +02:00
|
|
|
* @param tracker Receiver ID
|
2017-04-10 05:39:22 +02:00
|
|
|
*/
|
2019-08-30 21:44:54 +02:00
|
|
|
public PacketDownloadProxyInfo(SubProxy plugin, String proxy, UUID tracker) {
|
2018-08-09 20:54:56 +02:00
|
|
|
if (Util.isNull(plugin)) throw new NullPointerException();
|
2017-04-10 05:39:22 +02:00
|
|
|
this.plugin = plugin;
|
2018-08-09 20:54:56 +02:00
|
|
|
this.proxy = proxy;
|
2019-04-18 16:02:09 +02:00
|
|
|
this.tracker = tracker;
|
2017-04-10 05:39:22 +02:00
|
|
|
}
|
|
|
|
|
2018-08-09 20:54:56 +02:00
|
|
|
@SuppressWarnings("unchecked")
|
2017-04-10 05:39:22 +02:00
|
|
|
@Override
|
2019-04-18 16:02:09 +02:00
|
|
|
public ObjectMap<Integer> send(SubDataClient client) {
|
|
|
|
ObjectMap<Integer> data = new ObjectMap<Integer>();
|
|
|
|
if (tracker != null) data.set(0x0000, tracker);
|
2018-08-09 20:54:56 +02:00
|
|
|
|
2019-04-18 16:02:09 +02:00
|
|
|
ObjectMap<String> proxies = new ObjectMap<String>();
|
2018-08-09 20:54:56 +02:00
|
|
|
for (Proxy proxy : plugin.api.getProxies().values()) {
|
|
|
|
if (this.proxy == null || this.proxy.equalsIgnoreCase(proxy.getName())) {
|
2019-04-18 16:02:09 +02:00
|
|
|
proxies.set(proxy.getName(), proxy.forSubData());
|
2018-08-09 20:54:56 +02:00
|
|
|
}
|
2018-08-05 05:29:52 +02:00
|
|
|
}
|
2019-04-18 16:02:09 +02:00
|
|
|
data.set(0x0001, proxies);
|
|
|
|
if ((this.proxy == null || this.proxy.length() <= 0) && plugin.api.getMasterProxy() != null) data.set(0x0002, plugin.api.getMasterProxy().forSubData());
|
2018-04-15 03:53:51 +02:00
|
|
|
return data;
|
2017-04-10 05:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-04-18 16:02:09 +02:00
|
|
|
public void receive(SubDataClient client, ObjectMap<Integer> data) {
|
|
|
|
client.sendPacket(new PacketDownloadProxyInfo(plugin, (data.contains(0x0001))?data.getRawString(0x0001):null, (data.contains(0x0000))?data.getUUID(0x0000):null));
|
2017-04-10 05:39:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2019-04-18 16:02:09 +02:00
|
|
|
public int version() {
|
|
|
|
return 0x0001;
|
2017-04-10 05:39:22 +02:00
|
|
|
}
|
|
|
|
}
|