diff --git a/src/main/java/net/raphimc/viaproxy/plugins/events/ClientLoggedInEvent.java b/src/main/java/net/raphimc/viaproxy/plugins/events/ClientLoggedInEvent.java new file mode 100644 index 0000000..990a590 --- /dev/null +++ b/src/main/java/net/raphimc/viaproxy/plugins/events/ClientLoggedInEvent.java @@ -0,0 +1,34 @@ +/* + * This file is part of ViaProxy - https://github.com/RaphiMC/ViaProxy + * Copyright (C) 2023 RK_01/RaphiMC and contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package net.raphimc.viaproxy.plugins.events; + +import net.raphimc.viaproxy.proxy.session.ProxyConnection; + +public class ClientLoggedInEvent { + + private final ProxyConnection proxyConnection; + + public ClientLoggedInEvent(final ProxyConnection proxyConnection) { + this.proxyConnection = proxyConnection; + } + + public ProxyConnection getProxyConnection() { + return this.proxyConnection; + } + +} diff --git a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java index 638fa73..46ed81d 100644 --- a/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java +++ b/src/main/java/net/raphimc/viaproxy/proxy/packethandler/LoginPacketHandler.java @@ -30,6 +30,8 @@ import net.raphimc.netminecraft.packet.impl.login.*; import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.storage.ProtocolMetadataStorage; import net.raphimc.vialoader.util.VersionEnum; import net.raphimc.viaproxy.cli.options.Options; +import net.raphimc.viaproxy.plugins.PluginManager; +import net.raphimc.viaproxy.plugins.events.ClientLoggedInEvent; import net.raphimc.viaproxy.proxy.LoginState; import net.raphimc.viaproxy.proxy.external_interface.AuthLibServices; import net.raphimc.viaproxy.proxy.external_interface.ExternalInterface; @@ -91,6 +93,7 @@ public class LoginPacketHandler extends PacketHandler { if (Options.ONLINE_MODE) { this.proxyConnection.getC2P().writeAndFlush(new S2CLoginKeyPacket1_8("", KEY_PAIR.getPublic().getEncoded(), this.verifyToken)).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } else { + PluginManager.EVENT_MANAGER.call(new ClientLoggedInEvent(proxyConnection)); ExternalInterface.fillPlayerData(this.proxyConnection); this.proxyConnection.getChannel().writeAndFlush(this.proxyConnection.getLoginHelloPacket()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE); } @@ -133,6 +136,7 @@ public class LoginPacketHandler extends PacketHandler { throw new RuntimeException("Failed to make session request for user '" + userName + "'!", e); } + PluginManager.EVENT_MANAGER.call(new ClientLoggedInEvent(proxyConnection)); ExternalInterface.fillPlayerData(this.proxyConnection); this.proxyConnection.getChannel().writeAndFlush(this.proxyConnection.getLoginHelloPacket()).addListener(ChannelFutureListener.FIRE_EXCEPTION_ON_FAILURE);