From 45f8baf49e284bb5d06d89019ec445043bd5f3e0 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Sun, 22 Sep 2024 13:05:33 -0400 Subject: [PATCH] Remove GeyserPluginBootstrap as it's no longer necessary --- .../bungeecord/GeyserBungeeInjector.java | 6 ++-- .../bungeecord/GeyserBungeePlugin.java | 4 +-- .../platform/mod/GeyserModBootstrap.java | 4 +-- .../platform/mod/GeyserModInjector.java | 3 +- .../platform/spigot/GeyserSpigotInjector.java | 11 +++--- .../platform/spigot/GeyserSpigotPlugin.java | 4 +-- .../velocity/GeyserVelocityInjector.java | 4 +-- .../velocity/GeyserVelocityPlugin.java | 4 +-- .../viaproxy/GeyserViaProxyPlugin.java | 4 +-- .../geyser/GeyserPluginBootstrap.java | 36 ------------------- .../geyser/network/netty/GeyserInjector.java | 8 ++--- 11 files changed, 27 insertions(+), 61 deletions(-) delete mode 100644 core/src/main/java/org/geysermc/geyser/GeyserPluginBootstrap.java diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeInjector.java b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeInjector.java index 35d572cbd..f84702ead 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeInjector.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeeInjector.java @@ -40,8 +40,8 @@ import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.netty.PipelineUtils; import org.checkerframework.checker.nullness.qual.NonNull; +import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.network.netty.GeyserInjector; import org.geysermc.geyser.network.netty.LocalServerChannelWrapper; import org.geysermc.geyser.network.netty.LocalSession; @@ -67,7 +67,7 @@ public class GeyserBungeeInjector extends GeyserInjector implements Listener { @Override @SuppressWarnings("unchecked") - protected void initializeLocalChannel0(GeyserPluginBootstrap bootstrap) throws Exception { + protected void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Exception { // TODO - allow Geyser to specify its own listener info properties if (proxy.getConfig().getListeners().size() != 1) { throw new UnsupportedOperationException("Geyser does not currently support multiple listeners with injection! " + @@ -191,7 +191,7 @@ public class GeyserBungeeInjector extends GeyserInjector implements Listener { this.bungeeChannels = null; if (this.localChannel != null) { shutdown(); - initializeLocalChannel((GeyserPluginBootstrap) GeyserImpl.getInstance().getBootstrap()); + initializeLocalChannel(GeyserImpl.getInstance().getBootstrap()); } } } diff --git a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java index 9745b0497..70a4d082a 100644 --- a/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java +++ b/bootstrap/bungeecord/src/main/java/org/geysermc/geyser/platform/bungeecord/GeyserBungeePlugin.java @@ -34,8 +34,8 @@ import net.md_5.bungee.protocol.ProtocolConstants; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.FloodgateKeyLoader; +import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.command.CommandRegistry; import org.geysermc.geyser.command.CommandSourceConverter; @@ -62,7 +62,7 @@ import java.util.Collection; import java.util.Optional; import java.util.concurrent.TimeUnit; -public class GeyserBungeePlugin extends Plugin implements GeyserPluginBootstrap { +public class GeyserBungeePlugin extends Plugin implements GeyserBootstrap { private CommandRegistry commandRegistry; private GeyserPluginConfig geyserConfig; diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java index 75bae5acd..f229c4974 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModBootstrap.java @@ -32,9 +32,9 @@ import net.minecraft.server.MinecraftServer; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.FloodgateKeyLoader; +import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; -import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.command.CommandRegistry; import org.geysermc.geyser.configuration.ConfigLoader; @@ -52,7 +52,7 @@ import java.net.SocketAddress; import java.nio.file.Path; @RequiredArgsConstructor -public abstract class GeyserModBootstrap implements GeyserPluginBootstrap { +public abstract class GeyserModBootstrap implements GeyserBootstrap { @Getter private static GeyserModBootstrap instance; diff --git a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java index ccbc2a1e7..4bfc7464a 100644 --- a/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java +++ b/bootstrap/mod/src/main/java/org/geysermc/geyser/platform/mod/GeyserModInjector.java @@ -38,7 +38,6 @@ import net.minecraft.server.network.ServerConnectionListener; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.network.netty.GeyserInjector; import org.geysermc.geyser.network.netty.LocalServerChannelWrapper; import org.geysermc.geyser.platform.mod.platform.GeyserModPlatform; @@ -64,7 +63,7 @@ public class GeyserModInjector extends GeyserInjector { } @Override - protected void initializeLocalChannel0(GeyserPluginBootstrap bootstrap) throws Exception { + protected void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Exception { ServerConnectionListener connection = this.server.getConnection(); // Find the channel that Minecraft uses to listen to connections diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotInjector.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotInjector.java index a0ab1c839..c9500031a 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotInjector.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotInjector.java @@ -25,11 +25,13 @@ package org.geysermc.geyser.platform.spigot; -import org.geysermc.geyser.GeyserPluginBootstrap; -import org.geysermc.mcprotocollib.protocol.MinecraftProtocol; import com.viaversion.viaversion.bukkit.handlers.BukkitChannelInitializer; import io.netty.bootstrap.ServerBootstrap; -import io.netty.channel.*; +import io.netty.channel.Channel; +import io.netty.channel.ChannelFuture; +import io.netty.channel.ChannelHandler; +import io.netty.channel.ChannelInitializer; +import io.netty.channel.DefaultEventLoopGroup; import io.netty.channel.local.LocalAddress; import io.netty.util.concurrent.DefaultThreadFactory; import org.bukkit.Bukkit; @@ -38,6 +40,7 @@ import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.network.netty.GeyserInjector; import org.geysermc.geyser.network.netty.LocalServerChannelWrapper; import org.geysermc.geyser.network.netty.LocalSession; +import org.geysermc.mcprotocollib.protocol.MinecraftProtocol; import java.lang.reflect.Field; import java.lang.reflect.Method; @@ -61,7 +64,7 @@ public class GeyserSpigotInjector extends GeyserInjector { @Override @SuppressWarnings("unchecked") - protected void initializeLocalChannel0(GeyserPluginBootstrap bootstrap) throws Exception { + protected void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Exception { Class serverClazz; try { serverClazz = Class.forName("net.minecraft.server.MinecraftServer"); diff --git a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java index f3fbbe7bd..74364f57e 100644 --- a/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java +++ b/bootstrap/spigot/src/main/java/org/geysermc/geyser/platform/spigot/GeyserSpigotPlugin.java @@ -43,8 +43,8 @@ import org.bukkit.plugin.PluginManager; import org.bukkit.plugin.java.JavaPlugin; import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.geyser.FloodgateKeyLoader; +import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.adapters.paper.PaperAdapters; import org.geysermc.geyser.adapters.spigot.SpigotAdapters; import org.geysermc.geyser.api.event.lifecycle.GeyserRegisterPermissionsEvent; @@ -77,7 +77,7 @@ import java.nio.file.Path; import java.util.List; import java.util.Objects; -public class GeyserSpigotPlugin extends JavaPlugin implements GeyserPluginBootstrap { +public class GeyserSpigotPlugin extends JavaPlugin implements GeyserBootstrap { private CommandRegistry commandRegistry; private GeyserPluginConfig geyserConfig; diff --git a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityInjector.java b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityInjector.java index 7039706e5..ef56b1bfa 100644 --- a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityInjector.java +++ b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityInjector.java @@ -35,7 +35,7 @@ import io.netty.channel.EventLoopGroup; import io.netty.channel.WriteBufferWaterMark; import io.netty.channel.local.LocalAddress; import org.checkerframework.checker.nullness.qual.NonNull; -import org.geysermc.geyser.GeyserPluginBootstrap; +import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.network.netty.GeyserInjector; import org.geysermc.geyser.network.netty.LocalServerChannelWrapper; @@ -52,7 +52,7 @@ public class GeyserVelocityInjector extends GeyserInjector { @Override @SuppressWarnings("unchecked") - protected void initializeLocalChannel0(GeyserPluginBootstrap bootstrap) throws Exception { + protected void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Exception { Field cm = proxy.getClass().getDeclaredField("cm"); cm.setAccessible(true); Object connectionManager = cm.get(proxy); diff --git a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java index a39a7a891..017087d90 100644 --- a/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java +++ b/bootstrap/velocity/src/main/java/org/geysermc/geyser/platform/velocity/GeyserVelocityPlugin.java @@ -40,8 +40,8 @@ import lombok.Getter; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.checker.nullness.qual.Nullable; import org.geysermc.geyser.FloodgateKeyLoader; +import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.api.util.PlatformType; import org.geysermc.geyser.command.CommandRegistry; import org.geysermc.geyser.command.CommandSourceConverter; @@ -67,7 +67,7 @@ import java.nio.file.Paths; import java.util.Optional; @Plugin(id = "geyser", name = GeyserImpl.NAME + "-Velocity", version = GeyserImpl.VERSION, url = "https://geysermc.org", authors = "GeyserMC") -public class GeyserVelocityPlugin implements GeyserPluginBootstrap { +public class GeyserVelocityPlugin implements GeyserBootstrap { private final ProxyServer proxyServer; private final PluginContainer container; diff --git a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java index 56157c87f..6030d4f83 100644 --- a/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java +++ b/bootstrap/viaproxy/src/main/java/org/geysermc/geyser/platform/viaproxy/GeyserViaProxyPlugin.java @@ -36,9 +36,9 @@ import net.raphimc.viaproxy.plugins.events.ShouldVerifyOnlineModeEvent; import net.raphimc.viaproxy.protocoltranslator.viaproxy.ViaProxyConfig; import org.apache.logging.log4j.LogManager; import org.checkerframework.checker.nullness.qual.NonNull; +import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; -import org.geysermc.geyser.GeyserPluginBootstrap; import org.geysermc.geyser.api.event.EventRegistrar; import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.api.util.PlatformType; @@ -61,7 +61,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.UUID; -public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserPluginBootstrap, EventRegistrar { +public class GeyserViaProxyPlugin extends ViaProxyPlugin implements GeyserBootstrap, EventRegistrar { private static final File ROOT_FOLDER = new File(PluginManager.PLUGINS_DIR, "Geyser"); diff --git a/core/src/main/java/org/geysermc/geyser/GeyserPluginBootstrap.java b/core/src/main/java/org/geysermc/geyser/GeyserPluginBootstrap.java deleted file mode 100644 index ed05ec1f3..000000000 --- a/core/src/main/java/org/geysermc/geyser/GeyserPluginBootstrap.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2024 GeyserMC. http://geysermc.org - * - * Permission is hereby granted, free of charge, to any person obtaining a copy - * of this software and associated documentation files (the "Software"), to deal - * in the Software without restriction, including without limitation the rights - * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell - * copies of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included in - * all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR - * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE - * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER - * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, - * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN - * THE SOFTWARE. - * - * @author GeyserMC - * @link https://github.com/GeyserMC/Geyser - */ - -package org.geysermc.geyser; - -import org.geysermc.geyser.configuration.GeyserPluginConfig; - -/** - * Used in any instance where Geyser is directly attached to a server instance of some sort. - */ -public interface GeyserPluginBootstrap extends GeyserBootstrap { - @Override - GeyserPluginConfig config(); -} diff --git a/core/src/main/java/org/geysermc/geyser/network/netty/GeyserInjector.java b/core/src/main/java/org/geysermc/geyser/network/netty/GeyserInjector.java index f19f159ba..d14282e95 100644 --- a/core/src/main/java/org/geysermc/geyser/network/netty/GeyserInjector.java +++ b/core/src/main/java/org/geysermc/geyser/network/netty/GeyserInjector.java @@ -27,7 +27,7 @@ package org.geysermc.geyser.network.netty; import io.netty.channel.ChannelFuture; import lombok.Getter; -import org.geysermc.geyser.GeyserPluginBootstrap; +import org.geysermc.geyser.GeyserBootstrap; import java.net.SocketAddress; @@ -49,7 +49,7 @@ public abstract class GeyserInjector { /** * @param bootstrap the bootstrap of the Geyser instance. */ - public void initializeLocalChannel(GeyserPluginBootstrap bootstrap) { + public void initializeLocalChannel(GeyserBootstrap bootstrap) { if (!bootstrap.config().advanced().useDirectConnection()) { bootstrap.getGeyserLogger().debug("Disabling direct injection!"); return; @@ -71,9 +71,9 @@ public abstract class GeyserInjector { } /** - * The method to implement that is called by {@link #initializeLocalChannel(GeyserPluginBootstrap)} wrapped around a try/catch. + * The method to implement that is called by {@link #initializeLocalChannel(GeyserBootstrap)} wrapped around a try/catch. */ - protected abstract void initializeLocalChannel0(GeyserPluginBootstrap bootstrap) throws Exception; + protected abstract void initializeLocalChannel0(GeyserBootstrap bootstrap) throws Exception; public void shutdown() { if (localChannel != null && localChannel.channel().isOpen()) {