mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-14 19:15:08 -05:00
Fixed compile error better
This commit is contained in:
parent
a1e14e5610
commit
277a845bc8
3 changed files with 5 additions and 62 deletions
|
@ -9,7 +9,7 @@ buildscript {
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath "net.raphimc.javadowngrader:gradle-plugin:1.0.0"
|
classpath "net.raphimc.javadowngrader:gradle-plugin:1.0.1-SNAPSHOT"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,9 +105,9 @@ dependencies {
|
||||||
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"
|
||||||
}
|
}
|
||||||
include("net.raphimc.javadowngrader:impl-classtransform:1.0.0") {
|
include("net.raphimc.javadowngrader:impl-classtransform:1.0.1-SNAPSHOT") {
|
||||||
exclude group: "org.ow2.asm", module: "asm-commons"
|
exclude group: "org.ow2.asm", module: "asm-commons"
|
||||||
exclude group: "net.lenni0451.classtransform", module: "core"
|
exclude group: "net.lenni0451.classtransform", module: "additionalclassprovider"
|
||||||
}
|
}
|
||||||
include("org.cloudburstmc.netty:netty-transport-raknet:1.0.0.CR1-SNAPSHOT") {
|
include("org.cloudburstmc.netty:netty-transport-raknet:1.0.0.CR1-SNAPSHOT") {
|
||||||
exclude group: "io.netty", module: "netty-common"
|
exclude group: "io.netty", module: "netty-common"
|
||||||
|
|
|
@ -20,6 +20,7 @@ package net.raphimc.viaproxy.plugins;
|
||||||
import com.vdurmont.semver4j.Semver;
|
import com.vdurmont.semver4j.Semver;
|
||||||
import net.lenni0451.classtransform.TransformerManager;
|
import net.lenni0451.classtransform.TransformerManager;
|
||||||
import net.lenni0451.classtransform.additionalclassprovider.GuavaClassPathProvider;
|
import net.lenni0451.classtransform.additionalclassprovider.GuavaClassPathProvider;
|
||||||
|
import net.lenni0451.classtransform.additionalclassprovider.LazyFileClassProvider;
|
||||||
import net.lenni0451.classtransform.utils.loader.InjectionClassLoader;
|
import net.lenni0451.classtransform.utils.loader.InjectionClassLoader;
|
||||||
import net.lenni0451.classtransform.utils.tree.IClassProvider;
|
import net.lenni0451.classtransform.utils.tree.IClassProvider;
|
||||||
import net.lenni0451.lambdaevents.LambdaManager;
|
import net.lenni0451.lambdaevents.LambdaManager;
|
||||||
|
@ -27,7 +28,6 @@ import net.lenni0451.lambdaevents.generator.LambdaMetaFactoryGenerator;
|
||||||
import net.lenni0451.reflect.stream.RStream;
|
import net.lenni0451.reflect.stream.RStream;
|
||||||
import net.raphimc.javadowngrader.impl.classtransform.JavaDowngraderTransformer;
|
import net.raphimc.javadowngrader.impl.classtransform.JavaDowngraderTransformer;
|
||||||
import net.raphimc.viaproxy.ViaProxy;
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
import net.raphimc.viaproxy.util.URLClassProvider;
|
|
||||||
import net.raphimc.viaproxy.util.logging.Logger;
|
import net.raphimc.viaproxy.util.logging.Logger;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ public class PluginManager {
|
||||||
|
|
||||||
private static void loadAndScanJar(final File file) throws Throwable {
|
private static void loadAndScanJar(final File file) throws Throwable {
|
||||||
final URL url = file.toURI().toURL();
|
final URL url = file.toURI().toURL();
|
||||||
final TransformerManager transformerManager = new TransformerManager(new URLClassProvider(ROOT_CLASS_PROVIDER, url));
|
final TransformerManager transformerManager = new TransformerManager(new LazyFileClassProvider(Collections.singletonList(file), ROOT_CLASS_PROVIDER));
|
||||||
transformerManager.addBytecodeTransformer(new JavaDowngraderTransformer(transformerManager));
|
transformerManager.addBytecodeTransformer(new JavaDowngraderTransformer(transformerManager));
|
||||||
final InjectionClassLoader loader = new InjectionClassLoader(transformerManager, PluginManager.class.getClassLoader(), url);
|
final InjectionClassLoader loader = new InjectionClassLoader(transformerManager, PluginManager.class.getClassLoader(), url);
|
||||||
final InputStream viaproxyYml = loader.getResourceAsStream("viaproxy.yml");
|
final InputStream viaproxyYml = loader.getResourceAsStream("viaproxy.yml");
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
/*
|
|
||||||
* 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.util;
|
|
||||||
|
|
||||||
import net.lenni0451.classtransform.utils.ASMUtils;
|
|
||||||
import net.lenni0451.classtransform.utils.tree.IClassProvider;
|
|
||||||
import org.apache.commons.io.IOUtils;
|
|
||||||
|
|
||||||
import java.io.InputStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.function.Supplier;
|
|
||||||
|
|
||||||
public class URLClassProvider implements IClassProvider {
|
|
||||||
|
|
||||||
private final IClassProvider parent;
|
|
||||||
private final List<URL> urls;
|
|
||||||
|
|
||||||
public URLClassProvider(final IClassProvider parent, final URL... urls) {
|
|
||||||
this.parent = parent;
|
|
||||||
this.urls = Arrays.asList(urls);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public byte[] getClass(String name) throws ClassNotFoundException {
|
|
||||||
for (URL url : this.urls) {
|
|
||||||
try (InputStream is = new URL("jar:" + url + "!/" + ASMUtils.slash(name) + ".class").openStream()) {
|
|
||||||
return IOUtils.toByteArray(is);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return this.parent.getClass(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, Supplier<byte[]>> getAllClasses() {
|
|
||||||
return this.parent.getAllClasses();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
Loading…
Reference in a new issue