Update SubData

This commit is contained in:
ME1312 2021-01-21 14:28:23 -05:00
parent ea9eec9aa8
commit 9af8dd02ce
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
24 changed files with 55 additions and 30 deletions

View File

@ -50,7 +50,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Server</artifactId>
<version>20w48b</version>
<version>21w04b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -2,6 +2,7 @@ package net.ME1312.SubServers.Bungee.Network.Packet;
import net.ME1312.Galaxi.Library.UniversalFile;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.Library.DataSize;
import net.ME1312.SubData.Server.Protocol.PacketIn;
import net.ME1312.SubData.Server.Protocol.PacketStreamOut;
import net.ME1312.SubData.Server.SubDataClient;
@ -37,7 +38,10 @@ public class PacketExDownloadTemplates implements PacketIn, PacketStreamOut {
@Override
public void send(SubDataClient client, OutputStream stream) throws Throwable {
try {
int initial = client.getBlockSize();
client.setBlockSize(DataSize.MBB);
Util.zip(new UniversalFile(plugin.dir, "SubServers:Templates"), stream);
client.setBlockSize(initial);
stream.close();
Util.isException(() -> Util.reflect(ExternalSubCreator.class.getDeclaredField("enableRT"), host.getCreator(), true));

View File

@ -67,7 +67,7 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
((ExternalHost) host).setSubData(client, channel);
Logger.get("SubData").info(client.getAddress().toString() + " has been defined as Host: " + host.getName() + ((channel > 0)?" (Sub-"+channel+")":""));
queue(host.getName(), () -> client.sendPacket(new PacketLinkExHost(0, null)));
setReady(client, true);
setReady(client);
} else {
client.sendPacket(new PacketLinkExHost(3, "Host already linked"));
}

View File

@ -78,7 +78,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
if (isnew) plugin.getPluginManager().callEvent(new SubAddProxyEvent(proxy));
Logger.get("SubData").info(client.getAddress().toString() + " has been defined as Proxy: " + proxy.getName() + ((channel > 0)?" (Sub-"+channel+")":""));
queue(proxy.getName(), () -> client.sendPacket(new PacketLinkProxy(proxy.getName(), 0, null)));
setReady(client, true);
setReady(client);
} else {
client.sendPacket(new PacketLinkProxy(proxy.getName(), 2, "Proxy already linked"));

View File

@ -140,7 +140,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
++req;
last = now;
setReady(client, true);
setReady(client);
} else {
client.sendPacket(new PacketLinkServer(null, 4, "Server already linked"));
}

View File

@ -2,6 +2,8 @@ package net.ME1312.SubServers.Bungee.Network;
import net.ME1312.Galaxi.Library.Callback.Callback;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Server.Library.DataSize;
import net.ME1312.SubData.Server.SubDataClient;
import net.ME1312.SubData.Server.SubDataProtocol;
import net.ME1312.SubData.Server.SubDataServer;
import net.ME1312.SubServers.Bungee.Event.SubNetworkConnectEvent;
@ -28,6 +30,7 @@ public class SubProtocol extends SubDataProtocol {
setName("SubServers 2");
setVersion(new Version("2.16a+"));
setBlockSize(DataSize.MB);
// 00-0F: Object Link Packets
@ -155,7 +158,10 @@ public class SubProtocol extends SubDataProtocol {
subdata.on.closed(server -> plugin.subdata = null);
subdata.on.connect(client -> {
if (!plugin.getPluginManager().callEvent(new SubNetworkConnectEvent(client.getServer(), client)).isCancelled()) {
client.on.ready(c -> plugin.getPluginManager().callEvent(new SubNetworkLoginEvent(c.getServer(), c)));
client.on.ready(c -> {
((SubDataClient) c).setBlockSize((int) DataSize.KBB);
plugin.getPluginManager().callEvent(new SubNetworkLoginEvent(c.getServer(), c));
});
client.on.closed(c -> plugin.getPluginManager().callEvent(new SubNetworkDisconnectEvent(c.value().getServer(), c.value(), c.key())));
return true;
} else return false;

View File

@ -552,7 +552,6 @@ public final class SubProxy extends BungeeCommon implements Listener {
subprotocol.unregisterCipher("AES-256");
subprotocol.unregisterCipher("RSA");
subprotocol.setBlockSize(config.get().getMap("Settings").getMap("SubData").getLong("Block-Size", (long) DataSize.MB));
subprotocol.setTimeout(TimeUnit.SECONDS.toMillis(config.get().getMap("Settings").getMap("SubData").getInt("Timeout", 30)));
String cipher = config.get().getMap("Settings").getMap("SubData").getRawString("Encryption", "NULL");

View File

@ -62,7 +62,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>20w48b</version>
<version>21w04b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -53,7 +53,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
if (data.getInt(0x0001) == 0) {
try {
if (data.contains(0x0000)) Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client.getConnection(), true);
setReady(client.getConnection());
} catch (Throwable e) {
e.printStackTrace();
}

View File

@ -5,6 +5,7 @@ import net.ME1312.Galaxi.Library.Container.Pair;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Library.DataSize;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataProtocol;
import net.ME1312.SubServers.Client.Bukkit.Event.SubNetworkConnectEvent;
@ -35,6 +36,7 @@ public class SubProtocol extends SubDataProtocol {
setName("SubServers 2");
addVersion(new Version("2.16a+"));
setBlockSize(DataSize.MB);
// 00-0F: Object Link Packets
@ -165,7 +167,10 @@ public class SubProtocol extends SubDataProtocol {
subdata.sendPacket(new PacketLinkServer(plugin, 0));
subdata.sendPacket(new PacketDownloadLang());
subdata.on.ready(client -> Bukkit.getPluginManager().callEvent(new SubNetworkConnectEvent((SubDataClient) client)));
subdata.on.ready(client -> {
((SubDataClient) client).setBlockSize((int) DataSize.KBB);
Bukkit.getPluginManager().callEvent(new SubNetworkConnectEvent((SubDataClient) client));
});
subdata.on.closed(client -> {
SubNetworkDisconnectEvent event = new SubNetworkDisconnectEvent(client.value(), client.key());

View File

@ -93,7 +93,6 @@ public final class SubPlugin extends JavaPlugin {
subprotocol.registerCipher("DHE-128", DHE.get(128));
subprotocol.registerCipher("DHE-192", DHE.get(192));
subprotocol.registerCipher("DHE-256", DHE.get(256));
subprotocol.setBlockSize(config.get().getMap("Settings").getMap("SubData").getLong("Block-Size", (long) DataSize.MB));
api.name = config.get().getMap("Settings").getMap("SubData").getString("Name", System.getenv("name"));
if (config.get().getMap("Settings").getMap("SubData").getRawString("Password", "").length() > 0) {
@ -219,7 +218,7 @@ public final class SubPlugin extends JavaPlugin {
}
subdata.clear();
subdata.put(0, null);
} catch (IOException | InterruptedException e) {
} catch (InterruptedException e) {
e.printStackTrace();
}
}

View File

@ -26,7 +26,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>20w48b</version>
<version>21w04b</version>
<scope>provided</scope>
</dependency>
</dependencies>

View File

@ -44,7 +44,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>20w48b</version>
<version>21w04b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -55,7 +55,7 @@ public class PacketLinkServer implements InitialPacket, PacketObjectIn<Integer>,
if (data.getInt(0x0001) == 0) {
try {
if (data.contains(0x0000)) Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client.getConnection(), true);
setReady(client.getConnection());
} catch (Throwable e) {
e.printStackTrace();
}

View File

@ -5,6 +5,7 @@ import net.ME1312.Galaxi.Library.Container.Pair;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Library.DataSize;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataProtocol;
import net.ME1312.SubServers.Client.Common.Network.Packet.*;
@ -38,6 +39,7 @@ public class SubProtocol extends SubDataProtocol {
setName("SubServers 2");
addVersion(new Version("2.16a+"));
setBlockSize(DataSize.MB);
// 00-0F: Object Link Packets
@ -172,7 +174,10 @@ public class SubProtocol extends SubDataProtocol {
SubDataClient subdata = super.open(scheduler, logger, address, port);
subdata.sendPacket(new PacketLinkServer(plugin, 0));
subdata.sendPacket(new PacketDownloadLang());
subdata.on.ready(client -> Sponge.getEventManager().post(new SubNetworkConnectEvent((SubDataClient) client)));
subdata.on.ready(client -> {
((SubDataClient) client).setBlockSize((int) DataSize.KBB);
Sponge.getEventManager().post(new SubNetworkConnectEvent((SubDataClient) client));
});
subdata.on.closed(client -> {
SubNetworkDisconnectEvent event = new SubNetworkDisconnectEvent(client.value(), client.key());
Sponge.getEventManager().post(event);

View File

@ -112,7 +112,6 @@ public final class SubPlugin {
subprotocol.registerCipher("DHE-128", DHE.get(128));
subprotocol.registerCipher("DHE-192", DHE.get(192));
subprotocol.registerCipher("DHE-256", DHE.get(256));
subprotocol.setBlockSize(config.get().getMap("Settings").getMap("SubData").getLong("Block-Size", (long) DataSize.MB));
api.name = config.get().getMap("Settings").getMap("SubData").getString("Name", System.getenv("name"));
Logger log = LoggerFactory.getLogger("SubData");
@ -247,7 +246,7 @@ public final class SubPlugin {
}
subdata.clear();
subdata.put(0, null);
} catch (IOException | InterruptedException e) {
} catch (InterruptedException e) {
e.printStackTrace();
}
}

View File

@ -34,7 +34,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>20w48b</version>
<version>21w04b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -183,7 +183,6 @@ public final class ExHost {
subprotocol.registerCipher("DHE-128", DHE.get(128));
subprotocol.registerCipher("DHE-192", DHE.get(192));
subprotocol.registerCipher("DHE-256", DHE.get(256));
subprotocol.setBlockSize(config.get().getMap("Settings").getMap("SubData").getLong("Block-Size", (long) DataSize.MB));
api.name = config.get().getMap("Settings").getMap("SubData").getString("Name", null);
Logger log = new Logger("SubData");

View File

@ -53,7 +53,7 @@ public class PacketLinkExHost implements InitialPacket, PacketObjectIn<Integer>,
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.getConnection(), true);
setReady(client.getConnection());
} else {
log.severe("Could not link name with host" + ((data.contains(0x0002))?": "+data.getRawString(0x0002):'.'));
DebugUtil.logException(new IllegalStateException(), log);

View File

@ -6,6 +6,7 @@ import net.ME1312.Galaxi.Library.Container.Pair;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Library.DataSize;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataProtocol;
import net.ME1312.SubServers.Client.Common.Network.Packet.*;
@ -33,6 +34,7 @@ public class SubProtocol extends SubDataProtocol {
setName("SubServers 2");
addVersion(new Version("2.16a+"));
setBlockSize(DataSize.MB);
// 00-0F: Object Link Packets
@ -163,14 +165,16 @@ public class SubProtocol extends SubDataProtocol {
subdata.sendPacket(new PacketExDownloadTemplates(host));
subdata.sendPacket(new PacketDownloadLang());
subdata.sendPacket(new PacketOutExRequestQueue());
subdata.on.ready(client -> host.engine.getPluginManager().executeEvent(new SubNetworkConnectEvent((SubDataClient) client)));
subdata.on.ready(client -> {
((SubDataClient) client).setBlockSize((int) DataSize.KBB);
host.engine.getPluginManager().executeEvent(new SubNetworkConnectEvent((SubDataClient) client));
});
subdata.on.closed(client -> {
SubNetworkDisconnectEvent event = new SubNetworkDisconnectEvent(client.value(), client.key());
host.engine.getPluginManager().executeEvent(event);
if (Util.getDespiteException(() -> Util.reflect(ExHost.class.getDeclaredField("running"), host), true)) {
Logger log = Util.getDespiteException(() -> Util.reflect(SubDataClient.class.getDeclaredField("log"), client.value()), null);
log.info("Attempting reconnect in " + host.config.get().getMap("Settings", new YAMLSection()).getMap("SubData", new YAMLSection()).getInt("Reconnect", 60) + " seconds");
Util.isException(() -> Util.reflect(ExHost.class.getDeclaredMethod("connect", Logger.class, Pair.class), host, log, client));
} else map.put(0, null);
});

View File

@ -57,7 +57,7 @@
<dependency>
<groupId>net.ME1312.SubData</groupId>
<artifactId>Client</artifactId>
<version>20w48b</version>
<version>21w04b</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>

View File

@ -155,7 +155,6 @@ public final class ExProxy extends BungeeCommon implements Listener {
subprotocol.unregisterCipher("AES-256");
subprotocol.unregisterCipher("RSA");
subprotocol.setBlockSize(config.get().getMap("Settings").getMap("SubData").getLong("Block-Size", (long) DataSize.MB));
api.name = config.get().getMap("Settings").getMap("SubData").getString("Name", null);
if (config.get().getMap("Settings").getMap("SubData").getRawString("Password", "").length() > 0) {
@ -178,7 +177,7 @@ public final class ExProxy extends BungeeCommon implements Listener {
reconnect = true;
Logger.get("SubData").info("");
Logger.get("SubData").info("Connecting to /" + config.get().getMap("Settings").getMap("SubData").getRawString("Address", "127.0.0.1:4391"));
connect(null);
connect(Logger.get("SubData"), null);
super.startListeners();
@ -199,11 +198,12 @@ public final class ExProxy extends BungeeCommon implements Listener {
}
}
private void connect(Pair<DisconnectReason, DataClient> disconnect) throws IOException {
private void connect(java.util.logging.Logger log, Pair<DisconnectReason, DataClient> disconnect) throws IOException {
int reconnect = config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 60);
if (disconnect == null || (this.reconnect && reconnect > 0 && disconnect.key() != DisconnectReason.PROTOCOL_MISMATCH && disconnect.key() != DisconnectReason.ENCRYPTION_MISMATCH)) {
long reset = resetDate;
Timer timer = new Timer("SubServers.Sync::SubData_Reconnect_Handler");
if (disconnect != null) log.info("Attempting reconnect in " + reconnect + " seconds");
timer.scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {

View File

@ -51,7 +51,7 @@ public class PacketLinkProxy implements InitialPacket, PacketObjectIn<Integer>,
if (data.getInt(0x0001) == 0) {
try {
if (data.contains(0x0000)) Util.reflect(SubAPI.class.getDeclaredField("name"), plugin.api, data.getRawString(0x0000));
setReady(client.getConnection(), true);
setReady(client.getConnection());
} catch (Throwable e) {
e.printStackTrace();
}

View File

@ -5,6 +5,7 @@ import net.ME1312.Galaxi.Library.Container.Pair;
import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.Galaxi.Library.Version.Version;
import net.ME1312.SubData.Client.Library.DataSize;
import net.ME1312.SubData.Client.SubDataClient;
import net.ME1312.SubData.Client.SubDataProtocol;
import net.ME1312.SubServers.Client.Common.Network.API.RemotePlayer;
@ -42,6 +43,7 @@ public class SubProtocol extends SubDataProtocol {
setName("SubServers 2");
addVersion(new Version("2.16a+"));
setBlockSize(DataSize.MB);
// 00-0F: Object Link Packets
@ -199,14 +201,17 @@ public class SubProtocol extends SubDataProtocol {
});
}));
subdata.on.ready(client -> plugin.getPluginManager().callEvent(new SubNetworkConnectEvent((SubDataClient) client)));
subdata.on.ready(client -> {
((SubDataClient) client).setBlockSize((int) DataSize.KBB);
plugin.getPluginManager().callEvent(new SubNetworkConnectEvent((SubDataClient) client));
});
subdata.on.closed(client -> {
SubNetworkDisconnectEvent event = new SubNetworkDisconnectEvent(client.value(), client.key());
plugin.getPluginManager().callEvent(event);
if (plugin.isRunning) {
net.ME1312.SubServers.Bungee.Library.Compatibility.Logger.get("SubData").info("Attempting reconnect in " + plugin.config.get().getMap("Settings").getMap("SubData").getInt("Reconnect", 60) + " seconds");
Util.isException(() -> Util.reflect(ExProxy.class.getDeclaredMethod("connect", Pair.class), plugin, client));
Logger log = net.ME1312.SubServers.Bungee.Library.Compatibility.Logger.get("SubData");
Util.isException(() -> Util.reflect(ExProxy.class.getDeclaredMethod("connect", Logger.class, Pair.class), plugin, log, client));
} else map.put(0, null);
});