Add a post-connect subdata event

This commit is contained in:
ME1312 2019-06-17 20:20:46 -04:00
parent 03ece299d3
commit 3af2087f19
No known key found for this signature in database
GPG Key ID: FEFFE2F698E88FA8
8 changed files with 70 additions and 23 deletions

View File

@ -0,0 +1,43 @@
package net.ME1312.SubServers.Bungee.Event;
import net.ME1312.Galaxi.Library.Util;
import net.ME1312.SubData.Server.DataClient;
import net.ME1312.SubData.Server.DataServer;
import net.ME1312.SubServers.Bungee.Library.SubEvent;
import net.md_5.bungee.api.plugin.Cancellable;
import net.md_5.bungee.api.plugin.Event;
/**
* SubData Network Login Event
*/
public class SubNetworkLoginEvent extends Event implements SubEvent {
private DataServer network;
private DataClient client;
/**
* SubData Network Login Event
*/
public SubNetworkLoginEvent(DataServer network, DataClient client) {
if (Util.isNull(network, client)) throw new NullPointerException();
this.network = network;
this.client = client;
}
/**
* Get the network the client is connected to
*
* @return SubData Network
*/
public DataServer getNetwork() {
return network;
}
/**
* Get the connecting client
*
* @return Client
*/
public DataClient getClient() {
return client;
}
}

View File

@ -1,6 +1,7 @@
package net.ME1312.SubServers.Bungee.Host; package net.ME1312.SubServers.Bungee.Host;
import net.ME1312.Galaxi.Library.Map.ObjectMap; import net.ME1312.Galaxi.Library.Map.ObjectMap;
import net.ME1312.SubServers.Bungee.Event.SubEditServerEvent;
import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException; import net.ME1312.SubServers.Bungee.Library.Exception.InvalidServerException;
import net.ME1312.Galaxi.Library.NamedContainer; import net.ME1312.Galaxi.Library.NamedContainer;
import net.ME1312.SubServers.Bungee.SubAPI; import net.ME1312.SubServers.Bungee.SubAPI;
@ -63,6 +64,7 @@ public abstract class SubServerContainer extends ServerContainer implements SubS
@Override @Override
public void setTemplate(SubCreator.ServerTemplate template) { public void setTemplate(SubCreator.ServerTemplate template) {
SubAPI.getInstance().getInternals().getPluginManager().callEvent(new SubEditServerEvent(null, this, new NamedContainer<String, Object>("template", (template != null)?template.getName():null), false));
this.template = (template != null)?template.getName():null; this.template = (template != null)?template.getName():null;
} }

View File

@ -6,6 +6,7 @@ import net.ME1312.SubData.Server.SubDataProtocol;
import net.ME1312.SubData.Server.SubDataServer; import net.ME1312.SubData.Server.SubDataServer;
import net.ME1312.SubServers.Bungee.Event.SubNetworkConnectEvent; import net.ME1312.SubServers.Bungee.Event.SubNetworkConnectEvent;
import net.ME1312.SubServers.Bungee.Event.SubNetworkDisconnectEvent; import net.ME1312.SubServers.Bungee.Event.SubNetworkDisconnectEvent;
import net.ME1312.SubServers.Bungee.Event.SubNetworkLoginEvent;
import net.ME1312.SubServers.Bungee.Network.Packet.*; import net.ME1312.SubServers.Bungee.Network.Packet.*;
import net.ME1312.SubServers.Bungee.SubAPI; import net.ME1312.SubServers.Bungee.SubAPI;
import net.ME1312.SubServers.Bungee.SubPlugin; import net.ME1312.SubServers.Bungee.SubPlugin;
@ -31,7 +32,7 @@ public class SubProtocol extends SubDataProtocol {
instance.setVersion(new Version("2.14a+")); instance.setVersion(new Version("2.14a+"));
// 00-09: Object Link Packets // 00-0F: Object Link Packets
instance.registerPacket(0x0000, PacketLinkProxy.class); instance.registerPacket(0x0000, PacketLinkProxy.class);
instance.registerPacket(0x0001, PacketLinkExHost.class); instance.registerPacket(0x0001, PacketLinkExHost.class);
instance.registerPacket(0x0002, PacketLinkServer.class); instance.registerPacket(0x0002, PacketLinkServer.class);
@ -41,7 +42,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0002, new PacketLinkServer(plugin)); instance.registerPacket(0x0002, new PacketLinkServer(plugin));
// 10-29: Download Packets // 10-2F: Download Packets
instance.registerPacket(0x0010, PacketDownloadLang.class); instance.registerPacket(0x0010, PacketDownloadLang.class);
instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class); instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class);
instance.registerPacket(0x0012, PacketDownloadProxyInfo.class); instance.registerPacket(0x0012, PacketDownloadProxyInfo.class);
@ -61,7 +62,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0017, new PacketCheckPermission()); instance.registerPacket(0x0017, new PacketCheckPermission());
// 30-49: Control Packets // 30-4F: Control Packets
instance.registerPacket(0x0030, PacketCreateServer.class); instance.registerPacket(0x0030, PacketCreateServer.class);
instance.registerPacket(0x0031, PacketAddServer.class); instance.registerPacket(0x0031, PacketAddServer.class);
instance.registerPacket(0x0032, PacketStartServer.class); instance.registerPacket(0x0032, PacketStartServer.class);
@ -85,7 +86,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0039, new PacketDeleteServer(plugin)); instance.registerPacket(0x0039, new PacketDeleteServer(plugin));
// 50-69: External Host Packets // 50-6F: External Host Packets
instance.registerPacket(0x0050, PacketExConfigureHost.class); instance.registerPacket(0x0050, PacketExConfigureHost.class);
instance.registerPacket(0x0051, PacketExDownloadTemplates.class); instance.registerPacket(0x0051, PacketExDownloadTemplates.class);
//instance.registerPacket(0x0052, PacketInExRequestQueue.class); //instance.registerPacket(0x0052, PacketInExRequestQueue.class);
@ -107,7 +108,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0058, new PacketExRemoveServer()); instance.registerPacket(0x0058, new PacketExRemoveServer());
// 70-79: External Misc Packets // 70-7F: External Misc Packets
instance.registerPacket(0x0070, PacketOutExRunEvent.class); instance.registerPacket(0x0070, PacketOutExRunEvent.class);
instance.registerPacket(0x0071, PacketOutExReset.class); instance.registerPacket(0x0071, PacketOutExReset.class);
instance.registerPacket(0x0072, PacketOutExReload.class); instance.registerPacket(0x0072, PacketOutExReload.class);
@ -133,6 +134,7 @@ public class SubProtocol extends SubDataProtocol {
subdata.on.closed(server -> plugin.subdata = null); subdata.on.closed(server -> plugin.subdata = null);
subdata.on.connect(client -> { subdata.on.connect(client -> {
if (!plugin.getPluginManager().callEvent(new SubNetworkConnectEvent(client.getServer(), client)).isCancelled()) { if (!plugin.getPluginManager().callEvent(new SubNetworkConnectEvent(client.getServer(), client)).isCancelled()) {
client.on.ready(c -> plugin.getPluginManager().callEvent(new SubNetworkLoginEvent(c.getServer(), c)));
client.on.closed(c -> plugin.getPluginManager().callEvent(new SubNetworkDisconnectEvent(c.get().getServer(), c.get(), c.name()))); client.on.closed(c -> plugin.getPluginManager().callEvent(new SubNetworkDisconnectEvent(c.get().getServer(), c.get(), c.name())));
return true; return true;
} else return false; } else return false;

View File

@ -504,7 +504,7 @@ public final class SubPlugin extends BungeeCord implements Listener {
if (edits.getKeys().size() > 0) { if (edits.getKeys().size() > 0) {
server.permaEdit(edits); server.edit(edits);
server = api.getSubServer(name); server = api.getSubServer(name);
} }
} else { // Server cannot edit() } else { // Server cannot edit()

View File

@ -35,12 +35,12 @@ public class SubProtocol extends SubDataProtocol {
instance.addVersion(new Version("2.14a+")); instance.addVersion(new Version("2.14a+"));
// 00-09: Object Link Packets // 00-0F: Object Link Packets
instance.registerPacket(0x0002, PacketLinkServer.class); instance.registerPacket(0x0002, PacketLinkServer.class);
instance.registerPacket(0x0002, new PacketLinkServer(plugin)); instance.registerPacket(0x0002, new PacketLinkServer(plugin));
// 10-29: Download Packets // 10-2F: Download Packets
instance.registerPacket(0x0010, PacketDownloadLang.class); instance.registerPacket(0x0010, PacketDownloadLang.class);
instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class); instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class);
instance.registerPacket(0x0012, PacketDownloadProxyInfo.class); instance.registerPacket(0x0012, PacketDownloadProxyInfo.class);
@ -60,7 +60,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0017, new PacketCheckPermission()); instance.registerPacket(0x0017, new PacketCheckPermission());
// 30-49: Control Packets // 30-4F: Control Packets
instance.registerPacket(0x0030, PacketCreateServer.class); instance.registerPacket(0x0030, PacketCreateServer.class);
instance.registerPacket(0x0031, PacketAddServer.class); instance.registerPacket(0x0031, PacketAddServer.class);
instance.registerPacket(0x0032, PacketStartServer.class); instance.registerPacket(0x0032, PacketStartServer.class);
@ -84,7 +84,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0039, new PacketDeleteServer()); instance.registerPacket(0x0039, new PacketDeleteServer());
// 70-79: External Misc Packets // 70-7F: External Misc Packets
//instance.registerPacket(0x0070, PacketInExRunEvent.class); //instance.registerPacket(0x0070, PacketInExRunEvent.class);
//instance.registerPacket(0x0071, PacketInExReset.class); //instance.registerPacket(0x0071, PacketInExReset.class);
//instance.registerPacket(0x0072, PacketInExReload.class); //instance.registerPacket(0x0072, PacketInExReload.class);

View File

@ -42,12 +42,12 @@ public class SubProtocol extends SubDataProtocol {
instance.addVersion(new Version("2.14a+")); instance.addVersion(new Version("2.14a+"));
// 00-09: Object Link Packets // 00-0F: Object Link Packets
instance.registerPacket(0x0002, PacketLinkServer.class); instance.registerPacket(0x0002, PacketLinkServer.class);
instance.registerPacket(0x0002, new PacketLinkServer(plugin)); instance.registerPacket(0x0002, new PacketLinkServer(plugin));
// 10-29: Download Packets // 10-2F: Download Packets
instance.registerPacket(0x0010, PacketDownloadLang.class); instance.registerPacket(0x0010, PacketDownloadLang.class);
instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class); instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class);
instance.registerPacket(0x0012, PacketDownloadProxyInfo.class); instance.registerPacket(0x0012, PacketDownloadProxyInfo.class);
@ -67,7 +67,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0017, new PacketCheckPermission()); instance.registerPacket(0x0017, new PacketCheckPermission());
// 30-49: Control Packets // 30-4F: Control Packets
instance.registerPacket(0x0030, PacketCreateServer.class); instance.registerPacket(0x0030, PacketCreateServer.class);
instance.registerPacket(0x0031, PacketAddServer.class); instance.registerPacket(0x0031, PacketAddServer.class);
instance.registerPacket(0x0032, PacketStartServer.class); instance.registerPacket(0x0032, PacketStartServer.class);
@ -91,7 +91,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0039, new PacketDeleteServer()); instance.registerPacket(0x0039, new PacketDeleteServer());
// 70-79: External Misc Packets // 70-7F: External Misc Packets
//instance.registerPacket(0x0070, PacketInExRunEvent.class); //instance.registerPacket(0x0070, PacketInExRunEvent.class);
//instance.registerPacket(0x0071, PacketInExReset.class); //instance.registerPacket(0x0071, PacketInExReset.class);
//instance.registerPacket(0x0072, PacketInExReload.class); //instance.registerPacket(0x0072, PacketInExReload.class);

View File

@ -37,13 +37,13 @@ public class SubProtocol extends SubDataProtocol {
instance.addVersion(new Version("2.14a+")); instance.addVersion(new Version("2.14a+"));
// 00-09: Object Link Packets // 00-0F: Object Link Packets
instance.registerPacket(0x0001, PacketLinkExHost.class); instance.registerPacket(0x0001, PacketLinkExHost.class);
instance.registerPacket(0x0001, new PacketLinkExHost(host)); instance.registerPacket(0x0001, new PacketLinkExHost(host));
// 10-29: Download Packets // 10-2F: Download Packets
instance.registerPacket(0x0010, PacketDownloadLang.class); instance.registerPacket(0x0010, PacketDownloadLang.class);
instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class); instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class);
instance.registerPacket(0x0012, PacketDownloadProxyInfo.class); instance.registerPacket(0x0012, PacketDownloadProxyInfo.class);
@ -63,7 +63,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0017, new PacketCheckPermission()); instance.registerPacket(0x0017, new PacketCheckPermission());
// 30-49: Control Packets // 30-4F: Control Packets
instance.registerPacket(0x0030, PacketCreateServer.class); instance.registerPacket(0x0030, PacketCreateServer.class);
instance.registerPacket(0x0031, PacketAddServer.class); instance.registerPacket(0x0031, PacketAddServer.class);
instance.registerPacket(0x0032, PacketStartServer.class); instance.registerPacket(0x0032, PacketStartServer.class);
@ -87,7 +87,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0039, new PacketDeleteServer()); instance.registerPacket(0x0039, new PacketDeleteServer());
// 50-69: External Host Packets // 50-6F: External Host Packets
instance.registerPacket(0x0050, PacketExConfigureHost.class); instance.registerPacket(0x0050, PacketExConfigureHost.class);
instance.registerPacket(0x0051, PacketExDownloadTemplates.class); instance.registerPacket(0x0051, PacketExDownloadTemplates.class);
instance.registerPacket(0x0052, PacketOutExRequestQueue.class); instance.registerPacket(0x0052, PacketOutExRequestQueue.class);
@ -109,7 +109,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0058, new PacketExRemoveServer(host)); instance.registerPacket(0x0058, new PacketExRemoveServer(host));
// 70-79: External Misc Packets // 70-7F: External Misc Packets
//instance.registerPacket(0x0070, PacketInExRunEvent.class); //instance.registerPacket(0x0070, PacketInExRunEvent.class);
//instance.registerPacket(0x0071, PacketInExReset.class); //instance.registerPacket(0x0071, PacketInExReset.class);
//instance.registerPacket(0x0072, PacketInExReload.class); //instance.registerPacket(0x0072, PacketInExReload.class);

View File

@ -43,12 +43,12 @@ public class SubProtocol extends SubDataProtocol {
instance.addVersion(new Version("2.14a+")); instance.addVersion(new Version("2.14a+"));
// 00-09: Object Link Packets // 00-0F: Object Link Packets
instance.registerPacket(0x0000, PacketLinkProxy.class); instance.registerPacket(0x0000, PacketLinkProxy.class);
instance.registerPacket(0x0000, new PacketLinkProxy(plugin)); instance.registerPacket(0x0000, new PacketLinkProxy(plugin));
// 10-29: Download Packets // 10-2F: Download Packets
instance.registerPacket(0x0010, PacketDownloadLang.class); instance.registerPacket(0x0010, PacketDownloadLang.class);
instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class); instance.registerPacket(0x0011, PacketDownloadPlatformInfo.class);
instance.registerPacket(0x0012, PacketDownloadProxyInfo.class); instance.registerPacket(0x0012, PacketDownloadProxyInfo.class);
@ -68,7 +68,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0017, new PacketCheckPermission()); instance.registerPacket(0x0017, new PacketCheckPermission());
// 30-49: Control Packets // 30-4F: Control Packets
instance.registerPacket(0x0030, PacketCreateServer.class); instance.registerPacket(0x0030, PacketCreateServer.class);
instance.registerPacket(0x0031, PacketAddServer.class); instance.registerPacket(0x0031, PacketAddServer.class);
instance.registerPacket(0x0032, PacketStartServer.class); instance.registerPacket(0x0032, PacketStartServer.class);
@ -92,7 +92,7 @@ public class SubProtocol extends SubDataProtocol {
instance.registerPacket(0x0039, new PacketDeleteServer()); instance.registerPacket(0x0039, new PacketDeleteServer());
// 70-79: External Misc Packets // 70-7F: External Misc Packets
//instance.registerPacket(0x0070, PacketInExRunEvent.class); //instance.registerPacket(0x0070, PacketInExRunEvent.class);
//instance.registerPacket(0x0071, PacketInExReset.class); //instance.registerPacket(0x0071, PacketInExReset.class);
//instance.registerPacket(0x0073, PacketInExReload.class); //instance.registerPacket(0x0073, PacketInExReload.class);