Moved ViaProxy specific dump data to platform dump section

This commit is contained in:
RaphiMC 2023-10-16 17:41:12 +02:00
parent faf9fe21f0
commit 85ddaf877a
No known key found for this signature in database
GPG Key ID: 0F6BB0657A03AC94
3 changed files with 26 additions and 51 deletions

View File

@ -24,7 +24,6 @@ import net.raphimc.vialoader.impl.platform.ViaBedrockPlatformImpl;
import net.raphimc.vialoader.impl.platform.ViaRewindPlatformImpl;
import net.raphimc.viaproxy.plugins.PluginManager;
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.ViaProxyViaLegacyPlatformImpl;
import net.raphimc.viaproxy.protocolhack.impl.ViaProxyViaVersionPlatformImpl;
@ -39,7 +38,7 @@ public class ProtocolHack {
public static void init() {
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]);
ViaLoader.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVLLoader(), new ViaProxyVLInjector(), null, platformSuppliers);
ViaLoader.init(new ViaProxyViaVersionPlatformImpl(), new ViaProxyVLLoader(), null, null, platformSuppliers);
}
private static void patchConfigs() {

View File

@ -1,49 +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.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;
}
}

View File

@ -17,8 +17,13 @@
*/
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.platform.ViaVersionPlatformImpl;
import net.raphimc.viaproxy.ViaProxy;
import net.raphimc.viaproxy.cli.ConsoleFormatter;
import net.raphimc.viaproxy.plugins.PluginManager;
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
import java.util.UUID;
@ -33,4 +38,24 @@ public class ViaProxyViaVersionPlatformImpl extends ViaVersionPlatformImpl {
super.sendMessage(uuid, ConsoleFormatter.convert(msg));
}
@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;
}
}