2016-12-24 05:55:17 +01:00
|
|
|
package net.ME1312.SubServers.Bungee.Network.Packet;
|
2016-12-15 22:04:39 +01:00
|
|
|
|
2016-12-24 05:55:17 +01:00
|
|
|
import net.ME1312.SubServers.Bungee.Host.Host;
|
2017-05-29 07:00:02 +02:00
|
|
|
import net.ME1312.SubServers.Bungee.Host.SubCreator;
|
2016-12-24 05:55:17 +01:00
|
|
|
import net.ME1312.SubServers.Bungee.Host.SubServer;
|
2017-12-10 15:14:49 +01:00
|
|
|
import net.ME1312.SubServers.Bungee.Library.NamedContainer;
|
2016-12-24 05:55:17 +01:00
|
|
|
import net.ME1312.SubServers.Bungee.Library.Version.Version;
|
|
|
|
import net.ME1312.SubServers.Bungee.Network.Client;
|
2017-07-19 01:28:59 +02:00
|
|
|
import net.ME1312.SubServers.Bungee.Network.ClientHandler;
|
2016-12-24 05:55:17 +01:00
|
|
|
import net.ME1312.SubServers.Bungee.Network.PacketIn;
|
|
|
|
import net.ME1312.SubServers.Bungee.Network.PacketOut;
|
2016-12-15 22:04:39 +01:00
|
|
|
|
2016-12-24 05:55:17 +01:00
|
|
|
import net.ME1312.SubServers.Bungee.SubPlugin;
|
2016-12-15 22:04:39 +01:00
|
|
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
|
|
import org.json.JSONObject;
|
|
|
|
|
2017-11-22 22:58:33 +01:00
|
|
|
import java.util.ArrayList;
|
2017-12-10 15:14:49 +01:00
|
|
|
import java.util.UUID;
|
2017-11-22 22:58:33 +01:00
|
|
|
|
2017-01-07 20:06:54 +01:00
|
|
|
/**
|
|
|
|
* Download Host Info Packet
|
|
|
|
*/
|
2016-12-15 22:04:39 +01:00
|
|
|
public class PacketDownloadHostInfo implements PacketIn, PacketOut {
|
|
|
|
private SubPlugin plugin;
|
|
|
|
private Host host;
|
|
|
|
private String id;
|
|
|
|
|
2017-01-07 20:06:54 +01:00
|
|
|
/**
|
|
|
|
* New PacketDownloadHostInfo (In)
|
|
|
|
*
|
|
|
|
* @param plugin SubPlugin
|
|
|
|
*/
|
2016-12-15 22:04:39 +01:00
|
|
|
public PacketDownloadHostInfo(SubPlugin plugin) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
}
|
2017-01-07 20:06:54 +01:00
|
|
|
|
|
|
|
/**
|
|
|
|
* New PacketDownloadHostInfo (Out)
|
|
|
|
*
|
|
|
|
* @param plugin SubPlugin
|
|
|
|
* @param host Host
|
|
|
|
* @param id Receiver ID
|
|
|
|
*/
|
2016-12-15 22:04:39 +01:00
|
|
|
public PacketDownloadHostInfo(SubPlugin plugin, Host host, String id) {
|
|
|
|
this.plugin = plugin;
|
|
|
|
this.host = host;
|
|
|
|
this.id = id;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public JSONObject generate() {
|
|
|
|
JSONObject json = new JSONObject();
|
|
|
|
json.put("id", id);
|
|
|
|
JSONObject info = new JSONObject();
|
|
|
|
|
|
|
|
if (host != null) {
|
|
|
|
json.put("valid", true);
|
2018-03-21 21:45:59 +01:00
|
|
|
info = new JSONObject(host.toString());
|
|
|
|
info.remove("type");
|
2016-12-15 22:04:39 +01:00
|
|
|
} else json.put("valid", false);
|
|
|
|
|
|
|
|
json.put("host", info);
|
|
|
|
return json;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void execute(Client client, JSONObject data) {
|
|
|
|
client.sendPacket(new PacketDownloadHostInfo(plugin, plugin.api.getHost(data.getString("host")), (data.keySet().contains("id"))?data.getString("id"):null));
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public Version getVersion() {
|
|
|
|
return new Version("2.11.0a");
|
|
|
|
}
|
|
|
|
}
|