mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-25 12:25:41 +01:00
Updated Via*
This commit is contained in:
parent
23a8ba45cd
commit
a86ec29c10
@ -68,7 +68,7 @@ dependencies {
|
||||
include "com.viaversion:viarewind-core:2.0.3-SNAPSHOT"
|
||||
include "net.raphimc:ViaLegacy:2.2.8"
|
||||
include "net.raphimc:ViaAprilFools:2.0.5"
|
||||
include("net.raphimc:ViaProtocolHack:2.1.6") {
|
||||
include("net.raphimc:ViaProtocolHack:2.1.9") {
|
||||
exclude group: "org.slf4j", module: "slf4j-api"
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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.injection.transformer;
|
||||
|
||||
import com.viaversion.viaversion.api.protocol.version.ProtocolVersion;
|
||||
import net.lenni0451.classtransform.annotations.CTransformer;
|
||||
import net.lenni0451.classtransform.annotations.injection.COverride;
|
||||
import net.raphimc.viaprotocolhack.util.VersionEnum;
|
||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
|
||||
|
||||
@CTransformer(VersionEnum.class)
|
||||
public abstract class VersionEnumTransformer {
|
||||
|
||||
@COverride
|
||||
private static ProtocolVersion getViaBedrockProtocol(final String name) {
|
||||
try {
|
||||
Class<?> clazz = null;
|
||||
for (ViaProxyPlugin plugin : PluginManager.getPlugins()) {
|
||||
try {
|
||||
clazz = Class.forName("net.raphimc.viabedrock.api.BedrockProtocolVersion", true, plugin.getClass().getClassLoader());
|
||||
break;
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
if (clazz != null) {
|
||||
return (ProtocolVersion) clazz.getField(name).get(null);
|
||||
}
|
||||
} catch (Throwable ignored) {
|
||||
}
|
||||
return ProtocolVersion.unknown;
|
||||
}
|
||||
|
||||
}
|
@ -27,6 +27,7 @@ import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.net.URLClassLoader;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@ -38,6 +39,10 @@ public class PluginManager {
|
||||
private static final File PLUGINS_DIR = new File("plugins");
|
||||
private static final List<ViaProxyPlugin> PLUGINS = new ArrayList<>();
|
||||
|
||||
public static List<ViaProxyPlugin> getPlugins() {
|
||||
return Collections.unmodifiableList(PLUGINS);
|
||||
}
|
||||
|
||||
public static void loadPlugins() {
|
||||
if (!PLUGINS_DIR.exists() || !PLUGINS_DIR.isDirectory()) {
|
||||
if (!PLUGINS_DIR.mkdirs()) {
|
||||
|
Loading…
Reference in New Issue
Block a user