mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-25 12:25:41 +01:00
Added new events
This commit is contained in:
parent
3160959eb5
commit
f19bbaca3c
@ -86,7 +86,7 @@ dependencies {
|
|||||||
include "net.lenni0451.classtransform:additionalclassprovider:1.8.3"
|
include "net.lenni0451.classtransform:additionalclassprovider:1.8.3"
|
||||||
include "net.lenni0451:Reflect:1.0.2"
|
include "net.lenni0451:Reflect:1.0.2"
|
||||||
include "net.lenni0451:LambdaEvents:2.0.3"
|
include "net.lenni0451:LambdaEvents:2.0.3"
|
||||||
include "net.raphimc.netminecraft:all:2.3.0"
|
include "net.raphimc.netminecraft:all:2.3.1"
|
||||||
include("net.raphimc:MinecraftAuth:2.0.1") {
|
include("net.raphimc:MinecraftAuth:2.0.1") {
|
||||||
exclude group: "com.google.code.gson", module: "gson"
|
exclude group: "com.google.code.gson", module: "gson"
|
||||||
exclude group: "org.slf4j", module: "slf4j-api"
|
exclude group: "org.slf4j", module: "slf4j-api"
|
||||||
|
@ -36,6 +36,8 @@ import net.raphimc.netminecraft.netty.connection.NetServer;
|
|||||||
import net.raphimc.viaproxy.cli.ConsoleHandler;
|
import net.raphimc.viaproxy.cli.ConsoleHandler;
|
||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.injection.Java17ToJava8;
|
import net.raphimc.viaproxy.injection.Java17ToJava8;
|
||||||
|
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||||
|
import net.raphimc.viaproxy.plugins.events.Client2ProxyHandlerCreationEvent;
|
||||||
import net.raphimc.viaproxy.proxy.ProxyConnection;
|
import net.raphimc.viaproxy.proxy.ProxyConnection;
|
||||||
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer;
|
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyChannelInitializer;
|
||||||
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyHandler;
|
import net.raphimc.viaproxy.proxy.client2proxy.Client2ProxyHandler;
|
||||||
@ -96,6 +98,8 @@ public class ViaProxy {
|
|||||||
setNettyParameters();
|
setNettyParameters();
|
||||||
MCPipeline.useOptimizedPipeline();
|
MCPipeline.useOptimizedPipeline();
|
||||||
c2pChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
|
c2pChannels = new DefaultChannelGroup(GlobalEventExecutor.INSTANCE);
|
||||||
|
PluginManager.loadPlugins();
|
||||||
|
|
||||||
Thread loaderThread = new Thread(new LoaderTask(), "ViaProtocolHack-Loader");
|
Thread loaderThread = new Thread(new LoaderTask(), "ViaProtocolHack-Loader");
|
||||||
Thread accountRefreshThread = new Thread(new AccountRefreshTask(saveManager), "AccountRefresh");
|
Thread accountRefreshThread = new Thread(new AccountRefreshTask(saveManager), "AccountRefresh");
|
||||||
Thread updateCheckThread = new Thread(new UpdatedCheckTask(hasUI), "UpdateCheck");
|
Thread updateCheckThread = new Thread(new UpdatedCheckTask(hasUI), "UpdateCheck");
|
||||||
@ -135,7 +139,7 @@ public class ViaProxy {
|
|||||||
throw new IllegalStateException("Proxy is already running");
|
throw new IllegalStateException("Proxy is already running");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
currentProxyServer = new NetServer(Client2ProxyHandler::new, Client2ProxyChannelInitializer::new);
|
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);
|
Logger.LOGGER.info("Binding proxy server to " + Options.BIND_ADDRESS + ":" + Options.BIND_PORT);
|
||||||
currentProxyServer.bind(Options.BIND_ADDRESS, Options.BIND_PORT, false);
|
currentProxyServer.bind(Options.BIND_ADDRESS, Options.BIND_PORT, false);
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
@ -18,16 +18,14 @@
|
|||||||
package net.raphimc.viaproxy.plugins.events;
|
package net.raphimc.viaproxy.plugins.events;
|
||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ICancellable;
|
import net.raphimc.viaproxy.plugins.events.types.EventCancellable;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
||||||
|
|
||||||
public class Client2ProxyChannelInitializeEvent implements ICancellable, ITyped {
|
public class Client2ProxyChannelInitializeEvent extends EventCancellable implements ITyped {
|
||||||
|
|
||||||
private final Type type;
|
private final Type type;
|
||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
|
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
public Client2ProxyChannelInitializeEvent(final Type type, final Channel channel) {
|
public Client2ProxyChannelInitializeEvent(final Type type, final Channel channel) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
@ -38,16 +36,6 @@ public class Client2ProxyChannelInitializeEvent implements ICancellable, ITyped
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
|
|
||||||
|
public class Client2ProxyHandlerCreationEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The handler which will be used to handle Client<->Proxy packets
|
||||||
|
*/
|
||||||
|
private ChannelHandler handler;
|
||||||
|
|
||||||
|
public Client2ProxyHandlerCreationEvent(final ChannelHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHandler(final ChannelHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelHandler getHandler() {
|
||||||
|
return this.handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -17,13 +17,12 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.viaproxy.plugins.events;
|
package net.raphimc.viaproxy.plugins.events;
|
||||||
|
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ICancellable;
|
import net.raphimc.viaproxy.plugins.events.types.EventCancellable;
|
||||||
|
|
||||||
public class ConsoleCommandEvent implements ICancellable {
|
public class ConsoleCommandEvent extends EventCancellable {
|
||||||
|
|
||||||
private final String command;
|
private final String command;
|
||||||
private final String[] args;
|
private final String[] args;
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
public ConsoleCommandEvent(final String command, final String[] args) {
|
public ConsoleCommandEvent(final String command, final String[] args) {
|
||||||
this.command = command;
|
this.command = command;
|
||||||
@ -38,14 +37,4 @@ public class ConsoleCommandEvent implements ICancellable {
|
|||||||
return this.args;
|
return this.args;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,16 +20,15 @@ package net.raphimc.viaproxy.plugins.events;
|
|||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.raphimc.netminecraft.util.ServerAddress;
|
import net.raphimc.netminecraft.util.ServerAddress;
|
||||||
import net.raphimc.viaprotocolhack.util.VersionEnum;
|
import net.raphimc.viaprotocolhack.util.VersionEnum;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ICancellable;
|
import net.raphimc.viaproxy.plugins.events.types.EventCancellable;
|
||||||
|
|
||||||
public class PreConnectEvent implements ICancellable {
|
public class PreConnectEvent extends EventCancellable {
|
||||||
|
|
||||||
private final ServerAddress serverAddress;
|
private final ServerAddress serverAddress;
|
||||||
private final VersionEnum serverVersion;
|
private final VersionEnum serverVersion;
|
||||||
private final VersionEnum clientVersion;
|
private final VersionEnum clientVersion;
|
||||||
private final Channel clientChannel;
|
private final Channel clientChannel;
|
||||||
|
|
||||||
private boolean cancelled;
|
|
||||||
private String cancelMessage = "§cCould not connect to the backend server! (Server is blacklisted)";
|
private String cancelMessage = "§cCould not connect to the backend server! (Server is blacklisted)";
|
||||||
|
|
||||||
public PreConnectEvent(final ServerAddress serverAddress, final VersionEnum serverVersion, final VersionEnum clientVersion, final Channel clientChannel) {
|
public PreConnectEvent(final ServerAddress serverAddress, final VersionEnum serverVersion, final VersionEnum clientVersion, final Channel clientChannel) {
|
||||||
@ -55,21 +54,12 @@ public class PreConnectEvent implements ICancellable {
|
|||||||
return this.clientChannel;
|
return this.clientChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getCancelMessage() {
|
public String getCancelMessage() {
|
||||||
return this.cancelMessage;
|
return this.cancelMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCancelMessage(final String cancelMessage) {
|
public void setCancelMessage(final String cancelMessage) {
|
||||||
|
this.setCancelled(true);
|
||||||
this.cancelMessage = cancelMessage;
|
this.cancelMessage = cancelMessage;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
|
public class ProtocolHackInitEvent {
|
||||||
|
|
||||||
|
private final List<Supplier<?>> additionalPlatformSuppliers = new ArrayList<>();
|
||||||
|
|
||||||
|
public ProtocolHackInitEvent(final Supplier<?>... additionalPlatformSuppliers) {
|
||||||
|
for (final Supplier<?> platformSupplier : additionalPlatformSuppliers) {
|
||||||
|
this.registerPlatform(platformSupplier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void registerPlatform(final Supplier<?> platformSupplier) {
|
||||||
|
this.additionalPlatformSuppliers.add(platformSupplier);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Supplier<?>> getPlatformSuppliers() {
|
||||||
|
return this.additionalPlatformSuppliers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -18,16 +18,14 @@
|
|||||||
package net.raphimc.viaproxy.plugins.events;
|
package net.raphimc.viaproxy.plugins.events;
|
||||||
|
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ICancellable;
|
import net.raphimc.viaproxy.plugins.events.types.EventCancellable;
|
||||||
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
import net.raphimc.viaproxy.plugins.events.types.ITyped;
|
||||||
|
|
||||||
public class Proxy2ServerChannelInitializeEvent implements ICancellable, ITyped {
|
public class Proxy2ServerChannelInitializeEvent extends EventCancellable implements ITyped {
|
||||||
|
|
||||||
private final Type type;
|
private final Type type;
|
||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
|
|
||||||
private boolean cancelled;
|
|
||||||
|
|
||||||
public Proxy2ServerChannelInitializeEvent(final Type type, final Channel channel) {
|
public Proxy2ServerChannelInitializeEvent(final Type type, final Channel channel) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.channel = channel;
|
this.channel = channel;
|
||||||
@ -38,16 +36,6 @@ public class Proxy2ServerChannelInitializeEvent implements ICancellable, ITyped
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isCancelled() {
|
|
||||||
return this.cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setCancelled(boolean cancelled) {
|
|
||||||
this.cancelled = cancelled;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return this.type;
|
return this.type;
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
import io.netty.channel.ChannelHandler;
|
||||||
|
|
||||||
|
public class Proxy2ServerHandlerCreationEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The handler which will be used to handle Proxy<->Server packets
|
||||||
|
*/
|
||||||
|
private ChannelHandler handler;
|
||||||
|
|
||||||
|
public Proxy2ServerHandlerCreationEvent(final ChannelHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHandler(final ChannelHandler handler) {
|
||||||
|
this.handler = handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChannelHandler getHandler() {
|
||||||
|
return this.handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* 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 ViaLoadingEvent {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* 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.types;
|
||||||
|
|
||||||
|
public abstract class EventCancellable {
|
||||||
|
|
||||||
|
private boolean cancelled = false;
|
||||||
|
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return this.cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCancelled(final boolean cancelled) {
|
||||||
|
this.cancelled = cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -19,12 +19,17 @@ package net.raphimc.viaproxy.protocolhack;
|
|||||||
|
|
||||||
import net.raphimc.viaprotocolhack.ViaProtocolHack;
|
import net.raphimc.viaprotocolhack.ViaProtocolHack;
|
||||||
import net.raphimc.viaprotocolhack.impl.platform.ViaLegacyPlatformImpl;
|
import net.raphimc.viaprotocolhack.impl.platform.ViaLegacyPlatformImpl;
|
||||||
|
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||||
|
import net.raphimc.viaproxy.plugins.events.ProtocolHackInitEvent;
|
||||||
import net.raphimc.viaproxy.protocolhack.impl.*;
|
import net.raphimc.viaproxy.protocolhack.impl.*;
|
||||||
|
|
||||||
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
public class ProtocolHack {
|
public class ProtocolHack {
|
||||||
|
|
||||||
public static void init() {
|
public static void init() {
|
||||||
ViaProtocolHack.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVPLoader(), null, null, ViaProxyViaBackwardsPlatformImpl::new, ViaProxyViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new);
|
final Supplier<?>[] additionalPlatformSuppliers = PluginManager.EVENT_MANAGER.call(new ProtocolHackInitEvent(ViaAprilFoolsPlatformImpl::new)).getPlatformSuppliers().toArray(new Supplier[0]);
|
||||||
|
ViaProtocolHack.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVPLoader(), null, null, ViaProxyViaBackwardsPlatformImpl::new, ViaProxyViaRewindPlatformImpl::new, ViaLegacyPlatformImpl::new, additionalPlatformSuppliers);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,6 +28,8 @@ import net.raphimc.vialegacy.protocols.release.protocol1_3_1_2to1_2_4_5.provider
|
|||||||
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider;
|
import net.raphimc.vialegacy.protocols.release.protocol1_7_2_5to1_6_4.providers.EncryptionProvider;
|
||||||
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
import net.raphimc.vialegacy.protocols.release.protocol1_8to1_7_6_10.providers.GameProfileFetcher;
|
||||||
import net.raphimc.viaprotocolhack.impl.viaversion.VPLoader;
|
import net.raphimc.viaprotocolhack.impl.viaversion.VPLoader;
|
||||||
|
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||||
|
import net.raphimc.viaproxy.plugins.events.ViaLoadingEvent;
|
||||||
import net.raphimc.viaproxy.protocolhack.providers.*;
|
import net.raphimc.viaproxy.protocolhack.providers.*;
|
||||||
|
|
||||||
public class ViaProxyVPLoader extends VPLoader {
|
public class ViaProxyVPLoader extends VPLoader {
|
||||||
@ -46,6 +48,8 @@ public class ViaProxyVPLoader extends VPLoader {
|
|||||||
Via.getManager().getProviders().use(ClassicWorldHeightProvider.class, new ViaProxyClassicWorldHeightProvider());
|
Via.getManager().getProviders().use(ClassicWorldHeightProvider.class, new ViaProxyClassicWorldHeightProvider());
|
||||||
Via.getManager().getProviders().use(ClassicCustomCommandProvider.class, new ViaProxyClassicCustomCommandProvider());
|
Via.getManager().getProviders().use(ClassicCustomCommandProvider.class, new ViaProxyClassicCustomCommandProvider());
|
||||||
Via.getManager().getProviders().use(ClassicMPPassProvider.class, new ViaProxyClassicMPPassProvider());
|
Via.getManager().getProviders().use(ClassicMPPassProvider.class, new ViaProxyClassicMPPassProvider());
|
||||||
|
|
||||||
|
PluginManager.EVENT_MANAGER.call(new ViaLoadingEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,7 +25,6 @@ import io.netty.buffer.Unpooled;
|
|||||||
import io.netty.channel.ChannelFutureListener;
|
import io.netty.channel.ChannelFutureListener;
|
||||||
import io.netty.channel.ChannelHandlerContext;
|
import io.netty.channel.ChannelHandlerContext;
|
||||||
import io.netty.channel.SimpleChannelInboundHandler;
|
import io.netty.channel.SimpleChannelInboundHandler;
|
||||||
import io.netty.channel.socket.SocketChannel;
|
|
||||||
import net.raphimc.netminecraft.constants.ConnectionState;
|
import net.raphimc.netminecraft.constants.ConnectionState;
|
||||||
import net.raphimc.netminecraft.constants.MCPackets;
|
import net.raphimc.netminecraft.constants.MCPackets;
|
||||||
import net.raphimc.netminecraft.constants.MCPipeline;
|
import net.raphimc.netminecraft.constants.MCPipeline;
|
||||||
@ -42,6 +41,7 @@ import net.raphimc.viaproxy.ViaProxy;
|
|||||||
import net.raphimc.viaproxy.cli.options.Options;
|
import net.raphimc.viaproxy.cli.options.Options;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||||
import net.raphimc.viaproxy.plugins.events.PreConnectEvent;
|
import net.raphimc.viaproxy.plugins.events.PreConnectEvent;
|
||||||
|
import net.raphimc.viaproxy.plugins.events.Proxy2ServerHandlerCreationEvent;
|
||||||
import net.raphimc.viaproxy.proxy.LoginState;
|
import net.raphimc.viaproxy.proxy.LoginState;
|
||||||
import net.raphimc.viaproxy.proxy.ProxyConnection;
|
import net.raphimc.viaproxy.proxy.ProxyConnection;
|
||||||
import net.raphimc.viaproxy.proxy.external_interface.AuthLibServices;
|
import net.raphimc.viaproxy.proxy.external_interface.AuthLibServices;
|
||||||
@ -87,7 +87,7 @@ public class Client2ProxyHandler extends SimpleChannelInboundHandler<IPacket> {
|
|||||||
super.channelActive(ctx);
|
super.channelActive(ctx);
|
||||||
|
|
||||||
RANDOM.nextBytes(this.verifyToken);
|
RANDOM.nextBytes(this.verifyToken);
|
||||||
this.proxyConnection = new ProxyConnection(Proxy2ServerHandler::new, Proxy2ServerChannelInitializer::new, (SocketChannel) ctx.channel());
|
this.proxyConnection = new ProxyConnection(() -> PluginManager.EVENT_MANAGER.call(new Proxy2ServerHandlerCreationEvent(new Proxy2ServerHandler())).getHandler(), Proxy2ServerChannelInitializer::new, ctx.channel());
|
||||||
ctx.channel().attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);
|
ctx.channel().attr(ProxyConnection.PROXY_CONNECTION_ATTRIBUTE_KEY).set(this.proxyConnection);
|
||||||
|
|
||||||
ViaProxy.c2pChannels.add(ctx.channel());
|
ViaProxy.c2pChannels.add(ctx.channel());
|
||||||
|
@ -17,7 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package net.raphimc.viaproxy.tasks;
|
package net.raphimc.viaproxy.tasks;
|
||||||
|
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
|
||||||
import net.raphimc.viaproxy.protocolhack.ProtocolHack;
|
import net.raphimc.viaproxy.protocolhack.ProtocolHack;
|
||||||
|
|
||||||
public class LoaderTask implements Runnable {
|
public class LoaderTask implements Runnable {
|
||||||
@ -25,7 +24,6 @@ public class LoaderTask implements Runnable {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
ProtocolHack.init();
|
ProtocolHack.init();
|
||||||
PluginManager.loadPlugins();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user