mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-22 23:48:15 -05:00
Fill ViaVersion platform dump data
This commit is contained in:
parent
0197c6098c
commit
4353ebfa7f
4 changed files with 62 additions and 1 deletions
10
build.gradle
10
build.gradle
|
@ -122,6 +122,7 @@ sourceSets {
|
||||||
main {
|
main {
|
||||||
classTokenReplacer {
|
classTokenReplacer {
|
||||||
property("\${version}", project.version)
|
property("\${version}", project.version)
|
||||||
|
property("\${impl_version}", "git-${project.name}-${project.version}:${project.latestCommitHash()}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -210,3 +211,12 @@ tasks.register("java8Jar", DowngradeJarTask) {
|
||||||
copyRuntimeClasses = false
|
copyRuntimeClasses = false
|
||||||
}.get().dependsOn("build")
|
}.get().dependsOn("build")
|
||||||
build.finalizedBy("java8Jar")
|
build.finalizedBy("java8Jar")
|
||||||
|
|
||||||
|
String latestCommitHash() {
|
||||||
|
def stdout = new ByteArrayOutputStream()
|
||||||
|
exec {
|
||||||
|
commandLine "git", "rev-parse", "--short", "HEAD"
|
||||||
|
standardOutput = stdout
|
||||||
|
}
|
||||||
|
return stdout.toString().trim()
|
||||||
|
}
|
||||||
|
|
|
@ -59,6 +59,7 @@ import java.lang.instrument.Instrumentation;
|
||||||
public class ViaProxy {
|
public class ViaProxy {
|
||||||
|
|
||||||
public static final String VERSION = "${version}";
|
public static final String VERSION = "${version}";
|
||||||
|
public static final String IMPL_VERSION = "${impl_version}";
|
||||||
|
|
||||||
private static Instrumentation instrumentation;
|
private static Instrumentation instrumentation;
|
||||||
public static SaveManager saveManager;
|
public static SaveManager saveManager;
|
||||||
|
|
|
@ -24,6 +24,7 @@ import net.raphimc.vialoader.impl.platform.ViaBedrockPlatformImpl;
|
||||||
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
|
||||||
import net.raphimc.viaproxy.plugins.PluginManager;
|
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||||
import net.raphimc.viaproxy.plugins.events.ProtocolHackInitEvent;
|
import net.raphimc.viaproxy.plugins.events.ProtocolHackInitEvent;
|
||||||
|
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVLInjector;
|
||||||
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVLLoader;
|
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyVLLoader;
|
||||||
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaLegacyPlatformImpl;
|
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaLegacyPlatformImpl;
|
||||||
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaVersionPlatformImpl;
|
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaVersionPlatformImpl;
|
||||||
|
@ -38,7 +39,7 @@ public class ProtocolHack {
|
||||||
public static void init() {
|
public static void init() {
|
||||||
patchConfigs();
|
patchConfigs();
|
||||||
final Supplier<?>[] platformSuppliers = PluginManager.EVENT_MANAGER.call(new ProtocolHackInitEvent(ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaProxyViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new)).getPlatformSuppliers().toArray(new Supplier[0]);
|
final Supplier<?>[] platformSuppliers = PluginManager.EVENT_MANAGER.call(new ProtocolHackInitEvent(ViaBackwardsPlatformImpl::new, ViaRewindPlatformImpl::new, ViaProxyViaLegacyPlatformImpl::new, ViaAprilFoolsPlatformImpl::new, ViaBedrockPlatformImpl::new)).getPlatformSuppliers().toArray(new Supplier[0]);
|
||||||
ViaLoader.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVLLoader(), null, null, platformSuppliers);
|
ViaLoader.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVLLoader(), new ViaProxyVLInjector(), null, platformSuppliers);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void patchConfigs() {
|
private static void patchConfigs() {
|
||||||
|
|
|
@ -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.protocolhack.impl;
|
||||||
|
|
||||||
|
import com.viaversion.viaversion.libs.gson.JsonArray;
|
||||||
|
import com.viaversion.viaversion.libs.gson.JsonObject;
|
||||||
|
import net.raphimc.vialoader.impl.viaversion.VLInjector;
|
||||||
|
import net.raphimc.viaproxy.ViaProxy;
|
||||||
|
import net.raphimc.viaproxy.plugins.PluginManager;
|
||||||
|
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
|
||||||
|
|
||||||
|
public class ViaProxyVLInjector extends VLInjector {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public JsonObject getDump() {
|
||||||
|
final JsonObject root = new JsonObject();
|
||||||
|
|
||||||
|
root.addProperty("version", ViaProxy.VERSION);
|
||||||
|
root.addProperty("impl_version", ViaProxy.IMPL_VERSION);
|
||||||
|
|
||||||
|
final JsonArray plugins = new JsonArray();
|
||||||
|
for (ViaProxyPlugin plugin : PluginManager.getPlugins()) {
|
||||||
|
final JsonObject pluginObj = new JsonObject();
|
||||||
|
pluginObj.addProperty("name", plugin.getName());
|
||||||
|
pluginObj.addProperty("version", plugin.getVersion());
|
||||||
|
pluginObj.addProperty("author", plugin.getAuthor());
|
||||||
|
plugins.add(pluginObj);
|
||||||
|
}
|
||||||
|
root.add("plugins", plugins);
|
||||||
|
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue