mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-21 11:45:16 +01:00
Added new events
This commit is contained in:
parent
84e9c7441b
commit
1cb01789a9
@ -38,6 +38,8 @@ import net.raphimc.viaproxy.cli.options.Options;
|
||||
import net.raphimc.viaproxy.injection.Java17ToJava8;
|
||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||
import net.raphimc.viaproxy.plugins.events.Client2ProxyHandlerCreationEvent;
|
||||
import net.raphimc.viaproxy.plugins.events.ProxyStartEvent;
|
||||
import net.raphimc.viaproxy.plugins.events.ProxyStopEvent;
|
||||
import net.raphimc.viaproxy.proxy.EventListener;
|
||||
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer;
|
||||
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyHandler;
|
||||
@ -165,6 +167,9 @@ public class ViaProxy {
|
||||
throw new IllegalStateException("Proxy is already running");
|
||||
}
|
||||
try {
|
||||
Logger.LOGGER.info("Starting proxy server");
|
||||
PluginManager.EVENT_MANAGER.call(new ProxyStartEvent());
|
||||
|
||||
currentProxyServer = new NetServer(() -> PluginManager.EVENT_MANAGER.call(new Client2ProxyHandlerCreationEvent(new Client2ProxyHandler())).getHandler(), Client2ProxyChannelInitializer::new);
|
||||
Logger.LOGGER.info("Binding proxy server to " + Options.BIND_ADDRESS + ":" + Options.BIND_PORT);
|
||||
currentProxyServer.bind(Options.BIND_ADDRESS, Options.BIND_PORT, false);
|
||||
@ -177,6 +182,8 @@ public class ViaProxy {
|
||||
public static void stopProxy() {
|
||||
if (currentProxyServer != null) {
|
||||
Logger.LOGGER.info("Stopping proxy server");
|
||||
PluginManager.EVENT_MANAGER.call(new ProxyStopEvent());
|
||||
|
||||
currentProxyServer.getChannel().close();
|
||||
currentProxyServer = null;
|
||||
|
||||
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.raphimc.viaproxy.plugins.events;
|
||||
|
||||
public class ProxyStartEvent {
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* 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 <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package net.raphimc.viaproxy.plugins.events;
|
||||
|
||||
public class ProxyStopEvent {
|
||||
}
|
Loading…
Reference in New Issue
Block a user