Update SubData

This commit is contained in:
ME1312 2019-10-18 18:24:58 -04:00
parent b7639ae3dc
commit bfcb076cfd
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
136 changed files with 773 additions and 622 deletions

View File

@ -43,7 +43,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Server</artifactId>
<version>19w39a</version>
<version>19w42c</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -1,21 +1,22 @@
package net.ME1312.SubServers.Bungee.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubServers.Bungee.Host.Server;
import net.ME1312.SubServers.Bungee.SubAPI;
import net.md_5.bungee.api.ProxyServer;
import java.util.HashMap;
import java.util.UUID;
/**
* Check Permission Packet
*/
public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private boolean result;
static HashMap<UUID, Callback<Boolean>[]> callbacks = new HashMap<UUID, Callback<Boolean>[]>();
private UUID player;
private String permission;
private UUID tracker;
/**
@ -28,35 +29,28 @@ public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObj
*
* @param player Player to check on
* @param permission Permission to check
* @param tracker Receiver ID
* @param callback Callbacks
*/
public PacketCheckPermission(UUID player, String permission, UUID tracker) {
this(Util.getDespiteException(() -> ProxyServer.getInstance().getPlayer(player).hasPermission(permission), false), tracker);
}
PacketCheckPermission(boolean result, UUID tracker) {
this.result = result;
this.tracker = tracker;
@SafeVarargs
public PacketCheckPermission(UUID player, String permission, Callback<Boolean>... callback) {
this.player = player;
this.permission = permission;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
}
@Override
public ObjectMap<Integer> send(SubDataClient client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, result);
data.set(0x0001, player);
data.set(0x0002, permission);
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) throws Throwable {
Server server = data.contains(0x0003)?SubAPI.getInstance().getServer(data.getRawString(0x0003)):null;
if (server != null && server.getSubData()[0] != null) {
((SubDataClient) server.getSubData()[0]).sendPacket(new PacketExCheckPermission(data.getUUID(0x0001), data.getRawString(0x0002), result -> {
client.sendPacket(new PacketCheckPermission(result, (data.contains(0x0000))?data.getUUID(0x0000):null));
}));
} else {
client.sendPacket(new PacketCheckPermission(data.getUUID(0x0001), data.getRawString(0x0002), (data.contains(0x0000))?data.getUUID(0x0000):null));
}
client.sendPacket(new PacketCheckPermissionResponse(data.getUUID(0x0001), data.getRawString(0x0002), (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override

View File

@ -6,45 +6,42 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Protocol.PacketObjectIn;
import net.ME1312.SubData.Server.Protocol.PacketObjectOut;
import net.ME1312.SubData.Server.SubDataClient;
import net.md_5.bungee.api.ProxyServer;
import java.util.HashMap;
import java.util.UUID;
import static net.ME1312.SubServers.Bungee.Network.Packet.PacketCheckPermission.callbacks;
/**
* Packet Check Permission
* Check Permission Response Packet
*/
public class PacketExCheckPermission implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<Boolean>[]> callbacks = new HashMap<UUID, Callback<Boolean>[]>();
private UUID player;
private String permission;
public class PacketCheckPermissionResponse implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private boolean result;
private UUID tracker;
/**
* New PacketCheckPermission (In)
* New PacketCheckPermissionResponse (In)
*/
public PacketExCheckPermission() {}
public PacketCheckPermissionResponse() {}
/**
* New PacketCheckPermission (Out)
* New PacketCheckPermissionResponse (Out)
*
* @param player Player to check on
* @param permission Permission to check
* @param callback Callbacks
* @param tracker Receiver ID
*/
@SafeVarargs
public PacketExCheckPermission(UUID player, String permission, Callback<Boolean>... callback) {
this.player = player;
this.permission = permission;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
callbacks.put(tracker, callback);
public PacketCheckPermissionResponse(UUID player, String permission, UUID tracker) {
this.result = Util.getDespiteException(() -> ProxyServer.getInstance().getPlayer(player).hasPermission(permission), false);
this.tracker = tracker;
}
@Override
public ObjectMap<Integer> send(SubDataClient client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, player);
data.set(0x0002, permission);
data.set(0x0001, result);
return data;
}

View File

@ -51,6 +51,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0015, PacketDownloadServerInfo.class);
instance.registerPacket(0x0016, PacketDownloadPlayerList.class);
instance.registerPacket(0x0017, PacketCheckPermission.class);
instance.registerPacket(0x0018, PacketCheckPermissionResponse.class);
instance.registerPacket(0x0010, new PacketDownloadLang(plugin));
instance.registerPacket(0x0011, new PacketDownloadPlatformInfo(plugin));
@ -60,6 +61,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0015, new PacketDownloadServerInfo(plugin));
instance.registerPacket(0x0016, new PacketDownloadPlayerList(plugin));
instance.registerPacket(0x0017, new PacketCheckPermission());
instance.registerPacket(0x0018, new PacketCheckPermissionResponse());
// 30-4F: Control Packets
@ -113,13 +115,11 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0071, PacketOutExReset.class);
instance.registerPacket(0x0072, PacketOutExReload.class);
instance.registerPacket(0x0073, PacketOutExUpdateWhitelist.class);
instance.registerPacket(0x0074, PacketExCheckPermission.class);
//instance.registerPacket(0x0070, new PacketOutRunEvent());
//instance.registerPacket(0x0071, new PacketOutReset());
//instance.registerPacket(0x0072, new PacketOutReload());
//instance.registerPacket(0x0073, new PacketOutExUpdateWhitelist());
instance.registerPacket(0x0074, new PacketExCheckPermission());
}
return instance;

View File

@ -11,7 +11,7 @@ import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Server.ClientHandler;
import net.ME1312.SubServers.Bungee.Library.Compatibility.GalaxiInfo;
import net.ME1312.SubServers.Bungee.Library.Compatibility.Logger;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketExCheckPermission;
import net.ME1312.SubServers.Bungee.Network.Packet.PacketCheckPermission;
import net.md_5.bungee.BungeeCord;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
@ -719,7 +719,7 @@ public final class SubCommand extends CommandX {
HashMap<ServerInfo, NamedContainer<Long, Boolean>> map = (players.keySet().contains(((ProxiedPlayer) sender).getUniqueId()))?players.get(((ProxiedPlayer) sender).getUniqueId()):new HashMap<ServerInfo, NamedContainer<Long, Boolean>>();
map.put(((ProxiedPlayer) sender).getServer().getInfo(), new NamedContainer<>(null, false));
players.put(((ProxiedPlayer) sender).getUniqueId(), map);
((SubDataClient) ((Server) ((ProxiedPlayer) sender).getServer().getInfo()).getSubData()[0]).sendPacket(new PacketExCheckPermission(((ProxiedPlayer) sender).getUniqueId(), "subservers.command", result -> {
((SubDataClient) ((Server) ((ProxiedPlayer) sender).getServer().getInfo()).getSubData()[0]).sendPacket(new PacketCheckPermission(((ProxiedPlayer) sender).getUniqueId(), "subservers.command", result -> {
map.put(((ProxiedPlayer) sender).getServer().getInfo(), new NamedContainer<>(Calendar.getInstance().getTime().getTime(), result));
}));
}
@ -727,7 +727,7 @@ public final class SubCommand extends CommandX {
return new NamedContainer<>(null, Collections.emptyList());
} else if (args.length <= 1) {
List<String> cmds = new ArrayList<>();
cmds.addAll(Arrays.asList("help", "list", "info", "status", "version", "start", "stop", "restart", "kill", "terminate", "cmd", "command", "create", "update", "upgrade"));
cmds.addAll(Arrays.asList("help", "list", "info", "status", "version", "start", "restart", "stop", "kill", "terminate", "cmd", "command", "create", "update", "upgrade"));
if (!(sender instanceof ProxiedPlayer)) cmds.addAll(Arrays.asList("reload", "sudo", "screen", "delete", "restore"));
if (last.length() == 0) {
return new NamedContainer<>(null, cmds);

View File

@ -55,7 +55,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>19w39a</version>
<version>19w42c</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -4,7 +4,10 @@ import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.*;
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
@ -58,16 +61,16 @@ public class Host {
* @return SubData Client Channel ID Array (may be empty if unsupported)
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
if (raw.contains("subdata")) {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
} else {
return new UUID[0];
return new SubDataSender[0];
}
}

View File

@ -4,7 +4,10 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadProxyInfo;
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
@ -47,13 +50,13 @@ public class Proxy {
* @return SubData Client Channel ID Array
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
}
/**

View File

@ -2,7 +2,10 @@ package net.ME1312.SubServers.Client.Bukkit.Network.API;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketDownloadServerInfo;
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
@ -46,13 +49,13 @@ public class Server {
* @return SubData Client Channel ID Array
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
}
/**

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Graphic.UIRenderer;
import java.net.InetAddress;
@ -102,7 +102,7 @@ public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, name);
@ -113,7 +113,7 @@ public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -3,19 +3,19 @@ package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.Forwardable;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
/**
* Packet Check Permission
* Check Permission Packet
*/
public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<Boolean>[]> callbacks = new HashMap<UUID, Callback<Boolean>[]>();
private String name;
public class PacketCheckPermission implements Forwardable, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
static HashMap<UUID, Callback<Boolean>[]> callbacks = new HashMap<UUID, Callback<Boolean>[]>();
private UUID player;
private String permission;
private UUID tracker;
@ -34,20 +34,6 @@ public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObj
*/
@SafeVarargs
public PacketCheckPermission(UUID player, String permission, Callback<Boolean>... callback) {
this(null, player, permission, callback);
}
/**
* New PacketCheckPermission (Out)
*
* @param server Server to check on
* @param player Player to check on
* @param permission Permission to check
* @param callback Callbacks
*/
@SafeVarargs
public PacketCheckPermission(String server, UUID player, String permission, Callback<Boolean>... callback) {
this.name = server;
this.player = player;
this.permission = permission;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
@ -55,19 +41,17 @@ public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObj
}
@Override
public ObjectMap<Integer> send(SubDataClient client) throws Throwable {
public ObjectMap<Integer> send(SubDataSender client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, player);
data.set(0x0002, permission);
if (name != null) data.set(0x0003, name);
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) throws Throwable {
for (Callback<Boolean> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data.getBoolean(0x0001));
callbacks.remove(data.getUUID(0x0000));
public void receive(SubDataSender client, ObjectMap<Integer> data) throws Throwable {
client.sendPacket(new PacketCheckPermissionResponse(data.getUUID(0x0001), data.getRawString(0x0002), (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override

View File

@ -0,0 +1,59 @@
package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.Forwardable;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import org.bukkit.Bukkit;
import java.util.UUID;
import static net.ME1312.SubServers.Client.Bukkit.Network.Packet.PacketCheckPermission.callbacks;
/**
* Check Permission Response Packet
*/
public class PacketCheckPermissionResponse implements Forwardable, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private boolean result;
private UUID tracker;
/**
* New PacketCheckPermissionResponse (In)
*/
public PacketCheckPermissionResponse() {}
/**
* New PacketCheckPermissionResponse (Out)
*
* @param player Player to check on
* @param permission Permission to check
* @param tracker Receiver ID
*/
public PacketCheckPermissionResponse(UUID player, String permission, UUID tracker) {
this.result = Util.getDespiteException(() -> Bukkit.getServer().getPlayer(player).hasPermission(permission), false);
this.tracker = tracker;
}
@Override
public ObjectMap<Integer> send(SubDataSender client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, result);
return data;
}
@Override
public void receive(SubDataSender client, ObjectMap<Integer> data) throws Throwable {
for (Callback<Boolean> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data.getBoolean(0x0001));
callbacks.remove(data.getUUID(0x0000));
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -44,7 +44,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -54,7 +54,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -2,7 +2,7 @@ package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Graphic.UIRenderer;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
@ -109,7 +109,7 @@ public class PacketCreateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, name);
@ -123,7 +123,7 @@ public class PacketCreateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -45,7 +45,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -56,7 +56,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
@ -48,7 +48,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -40,7 +40,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
@ -49,7 +49,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import org.bukkit.Bukkit;
@ -34,7 +34,7 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
public PacketDownloadLang() {}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
try {
Util.reflect(SubPlugin.class.getDeclaredField("lang"), plugin, new NamedContainer<>(Calendar.getInstance().getTime().getTime(), data.getObject(0x0001)));
Bukkit.getLogger().info("SubData > Lang Settings Downloaded");

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -30,7 +30,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
return data;
@ -38,7 +38,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -32,7 +32,7 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
return json;
@ -40,7 +40,7 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -40,7 +40,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (proxy != null) json.set(0x0001, proxy);
@ -49,7 +49,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
boolean mode = callbacks.get(data.getUUID(0x0000)).name();
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000)).get()) {
if (mode) {

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (server != null) json.set(0x0001, server);
@ -48,7 +48,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -47,7 +47,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -58,7 +58,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -1,55 +0,0 @@
package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import org.bukkit.Bukkit;
import java.util.UUID;
/**
* External Check Permission Packet
*/
public class PacketExCheckPermission implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private UUID player;
private String permission;
private UUID tracker;
/**
* New PacketExCheckPermission (In)
*/
public PacketExCheckPermission() {}
/**
* New PacketExCheckPermission (Out)
*
* @param player Player to check on
* @param permission Permission to check
* @param tracker Receiver ID
*/
public PacketExCheckPermission(UUID player, String permission, UUID tracker) {
this.player = player;
this.permission = permission;
this.tracker = tracker;
}
@Override
public ObjectMap<Integer> send(SubDataClient client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, Util.getDespiteException(() -> Bukkit.getServer().getPlayer(player).hasPermission(permission), false));
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) throws Throwable {
client.sendPacket(new PacketExCheckPermission(data.getUUID(0x0001), data.getRawString(0x0002), (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -3,7 +3,7 @@ package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import org.bukkit.Bukkit;
@ -23,7 +23,7 @@ public class PacketInExReload implements PacketObjectIn<Integer> {
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
if (data != null && data.contains(0x0000)) Bukkit.getLogger().warning("SubData > Received request for a plugin reload: " + data.getString(0x0000));
else Bukkit.getLogger().warning("SubData > Received request for a plugin reload");
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {

View File

@ -3,7 +3,7 @@ package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import org.bukkit.Bukkit;
/**
@ -12,7 +12,7 @@ import org.bukkit.Bukkit;
public class PacketInExReset implements PacketObjectIn<Integer> {
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
if (data != null && data.contains(0x0000)) Bukkit.getLogger().warning("SubData > Received shutdown signal: " + data.getString(0x0000));
else Bukkit.getLogger().warning("SubData > Received shutdown signal");
Bukkit.shutdown();

View File

@ -1,7 +1,7 @@
package net.ME1312.SubServers.Client.Bukkit.Network.Packet;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Event.*;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
@ -147,7 +147,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
if (callbacks.keySet().contains(data.getString(0x0000))) {
List<Callback<ObjectMap<String>>> callbacks = PacketInExRunEvent.callbacks.get(data.getString(0x0000));
PacketInExRunEvent.callbacks.remove(data.getString(0x0000));

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.Initial.InitialPacket;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Event.SubNetworkConnectEvent;
import net.ME1312.SubServers.Client.Bukkit.SubAPI;
import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
@ -40,7 +40,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
if (plugin.api.getName() != null) json.set(0x0000, plugin.api.getName());
json.set(0x0001, Bukkit.getServer().getPort());
@ -49,12 +49,12 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
if (data.getInt(0x0001) == 0) {
try {
if (data.contains(0x0000)) {
Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client, true);
setReady(client.getConnection(), true);
}
} catch (Throwable e) {
e.printStackTrace();

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -43,7 +43,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -53,7 +53,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -41,7 +41,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -50,7 +50,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -41,7 +41,7 @@ public class PacketStartServer implements PacketObjectIn<Integer>, PacketObjectO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -50,7 +50,7 @@ public class PacketStartServer implements PacketObjectIn<Integer>, PacketObjectO
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -45,7 +45,7 @@ public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, id);
data.set(0x0001, server);
@ -55,7 +55,7 @@ public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Bukkit.Graphic.UIRenderer;
import java.util.HashMap;
@ -62,7 +62,7 @@ public class PacketUpdateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, name);
@ -73,7 +73,7 @@ public class PacketUpdateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -4,7 +4,6 @@ import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Library.DisconnectReason;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataProtocol;
import net.ME1312.SubServers.Client.Bukkit.Event.SubNetworkConnectEvent;
@ -15,7 +14,6 @@ import net.ME1312.SubServers.Client.Bukkit.SubPlugin;
import org.bukkit.Bukkit;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.logging.Handler;
@ -50,6 +48,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0015, PacketDownloadServerInfo.class);
instance.registerPacket(0x0016, PacketDownloadPlayerList.class);
instance.registerPacket(0x0017, PacketCheckPermission.class);
instance.registerPacket(0x0018, PacketCheckPermissionResponse.class);
instance.registerPacket(0x0010, new PacketDownloadLang(plugin));
instance.registerPacket(0x0011, new PacketDownloadPlatformInfo());
@ -59,6 +58,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0015, new PacketDownloadServerInfo());
instance.registerPacket(0x0016, new PacketDownloadPlayerList());
instance.registerPacket(0x0017, new PacketCheckPermission());
instance.registerPacket(0x0018, new PacketCheckPermissionResponse());
// 30-4F: Control Packets
@ -89,12 +89,10 @@ public class SubProtocol extends SubDataProtocol {
//instance.registerPacket(0x0070, PacketInExRunEvent.class);
//instance.registerPacket(0x0071, PacketInExReset.class);
//instance.registerPacket(0x0072, PacketInExReload.class);
instance.registerPacket(0x0074, PacketExCheckPermission.class);
instance.registerPacket(0x0070, new PacketInExRunEvent(plugin));
instance.registerPacket(0x0071, new PacketInExReset());
instance.registerPacket(0x0072, new PacketInExReload(plugin));
instance.registerPacket(0x0074, new PacketExCheckPermission());
}
return instance;
@ -164,12 +162,11 @@ public class SubProtocol extends SubDataProtocol {
subdata.on.closed(client -> {
SubNetworkDisconnectEvent event = new SubNetworkDisconnectEvent(client.get(), client.name());
if (plugin.isEnabled()) Bukkit.getPluginManager().callEvent(event);
map.put(0, null);
if (plugin.isEnabled()) {
Bukkit.getLogger().info("SubData > Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
Util.isException(() -> Util.reflect(SubPlugin.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
}
} else map.put(0, null);
});
return subdata;

View File

@ -182,10 +182,14 @@ public final class SubPlugin extends JavaPlugin {
@Override
public void run() {
try {
if (reset == resetDate && subdata.getOrDefault(0, null) == null)
subdata.put(0, subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?
null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1])));
if (reset == resetDate && subdata.getOrDefault(0, null) == null) {
SubDataClient open = subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?
null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1]));
if (subdata.getOrDefault(0, null) != null) subdata.get(0).reconnect(open);
subdata.put(0, open);
}
} catch (IOException e) {
Bukkit.getLogger().info("SubData > Connection was unsuccessful, retrying in " + reconnect + " seconds");

View File

@ -37,7 +37,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>19w39a</version>
<version>19w42c</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -4,7 +4,10 @@ import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketAddServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDeleteServer;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadHostInfo;
@ -61,16 +64,16 @@ public class Host {
* @return SubData Client Channel ID Array (may be empty if unsupported)
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
if (raw.contains("subdata")) {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
} else {
return new UUID[0];
return new SubDataSender[0];
}
}

View File

@ -4,7 +4,10 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadProxyInfo;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
@ -47,13 +50,13 @@ public class Proxy {
* @return SubData Client Channel ID Array
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
}
/**

View File

@ -2,7 +2,10 @@ package net.ME1312.SubServers.Client.Sponge.Network.API;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketDownloadServerInfo;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
@ -46,13 +49,13 @@ public class Server {
* @return SubData Client Channel ID Array
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
}
/**

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.net.InetAddress;
import java.util.HashMap;
@ -100,7 +100,7 @@ public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, name);
@ -111,7 +111,7 @@ public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -3,19 +3,19 @@ package net.ME1312.SubServers.Client.Sponge.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.Forwardable;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
/**
* Packet Check Permission
* Check Permission Packet
*/
public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<Boolean>[]> callbacks = new HashMap<UUID, Callback<Boolean>[]>();
private String name;
public class PacketCheckPermission implements Forwardable, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
static HashMap<UUID, Callback<Boolean>[]> callbacks = new HashMap<UUID, Callback<Boolean>[]>();
private UUID player;
private String permission;
private UUID tracker;
@ -34,20 +34,6 @@ public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObj
*/
@SafeVarargs
public PacketCheckPermission(UUID player, String permission, Callback<Boolean>... callback) {
this(null, player, permission, callback);
}
/**
* New PacketCheckPermission (Out)
*
* @param server Server to check on
* @param player Player to check on
* @param permission Permission to check
* @param callback Callbacks
*/
@SafeVarargs
public PacketCheckPermission(String server, UUID player, String permission, Callback<Boolean>... callback) {
this.name = server;
this.player = player;
this.permission = permission;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
@ -55,19 +41,17 @@ public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObj
}
@Override
public ObjectMap<Integer> send(SubDataClient client) throws Throwable {
public ObjectMap<Integer> send(SubDataSender client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, player);
data.set(0x0002, permission);
if (name != null) data.set(0x0003, name);
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) throws Throwable {
for (Callback<Boolean> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data.getBoolean(0x0001));
callbacks.remove(data.getUUID(0x0000));
public void receive(SubDataSender client, ObjectMap<Integer> data) throws Throwable {
client.sendPacket(new PacketCheckPermissionResponse(data.getUUID(0x0001), data.getRawString(0x0002), (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override

View File

@ -0,0 +1,59 @@
package net.ME1312.SubServers.Client.Sponge.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.Forwardable;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import org.spongepowered.api.Sponge;
import java.util.UUID;
import static net.ME1312.SubServers.Client.Sponge.Network.Packet.PacketCheckPermission.callbacks;
/**
* Check Permission Response Packet
*/
public class PacketCheckPermissionResponse implements Forwardable, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private boolean result;
private UUID tracker;
/**
* New PacketCheckPermissionResponse (In)
*/
public PacketCheckPermissionResponse() {}
/**
* New PacketCheckPermissionResponse (Out)
*
* @param player Player to check on
* @param permission Permission to check
* @param tracker Receiver ID
*/
public PacketCheckPermissionResponse(UUID player, String permission, UUID tracker) {
this.result = Util.getDespiteException(() -> Sponge.getServer().getPlayer(player).get().hasPermission(permission), false);
this.tracker = tracker;
}
@Override
public ObjectMap<Integer> send(SubDataSender client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, result);
return data;
}
@Override
public void receive(SubDataSender client, ObjectMap<Integer> data) throws Throwable {
for (Callback<Boolean> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data.getBoolean(0x0001));
callbacks.remove(data.getUUID(0x0000));
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -44,7 +44,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -54,7 +54,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.Graphic.UIRenderer;
import java.util.HashMap;
@ -109,7 +109,7 @@ public class PacketCreateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, name);
@ -123,7 +123,7 @@ public class PacketCreateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -45,7 +45,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -56,7 +56,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
@ -48,7 +48,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
@ -48,7 +48,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -7,6 +7,7 @@ import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.SubPlugin;
import java.util.Calendar;
@ -34,8 +35,8 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
public PacketDownloadLang() {}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
try {
Util.reflect(SubPlugin.class.getDeclaredField("lang"), plugin, new NamedContainer<>(Calendar.getInstance().getTime().getTime(), data.getObject(0x0001)));
log.info("Lang Settings Downloaded");

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -30,7 +30,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
return data;
@ -38,7 +38,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -31,7 +31,7 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
return json;
@ -39,7 +39,7 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -40,7 +40,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (proxy != null) json.set(0x0001, proxy);
@ -49,7 +49,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
boolean mode = callbacks.get(data.getUUID(0x0000)).name();
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000)).get()) {
if (mode) {

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (server != null) json.set(0x0001, server);
@ -48,7 +48,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -47,7 +47,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -58,7 +58,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -1,56 +0,0 @@
package net.ME1312.SubServers.Client.Sponge.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import org.spongepowered.api.Sponge;
import java.util.UUID;
/**
* External Check Permission Packet
*/
public class PacketExCheckPermission implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private UUID player;
private String permission;
private UUID tracker;
/**
* New PacketExCheckPermission (In)
*/
public PacketExCheckPermission() {}
/**
* New PacketExCheckPermission (Out)
*
* @param player Player to check on
* @param permission Permission to check
* @param tracker Receiver ID
*/
public PacketExCheckPermission(UUID player, String permission, UUID tracker) {
this.player = player;
this.permission = permission;
this.tracker = tracker;
}
@SuppressWarnings("OptionalGetWithoutIsPresent")
@Override
public ObjectMap<Integer> send(SubDataClient client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, Util.getDespiteException(() -> Sponge.getServer().getPlayer(player).get().hasPermission(permission), false));
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) throws Throwable {
client.sendPacket(new PacketExCheckPermission(data.getUUID(0x0001), data.getRawString(0x0002), (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -4,6 +4,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.SubPlugin;
import org.spongepowered.api.Sponge;
@ -25,8 +26,8 @@ public class PacketInExReload implements PacketObjectIn<Integer> {
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
if (data != null && data.contains(0x0000)) log.warning("Received request for a plugin reload: " + data.getString(0x0000));
else log.warning("Received request for a plugin reload");
Sponge.getScheduler().createTaskBuilder().async().execute(() -> {

View File

@ -4,6 +4,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import org.spongepowered.api.Sponge;
import java.util.logging.Logger;
@ -14,8 +15,8 @@ import java.util.logging.Logger;
public class PacketInExReset implements PacketObjectIn<Integer> {
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
if (data != null && data.contains(0x0000)) log.warning("Received shutdown signal: " + data.getString(0x0000));
else log.warning("Received shutdown signal");
Sponge.getServer().shutdown();

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.Event.*;
import net.ME1312.SubServers.Client.Sponge.SubPlugin;
import org.spongepowered.api.Sponge;
@ -121,7 +121,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
if (callbacks.keySet().contains(data.getString(0x0000))) {
List<Callback<ObjectMap<String>>> callbacks = PacketInExRunEvent.callbacks.get(data.getString(0x0000));
PacketInExRunEvent.callbacks.remove(data.getString(0x0000));

View File

@ -6,6 +6,7 @@ import net.ME1312.SubData.Client.Protocol.Initial.InitialPacket;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
import net.ME1312.SubServers.Client.Sponge.SubPlugin;
@ -40,7 +41,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
if (plugin.api.getName() != null) json.set(0x0000, plugin.api.getName());
if (plugin.game.getServer().getBoundAddress().isPresent()) json.set(0x0001, plugin.game.getServer().getBoundAddress().get());
@ -49,13 +50,13 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
if (data.getInt(0x0001) == 0) {
try {
if (data.contains(0x0000)) {
Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client, true);
setReady(client.getConnection(), true);
}
} catch (Throwable e) {
e.printStackTrace();

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -43,7 +43,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -53,7 +53,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -41,7 +41,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -50,7 +50,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -41,7 +41,7 @@ public class PacketStartServer implements PacketObjectIn<Integer>, PacketObjectO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -50,7 +50,7 @@ public class PacketStartServer implements PacketObjectIn<Integer>, PacketObjectO
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -44,7 +44,7 @@ public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, id);
data.set(0x0001, server);
@ -54,7 +54,7 @@ public class PacketStopServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -61,7 +61,7 @@ public class PacketUpdateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, name);
@ -72,7 +72,7 @@ public class PacketUpdateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -4,7 +4,6 @@ import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Library.DisconnectReason;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataProtocol;
import net.ME1312.SubServers.Client.Sponge.Event.SubNetworkConnectEvent;
@ -13,15 +12,11 @@ import net.ME1312.SubServers.Client.Sponge.Network.Packet.*;
import net.ME1312.SubServers.Client.Sponge.SubAPI;
import net.ME1312.SubServers.Client.Sponge.SubPlugin;
import org.slf4j.LoggerFactory;
import org.spongepowered.api.GameState;
import org.spongepowered.api.Sponge;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.net.InetAddress;
import java.util.HashMap;
import java.util.concurrent.TimeUnit;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
import java.util.logging.Logger;
@ -57,6 +52,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0015, PacketDownloadServerInfo.class);
instance.registerPacket(0x0016, PacketDownloadPlayerList.class);
instance.registerPacket(0x0017, PacketCheckPermission.class);
instance.registerPacket(0x0018, PacketCheckPermissionResponse.class);
instance.registerPacket(0x0010, new PacketDownloadLang(plugin));
instance.registerPacket(0x0011, new PacketDownloadPlatformInfo());
@ -66,6 +62,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0015, new PacketDownloadServerInfo());
instance.registerPacket(0x0016, new PacketDownloadPlayerList());
instance.registerPacket(0x0017, new PacketCheckPermission());
instance.registerPacket(0x0018, new PacketCheckPermissionResponse());
// 30-4F: Control Packets
@ -96,12 +93,10 @@ public class SubProtocol extends SubDataProtocol {
//instance.registerPacket(0x0070, PacketInExRunEvent.class);
//instance.registerPacket(0x0071, PacketInExReset.class);
//instance.registerPacket(0x0072, PacketInExReload.class);
instance.registerPacket(0x0074, PacketExCheckPermission.class);
instance.registerPacket(0x0070, new PacketInExRunEvent(plugin));
instance.registerPacket(0x0071, new PacketInExReset());
instance.registerPacket(0x0072, new PacketInExReload(plugin));
instance.registerPacket(0x0074, new PacketExCheckPermission());
}
return instance;
@ -175,13 +170,12 @@ public class SubProtocol extends SubDataProtocol {
subdata.on.closed(client -> {
SubNetworkDisconnectEvent event = new SubNetworkDisconnectEvent(client.get(), client.name());
Sponge.getEventManager().post(event);
map.put(0, null);
if (Util.getDespiteException(() -> Util.reflect(SubPlugin.class.getDeclaredField("running"), plugin), true)) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.get()), null);
log.info("Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 30) + " seconds");
Util.isException(() -> Util.reflect(SubPlugin.class.getDeclaredMethod("connect", NamedContainer.class), plugin, client));
}
} else map.put(0, null);
});
return subdata;

View File

@ -201,10 +201,14 @@ public final class SubPlugin {
@Override
public void run() {
try {
if (reset == resetDate && subdata.getOrDefault(0, null) == null)
subdata.put(0, subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?
null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1])));
if (reset == resetDate && subdata.getOrDefault(0, null) == null) {
SubDataClient open = subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?
null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1]));
if (subdata.getOrDefault(0, null) != null) subdata.get(0).reconnect(open);
subdata.put(0, open);
}
} catch (IOException e) {
log.info("Connection was unsuccessful, retrying in " + reconnect + " seconds");

View File

@ -27,7 +27,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>19w39a</version>
<version>19w42c</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -299,10 +299,14 @@ public final class ExHost {
@Override
public void run() {
try {
if (reset == resetDate && subdata.getOrDefault(0, null) == null)
subdata.put(0, subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?
null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1])));
if (reset == resetDate && subdata.getOrDefault(0, null) == null) {
SubDataClient open = subprotocol.open((config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0].equals("0.0.0.0"))?
null:InetAddress.getByName(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[0]),
Integer.parseInt(config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391").split(":")[1]));
if (subdata.getOrDefault(0, null) != null) subdata.get(0).reconnect(open);
subdata.put(0, open);
}
timer.cancel();
} catch (IOException e) {
log.info("Connection was unsuccessful, retrying in " + reconnect + " seconds");

View File

@ -76,7 +76,7 @@ public class SubLoggerImpl {
Process process = this.process;
ExHost host = SubAPI.getInstance().getInternals();
if (logn) Util.isException(() -> {
channel = (SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0].newChannel();
channel = (SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0].openChannel();
channel.on.closed(new Callback<NamedContainer<DisconnectReason, DataClient>>() {
@Override
public void run(NamedContainer<DisconnectReason, DataClient> client) {
@ -93,8 +93,10 @@ public class SubLoggerImpl {
if (!started || SubLoggerImpl.this.process == null || process != SubLoggerImpl.this.process || !process.isAlive()) {
timer.cancel();
} else try {
channel = (SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0].newChannel();
channel.on.closed(run);
SubDataClient open = (SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0].openChannel();
open.on.closed(run);
channel.reconnect(channel);
channel = open;
timer.cancel();
} catch (NullPointerException | IOException e) {}
}

View File

@ -4,7 +4,10 @@ import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.Network.Packet.PacketAddServer;
import net.ME1312.SubServers.Host.Network.Packet.PacketDeleteServer;
import net.ME1312.SubServers.Host.Network.Packet.PacketDownloadHostInfo;
@ -61,16 +64,16 @@ public class Host {
* @return SubData Client Channel ID Array (may be empty if unsupported)
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
if (raw.contains("subdata")) {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
} else {
return new UUID[0];
return new SubDataSender[0];
}
}

View File

@ -4,7 +4,10 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Map.ObjectMapValue;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.Network.Packet.PacketDownloadProxyInfo;
import net.ME1312.SubServers.Host.SubAPI;
@ -47,13 +50,13 @@ public class Proxy {
* @return SubData Client Channel ID Array
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
}
/**

View File

@ -2,7 +2,10 @@ package net.ME1312.SubServers.Host.Network.API;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.SubData.Client.DataSender;
import net.ME1312.SubData.Client.Library.ForwardedDataSender;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.Network.Packet.PacketDownloadServerInfo;
import net.ME1312.SubServers.Host.SubAPI;
@ -46,13 +49,13 @@ public class Server {
* @return SubData Client Channel ID Array
*/
@SuppressWarnings("unchecked")
public UUID[] getSubData() {
public DataSender[] getSubData() {
ObjectMap<Integer> subdata = new ObjectMap<Integer>((Map<Integer, ?>) raw.getObject("subdata"));
LinkedList<Integer> keys = new LinkedList<Integer>(subdata.getKeys());
LinkedList<UUID> channels = new LinkedList<UUID>();
LinkedList<SubDataSender> channels = new LinkedList<SubDataSender>();
Collections.sort(keys);
for (Integer channel : keys) channels.add(subdata.getUUID(channel));
return channels.toArray(new UUID[0]);
for (Integer channel : keys) channels.add((subdata.isNull(channel))?null:new ForwardedDataSender((SubDataClient) SubAPI.getInstance().getSubDataNetwork()[0], subdata.getUUID(channel)));
return channels.toArray(new SubDataSender[0]);
}
/**

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.net.InetAddress;
import java.util.HashMap;
@ -100,7 +100,7 @@ public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, name);
@ -111,7 +111,7 @@ public class PacketAddServer implements PacketObjectIn<Integer>, PacketObjectOut
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -3,19 +3,19 @@ package net.ME1312.SubServers.Host.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.Forwardable;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
/**
* Packet Check Permission
* Check Permission Packet
*/
public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private static HashMap<UUID, Callback<Boolean>[]> callbacks = new HashMap<UUID, Callback<Boolean>[]>();
private String name;
public class PacketCheckPermission implements Forwardable, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
static HashMap<UUID, Callback<Boolean>[]> callbacks = new HashMap<UUID, Callback<Boolean>[]>();
private UUID player;
private String permission;
private UUID tracker;
@ -34,20 +34,6 @@ public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObj
*/
@SafeVarargs
public PacketCheckPermission(UUID player, String permission, Callback<Boolean>... callback) {
this(null, player, permission, callback);
}
/**
* New PacketCheckPermission (Out)
*
* @param server Server to check on
* @param player Player to check on
* @param permission Permission to check
* @param callback Callbacks
*/
@SafeVarargs
public PacketCheckPermission(String server, UUID player, String permission, Callback<Boolean>... callback) {
this.name = server;
this.player = player;
this.permission = permission;
this.tracker = Util.getNew(callbacks.keySet(), UUID::randomUUID);
@ -55,19 +41,17 @@ public class PacketCheckPermission implements PacketObjectIn<Integer>, PacketObj
}
@Override
public ObjectMap<Integer> send(SubDataClient client) throws Throwable {
public ObjectMap<Integer> send(SubDataSender client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, player);
data.set(0x0002, permission);
if (name != null) data.set(0x0003, name);
return data;
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) throws Throwable {
for (Callback<Boolean> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data.getBoolean(0x0001));
callbacks.remove(data.getUUID(0x0000));
public void receive(SubDataSender client, ObjectMap<Integer> data) throws Throwable {
client.sendPacket(new PacketCheckPermissionResponse(data.getUUID(0x0001), data.getRawString(0x0002), (data.contains(0x0000))?data.getUUID(0x0000):null));
}
@Override

View File

@ -0,0 +1,57 @@
package net.ME1312.SubServers.Host.Network.Packet;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubData.Client.Protocol.Forwardable;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.UUID;
import static net.ME1312.SubServers.Host.Network.Packet.PacketCheckPermission.callbacks;
/**
* Check Permission Response Packet
*/
public class PacketCheckPermissionResponse implements Forwardable, PacketObjectIn<Integer>, PacketObjectOut<Integer> {
private boolean result;
private UUID tracker;
/**
* New PacketCheckPermissionResponse (In)
*/
public PacketCheckPermissionResponse() {}
/**
* New PacketCheckPermissionResponse (Out)
*
* @param player Player to check on
* @param permission Permission to check
* @param tracker Receiver ID
*/
public PacketCheckPermissionResponse(UUID player, String permission, UUID tracker) {
this.result = false; // TODO
this.tracker = tracker;
}
@Override
public ObjectMap<Integer> send(SubDataSender client) throws Throwable {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, result);
return data;
}
@Override
public void receive(SubDataSender client, ObjectMap<Integer> data) throws Throwable {
for (Callback<Boolean> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data.getBoolean(0x0001));
callbacks.remove(data.getUUID(0x0000));
}
@Override
public int version() {
return 0x0001;
}
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -44,7 +44,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -54,7 +54,7 @@ public class PacketCommandServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -73,7 +73,7 @@ public class PacketCreateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, name);
@ -87,7 +87,7 @@ public class PacketCreateServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -45,7 +45,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -56,7 +56,7 @@ public class PacketDeleteServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
@ -48,7 +48,7 @@ public class PacketDownloadGroupInfo implements PacketObjectIn<Integer>, PacketO
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (group != null) json.set(0x0001, group);
@ -48,7 +48,7 @@ public class PacketDownloadHostInfo implements PacketObjectIn<Integer>, PacketOb
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,6 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.ExHost;
import java.util.Calendar;
@ -33,8 +34,8 @@ public class PacketDownloadLang implements PacketObjectIn<Integer>, PacketOut {
public PacketDownloadLang() {}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
try {
Util.reflect(ExHost.class.getDeclaredField("lang"), host, new NamedContainer<>(Calendar.getInstance().getTime().getTime(), data.getObject(0x0001)));
log.info("Lang Settings Downloaded");

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -30,7 +30,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
return data;
@ -38,7 +38,7 @@ public class PacketDownloadPlatformInfo implements PacketObjectIn<Integer>, Pack
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -31,7 +31,7 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
return json;
@ -39,7 +39,7 @@ public class PacketDownloadPlayerList implements PacketObjectIn<Integer>, Packet
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -40,7 +40,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (proxy != null) json.set(0x0001, proxy);
@ -49,7 +49,7 @@ public class PacketDownloadProxyInfo implements PacketObjectIn<Integer>, PacketO
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
boolean mode = callbacks.get(data.getUUID(0x0000)).name();
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000)).get()) {
if (mode) {

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.Map;
@ -39,7 +39,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> json = new ObjectMap<Integer>();
json.set(0x0000, tracker);
if (server != null) json.set(0x0001, server);
@ -48,7 +48,7 @@ public class PacketDownloadServerInfo implements PacketObjectIn<Integer>, Packet
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<String>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(new ObjectMap<String>((Map<String, ?>) data.getObject(0x0001)));
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -47,7 +47,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -58,7 +58,7 @@ public class PacketEditServer implements PacketObjectIn<Integer>, PacketObjectOu
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -6,6 +6,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.Executable.SubServerImpl;
import net.ME1312.SubServers.Host.ExHost;
@ -55,7 +56,7 @@ public class PacketExAddServer implements PacketObjectIn<Integer>, PacketObjectO
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
data.set(0x0001, response);
@ -64,8 +65,8 @@ public class PacketExAddServer implements PacketObjectIn<Integer>, PacketObjectO
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
Logger logger = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger logger = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
try {
String name = data.getRawString(0x0001);
@ -93,10 +94,10 @@ public class PacketExAddServer implements PacketObjectIn<Integer>, PacketObjectO
if (UPnP.isUPnPAvailable() && UPnP.isMappedTCP(server.getPort()))
UPnP.closePortTCP(server.getPort());
init(client, server = new SubServerImpl(host, name, enabled, port, log, dir, exec, stopcmd), running, tracker, logger);
init(client.getConnection(), server = new SubServerImpl(host, name, enabled, port, log, dir, exec, stopcmd), running, tracker, logger);
}
} else {
init(client, new SubServerImpl(host, name, enabled, port, log, dir, exec, stopcmd), running, tracker, logger);
init(client.getConnection(), new SubServerImpl(host, name, enabled, port, log, dir, exec, stopcmd), running, tracker, logger);
}
} catch (Throwable e) {
client.sendPacket(new PacketExAddServer(2, tracker));

View File

@ -6,7 +6,7 @@ import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.Executable.SubCreatorImpl;
import net.ME1312.SubServers.Host.ExHost;
@ -27,14 +27,14 @@ public class PacketExConfigureHost implements PacketObjectIn<Integer>, PacketOut
}
@Override
public void sending(SubDataClient client) {
public void sending(SubDataSender client) {
host.log.info.println("Downloading Host Settings...");
first = true;
}
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
host.host = new ObjectMap<>((Map<String, ?>) data.getObject(0x0000));
for (SubCreatorImpl.ServerTemplate template : host.templates.values()) {
Util.deleteDirectory(template.getDirectory());

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.ExHost;
import java.util.UUID;
@ -64,7 +64,7 @@ public class PacketExCreateServer implements PacketObjectIn<Integer>, PacketObje
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
data.set(0x0001, response);
@ -75,7 +75,7 @@ public class PacketExCreateServer implements PacketObjectIn<Integer>, PacketObje
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
try {
if (data.contains(0x0001)) {

View File

@ -9,6 +9,7 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.Executable.SubServerImpl;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
@ -50,7 +51,7 @@ public class PacketExDeleteServer implements PacketObjectIn<Integer>, PacketObje
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
data.set(0x0001, response);
@ -59,8 +60,8 @@ public class PacketExDeleteServer implements PacketObjectIn<Integer>, PacketObje
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
try {
String name = data.getRawString(0x0001);

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketOut;
import net.ME1312.SubData.Client.Protocol.PacketStreamIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
@ -25,14 +25,14 @@ public class PacketExDownloadTemplates implements PacketOut, PacketStreamIn {
}
@Override
public void sending(SubDataClient client) throws Throwable {
public void sending(SubDataSender client) throws Throwable {
UniversalFile dir = new UniversalFile(GalaxiEngine.getInstance().getRuntimeDirectory(), "Templates");
if (dir.exists()) Util.deleteDirectory(dir);
host.log.info.println("Downloading Template Files...");
}
@Override
public void receive(SubDataClient client, InputStream stream) {
public void receive(SubDataSender client, InputStream stream) {
try {
Util.unzip(stream, new UniversalFile(GalaxiEngine.getInstance().getRuntimeDirectory(), "Templates"));
host.log.info.println("Template Files Downloaded");

View File

@ -4,7 +4,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.Executable.SubLoggerImpl;
import net.ME1312.SubServers.Host.Executable.SubServerImpl;
import net.ME1312.SubServers.Host.ExHost;
@ -69,7 +69,7 @@ public class PacketExEditServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, server.getName());
data.set(0x0001, type.getValue());
@ -78,7 +78,7 @@ public class PacketExEditServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
try {
SubServerImpl server = host.servers.get(data.getString(0x0000).toLowerCase());
switch (data.getInt(0x0001)) {

View File

@ -6,6 +6,8 @@ import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.ExHost;
import net.ME1312.SubServers.Host.SubAPI;
@ -43,7 +45,7 @@ public class PacketExRemoveServer implements PacketObjectIn<Integer>, PacketObje
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
if (tracker != null) data.set(0x0000, tracker);
data.set(0x0001, response);
@ -51,8 +53,8 @@ public class PacketExRemoveServer implements PacketObjectIn<Integer>, PacketObje
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
UUID tracker = (data.contains(0x0000)?data.getUUID(0x0000):null);
try {
String name = data.getRawString(0x0001);

View File

@ -4,6 +4,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.ExHost;
import java.util.logging.Logger;
@ -24,8 +25,8 @@ public class PacketInExReload implements PacketObjectIn<Integer> {
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
if (data != null && data.contains(0x0000)) log.warning("Received request for a plugin reload: " + data.getString(0x0000));
else log.warning("Received request for a plugin reload");
new Thread(() -> {

View File

@ -2,7 +2,7 @@ package net.ME1312.SubServers.Host.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.ExHost;
/**
@ -16,7 +16,7 @@ public class PacketInExReset implements PacketObjectIn<Integer> {
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {/*
public void receive(SubDataSender client, ObjectMap<Integer> data) {/*
List<String> subservers = new ArrayList<String>();
subservers.addAll(host.servers.keySet());

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.Event.*;
import java.util.ArrayList;
@ -119,7 +119,7 @@ public class PacketInExRunEvent implements PacketObjectIn<Integer> {
@SuppressWarnings("unchecked")
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
if (callbacks.keySet().contains(data.getString(0x0000))) {
List<Callback<ObjectMap<String>>> callbacks = PacketInExRunEvent.callbacks.get(data.getString(0x0000));
PacketInExRunEvent.callbacks.remove(data.getString(0x0000));

View File

@ -8,6 +8,7 @@ import net.ME1312.SubData.Client.Protocol.Initial.InitialPacket;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import net.ME1312.SubServers.Host.ExHost;
import java.util.logging.Logger;
@ -41,7 +42,7 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, host.api.getName());
data.set(0x0001, channel);
@ -49,10 +50,10 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) throws Throwable {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client), null);
public void receive(SubDataSender client, ObjectMap<Integer> data) throws Throwable {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.getConnection()), null);
if (data.getInt(0x0001) == 0) {
setReady(client, true);
setReady(client.getConnection(), true);
} else {
log.severe("Could not link name with host" + ((data.contains(0x0002))?": "+data.getRawString(0x0002):'.'));
DebugUtil.logException(new IllegalStateException(), log);

View File

@ -3,7 +3,7 @@ package net.ME1312.SubServers.Host.Network.Packet;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.UUID;
@ -34,8 +34,8 @@ public class PacketOutExLogMessage implements PacketObjectOut<Integer> {
}
@Override
public ObjectMap<Integer> send(SubDataClient client) throws Exception {
if (terminate) client.close();
public ObjectMap<Integer> send(SubDataSender client) throws Exception {
if (terminate) client.getConnection().close();
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, address);

View File

@ -10,8 +10,7 @@ public class PacketOutExRequestQueue implements PacketOut {
/**
* New PacketOutExRequestQueue
*/
public PacketOutExRequestQueue() {
}
public PacketOutExRequestQueue() {}
@Override

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -43,7 +43,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -53,7 +53,7 @@ public class PacketRemoveServer implements PacketObjectIn<Integer>, PacketObject
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

View File

@ -5,7 +5,7 @@ import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Client.Protocol.PacketObjectIn;
import net.ME1312.SubData.Client.Protocol.PacketObjectOut;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataSender;
import java.util.HashMap;
import java.util.UUID;
@ -41,7 +41,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public ObjectMap<Integer> send(SubDataClient client) {
public ObjectMap<Integer> send(SubDataSender client) {
ObjectMap<Integer> data = new ObjectMap<Integer>();
data.set(0x0000, tracker);
data.set(0x0001, server);
@ -50,7 +50,7 @@ public class PacketRestartServer implements PacketObjectIn<Integer>, PacketObjec
}
@Override
public void receive(SubDataClient client, ObjectMap<Integer> data) {
public void receive(SubDataSender client, ObjectMap<Integer> data) {
for (Callback<ObjectMap<Integer>> callback : callbacks.get(data.getUUID(0x0000))) callback.run(data);
callbacks.remove(data.getUUID(0x0000));
}

Some files were not shown because too many files have changed in this diff Show More