From a48c3a6ec24ba4c2857cdf5e34279715ae1a3ea2 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Thu, 30 May 2024 21:51:38 +0200 Subject: [PATCH] Move Bungee and Sponge platforms to separate plugins Bungee support is half broken due to not having the same injection points as Velocity and has become less and less stable with every update. The Sponge plugin has been almost entirely unused --- build.gradle.kts | 6 +- bungee/build.gradle.kts | 6 - .../viaversion/viaversion/BungeePlugin.java | 227 -------------- .../bungee/commands/BungeeCommand.java | 41 --- .../bungee/commands/BungeeCommandHandler.java | 28 -- .../bungee/commands/BungeeCommandSender.java | 50 --- .../bungee/commands/subs/ProbeSubCmd.java | 44 --- .../handlers/BungeeChannelInitializer.java | 69 ----- .../bungee/handlers/BungeeDecodeHandler.java | 63 ---- .../bungee/handlers/BungeeEncodeHandler.java | 108 ------- .../bungee/handlers/BungeeServerHandler.java | 289 ------------------ .../bungee/listeners/ElytraPatch.java | 58 ---- .../bungee/listeners/UpdateListener.java | 35 --- .../bungee/platform/BungeeViaAPI.java | 48 --- .../bungee/platform/BungeeViaConfig.java | 124 -------- .../bungee/platform/BungeeViaInjector.java | 186 ----------- .../bungee/platform/BungeeViaLoader.java | 98 ------ .../bungee/platform/BungeeViaTask.java | 29 -- .../providers/BungeeBossBarProvider.java | 46 --- .../providers/BungeeEntityIdProvider.java | 44 --- .../providers/BungeeMainHandProvider.java | 60 ---- .../providers/BungeeVersionProvider.java | 80 ----- .../service/ProtocolDetectorService.java | 94 ------ .../bungee/storage/BungeeStorage.java | 95 ------ .../bungee/util/BungeePipelineUtil.java | 81 ----- bungee/src/main/resources/bungee.yml | 5 - .../rewriter/EntityPacketRewriter1_14.java | 6 +- gradle/libs.versions.toml | 4 - settings.gradle.kts | 5 - sponge/build.gradle.kts | 6 - .../viaversion/viaversion/SpongePlugin.java | 249 --------------- .../sponge/commands/SpongeCommandHandler.java | 71 ----- .../sponge/commands/SpongeCommandSender.java | 58 ---- .../sponge/commands/SpongePlayer.java | 51 ---- .../handlers/SpongeChannelInitializer.java | 75 ----- .../sponge/handlers/SpongeDecodeHandler.java | 66 ---- .../sponge/handlers/SpongeEncodeHandler.java | 72 ----- .../sponge/listeners/UpdateListener.java | 33 -- .../sponge/listeners/ViaSpongeListener.java | 43 --- .../sponge/platform/SpongeViaAPI.java | 36 --- .../sponge/platform/SpongeViaConfig.java | 43 --- .../sponge/platform/SpongeViaInjector.java | 70 ----- .../sponge/platform/SpongeViaLoader.java | 61 ---- .../sponge/platform/SpongeViaTask.java | 29 -- .../viaversion/sponge/util/LoggerWrapper.java | 85 ------ .../resources/META-INF/sponge_plugins.json | 62 ---- .../assets/viaversion/textures/logo.png | Bin 30715 -> 0 bytes universal/build.gradle.kts | 4 +- 48 files changed, 6 insertions(+), 3137 deletions(-) delete mode 100644 bungee/build.gradle.kts delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/BungeePlugin.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommand.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommandHandler.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommandSender.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/commands/subs/ProbeSubCmd.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeChannelInitializer.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeDecodeHandler.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeEncodeHandler.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/UpdateListener.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaAPI.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaConfig.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaInjector.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaLoader.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaTask.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeBossBarProvider.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeEntityIdProvider.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMainHandProvider.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/service/ProtocolDetectorService.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/storage/BungeeStorage.java delete mode 100644 bungee/src/main/java/com/viaversion/viaversion/bungee/util/BungeePipelineUtil.java delete mode 100644 bungee/src/main/resources/bungee.yml delete mode 100644 sponge/build.gradle.kts delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/SpongePlugin.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongeCommandHandler.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongeCommandSender.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongePlayer.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeChannelInitializer.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeDecodeHandler.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeEncodeHandler.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/listeners/UpdateListener.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/listeners/ViaSpongeListener.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaAPI.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaConfig.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaInjector.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaLoader.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaTask.java delete mode 100644 sponge/src/main/java/com/viaversion/viaversion/sponge/util/LoggerWrapper.java delete mode 100644 sponge/src/main/resources/META-INF/sponge_plugins.json delete mode 100644 sponge/src/main/resources/assets/viaversion/textures/logo.png diff --git a/build.gradle.kts b/build.gradle.kts index 5151f9692..5c7ba5223 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,10 +14,8 @@ val main = setOf( projects.viaversionCommon, projects.viaversionApi, projects.viaversionBukkit, - projects.viaversionBungee, - projects.viaversionFabric, - projects.viaversionSponge, - projects.viaversionVelocity + projects.viaversionVelocity, + projects.viaversionFabric ).map { it.dependencyProject } // val special = setOf().map { it.dependencyProject } diff --git a/bungee/build.gradle.kts b/bungee/build.gradle.kts deleted file mode 100644 index f90c5b32f..000000000 --- a/bungee/build.gradle.kts +++ /dev/null @@ -1,6 +0,0 @@ -dependencies { - compileOnlyApi(projects.viaversionCommon) - compileOnly(libs.bungee) -} - -publishShadowJar() diff --git a/bungee/src/main/java/com/viaversion/viaversion/BungeePlugin.java b/bungee/src/main/java/com/viaversion/viaversion/BungeePlugin.java deleted file mode 100644 index 05d0675d3..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/BungeePlugin.java +++ /dev/null @@ -1,227 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion; - -import com.google.common.collect.ImmutableList; -import com.google.gson.JsonObject; -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.ViaAPI; -import com.viaversion.viaversion.api.command.ViaCommandSender; -import com.viaversion.viaversion.api.platform.PlatformTask; -import com.viaversion.viaversion.api.platform.UnsupportedSoftware; -import com.viaversion.viaversion.api.platform.ViaServerProxyPlatform; -import com.viaversion.viaversion.bungee.commands.BungeeCommand; -import com.viaversion.viaversion.bungee.commands.BungeeCommandHandler; -import com.viaversion.viaversion.bungee.commands.BungeeCommandSender; -import com.viaversion.viaversion.bungee.platform.BungeeViaAPI; -import com.viaversion.viaversion.bungee.platform.BungeeViaConfig; -import com.viaversion.viaversion.bungee.platform.BungeeViaInjector; -import com.viaversion.viaversion.bungee.platform.BungeeViaLoader; -import com.viaversion.viaversion.bungee.platform.BungeeViaTask; -import com.viaversion.viaversion.bungee.service.ProtocolDetectorService; -import com.viaversion.viaversion.dump.PluginInfo; -import com.viaversion.viaversion.unsupported.UnsupportedServerSoftware; -import com.viaversion.viaversion.util.GsonUtil; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; -import java.util.UUID; -import java.util.concurrent.TimeUnit; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.plugin.Plugin; -import net.md_5.bungee.protocol.ProtocolConstants; - -public class BungeePlugin extends Plugin implements ViaServerProxyPlatform, Listener { - private final ProtocolDetectorService protocolDetectorService = new ProtocolDetectorService(); - private BungeeViaAPI api; - private BungeeViaConfig config; - - @Override - public void onLoad() { - try { - ProtocolConstants.class.getField("MINECRAFT_1_20_5"); - } catch (NoSuchFieldException e) { - getLogger().warning(" / \\"); - getLogger().warning(" / \\"); - getLogger().warning(" / | \\"); - getLogger().warning(" / | \\ BUNGEECORD IS OUTDATED"); - getLogger().warning(" / \\ VIAVERSION MAY NOT WORK AS INTENDED"); - getLogger().warning(" / o \\"); - getLogger().warning("/_____________\\"); - } - - getLogger().warning("ViaVersion does not work as intended across many different server versions, especially the more recent ones. " + - "Consider moving Via plugins to your backend server or switching to Velocity."); - - api = new BungeeViaAPI(); - config = new BungeeViaConfig(getDataFolder(), getLogger()); - BungeeCommandHandler commandHandler = new BungeeCommandHandler(); - ProxyServer.getInstance().getPluginManager().registerCommand(this, new BungeeCommand(commandHandler)); - - // Init platform - Via.init(ViaManagerImpl.builder() - .platform(this) - .injector(new BungeeViaInjector()) - .loader(new BungeeViaLoader(this)) - .commandHandler(commandHandler) - .build()); - - config.reload(); - } - - @Override - public void onEnable() { - final ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); - manager.init(); - manager.onServerLoaded(); - } - - @Override - public String getPlatformName() { - return getProxy().getName(); - } - - @Override - public String getPlatformVersion() { - return getProxy().getVersion(); - } - - @Override - public boolean isProxy() { - return true; - } - - @Override - public String getPluginVersion() { - return getDescription().getVersion(); - } - - @Override - public PlatformTask runAsync(Runnable runnable) { - return new BungeeViaTask(getProxy().getScheduler().runAsync(this, runnable)); - } - - @Override - public PlatformTask runRepeatingAsync(final Runnable runnable, final long ticks) { - return new BungeeViaTask(getProxy().getScheduler().schedule(this, runnable, 0, ticks * 50, TimeUnit.MILLISECONDS)); - } - - @Override - public PlatformTask runSync(Runnable runnable) { - return runAsync(runnable); - } - - @Override - public PlatformTask runSync(Runnable runnable, long delay) { - return new BungeeViaTask(getProxy().getScheduler().schedule(this, runnable, delay * 50, TimeUnit.MILLISECONDS)); - } - - @Override - public PlatformTask runRepeatingSync(Runnable runnable, long period) { - return runRepeatingAsync(runnable, period); - } - - @Override - public ViaCommandSender[] getOnlinePlayers() { - Collection players = getProxy().getPlayers(); - ViaCommandSender[] array = new ViaCommandSender[players.size()]; - int i = 0; - for (ProxiedPlayer player : players) { - array[i++] = new BungeeCommandSender(player); - } - return array; - } - - @Override - public void sendMessage(UUID uuid, String message) { - getProxy().getPlayer(uuid).sendMessage(message); - } - - @Override - public boolean kickPlayer(UUID uuid, String message) { - ProxiedPlayer player = getProxy().getPlayer(uuid); - if (player != null) { - player.disconnect(message); - return true; - } - return false; - } - - @Override - public boolean isPluginEnabled() { - return true; - } - - @Override - public ViaAPI getApi() { - return api; - } - - @Override - public BungeeViaConfig getConf() { - return config; - } - - @Override - public void onReload() { - // Injector prints a message <3 - } - - @Override - public JsonObject getDump() { - JsonObject platformSpecific = new JsonObject(); - - List plugins = new ArrayList<>(); - for (Plugin p : ProxyServer.getInstance().getPluginManager().getPlugins()) - plugins.add(new PluginInfo( - true, - p.getDescription().getName(), - p.getDescription().getVersion(), - p.getDescription().getMain(), - Collections.singletonList(p.getDescription().getAuthor()) - )); - - platformSpecific.add("plugins", GsonUtil.getGson().toJsonTree(plugins)); - platformSpecific.add("servers", GsonUtil.getGson().toJsonTree(protocolDetectorService.detectedProtocolVersions())); - return platformSpecific; - } - - @Override - public Collection getUnsupportedSoftwareClasses() { - final Collection list = new ArrayList<>(ViaServerProxyPlatform.super.getUnsupportedSoftwareClasses()); - list.add(new UnsupportedServerSoftware.Builder() - .name("FlameCord") - .addClassName("dev._2lstudios.flamecord.FlameCord") - .reason(UnsupportedServerSoftware.Reason.BREAKING_PROXY_SOFTWARE) - .build()); - return ImmutableList.copyOf(list); - } - - @Override - public boolean hasPlugin(final String name) { - return getProxy().getPluginManager().getPlugin(name) != null; - } - - @Override - public ProtocolDetectorService protocolDetectorService() { - return protocolDetectorService; - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommand.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommand.java deleted file mode 100644 index 8548fb6a1..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommand.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.commands; - -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.plugin.Command; -import net.md_5.bungee.api.plugin.TabExecutor; - -public class BungeeCommand extends Command implements TabExecutor { - private final BungeeCommandHandler handler; - - public BungeeCommand(BungeeCommandHandler handler) { - super("viaversion", "viaversion.command", "viaver", "vvbungee"); // The permission is also referenced here to filter root suggestions (/via) - this.handler = handler; - } - - @Override - public void execute(CommandSender commandSender, String[] strings) { - handler.onCommand(new BungeeCommandSender(commandSender), strings); - } - - @Override - public Iterable onTabComplete(CommandSender commandSender, String[] strings) { - return handler.onTabComplete(new BungeeCommandSender(commandSender), strings); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommandHandler.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommandHandler.java deleted file mode 100644 index 7a2b2a3e3..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommandHandler.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.commands; - -import com.viaversion.viaversion.bungee.commands.subs.ProbeSubCmd; -import com.viaversion.viaversion.commands.ViaCommandHandler; - -public class BungeeCommandHandler extends ViaCommandHandler { - - public BungeeCommandHandler() { - registerSubCommand(new ProbeSubCmd()); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommandSender.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommandSender.java deleted file mode 100644 index a3abe64ed..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/BungeeCommandSender.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.commands; - -import com.viaversion.viaversion.api.command.ViaCommandSender; -import java.util.UUID; -import net.md_5.bungee.api.CommandSender; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public record BungeeCommandSender(CommandSender sender) implements ViaCommandSender { - - @Override - public boolean hasPermission(String permission) { - return sender.hasPermission(permission); - } - - @Override - public void sendMessage(String msg) { - sender.sendMessage(msg); - } - - @Override - public UUID getUUID() { - if (sender instanceof ProxiedPlayer player) { - return player.getUniqueId(); - } else { - return new UUID(0, 0); - } - } - - @Override - public String getName() { - return sender.getName(); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/subs/ProbeSubCmd.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/subs/ProbeSubCmd.java deleted file mode 100644 index adbb352f6..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/commands/subs/ProbeSubCmd.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.commands.subs; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.command.ViaCommandSender; -import com.viaversion.viaversion.api.command.ViaSubCommand; -import com.viaversion.viaversion.bungee.platform.BungeeViaConfig; - -public class ProbeSubCmd implements ViaSubCommand { - @Override - public String name() { - return "probe"; - } - - @Override - public String description() { - return "Forces ViaVersion to scan server protocol versions " + - (((BungeeViaConfig) Via.getConfig()).getBungeePingInterval() == -1 ? - "" : "(Also happens at an interval)"); - } - - @Override - public boolean execute(ViaCommandSender sender, String[] args) { - Via.proxyPlatform().protocolDetectorService().probeAllServers(); - sendMessage(sender, "&6Started searching for protocol versions"); - return true; - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeChannelInitializer.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeChannelInitializer.java deleted file mode 100644 index bd4efb6d9..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeChannelInitializer.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.handlers; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.connection.UserConnectionImpl; -import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; -import io.netty.channel.Channel; -import io.netty.channel.ChannelInitializer; -import java.lang.reflect.Method; -import java.util.logging.Level; - -public class BungeeChannelInitializer extends ChannelInitializer { - private final ChannelInitializer original; - private Method method; - - public BungeeChannelInitializer(ChannelInitializer oldInit) { - this.original = oldInit; - try { - this.method = ChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class); - this.method.setAccessible(true); - } catch (NoSuchMethodException e) { - Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get initChannel method", e); - } - } - - @Override - protected void initChannel(Channel socketChannel) throws Exception { - if (!socketChannel.isActive()) { - return; - } - - UserConnection info = new UserConnectionImpl(socketChannel); - // init protocol - new ProtocolPipelineImpl(info); - // Add originals - this.method.invoke(this.original, socketChannel); - - if (!socketChannel.isActive()) return; // Don't inject if inactive - if (socketChannel.pipeline().get("packet-encoder") == null) return; // Don't inject if no packet-encoder - if (socketChannel.pipeline().get("packet-decoder") == null) return; // Don't inject if no packet-decoder - // Add our transformers - BungeeEncodeHandler encoder = new BungeeEncodeHandler(info); - BungeeDecodeHandler decoder = new BungeeDecodeHandler(info); - - socketChannel.pipeline().addBefore("packet-encoder", "via-encoder", encoder); - socketChannel.pipeline().addBefore("packet-decoder", "via-decoder", decoder); - } - - public ChannelInitializer getOriginal() { - return original; - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeDecodeHandler.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeDecodeHandler.java deleted file mode 100644 index a7d25cc6f..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeDecodeHandler.java +++ /dev/null @@ -1,63 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.handlers; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.exception.CancelCodecException; -import com.viaversion.viaversion.exception.CancelDecoderException; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToMessageDecoder; -import java.util.List; - -@ChannelHandler.Sharable -public class BungeeDecodeHandler extends MessageToMessageDecoder { - private final UserConnection info; - - public BungeeDecodeHandler(UserConnection info) { - this.info = info; - } - - @Override - protected void decode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List out) throws Exception { - if (!ctx.channel().isActive()) { - throw CancelDecoderException.generate(null); - } - - if (!info.checkServerboundPacket()) throw CancelDecoderException.generate(null); - if (!info.shouldTransformPacket()) { - out.add(bytebuf.retain()); - return; - } - - ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); - try { - info.transformServerbound(transformedBuf, CancelDecoderException::generate); - out.add(transformedBuf.retain()); - } finally { - transformedBuf.release(); - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if (cause instanceof CancelCodecException) return; - super.exceptionCaught(ctx, cause); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeEncodeHandler.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeEncodeHandler.java deleted file mode 100644 index 8dcfc1863..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeEncodeHandler.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.handlers; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.bungee.util.BungeePipelineUtil; -import com.viaversion.viaversion.exception.CancelCodecException; -import com.viaversion.viaversion.exception.CancelEncoderException; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToMessageEncoder; -import java.util.List; - -@ChannelHandler.Sharable -public class BungeeEncodeHandler extends MessageToMessageEncoder { - private final UserConnection info; - private boolean handledCompression; - - public BungeeEncodeHandler(UserConnection info) { - this.info = info; - } - - @Override - protected void encode(final ChannelHandlerContext ctx, ByteBuf bytebuf, List out) throws Exception { - if (!ctx.channel().isActive()) { - throw CancelEncoderException.generate(null); - } - - if (!info.checkClientboundPacket()) throw CancelEncoderException.generate(null); - if (!info.shouldTransformPacket()) { - out.add(bytebuf.retain()); - return; - } - - ByteBuf transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); - try { - boolean needsCompress = handleCompressionOrder(ctx, transformedBuf); - info.transformClientbound(transformedBuf, CancelEncoderException::generate); - - if (needsCompress) { - recompress(ctx, transformedBuf); - } - - out.add(transformedBuf.retain()); - } finally { - transformedBuf.release(); - } - } - - private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf buf) { - boolean needsCompress = false; - if (!handledCompression && ctx.pipeline().names().indexOf("compress") > ctx.pipeline().names().indexOf("via-encoder")) { - // Need to decompress this packet due to bad order - ByteBuf decompressed = BungeePipelineUtil.decompress(ctx, buf); - - // Ensure the buffer wasn't reused - if (buf != decompressed) { - try { - buf.clear().writeBytes(decompressed); - } finally { - decompressed.release(); - } - } - - // Reorder the pipeline - ChannelHandler decoder = ctx.pipeline().get("via-decoder"); - ChannelHandler encoder = ctx.pipeline().get("via-encoder"); - ctx.pipeline().remove(decoder); - ctx.pipeline().remove(encoder); - ctx.pipeline().addAfter("decompress", "via-decoder", decoder); - ctx.pipeline().addAfter("compress", "via-encoder", encoder); - needsCompress = true; - handledCompression = true; - } - return needsCompress; - } - - private void recompress(ChannelHandlerContext ctx, ByteBuf buf) { - ByteBuf compressed = BungeePipelineUtil.compress(ctx, buf); - try { - buf.clear().writeBytes(compressed); - } finally { - compressed.release(); - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if (cause instanceof CancelCodecException) return; - super.exceptionCaught(ctx, cause); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java deleted file mode 100644 index fc3cd7d20..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java +++ /dev/null @@ -1,289 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.handlers; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.connection.ProtocolInfo; -import com.viaversion.viaversion.api.connection.StorableObject; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.data.entity.ClientEntityIdChangeListener; -import com.viaversion.viaversion.api.data.entity.EntityTracker; -import com.viaversion.viaversion.api.protocol.ProtocolPathEntry; -import com.viaversion.viaversion.api.protocol.ProtocolPipeline; -import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.type.Types; -import com.viaversion.viaversion.bungee.storage.BungeeStorage; -import com.viaversion.viaversion.protocols.v1_12_2to1_13.rewriter.ItemPacketRewriter1_13; -import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; -import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; -import com.viaversion.viaversion.protocols.v1_8to1_9.provider.EntityIdProvider; -import com.viaversion.viaversion.protocols.v1_8to1_9.storage.EntityTracker1_9; -import java.lang.invoke.MethodHandle; -import java.lang.invoke.MethodHandles; -import java.lang.invoke.MethodType; -import java.util.Collection; -import java.util.HashSet; -import java.util.Iterator; -import java.util.List; -import java.util.Set; -import java.util.UUID; -import java.util.logging.Level; -import java.util.stream.Collectors; -import net.md_5.bungee.api.connection.ProxiedPlayer; -import net.md_5.bungee.api.connection.Server; -import net.md_5.bungee.api.event.ServerConnectEvent; -import net.md_5.bungee.api.event.ServerConnectedEvent; -import net.md_5.bungee.api.event.ServerSwitchEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.score.Team; -import net.md_5.bungee.event.EventHandler; -import net.md_5.bungee.protocol.packet.Handshake; -import net.md_5.bungee.protocol.packet.PluginMessage; - -// All of this is madness -public class BungeeServerHandler implements Listener { - private static final MethodHandle GET_HANDSHAKE; - private static final MethodHandle GET_REGISTERED_CHANNELS; - private static final MethodHandle GET_BRAND_MESSAGE; - private static final MethodHandle GET_ENTITY_MAP; - private static final MethodHandle SET_VERSION; - private static final MethodHandle SET_ENTITY_REWRITE; - private static final MethodHandle GET_CHANNEL_WRAPPER; - - static { - try { - final MethodHandles.Lookup lookup = MethodHandles.lookup(); - final Class initialHandlerClass = Class.forName("net.md_5.bungee.connection.InitialHandler"); - GET_HANDSHAKE = lookup.findVirtual(initialHandlerClass, "getHandshake", MethodType.methodType(Handshake.class)); - GET_REGISTERED_CHANNELS = lookup.findVirtual(initialHandlerClass, "getRegisteredChannels", MethodType.methodType(Set.class)); - GET_BRAND_MESSAGE = lookup.findVirtual(initialHandlerClass, "getBrandMessage", MethodType.methodType(PluginMessage.class)); - - final Class entityMapClass = Class.forName("net.md_5.bungee.entitymap.EntityMap"); - final Class channelWrapperClass = Class.forName("net.md_5.bungee.netty.ChannelWrapper"); - GET_ENTITY_MAP = lookup.findStatic(entityMapClass, "getEntityMap", MethodType.methodType(entityMapClass, int.class)); - SET_VERSION = lookup.findVirtual(channelWrapperClass, "setVersion", MethodType.methodType(void.class, int.class)); - - final Class userConnectionClass = Class.forName("net.md_5.bungee.UserConnection"); - final MethodHandles.Lookup privateLookup = MethodHandles.privateLookupIn(userConnectionClass, lookup); - GET_CHANNEL_WRAPPER = privateLookup.findGetter(userConnectionClass, "ch", channelWrapperClass); - SET_ENTITY_REWRITE = privateLookup.findSetter(userConnectionClass, "entityRewrite", entityMapClass); - } catch (final ReflectiveOperationException e) { - Via.getPlatform().getLogger().severe("Error initializing BungeeServerHandler, try updating BungeeCord or ViaVersion!"); - throw new RuntimeException(e); - } - } - - // Set the handshake version every time someone connects to any server - @EventHandler(priority = 120) - public void onServerConnect(ServerConnectEvent event) { - if (event.isCancelled()) { - return; - } - - UserConnection user = Via.getManager().getConnectionManager().getConnectedClient(event.getPlayer().getUniqueId()); - if (user == null) { - return; - } - - if (!user.has(BungeeStorage.class)) { - user.put(new BungeeStorage(event.getPlayer())); - } - - ProtocolVersion serverProtocolVersion = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(event.getTarget().getName()); - ProtocolVersion clientProtocolVersion = user.getProtocolInfo().protocolVersion(); - List protocols = Via.getManager().getProtocolManager().getProtocolPath(clientProtocolVersion, serverProtocolVersion); - - // Check if ViaVersion can support that version - try { - Handshake handshake = (Handshake) GET_HANDSHAKE.invoke(event.getPlayer().getPendingConnection()); - handshake.setProtocolVersion(protocols == null ? clientProtocolVersion.getVersion() : serverProtocolVersion.getVersion()); - } catch (Throwable e) { - Via.getPlatform().getLogger().log(Level.SEVERE, "Error setting handshake version", e); - } - } - - @EventHandler(priority = -120) - public void onServerConnected(ServerConnectedEvent event) { - try { - checkServerChange(event, Via.getManager().getConnectionManager().getConnectedClient(event.getPlayer().getUniqueId())); - } catch (Throwable e) { - Via.getPlatform().getLogger().log(Level.SEVERE, "Failed to handle server switch", e); - } - } - - @EventHandler(priority = -120) - public void onServerSwitch(ServerSwitchEvent event) { - // Update entity id - UserConnection userConnection = Via.getManager().getConnectionManager().getConnectedClient(event.getPlayer().getUniqueId()); - if (userConnection == null) { - return; - } - - int playerId; - try { - playerId = Via.getManager().getProviders().get(EntityIdProvider.class).getEntityId(userConnection); - } catch (Exception ignored) { - return; - } - - for (EntityTracker tracker : userConnection.getEntityTrackers()) { - tracker.setClientEntityId(playerId); - } - - // For ViaRewind - for (StorableObject object : userConnection.getStoredObjects().values()) { - if (object instanceof ClientEntityIdChangeListener listener) { - listener.setClientEntityId(playerId); - } - } - } - - public void checkServerChange(ServerConnectedEvent event, UserConnection user) throws Throwable { - if (user == null) { - return; - } - - BungeeStorage storage = user.get(BungeeStorage.class); - if (storage == null) { - return; - } - - Server server = event.getServer(); - if (server == null || server.getInfo().getName().equals(storage.getCurrentServer())) { - return; - } - - - // Clear auto-team - EntityTracker1_9 oldEntityTracker = user.getEntityTracker(Protocol1_8To1_9.class); - if (oldEntityTracker != null && oldEntityTracker.isAutoTeam() && oldEntityTracker.isTeamExists()) { - oldEntityTracker.sendTeamPacket(false, true); - } - - String serverName = server.getInfo().getName(); - storage.setCurrentServer(serverName); - ProtocolVersion serverProtocolVersion = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverName); - if (serverProtocolVersion.olderThanOrEqualTo(ProtocolVersion.v1_8) && storage.getBossbar() != null) { // 1.8 doesn't have BossBar packet - // This ensures we can encode it properly as only the 1.9 protocol is currently implemented. - if (user.getProtocolInfo().getPipeline().contains(Protocol1_8To1_9.class)) { - for (UUID uuid : storage.getBossbar()) { - PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.BOSS_EVENT, null, user); - wrapper.write(Types.UUID, uuid); - wrapper.write(Types.VAR_INT, 1); // remove - wrapper.send(Protocol1_8To1_9.class); - } - } - storage.getBossbar().clear(); - } - - ProtocolInfo info = user.getProtocolInfo(); - ProtocolVersion previousServerProtocol = info.serverProtocolVersion(); - - // Refresh the pipes - List protocolPath = Via.getManager().getProtocolManager().getProtocolPath(info.protocolVersion(), serverProtocolVersion); - ProtocolPipeline pipeline = user.getProtocolInfo().getPipeline(); - user.clearStoredObjects(true); - pipeline.cleanPipes(); - if (protocolPath != null) { - info.setServerProtocolVersion(serverProtocolVersion); - pipeline.add(protocolPath.stream().map(ProtocolPathEntry::protocol).collect(Collectors.toList())); - } else { - // TODO Check Bungee Supported Protocols? *shrugs* - serverProtocolVersion = info.protocolVersion(); - info.setServerProtocolVersion(serverProtocolVersion); - } - - // Add version-specific base Protocol - pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(serverProtocolVersion)); - - // Workaround 1.13 server change - boolean toNewId = previousServerProtocol.olderThan(ProtocolVersion.v1_13) && serverProtocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_13); - boolean toOldId = previousServerProtocol.newerThanOrEqualTo(ProtocolVersion.v1_13) && serverProtocolVersion.olderThan(ProtocolVersion.v1_13); - if (previousServerProtocol.isKnown() && (toNewId || toOldId)) { - Collection registeredChannels = (Collection) GET_REGISTERED_CHANNELS.invoke(event.getPlayer().getPendingConnection()); - if (!registeredChannels.isEmpty()) { - Collection newChannels = new HashSet<>(); - for (Iterator iterator = registeredChannels.iterator(); iterator.hasNext(); ) { - String channel = iterator.next(); - String oldChannel = channel; - if (toNewId) { - channel = ItemPacketRewriter1_13.getNewPluginChannelId(channel); - } else { - channel = ItemPacketRewriter1_13.getOldPluginChannelId(channel); - } - if (channel == null) { - iterator.remove(); - continue; - } - if (!oldChannel.equals(channel)) { - iterator.remove(); - newChannels.add(channel); - } - } - registeredChannels.addAll(newChannels); - } - - PluginMessage brandMessage = (PluginMessage) GET_BRAND_MESSAGE.invoke(event.getPlayer().getPendingConnection()); - if (brandMessage != null) { - String channel = brandMessage.getTag(); - if (toNewId) { - channel = ItemPacketRewriter1_13.getNewPluginChannelId(channel); - } else { - channel = ItemPacketRewriter1_13.getOldPluginChannelId(channel); - } - if (channel != null) { - brandMessage.setTag(channel); - } - } - } - - user.put(storage); - - user.setActive(protocolPath != null); - - ProxiedPlayer player = storage.getPlayer(); - EntityTracker1_9 newTracker = user.getEntityTracker(Protocol1_8To1_9.class); - if (newTracker != null && Via.getConfig().isAutoTeam()) { - String currentTeam = null; - for (Team team : player.getScoreboard().getTeams()) { - if (team.getPlayers().contains(info.getUsername())) { - currentTeam = team.getName(); - } - } - - // Reinitialize auto-team - newTracker.setAutoTeam(true); - if (currentTeam == null) { - // Send auto-team as it was cleared above - newTracker.sendTeamPacket(true, true); - newTracker.setCurrentTeam("viaversion"); - } else { - // Auto-team will be sent when bungee send remove packet - newTracker.setAutoTeam(Via.getConfig().isAutoTeam()); - newTracker.setCurrentTeam(currentTeam); - } - } - - Object wrapper = GET_CHANNEL_WRAPPER.invoke(player); - SET_VERSION.invoke(wrapper, serverProtocolVersion.getVersion()); - - Object entityMap = GET_ENTITY_MAP.invoke(serverProtocolVersion.getVersion()); - SET_ENTITY_REWRITE.invoke(player, entityMap); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java deleted file mode 100644 index 2308eb1b5..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/ElytraPatch.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.listeners; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.minecraft.entitydata.EntityData; -import com.viaversion.viaversion.api.minecraft.entitydata.types.EntityDataTypes1_9; -import com.viaversion.viaversion.api.protocol.packet.PacketWrapper; -import com.viaversion.viaversion.api.type.Types; -import com.viaversion.viaversion.api.type.types.version.Types1_9; -import com.viaversion.viaversion.protocols.v1_8to1_9.Protocol1_8To1_9; -import com.viaversion.viaversion.protocols.v1_8to1_9.packet.ClientboundPackets1_9; -import com.viaversion.viaversion.protocols.v1_8to1_9.storage.EntityTracker1_9; -import java.util.Collections; -import net.md_5.bungee.api.event.ServerConnectedEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; -import net.md_5.bungee.event.EventPriority; - -/* - * This patches https://github.com/ViaVersion/ViaVersion/issues/555 - */ -public class ElytraPatch implements Listener { - - @EventHandler(priority = EventPriority.HIGH) - public void onServerConnected(ServerConnectedEvent event) { - UserConnection user = Via.getManager().getConnectionManager().getConnectedClient(event.getPlayer().getUniqueId()); - if (user == null) return; - - if (user.getProtocolInfo().getPipeline().contains(Protocol1_8To1_9.class)) { - EntityTracker1_9 tracker = user.getEntityTracker(Protocol1_8To1_9.class); - int entityId = tracker.getProvidedEntityId(); - - PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.SET_ENTITY_DATA, null, user); - - wrapper.write(Types.VAR_INT, entityId); - wrapper.write(Types1_9.ENTITY_DATA_LIST, Collections.singletonList(new EntityData(0, EntityDataTypes1_9.BYTE, (byte) 0))); - - wrapper.scheduleSend(Protocol1_8To1_9.class); - } - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/UpdateListener.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/UpdateListener.java deleted file mode 100644 index 9789e2f89..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/listeners/UpdateListener.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.listeners; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.update.UpdateUtil; -import net.md_5.bungee.api.event.PostLoginEvent; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.event.EventHandler; - -public class UpdateListener implements Listener { - - @EventHandler - public void onJoin(PostLoginEvent e) { - if (e.getPlayer().hasPermission("viaversion.update") - && Via.getConfig().isCheckForUpdates()) { - UpdateUtil.sendUpdateMessage(e.getPlayer().getUniqueId()); - } - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaAPI.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaAPI.java deleted file mode 100644 index ad31125e6..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaAPI.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.platform; - -import com.viaversion.viaversion.ViaAPIBase; -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.bungee.service.ProtocolDetectorService; -import io.netty.buffer.ByteBuf; -import net.md_5.bungee.api.config.ServerInfo; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public class BungeeViaAPI extends ViaAPIBase { - - @Override - public ProtocolVersion getPlayerProtocolVersion(ProxiedPlayer player) { - return getPlayerProtocolVersion(player.getUniqueId()); - } - - @Override - public void sendRawPacket(ProxiedPlayer player, ByteBuf packet) throws IllegalArgumentException { - sendRawPacket(player.getUniqueId(), packet); - } - - /** - * Forces ViaVersion to probe a server - * - * @param serverInfo The serverinfo to probe - */ - public void probeServer(ServerInfo serverInfo) { - ((ProtocolDetectorService) Via.proxyPlatform().protocolDetectorService()).probeServer(serverInfo); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaConfig.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaConfig.java deleted file mode 100644 index 62cc15621..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaConfig.java +++ /dev/null @@ -1,124 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.platform; - -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.bungee.providers.BungeeVersionProvider; -import com.viaversion.viaversion.configuration.AbstractViaConfig; -import java.io.File; -import java.util.Arrays; -import java.util.HashMap; -import java.util.HashSet; -import java.util.List; -import java.util.Map; -import java.util.logging.Logger; - -public class BungeeViaConfig extends AbstractViaConfig { - private static final List UNSUPPORTED = Arrays.asList("nms-player-ticking", "item-cache", "quick-move-action-fix", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", "blockconnection-method", "change-1_9-hitbox", "change-1_14-hitbox"); - private int bungeePingInterval; - private boolean bungeePingSave; - private Map bungeeServerProtocols; - - public BungeeViaConfig(File folder, Logger logger) { - super(new File(folder, "config.yml"), logger); - } - - @Override - protected void loadFields() { - super.loadFields(); - bungeePingInterval = getInt("bungee-ping-interval", 60); - bungeePingSave = getBoolean("bungee-ping-save", true); - bungeeServerProtocols = get("bungee-servers", new HashMap<>()); - } - - @Override - protected void handleConfig(Map config) { - // Parse servers - Map servers; - if (!(config.get("bungee-servers") instanceof Map)) { - servers = new HashMap<>(); - } else { - servers = (Map) config.get("bungee-servers"); - } - // Convert any bad Protocol Ids - for (Map.Entry entry : new HashSet<>(servers.entrySet())) { - if (!(entry.getValue() instanceof Integer)) { - if (entry.getValue() instanceof String stringValue) { - ProtocolVersion found = ProtocolVersion.getClosest(stringValue); - if (found != null) { - servers.put(entry.getKey(), found.getVersion()); - } else { - servers.remove(entry.getKey()); // Remove! - } - } else { - servers.remove(entry.getKey()); // Remove! - } - } - } - // Ensure default exists - if (!servers.containsKey("default")) { - servers.put("default", BungeeVersionProvider.getLowestSupportedVersion().getVersion()); - } - // Put back - config.put("bungee-servers", servers); - } - - @Override - public List getUnsupportedOptions() { - return UNSUPPORTED; - } - - @Override - public boolean isItemCache() { - return false; - } - - @Override - public boolean isNMSPlayerTicking() { - return false; - } - - /** - * What is the interval for checking servers via ping - * -1 for disabled - * - * @return Ping interval in seconds - */ - public int getBungeePingInterval() { - return bungeePingInterval; - } - - /** - * Should the bungee ping be saved to the config on change. - * - * @return True if it should save - */ - public boolean isBungeePingSave() { - return bungeePingSave; - } - - /** - * Get the listed server protocols in the config. - * default will be listed as default. - * - * @return Map of String, Integer - */ - public Map getBungeeServerProtocols() { - return bungeeServerProtocols; - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaInjector.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaInjector.java deleted file mode 100644 index db009d84e..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaInjector.java +++ /dev/null @@ -1,186 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.platform; - -import com.google.gson.JsonArray; -import com.google.gson.JsonObject; -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.platform.ViaInjector; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.bungee.handlers.BungeeChannelInitializer; -import com.viaversion.viaversion.util.ReflectionUtil; -import com.viaversion.viaversion.util.SetWrapper; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelInitializer; -import it.unimi.dsi.fastutil.objects.ObjectLinkedOpenHashSet; -import java.lang.reflect.Field; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; -import java.util.SortedSet; -import net.md_5.bungee.api.ProxyServer; - -public class BungeeViaInjector implements ViaInjector { - - private static final Field LISTENERS_FIELD; - private final List injectedChannels = new ArrayList<>(); - - static { - try { - LISTENERS_FIELD = ProxyServer.getInstance().getClass().getDeclaredField("listeners"); - LISTENERS_FIELD.setAccessible(true); - } catch (ReflectiveOperationException e) { - throw new RuntimeException("Unable to access listeners field.", e); - } - } - - @Override - public void inject() throws ReflectiveOperationException { - Set listeners = (Set) LISTENERS_FIELD.get(ProxyServer.getInstance()); - - // Iterate through current list - for (Channel channel : listeners) { - injectChannel(channel); - } - - // Inject the list - Set wrapper = new SetWrapper<>(listeners, channel -> { - try { - injectChannel(channel); - } catch (Exception e) { - throw new RuntimeException(e); - } - }); - - LISTENERS_FIELD.set(ProxyServer.getInstance(), wrapper); - } - - @Override - public void uninject() { - Via.getPlatform().getLogger().severe("ViaVersion cannot remove itself from Bungee without a reboot!"); - } - - private void injectChannel(Channel channel) throws ReflectiveOperationException { - List names = channel.pipeline().names(); - ChannelHandler bootstrapAcceptor = null; - - for (String name : names) { - ChannelHandler handler = channel.pipeline().get(name); - try { - ReflectionUtil.get(handler, "childHandler", ChannelInitializer.class); - bootstrapAcceptor = handler; - } catch (Exception e) { - // Not this one - } - } - - // Default to first - if (bootstrapAcceptor == null) { - bootstrapAcceptor = channel.pipeline().first(); - } - - if (bootstrapAcceptor.getClass().getName().equals("net.md_5.bungee.query.QueryHandler")) { - return; - } - - try { - ChannelInitializer oldInit = ReflectionUtil.get(bootstrapAcceptor, "childHandler", ChannelInitializer.class); - ChannelInitializer newInit = new BungeeChannelInitializer(oldInit); - - ReflectionUtil.set(bootstrapAcceptor, "childHandler", newInit); - this.injectedChannels.add(channel); - } catch (NoSuchFieldException ignored) { - throw new RuntimeException("Unable to find core component 'childHandler', please check your plugins. issue: " + bootstrapAcceptor.getClass().getName()); - } - } - - @Override - public ProtocolVersion getServerProtocolVersion() throws ReflectiveOperationException { - return ProtocolVersion.getProtocol(getBungeeSupportedVersions().get(0)); - } - - @Override - public SortedSet getServerProtocolVersions() throws ReflectiveOperationException { - final SortedSet versions = new ObjectLinkedOpenHashSet<>(); - for (final Integer version : getBungeeSupportedVersions()) { - versions.add(ProtocolVersion.getProtocol(version)); - } - return versions; - } - - private List getBungeeSupportedVersions() throws ReflectiveOperationException { - return ReflectionUtil.getStatic(Class.forName("net.md_5.bungee.protocol.ProtocolConstants"), "SUPPORTED_VERSION_IDS", List.class); - } - - @Override - public JsonObject getDump() { - JsonObject data = new JsonObject(); - - // Generate information about current injections - JsonArray injectedChannelInitializers = new JsonArray(); - for (Channel channel : this.injectedChannels) { - JsonObject channelInfo = new JsonObject(); - channelInfo.addProperty("channelClass", channel.getClass().getName()); - - // Get information about the pipes for this channel - JsonArray pipeline = new JsonArray(); - for (String pipeName : channel.pipeline().names()) { - JsonObject handlerInfo = new JsonObject(); - handlerInfo.addProperty("name", pipeName); - - ChannelHandler channelHandler = channel.pipeline().get(pipeName); - if (channelHandler == null) { - handlerInfo.addProperty("status", "INVALID"); - continue; - } - - handlerInfo.addProperty("class", channelHandler.getClass().getName()); - - try { - Object child = ReflectionUtil.get(channelHandler, "childHandler", ChannelInitializer.class); - handlerInfo.addProperty("childClass", child.getClass().getName()); - if (child instanceof BungeeChannelInitializer bungeeChannelInitializer) { - handlerInfo.addProperty("oldInit", bungeeChannelInitializer.getOriginal().getClass().getName()); - } - } catch (ReflectiveOperationException e) { - // Don't display - } - - pipeline.add(handlerInfo); - } - channelInfo.add("pipeline", pipeline); - - injectedChannelInitializers.add(channelInfo); - } - - data.add("injectedChannelInitializers", injectedChannelInitializers); - - try { - Object list = LISTENERS_FIELD.get(ProxyServer.getInstance()); - data.addProperty("currentList", list.getClass().getName()); - if (list instanceof SetWrapper wrapper) { - data.addProperty("wrappedList", wrapper.originalSet().getClass().getName()); - } - } catch (ReflectiveOperationException ignored) { - // Ignored - } - - return data; - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaLoader.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaLoader.java deleted file mode 100644 index 7d952a8e5..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaLoader.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.platform; - -import com.viaversion.viaversion.BungeePlugin; -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.platform.ViaPlatformLoader; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.api.protocol.version.VersionProvider; -import com.viaversion.viaversion.bungee.handlers.BungeeServerHandler; -import com.viaversion.viaversion.bungee.listeners.ElytraPatch; -import com.viaversion.viaversion.bungee.listeners.UpdateListener; -import com.viaversion.viaversion.bungee.providers.BungeeBossBarProvider; -import com.viaversion.viaversion.bungee.providers.BungeeEntityIdProvider; -import com.viaversion.viaversion.bungee.providers.BungeeMainHandProvider; -import com.viaversion.viaversion.bungee.providers.BungeeVersionProvider; -import com.viaversion.viaversion.protocols.v1_8to1_9.provider.BossBarProvider; -import com.viaversion.viaversion.protocols.v1_8to1_9.provider.EntityIdProvider; -import com.viaversion.viaversion.protocols.v1_8to1_9.provider.MainHandProvider; -import java.util.HashSet; -import java.util.Set; -import java.util.concurrent.TimeUnit; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.plugin.Listener; -import net.md_5.bungee.api.scheduler.ScheduledTask; - -public class BungeeViaLoader implements ViaPlatformLoader { - private final Set listeners = new HashSet<>(); - private final Set tasks = new HashSet<>(); - private final BungeePlugin plugin; - - public BungeeViaLoader(BungeePlugin plugin) { - this.plugin = plugin; - } - - private void registerListener(Listener listener) { - listeners.add(listener); - ProxyServer.getInstance().getPluginManager().registerListener(plugin, listener); - } - - @Override - public void load() { - // Listeners - registerListener(plugin); - registerListener(new UpdateListener()); - registerListener(new BungeeServerHandler()); - - final ProtocolVersion protocolVersion = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion(); - if (protocolVersion.olderThan(ProtocolVersion.v1_9)) { - registerListener(new ElytraPatch()); - } - - // Providers - Via.getManager().getProviders().use(VersionProvider.class, new BungeeVersionProvider()); - Via.getManager().getProviders().use(EntityIdProvider.class, new BungeeEntityIdProvider()); - - if (protocolVersion.olderThan(ProtocolVersion.v1_9)) { - Via.getManager().getProviders().use(BossBarProvider.class, new BungeeBossBarProvider()); - Via.getManager().getProviders().use(MainHandProvider.class, new BungeeMainHandProvider()); - } - - if (plugin.getConf().getBungeePingInterval() > 0) { - tasks.add(plugin.getProxy().getScheduler().schedule( - plugin, - () -> Via.proxyPlatform().protocolDetectorService().probeAllServers(), - 0, plugin.getConf().getBungeePingInterval(), - TimeUnit.SECONDS - )); - } - } - - @Override - public void unload() { - for (Listener listener : listeners) { - ProxyServer.getInstance().getPluginManager().unregisterListener(listener); - } - listeners.clear(); - for (ScheduledTask task : tasks) { - task.cancel(); - } - tasks.clear(); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaTask.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaTask.java deleted file mode 100644 index 7294c8110..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/platform/BungeeViaTask.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.platform; - -import com.viaversion.viaversion.api.platform.PlatformTask; -import net.md_5.bungee.api.scheduler.ScheduledTask; - -public record BungeeViaTask(ScheduledTask task) implements PlatformTask { - - @Override - public void cancel() { - task.cancel(); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeBossBarProvider.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeBossBarProvider.java deleted file mode 100644 index e185a46be..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeBossBarProvider.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.providers; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.bungee.storage.BungeeStorage; -import com.viaversion.viaversion.protocols.v1_8to1_9.provider.BossBarProvider; -import java.util.UUID; - -public class BungeeBossBarProvider extends BossBarProvider { - @Override - public void handleAdd(UserConnection user, UUID barUUID) { - if (user.has(BungeeStorage.class)) { - BungeeStorage storage = user.get(BungeeStorage.class); - // Check if bossbars are supported by bungee, static maybe - if (storage.getBossbar() != null) { - storage.getBossbar().add(barUUID); - } - } - } - - @Override - public void handleRemove(UserConnection user, UUID barUUID) { - if (user.has(BungeeStorage.class)) { - BungeeStorage storage = user.get(BungeeStorage.class); - if (storage.getBossbar() != null) { - storage.getBossbar().remove(barUUID); - } - } - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeEntityIdProvider.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeEntityIdProvider.java deleted file mode 100644 index 889b0e14f..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeEntityIdProvider.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.providers; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.bungee.storage.BungeeStorage; -import com.viaversion.viaversion.protocols.v1_8to1_9.provider.EntityIdProvider; -import java.lang.reflect.Method; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public class BungeeEntityIdProvider extends EntityIdProvider { - private static final Method GET_CLIENT_ENTITY_ID; - - static { - try { - GET_CLIENT_ENTITY_ID = Class.forName("net.md_5.bungee.UserConnection").getDeclaredMethod("getClientEntityId"); - } catch (NoSuchMethodException | ClassNotFoundException e) { - throw new RuntimeException(e); - } - } - - @Override - public int getEntityId(UserConnection user) throws Exception { - BungeeStorage storage = user.get(BungeeStorage.class); - ProxiedPlayer player = storage.getPlayer(); - - return (int) GET_CLIENT_ENTITY_ID.invoke(player); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMainHandProvider.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMainHandProvider.java deleted file mode 100644 index 9fc96338b..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeMainHandProvider.java +++ /dev/null @@ -1,60 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.providers; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.connection.ProtocolInfo; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.protocols.v1_8to1_9.provider.MainHandProvider; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.logging.Level; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -/* - This solves the wrong main hand issue when you join with BungeeCord on a 1.8 server, and switch to a 1.9 or higher. - */ -public class BungeeMainHandProvider extends MainHandProvider { - private static Method getSettings; - private static Method setMainHand; - - static { - try { - getSettings = Class.forName("net.md_5.bungee.UserConnection").getDeclaredMethod("getSettings"); - setMainHand = Class.forName("net.md_5.bungee.protocol.packet.ClientSettings").getDeclaredMethod("setMainHand", int.class); - } catch (Exception ignored) { - } - } - - @Override - public void setMainHand(UserConnection user, int hand) { - ProtocolInfo info = user.getProtocolInfo(); - if (info == null || info.getUuid() == null) return; - ProxiedPlayer player = ProxyServer.getInstance().getPlayer(info.getUuid()); - if (player == null) return; - try { - Object settings = getSettings.invoke(player); - if (settings != null) { - setMainHand.invoke(settings, hand); - } - } catch (IllegalAccessException | InvocationTargetException e) { - Via.getPlatform().getLogger().log(Level.WARNING, "Failed to set main hand for " + player.getName(), e); - } - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java deleted file mode 100644 index c78e8d10a..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/providers/BungeeVersionProvider.java +++ /dev/null @@ -1,80 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.providers; - -import com.google.common.collect.Lists; -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.connection.ProtocolInfo; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.protocol.version.BaseVersionProvider; -import com.viaversion.viaversion.util.ReflectionUtil; -import java.util.ArrayList; -import java.util.Collections; -import java.util.HashSet; -import java.util.List; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.protocol.ProtocolConstants; - -public class BungeeVersionProvider extends BaseVersionProvider { - - @Override - public ProtocolVersion getClosestServerProtocol(UserConnection user) throws Exception { - // TODO Have one constant list forever until restart? (Might limit plugins if they change this) - List list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class); - List sorted = new ArrayList<>(list); - Collections.sort(sorted); - - ProtocolInfo info = user.getProtocolInfo(); - - // Bungee supports it - final ProtocolVersion clientProtocolVersion = info.protocolVersion(); - if (new HashSet<>(sorted).contains(clientProtocolVersion.getVersion())) { - return clientProtocolVersion; - } - - // Older than bungee supports, get the lowest version - if (clientProtocolVersion.getVersion() < sorted.get(0)) { - return getLowestSupportedVersion(); - } - - // Loop through all protocols to get the closest protocol id that bungee supports (and that viaversion does too) - - // TODO: This needs a better fix, i.e checking ProtocolRegistry to see if it would work. - // This is more of a workaround for snapshot support by bungee. - for (Integer protocol : Lists.reverse(sorted)) { - if (clientProtocolVersion.getVersion() > protocol && ProtocolVersion.isRegistered(protocol)) { - return ProtocolVersion.getProtocol(protocol); - } - } - - Via.getPlatform().getLogger().severe("Panic, no protocol id found for " + clientProtocolVersion); - return clientProtocolVersion; - } - - public static ProtocolVersion getLowestSupportedVersion() { - List list; - try { - list = ReflectionUtil.getStatic(ProtocolConstants.class, "SUPPORTED_VERSION_IDS", List.class); - return ProtocolVersion.getProtocol(list.get(0)); - } catch (NoSuchFieldException | IllegalAccessException ignored) { - // Fallback - return ProtocolVersion.getProtocol(ProxyServer.getInstance().getProtocolVersion()); - } - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/service/ProtocolDetectorService.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/service/ProtocolDetectorService.java deleted file mode 100644 index 30cc097a9..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/service/ProtocolDetectorService.java +++ /dev/null @@ -1,94 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.service; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.bungee.platform.BungeeViaConfig; -import com.viaversion.viaversion.bungee.providers.BungeeVersionProvider; -import com.viaversion.viaversion.platform.AbstractProtocolDetectorService; -import java.util.Collection; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import net.md_5.bungee.api.ProxyServer; -import net.md_5.bungee.api.config.ServerInfo; - -public final class ProtocolDetectorService extends AbstractProtocolDetectorService { - - public void probeServer(final ServerInfo serverInfo) { - final String serverName = serverInfo.getName(); - serverInfo.ping((serverPing, throwable) -> { - // Ensure protocol is positive, some services will return -1 - if (throwable != null || serverPing == null || serverPing.getVersion() == null || serverPing.getVersion().getProtocol() <= 0) { - return; - } - - final int oldProtocolVersion = serverProtocolVersion(serverName).getVersion(); - if (oldProtocolVersion == serverPing.getVersion().getProtocol()) { - // Same value as previously - return; - } - - setProtocolVersion(serverName, serverPing.getVersion().getProtocol()); - - final BungeeViaConfig config = (BungeeViaConfig) Via.getConfig(); - if (config.isBungeePingSave()) { - final Map servers = config.getBungeeServerProtocols(); - final Integer protocol = servers.get(serverName); - if (protocol != null && protocol == serverPing.getVersion().getProtocol()) { - return; - } - - // Ensure we're the only ones writing to the config - synchronized (Via.getManager().getConfigurationProvider()) { - servers.put(serverName, serverPing.getVersion().getProtocol()); - } - config.save(); - } - }); - } - - @Override - public void probeAllServers() { - final Collection servers = ProxyServer.getInstance().getServers().values(); - final Set serverNames = new HashSet<>(servers.size()); - for (final ServerInfo serverInfo : servers) { - probeServer(serverInfo); - serverNames.add(serverInfo.getName()); - } - - // Remove servers that aren't registered anymore - lock.writeLock().lock(); - try { - detectedProtocolIds.keySet().retainAll(serverNames); - } finally { - lock.writeLock().unlock(); - } - } - - @Override - protected Map configuredServers() { - return ((BungeeViaConfig) Via.getConfig()).getBungeeServerProtocols(); - } - - @Override - protected ProtocolVersion lowestSupportedProtocolVersion() { - return BungeeVersionProvider.getLowestSupportedVersion(); - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/storage/BungeeStorage.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/storage/BungeeStorage.java deleted file mode 100644 index 54470223b..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/storage/BungeeStorage.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.storage; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.connection.StorableObject; -import java.lang.reflect.Field; -import java.util.Objects; -import java.util.Set; -import java.util.UUID; -import java.util.logging.Level; -import net.md_5.bungee.api.connection.ProxiedPlayer; - -public class BungeeStorage implements StorableObject { - private static Field bossField; - - static { - try { - Class user = Class.forName("net.md_5.bungee.UserConnection"); - bossField = user.getDeclaredField("sentBossBars"); - bossField.setAccessible(true); - } catch (ClassNotFoundException e) { - // Not supported *shrug* probably modified - } catch (NoSuchFieldException e) { - // Not supported, old version probably - } - } - - private final ProxiedPlayer player; - private String currentServer; - private Set bossbar; - - public BungeeStorage(ProxiedPlayer player) { - this.player = player; - this.currentServer = ""; - - // Get bossbar list if it's supported - if (bossField != null) { - try { - bossbar = (Set) bossField.get(player); - } catch (IllegalAccessException e) { - Via.getPlatform().getLogger().log(Level.WARNING, "Failed to get bossbar list", e); - } - } - } - - public ProxiedPlayer getPlayer() { - return player; - } - - public String getCurrentServer() { - return currentServer; - } - - public void setCurrentServer(String currentServer) { - this.currentServer = currentServer; - } - - public Set getBossbar() { - return bossbar; - } - - @Override - public boolean equals(final Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - BungeeStorage that = (BungeeStorage) o; - if (!Objects.equals(player, that.player)) return false; - if (!Objects.equals(currentServer, that.currentServer)) return false; - return Objects.equals(bossbar, that.bossbar); - } - - @Override - public int hashCode() { - int result = player != null ? player.hashCode() : 0; - result = 31 * result + (currentServer != null ? currentServer.hashCode() : 0); - result = 31 * result + (bossbar != null ? bossbar.hashCode() : 0); - return result; - } -} diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/util/BungeePipelineUtil.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/util/BungeePipelineUtil.java deleted file mode 100644 index 3288df7d2..000000000 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/util/BungeePipelineUtil.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.bungee.util; - -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToByteEncoder; -import io.netty.handler.codec.MessageToMessageDecoder; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.List; - -public class BungeePipelineUtil { - private static final Method DECODE_METHOD; - private static final Method ENCODE_METHOD; - - static { - try { - DECODE_METHOD = MessageToMessageDecoder.class.getDeclaredMethod("decode", ChannelHandlerContext.class, Object.class, List.class); - DECODE_METHOD.setAccessible(true); - ENCODE_METHOD = MessageToByteEncoder.class.getDeclaredMethod("encode", ChannelHandlerContext.class, Object.class, ByteBuf.class); - ENCODE_METHOD.setAccessible(true); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - public static List callDecode(MessageToMessageDecoder decoder, ChannelHandlerContext ctx, ByteBuf input) throws InvocationTargetException { - List output = new ArrayList<>(); - try { - BungeePipelineUtil.DECODE_METHOD.invoke(decoder, ctx, input, output); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return output; - } - - public static ByteBuf callEncode(MessageToByteEncoder encoder, ChannelHandlerContext ctx, ByteBuf input) throws InvocationTargetException { - ByteBuf output = ctx.alloc().buffer(); - try { - BungeePipelineUtil.ENCODE_METHOD.invoke(encoder, ctx, input, output); - } catch (IllegalAccessException e) { - e.printStackTrace(); - } - return output; - } - - public static ByteBuf decompress(ChannelHandlerContext ctx, ByteBuf bytebuf) { - try { - return (ByteBuf) callDecode((MessageToMessageDecoder) ctx.pipeline().get("decompress"), ctx.pipeline().context("decompress"), bytebuf).get(0); - } catch (InvocationTargetException e) { - e.printStackTrace(); - return ctx.alloc().buffer(); - } - } - - public static ByteBuf compress(ChannelHandlerContext ctx, ByteBuf bytebuf) { - try { - return callEncode((MessageToByteEncoder) ctx.pipeline().get("compress"), ctx.pipeline().context("compress"), bytebuf); - } catch (InvocationTargetException e) { - e.printStackTrace(); - return ctx.alloc().buffer(); - } - } -} diff --git a/bungee/src/main/resources/bungee.yml b/bungee/src/main/resources/bungee.yml deleted file mode 100644 index 99ae4be8d..000000000 --- a/bungee/src/main/resources/bungee.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: ViaVersion -main: com.viaversion.viaversion.BungeePlugin -description: ${description} -author: _MylesC, creeper123123321, Gerrygames, kennytv, Matsv, EnZaXD, RK_01 -version: ${version} \ No newline at end of file diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/EntityPacketRewriter1_14.java b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/EntityPacketRewriter1_14.java index 84c83c618..7ef415ee1 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/EntityPacketRewriter1_14.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/v1_13_2to1_14/rewriter/EntityPacketRewriter1_14.java @@ -37,7 +37,7 @@ import com.viaversion.viaversion.protocols.v1_13_2to1_14.Protocol1_13_2To1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.packet.ClientboundPackets1_14; import com.viaversion.viaversion.protocols.v1_13_2to1_14.storage.EntityTracker1_14; import com.viaversion.viaversion.rewriter.EntityRewriter; -import java.util.LinkedList; +import java.util.ArrayList; import java.util.List; public class EntityPacketRewriter1_14 extends EntityRewriter { @@ -184,7 +184,7 @@ public class EntityPacketRewriter1_14 extends EntityRewriter metadataList = new LinkedList<>(); + List metadataList = new ArrayList<>(); if (tracker.clientEntityId() != entityId) { metadataList.add(new EntityData(6, Types1_14.ENTITY_DATA_TYPES.poseType, EntityPacketRewriter1_14.recalculatePlayerPose(entityId, tracker))); } @@ -242,7 +242,7 @@ public class EntityPacketRewriter1_14 extends EntityRewriter metadataList = new LinkedList<>(); + List metadataList = new ArrayList<>(); metadataList.add(new EntityData(12, Types1_14.ENTITY_DATA_TYPES.optionalBlockPositionType, position)); if (tracker.clientEntityId() != entityId) { metadataList.add(new EntityData(6, Types1_14.ENTITY_DATA_TYPES.poseType, EntityPacketRewriter1_14.recalculatePlayerPose(entityId, tracker))); diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 29e515b99..f308b8dde 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -19,8 +19,6 @@ checkerQual = "3.43.0" # Platforms paper = "1.20.4-R0.1-SNAPSHOT" legacyBukkit = "1.8.8-R0.1-SNAPSHOT" -bungee = "1.20-R0.3-SNAPSHOT" -sponge = "8.0.0" velocity = "3.1.1" @@ -43,8 +41,6 @@ checkerQual = { group = "org.checkerframework", name = "checker-qual", version.r paper = { group = "io.papermc.paper", name = "paper-api", version.ref = "paper" } legacyBukkit = { group = "org.bukkit", name = "bukkit", version.ref = "legacyBukkit" } -bungee = { group = "net.md-5", name = "bungeecord-api", version.ref = "bungee" } -sponge = { group = "org.spongepowered", name = "spongeapi", version.ref = "sponge" } velocity = { group = "com.velocitypowered", name = "velocity-api", version.ref = "velocity" } diff --git a/settings.gradle.kts b/settings.gradle.kts index 46c8706f0..976ffcefb 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -5,9 +5,6 @@ dependencyResolutionManagement { repositories { maven("https://repo.viaversion.com") maven("https://repo.papermc.io/repository/maven-public/") - maven("https://oss.sonatype.org/content/repositories/snapshots/") - maven("https://repo.spongepowered.org/repository/maven-public/") - maven("https://libraries.minecraft.net") mavenCentral() } // only use these repos @@ -33,9 +30,7 @@ setupViaSubproject("api") setupViaSubproject("common") setupViaSubproject("bukkit") setupViaSubproject("bukkit-legacy") -setupViaSubproject("bungee") setupViaSubproject("velocity") -setupViaSubproject("sponge") setupViaSubproject("fabric") setupViaSubproject("template") diff --git a/sponge/build.gradle.kts b/sponge/build.gradle.kts deleted file mode 100644 index daff96f27..000000000 --- a/sponge/build.gradle.kts +++ /dev/null @@ -1,6 +0,0 @@ -dependencies { - compileOnlyApi(projects.viaversionCommon) - compileOnly(libs.sponge) -} - -publishShadowJar() diff --git a/sponge/src/main/java/com/viaversion/viaversion/SpongePlugin.java b/sponge/src/main/java/com/viaversion/viaversion/SpongePlugin.java deleted file mode 100644 index 09bbf87cc..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/SpongePlugin.java +++ /dev/null @@ -1,249 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion; - -import com.google.gson.JsonObject; -import com.google.inject.Inject; -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.command.ViaCommandSender; -import com.viaversion.viaversion.api.platform.PlatformTask; -import com.viaversion.viaversion.api.platform.ViaPlatform; -import com.viaversion.viaversion.dump.PluginInfo; -import com.viaversion.viaversion.sponge.commands.SpongeCommandHandler; -import com.viaversion.viaversion.sponge.commands.SpongePlayer; -import com.viaversion.viaversion.sponge.platform.SpongeViaAPI; -import com.viaversion.viaversion.sponge.platform.SpongeViaConfig; -import com.viaversion.viaversion.sponge.platform.SpongeViaInjector; -import com.viaversion.viaversion.sponge.platform.SpongeViaLoader; -import com.viaversion.viaversion.sponge.platform.SpongeViaTask; -import com.viaversion.viaversion.sponge.util.LoggerWrapper; -import com.viaversion.viaversion.util.GsonUtil; -import java.io.File; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; -import java.util.UUID; -import java.util.logging.Logger; -import java.util.stream.Collectors; -import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer; -import org.spongepowered.api.Game; -import org.spongepowered.api.Platform; -import org.spongepowered.api.Server; -import org.spongepowered.api.Sponge; -import org.spongepowered.api.command.Command; -import org.spongepowered.api.config.ConfigDir; -import org.spongepowered.api.entity.living.player.Player; -import org.spongepowered.api.entity.living.player.server.ServerPlayer; -import org.spongepowered.api.event.Listener; -import org.spongepowered.api.event.lifecycle.ConstructPluginEvent; -import org.spongepowered.api.event.lifecycle.StartedEngineEvent; -import org.spongepowered.api.event.lifecycle.StartingEngineEvent; -import org.spongepowered.api.event.lifecycle.StoppingEngineEvent; -import org.spongepowered.api.scheduler.Task; -import org.spongepowered.api.util.Ticks; -import org.spongepowered.plugin.PluginContainer; -import org.spongepowered.plugin.builtin.jvm.Plugin; -import org.spongepowered.plugin.metadata.PluginMetadata; -import org.spongepowered.plugin.metadata.model.PluginContributor; - -@Plugin("viaversion") -public class SpongePlugin implements ViaPlatform { - - public static final LegacyComponentSerializer LEGACY_SERIALIZER = LegacyComponentSerializer.builder().extractUrls().build(); - private final SpongeViaAPI api = new SpongeViaAPI(); - private final PluginContainer container; - private final Game game; - @SuppressWarnings("SpongeLogging") - private final Logger logger; - private SpongeViaConfig conf; - @Inject - @ConfigDir(sharedRoot = false) - private Path configDir; - - @Inject - SpongePlugin(final PluginContainer container, final Game game, final org.apache.logging.log4j.Logger logger) { - this.container = container; - this.game = game; - this.logger = new LoggerWrapper(logger); - } - - @Listener - public void constructPlugin(ConstructPluginEvent event) { - // Setup Plugin - conf = new SpongeViaConfig(configDir.toFile(), getLogger()); - - // Init platform - Via.init(ViaManagerImpl.builder() - .platform(this) - .commandHandler(new SpongeCommandHandler()) - .injector(new SpongeViaInjector()) - .loader(new SpongeViaLoader(this)) - .build()); - conf.reload(); - } - - @Listener - public void onServerStart(StartingEngineEvent event) { - // Can't use the command register event for raw commands... - Sponge.server().commandManager().registrar(Command.Raw.class).get().register(container, (Command.Raw) Via.getManager().getCommandHandler(), "viaversion", "viaver", "vvsponge"); - - final ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); - manager.init(); - } - - @Listener - public void onServerStarted(StartedEngineEvent event) { - final ViaManagerImpl manager = (ViaManagerImpl) Via.getManager(); - manager.onServerLoaded(); - } - - @Listener - public void onServerStop(StoppingEngineEvent event) { - ((ViaManagerImpl) Via.getManager()).destroy(); - } - - @Override - public String getPlatformName() { - return game.platform().container(Platform.Component.IMPLEMENTATION).metadata().name().orElse("unknown"); - } - - @Override - public String getPlatformVersion() { - return game.platform().container(Platform.Component.IMPLEMENTATION).metadata().version().toString(); - } - - @Override - public String getPluginVersion() { - return container.metadata().version().toString(); - } - - @Override - public PlatformTask runAsync(Runnable runnable) { - final Task task = Task.builder().plugin(container).execute(runnable).build(); - return new SpongeViaTask(game.asyncScheduler().submit(task)); - } - - @Override - public PlatformTask runRepeatingAsync(final Runnable runnable, final long ticks) { - final Task task = Task.builder().plugin(container).execute(runnable).interval(Ticks.of(ticks)).build(); - return new SpongeViaTask(game.asyncScheduler().submit(task)); - } - - @Override - public PlatformTask runSync(Runnable runnable) { - final Task task = Task.builder().plugin(container).execute(runnable).build(); - return new SpongeViaTask(game.server().scheduler().submit(task)); - } - - @Override - public PlatformTask runSync(Runnable runnable, long delay) { - final Task task = Task.builder().plugin(container).execute(runnable).delay(Ticks.of(delay)).build(); - return new SpongeViaTask(game.server().scheduler().submit(task)); - } - - @Override - public PlatformTask runRepeatingSync(Runnable runnable, long period) { - final Task task = Task.builder().plugin(container).execute(runnable).interval(Ticks.of(period)).build(); - return new SpongeViaTask(game.server().scheduler().submit(task)); - } - - @Override - public ViaCommandSender[] getOnlinePlayers() { - Collection players = game.server().onlinePlayers(); - ViaCommandSender[] array = new ViaCommandSender[players.size()]; - int i = 0; - for (ServerPlayer player : players) { - array[i++] = new SpongePlayer(player); - } - return array; - } - - @Override - public void sendMessage(UUID uuid, String message) { - game.server().player(uuid).ifPresent(player -> player.sendMessage(LEGACY_SERIALIZER.deserialize(message))); - } - - @Override - public boolean kickPlayer(UUID uuid, String message) { - return game.server().player(uuid).map(player -> { - player.kick(LegacyComponentSerializer.legacySection().deserialize(message)); - return true; - }).orElse(false); - } - - @Override - public boolean isPluginEnabled() { - return true; - } - - @Override - public File getDataFolder() { - return configDir.toFile(); - } - - @Override - public void onReload() { - logger.severe("ViaVersion is already loaded, this should work fine. If you get any console errors, try rebooting."); - } - - @Override - public JsonObject getDump() { - JsonObject platformSpecific = new JsonObject(); - - List plugins = new ArrayList<>(); - for (PluginContainer plugin : game.pluginManager().plugins()) { - PluginMetadata metadata = plugin.metadata(); - plugins.add(new PluginInfo( - true, - metadata.name().orElse("Unknown"), - metadata.version().toString(), - plugin.instance() != null ? plugin.instance().getClass().getCanonicalName() : "Unknown", - metadata.contributors().stream().map(PluginContributor::name).collect(Collectors.toList()) - )); - } - platformSpecific.add("plugins", GsonUtil.getGson().toJsonTree(plugins)); - - return platformSpecific; - } - - @Override - public boolean hasPlugin(final String name) { - return game.pluginManager().plugin(name).isPresent(); - } - - @Override - public SpongeViaAPI getApi() { - return api; - } - - @Override - public SpongeViaConfig getConf() { - return conf; - } - - @Override - public Logger getLogger() { - return logger; - } - - public PluginContainer container() { - return container; - } - -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongeCommandHandler.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongeCommandHandler.java deleted file mode 100644 index 9a1d34c05..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongeCommandHandler.java +++ /dev/null @@ -1,71 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.commands; - -import com.viaversion.viaversion.commands.ViaCommandHandler; -import java.util.List; -import java.util.Optional; -import java.util.stream.Collectors; -import net.kyori.adventure.text.Component; -import org.jetbrains.annotations.NotNull; -import org.spongepowered.api.command.Command; -import org.spongepowered.api.command.CommandCause; -import org.spongepowered.api.command.CommandCompletion; -import org.spongepowered.api.command.CommandResult; -import org.spongepowered.api.command.parameter.ArgumentReader; - -public class SpongeCommandHandler extends ViaCommandHandler implements Command.Raw { - - @Override - public CommandResult process(CommandCause cause, ArgumentReader.Mutable arguments) { - String[] args = !arguments.input().isEmpty() ? arguments.input().split(" ") : new String[0]; - onCommand(new SpongeCommandSender(cause), args); - return CommandResult.success(); - } - - @Override - public List complete(CommandCause cause, ArgumentReader.Mutable arguments) { - String[] args = arguments.input().split(" ", -1); // ViaCommandHandler handles empty String in array. -1: do not discard empty strings - return onTabComplete(new SpongeCommandSender(cause), args).stream().map(CommandCompletion::of).collect(Collectors.toList()); - } - - @Override - public boolean canExecute(CommandCause cause) { - return cause.hasPermission("viaversion.command"); - } - - @Override - public Optional shortDescription(CommandCause cause) { - return Optional.of(Component.text("Shows ViaVersion Version and more.")); - } - - @Override - public Optional extendedDescription(CommandCause cause) { - return shortDescription(cause); - } - - @Override - public Optional help(@NotNull CommandCause cause) { - return Optional.empty(); - } - - @Override - public Component usage(CommandCause cause) { - return Component.text("Usage /viaversion"); - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongeCommandSender.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongeCommandSender.java deleted file mode 100644 index d5b088030..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongeCommandSender.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.commands; - -import com.viaversion.viaversion.SpongePlugin; -import com.viaversion.viaversion.api.command.ViaCommandSender; -import java.util.UUID; -import net.kyori.adventure.identity.Identity; -import org.spongepowered.api.command.CommandCause; -import org.spongepowered.api.util.Identifiable; - -public class SpongeCommandSender implements ViaCommandSender { - private final CommandCause source; - - public SpongeCommandSender(CommandCause source) { - this.source = source; - } - - @Override - public boolean hasPermission(String permission) { - return source.hasPermission(permission); - } - - @Override - public void sendMessage(String msg) { - source.sendMessage(Identity.nil(), SpongePlugin.LEGACY_SERIALIZER.deserialize(msg)); - } - - @Override - public UUID getUUID() { - if (source instanceof Identifiable identifiable) { - return identifiable.uniqueId(); - } else { - return new UUID(0, 0); - } - - } - - @Override - public String getName() { - return source.friendlyIdentifier().orElse(source.identifier()); - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongePlayer.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongePlayer.java deleted file mode 100644 index 1d638db67..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/commands/SpongePlayer.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.commands; - -import com.viaversion.viaversion.SpongePlugin; -import com.viaversion.viaversion.api.command.ViaCommandSender; -import java.util.UUID; -import org.spongepowered.api.entity.living.player.server.ServerPlayer; - -public class SpongePlayer implements ViaCommandSender { - private final ServerPlayer player; - - public SpongePlayer(ServerPlayer player) { - this.player = player; - } - - @Override - public boolean hasPermission(String permission) { - return player.hasPermission(permission); - } - - @Override - public void sendMessage(String msg) { - player.sendMessage(SpongePlugin.LEGACY_SERIALIZER.deserialize(msg)); - } - - @Override - public UUID getUUID() { - return player.uniqueId(); - } - - @Override - public String getName() { - return player.friendlyIdentifier().orElse(player.identifier()); - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeChannelInitializer.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeChannelInitializer.java deleted file mode 100644 index ead126943..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeChannelInitializer.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.handlers; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.connection.UserConnectionImpl; -import com.viaversion.viaversion.platform.WrappedChannelInitializer; -import com.viaversion.viaversion.protocol.ProtocolPipelineImpl; -import io.netty.channel.Channel; -import io.netty.channel.ChannelInitializer; -import io.netty.channel.socket.SocketChannel; -import io.netty.handler.codec.ByteToMessageDecoder; -import io.netty.handler.codec.MessageToByteEncoder; -import java.lang.reflect.Method; - -public class SpongeChannelInitializer extends ChannelInitializer implements WrappedChannelInitializer { - - private static final Method INIT_CHANNEL_METHOD; - private final ChannelInitializer original; - - static { - try { - INIT_CHANNEL_METHOD = ChannelInitializer.class.getDeclaredMethod("initChannel", Channel.class); - INIT_CHANNEL_METHOD.setAccessible(true); - } catch (NoSuchMethodException e) { - throw new RuntimeException(e); - } - } - - public SpongeChannelInitializer(ChannelInitializer oldInit) { - this.original = oldInit; - } - - @Override - protected void initChannel(Channel channel) throws Exception { - // Ensure ViaVersion is loaded - if (Via.getAPI().getServerVersion().isKnown() - && channel instanceof SocketChannel) { // channel can be LocalChannel on internal server - UserConnection info = new UserConnectionImpl(channel); - // init protocol - new ProtocolPipelineImpl(info); - // Add originals - INIT_CHANNEL_METHOD.invoke(this.original, channel); - // Add our transformers - MessageToByteEncoder encoder = new SpongeEncodeHandler(info, (MessageToByteEncoder) channel.pipeline().get("encoder")); - ByteToMessageDecoder decoder = new SpongeDecodeHandler(info, (ByteToMessageDecoder) channel.pipeline().get("decoder")); - - channel.pipeline().replace("encoder", "encoder", encoder); - channel.pipeline().replace("decoder", "decoder", decoder); - } else { - INIT_CHANNEL_METHOD.invoke(this.original, channel); - } - } - - @Override - public ChannelInitializer original() { - return original; - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeDecodeHandler.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeDecodeHandler.java deleted file mode 100644 index 39900886f..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeDecodeHandler.java +++ /dev/null @@ -1,66 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.handlers; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.exception.CancelCodecException; -import com.viaversion.viaversion.exception.CancelDecoderException; -import com.viaversion.viaversion.util.PipelineUtil; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.ByteToMessageDecoder; -import java.util.List; - -public class SpongeDecodeHandler extends ByteToMessageDecoder { - - private final ByteToMessageDecoder minecraftDecoder; - private final UserConnection info; - - public SpongeDecodeHandler(UserConnection info, ByteToMessageDecoder minecraftDecoder) { - this.info = info; - this.minecraftDecoder = minecraftDecoder; - } - - @Override - protected void decode(ChannelHandlerContext ctx, ByteBuf bytebuf, List list) throws Exception { - if (!info.checkServerboundPacket()) { - bytebuf.clear(); // Don't accumulate - throw CancelDecoderException.generate(null); - } - - ByteBuf transformedBuf = null; - try { - if (info.shouldTransformPacket()) { - transformedBuf = ctx.alloc().buffer().writeBytes(bytebuf); - info.transformServerbound(transformedBuf, CancelDecoderException::generate); - } - - list.addAll(PipelineUtil.callDecode(this.minecraftDecoder, ctx, transformedBuf == null ? bytebuf : transformedBuf)); - } finally { - if (transformedBuf != null) { - transformedBuf.release(); - } - } - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if (cause instanceof CancelCodecException) return; - super.exceptionCaught(ctx, cause); - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeEncodeHandler.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeEncodeHandler.java deleted file mode 100644 index 095ee4b1c..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/handlers/SpongeEncodeHandler.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.handlers; - -import com.viaversion.viaversion.api.connection.UserConnection; -import com.viaversion.viaversion.exception.CancelCodecException; -import com.viaversion.viaversion.exception.CancelEncoderException; -import com.viaversion.viaversion.handlers.ChannelHandlerContextWrapper; -import com.viaversion.viaversion.handlers.ViaCodecHandler; -import com.viaversion.viaversion.util.PipelineUtil; -import io.netty.buffer.ByteBuf; -import io.netty.channel.ChannelHandlerContext; -import io.netty.handler.codec.MessageToByteEncoder; -import java.lang.reflect.InvocationTargetException; - -public class SpongeEncodeHandler extends MessageToByteEncoder implements ViaCodecHandler { - private final UserConnection info; - private final MessageToByteEncoder minecraftEncoder; - - public SpongeEncodeHandler(UserConnection info, MessageToByteEncoder minecraftEncoder) { - this.info = info; - this.minecraftEncoder = minecraftEncoder; - } - - @Override - protected void encode(final ChannelHandlerContext ctx, Object o, final ByteBuf bytebuf) throws Exception { - // handle the packet type - if (!(o instanceof ByteBuf buf)) { - // call minecraft encoder - try { - PipelineUtil.callEncode(this.minecraftEncoder, new ChannelHandlerContextWrapper(ctx, this), o, bytebuf); - } catch (InvocationTargetException e) { - if (e.getCause() instanceof Exception cause) { - throw cause; - } else if (e.getCause() instanceof Error cause) { - throw cause; - } - } - } else { - bytebuf.writeBytes(buf); - } - transform(bytebuf); - } - - @Override - public void transform(ByteBuf bytebuf) throws Exception { - if (!info.checkClientboundPacket()) throw CancelEncoderException.generate(null); - if (!info.shouldTransformPacket()) return; - info.transformClientbound(bytebuf, CancelEncoderException::generate); - } - - @Override - public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) throws Exception { - if (cause instanceof CancelCodecException) return; - super.exceptionCaught(ctx, cause); - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/listeners/UpdateListener.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/listeners/UpdateListener.java deleted file mode 100644 index c3369a874..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/listeners/UpdateListener.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.listeners; - -import com.viaversion.viaversion.api.Via; -import com.viaversion.viaversion.update.UpdateUtil; -import org.spongepowered.api.event.Listener; -import org.spongepowered.api.event.network.ServerSideConnectionEvent; - -public class UpdateListener { - - @Listener - public void onJoin(ServerSideConnectionEvent.Join join) { - if (join.player().hasPermission("viaversion.update") && Via.getConfig().isCheckForUpdates()) { - UpdateUtil.sendUpdateMessage(join.player().uniqueId()); - } - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/listeners/ViaSpongeListener.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/listeners/ViaSpongeListener.java deleted file mode 100644 index 7610e6e0e..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/listeners/ViaSpongeListener.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.listeners; - -import com.viaversion.viaversion.SpongePlugin; -import com.viaversion.viaversion.ViaListener; -import com.viaversion.viaversion.api.protocol.Protocol; -import java.lang.reflect.Field; -import org.spongepowered.api.Sponge; - -public class ViaSpongeListener extends ViaListener { - private static Field entityIdField; - - private final SpongePlugin plugin; - - public ViaSpongeListener(SpongePlugin plugin, Class requiredPipeline) { - super(requiredPipeline); - this.plugin = plugin; - } - - @Override - public void register() { - if (isRegistered()) return; - - Sponge.eventManager().registerListeners(plugin.container(), this); - setRegistered(true); - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaAPI.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaAPI.java deleted file mode 100644 index 83d2e62a8..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaAPI.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.platform; - -import com.viaversion.viaversion.ViaAPIBase; -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import io.netty.buffer.ByteBuf; -import org.spongepowered.api.entity.living.player.Player; - -public class SpongeViaAPI extends ViaAPIBase { - - @Override - public ProtocolVersion getPlayerProtocolVersion(Player player) { - return getPlayerProtocolVersion(player.uniqueId()); - } - - @Override - public void sendRawPacket(Player player, ByteBuf packet) throws IllegalArgumentException { - sendRawPacket(player.uniqueId(), packet); - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaConfig.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaConfig.java deleted file mode 100644 index 46e3c6d4c..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaConfig.java +++ /dev/null @@ -1,43 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.platform; - -import com.viaversion.viaversion.configuration.AbstractViaConfig; -import java.io.File; -import java.util.Arrays; -import java.util.List; -import java.util.Map; - -public class SpongeViaConfig extends AbstractViaConfig { - private static final List UNSUPPORTED = Arrays.asList("bungee-ping-interval", - "bungee-ping-save", "bungee-servers", "velocity-ping-interval", "velocity-ping-save", "velocity-servers", - "quick-move-action-fix", "change-1_9-hitbox", "change-1_14-hitbox", "blockconnection-method"); - - public SpongeViaConfig(File folder, java.util.logging.Logger logger) { - super(new File(folder, "config.yml"), logger); - } - - @Override - protected void handleConfig(Map config) { - } - - @Override - public List getUnsupportedOptions() { - return UNSUPPORTED; - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaInjector.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaInjector.java deleted file mode 100644 index 761b49475..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaInjector.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.platform; - -import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; -import com.viaversion.viaversion.platform.LegacyViaInjector; -import com.viaversion.viaversion.platform.WrappedChannelInitializer; -import com.viaversion.viaversion.sponge.handlers.SpongeChannelInitializer; -import io.netty.channel.Channel; -import io.netty.channel.ChannelHandler; -import io.netty.channel.ChannelInitializer; -import org.checkerframework.checker.nullness.qual.Nullable; -import org.spongepowered.api.MinecraftVersion; -import org.spongepowered.api.Sponge; - -public class SpongeViaInjector extends LegacyViaInjector { - - @Override - public ProtocolVersion getServerProtocolVersion() throws ReflectiveOperationException { - MinecraftVersion version = Sponge.platform().minecraftVersion(); - - // 'protocolVersion' method was exposed to the API in a 1.19.4 build and 'getProtocol' no longer exists in the impl. - try { - return ProtocolVersion.getProtocol((int) version.getClass().getDeclaredMethod("getProtocol").invoke(version)); - } catch (NoSuchMethodException e) { - return ProtocolVersion.getProtocol((int) version.getClass().getDeclaredMethod("protocolVersion").invoke(version)); - } - } - - @Override - protected @Nullable Object getServerConnection() throws ReflectiveOperationException { - Class serverClazz = Class.forName("net.minecraft.server.MinecraftServer"); - return serverClazz.getDeclaredMethod("getConnection").invoke(Sponge.server()); - } - - @Override - protected WrappedChannelInitializer createChannelInitializer(ChannelInitializer oldInitializer) { - return new SpongeChannelInitializer(oldInitializer); - } - - @Override - protected void blame(ChannelHandler bootstrapAcceptor) { - throw new RuntimeException("Unable to find core component 'childHandler', please check your plugins. Issue: " + bootstrapAcceptor.getClass().getName()); - } - - @Override - public String getEncoderName() { - return "encoder"; - } - - @Override - public String getDecoderName() { - return "decoder"; - } -} \ No newline at end of file diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaLoader.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaLoader.java deleted file mode 100644 index 3607cf29b..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaLoader.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.platform; - -import com.viaversion.viaversion.SpongePlugin; -import com.viaversion.viaversion.api.platform.PlatformTask; -import com.viaversion.viaversion.api.platform.ViaPlatformLoader; -import com.viaversion.viaversion.sponge.listeners.UpdateListener; -import java.util.HashSet; -import java.util.Set; -import org.spongepowered.api.Sponge; - -public class SpongeViaLoader implements ViaPlatformLoader { - - private final SpongePlugin plugin; - - private final Set listeners = new HashSet<>(); - private final Set tasks = new HashSet<>(); - - public SpongeViaLoader(SpongePlugin plugin) { - this.plugin = plugin; - } - - private void registerListener(Object listener) { - Sponge.eventManager().registerListeners(plugin.container(), storeListener(listener)); - } - - private T storeListener(T listener) { - listeners.add(listener); - return listener; - } - - @Override - public void load() { - // Update Listener - registerListener(new UpdateListener()); - } - - @Override - public void unload() { - listeners.forEach(Sponge.eventManager()::unregisterListeners); - listeners.clear(); - tasks.forEach(PlatformTask::cancel); - tasks.clear(); - } -} \ No newline at end of file diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaTask.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaTask.java deleted file mode 100644 index b507321cf..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/platform/SpongeViaTask.java +++ /dev/null @@ -1,29 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.platform; - -import com.viaversion.viaversion.api.platform.PlatformTask; -import org.spongepowered.api.scheduler.ScheduledTask; - -public record SpongeViaTask(ScheduledTask task) implements PlatformTask { - - @Override - public void cancel() { - task.cancel(); - } -} diff --git a/sponge/src/main/java/com/viaversion/viaversion/sponge/util/LoggerWrapper.java b/sponge/src/main/java/com/viaversion/viaversion/sponge/util/LoggerWrapper.java deleted file mode 100644 index f21bf8802..000000000 --- a/sponge/src/main/java/com/viaversion/viaversion/sponge/util/LoggerWrapper.java +++ /dev/null @@ -1,85 +0,0 @@ -/* - * This file is part of ViaVersion - https://github.com/ViaVersion/ViaVersion - * Copyright (C) 2016-2024 ViaVersion 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 . - */ -package com.viaversion.viaversion.sponge.util; - -import java.text.MessageFormat; -import java.util.logging.Level; -import java.util.logging.LogRecord; -import org.apache.logging.log4j.Logger; - -public class LoggerWrapper extends java.util.logging.Logger { - private final Logger base; - - public LoggerWrapper(Logger logger) { - super("logger", null); - this.base = logger; - } - - @Override - public void log(LogRecord record) { - log(record.getLevel(), record.getMessage()); - } - - @Override - public void log(Level level, String msg) { - if (level == Level.FINE) - base.debug(msg); - else if (level == Level.WARNING) - base.warn(msg); - else if (level == Level.SEVERE) - base.error(msg); - else if (level == Level.INFO) - base.info(msg); - else - base.trace(msg); - } - - @Override - public void log(Level level, String msg, Object param1) { - if (level == Level.FINE) - base.debug(msg, param1); - else if (level == Level.WARNING) - base.warn(msg, param1); - else if (level == Level.SEVERE) - base.error(msg, param1); - else if (level == Level.INFO) - base.info(msg, param1); - else - base.trace(msg, param1); - } - - @Override - public void log(Level level, String msg, Object[] params) { - log(level, MessageFormat.format(msg, params)); // workaround not formatting correctly - } - - @Override - public void log(Level level, String msg, Throwable params) { - if (level == Level.FINE) - base.debug(msg, params); - else if (level == Level.WARNING) - base.warn(msg, params); - else if (level == Level.SEVERE) - base.error(msg, params); - else if (level == Level.INFO) - base.info(msg, params); - else - base.trace(msg, params); - } - -} diff --git a/sponge/src/main/resources/META-INF/sponge_plugins.json b/sponge/src/main/resources/META-INF/sponge_plugins.json deleted file mode 100644 index c3d57a297..000000000 --- a/sponge/src/main/resources/META-INF/sponge_plugins.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "loader": { - "name": "java_plain", - "version": "1.0" - }, - "license": "GNU GPLv3", - "global": { - "version": "${version}", - "links": { - "homepage": "https://viaversion.com/", - "source": "https://github.com/ViaVersion/ViaVersion", - "issues": "https://github.com/ViaVersion/ViaVersion/issues" - }, - "contributors": [ - { - "name": "_MylesC", - "description": "Maintainer" - }, - { - "name": "creeper123123321", - "description": "Contributor" - }, - { - "name": "Gerrygames", - "description": "Contributor" - }, - { - "name": "kennytv", - "description": "Maintainer" - }, - { - "name": "Matsv", - "description": "Contributor" - }, - { - "name": "EnZaXD", - "description": "Contributor" - }, - { - "name": "RK_01", - "description": "Contributor" - } - ], - "dependencies": [ - { - "id": "spongeapi", - "version": "8.0.0" - } - ], - "branding": { - "logo": "assets/viaversion/textures/logo.png" - } - }, - "plugins": [ - { - "id": "viaversion", - "name": "ViaVersion", - "entrypoint": "com.viaversion.viaversion.SpongePlugin", - "description": "${description}" - } - ] -} \ No newline at end of file diff --git a/sponge/src/main/resources/assets/viaversion/textures/logo.png b/sponge/src/main/resources/assets/viaversion/textures/logo.png deleted file mode 100644 index 7b6cbc87e5368ad0899c4d83d1907819cefb1974..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 30715 zcmeIbc|6tK_cwf$Ib{lEo@JirF>?u-k15A+%=4I;qcRntC>#}qI5-HIohTtwMaGn| zjAfqP`{)|Fe6Me>-*eyh^ZfJV^@{WP?7h}r`@Pm)!`_=>FY9QWB&H>XKp-bCXsYT% zAjhB(2#ydTK6vB8P3jMR5P52v`amEjD6#)=AnBQBAP{0*Cl!^;mmNKPJ$xKJJee=3 zs4#nad)Pa@*5vlm9=6b?r3@FQxP)jE5}EiPU7TYAtJjN!}4g5 zN)JP>riM%R`eDrRgoKEjRC;_Qal``zlPuW@Q8_Vj?K_`?b6ooCHl{oGD?TX9pjMFO z-2_d9B&nLBdg2izPn8+TKSi~+y!t#TpcF~W?g=3yEVpCv*<-_jY=+6n@v=4%G(d2! zzB@q(Y0}PU5~7bjAe~jdZ-EnW4X4RBNlJ?_;xt4lC_yAt6isx zySgM2Do`!$UdMZI6pMAr6_xS|NX(MFuBi#10ITmppubg=3w-Ik& zMyg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l&!@b0FfqvY z;(4z$$f-x^3;0eH9%#8QE@htMD|6N!8`&3@tRYdGxFzsu+PS^g*JmweTp72}8RIO- z&Fyp{RaUDUXKos@!^eJ~+Dk5r97ndPRK#^5qnvaUY_>%uN4n zGRk+F@L~@)B{Xt6$YzEXErS6t=qrxfRP=DL{xN4(W?*L^XDdH{^eMOR=H}Vc@*gjSf zcT-qo|8oAbjlPdj(I_*6jitH$`ap5Yd=t^8Lg&W1f-nY5Tw0-3AO|0yzz?m~pO4bC zatjFXc8#yKZT)N`3f7W*>F()UY5ZZgU`TGLZQbeAXY9PArIIp^!IDO)czun*)NPf! z!IFC=P1TGKq)7bjA-|PuSjGpk~|epE+b7UlT3-5oyCjtU1@?85J=PgOhXHsLYUu1y#-z*HQN^U;%>{k zW@C(5BD2%OIg$odAi;N3l`hC3IJ`yd$@wIX*Od}w9h0O!bn`RzVli2_ z&@k@Y0h>DQSA}RnaDiG$&U^tov2ZrEV`8)2*z3d0S&9R!Py;enoT0=StwW+a-%c2d z85@+6vQRJw<5;nRYrn1=Z za21k_<@{l`DIJn@h*ti1Hk#O2gZ(w6bLrEeT)M4j;(l7(*AUCx?>~^y-o#c!rP*h2 zM3g?-a3!Ce!gloJd>QxPnl^fyMG@c0kLCx&+tJ!+2{r}%uM!zQ=9Hnrad;EFvI&U# vzj+n>KW~)(m#g6ad5io%Nq^iZ_ueJFt1Gnrm6`b&R;&wZI;zFWFvR}?0@`PD diff --git a/universal/build.gradle.kts b/universal/build.gradle.kts index a4c087857..0a56b6f12 100644 --- a/universal/build.gradle.kts +++ b/universal/build.gradle.kts @@ -6,10 +6,8 @@ plugins { dependencies { api(projects.viaversionCommon) api(projects.viaversionBukkit) - api(projects.viaversionBungee) - api(projects.viaversionFabric) - api(projects.viaversionSponge) api(projects.viaversionVelocity) + api(projects.viaversionFabric) } tasks {