From b794569388a717cd8b746a965da1edfd9fd63554 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+Camotoy@users.noreply.github.com> Date: Thu, 22 Sep 2022 19:49:35 -0400 Subject: [PATCH] 1.19.30 support probably --- bootstrap/fabric/build.gradle | 4 ++-- bootstrap/fabric/gradle.properties | 2 +- .../platform/fabric/GeyserFabricMod.java | 22 ++++++++++--------- .../fabric/command/FabricCommandSender.java | 6 ++--- .../command/GeyserFabricCommandExecutor.java | 12 +++++----- .../command/GeyserFabricCommandManager.java | 6 ++--- .../world/GeyserFabricWorldManager.java | 3 +-- 7 files changed, 29 insertions(+), 26 deletions(-) diff --git a/bootstrap/fabric/build.gradle b/bootstrap/fabric/build.gradle index 96f3ee8b1..2ea9fd686 100644 --- a/bootstrap/fabric/build.gradle +++ b/bootstrap/fabric/build.gradle @@ -27,8 +27,8 @@ dependencies { // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. - implementation "org.geysermc:core:${project.mod_version}" - shadow("org.geysermc:core:${project.mod_version}") { + api "org.geysermc.geyser:core:${project.mod_version}" + shadow("org.geysermc.geyser:core:${project.mod_version}") { exclude group: 'com.google.guava', module: "guava" exclude group: 'com.google.code.gson', module: "gson" exclude group: 'org.slf4j' diff --git a/bootstrap/fabric/gradle.properties b/bootstrap/fabric/gradle.properties index 9c79b7141..341d6bbe4 100644 --- a/bootstrap/fabric/gradle.properties +++ b/bootstrap/fabric/gradle.properties @@ -6,7 +6,7 @@ minecraft_version=1.19.1 yarn_mappings=1.19.1+build.1 loader_version=0.14.8 # Mod Properties -mod_version=2.0.7-SNAPSHOT +mod_version=2.1.0-SNAPSHOT maven_group=org.geysermc.platform archives_base_name=Geyser-Fabric # Dependencies diff --git a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricMod.java b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricMod.java index f6a657bba..5a0b2527a 100644 --- a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricMod.java +++ b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/GeyserFabricMod.java @@ -37,11 +37,12 @@ import org.apache.logging.log4j.LogManager; import org.geysermc.common.PlatformType; import org.geysermc.geyser.GeyserImpl; import org.geysermc.geyser.GeyserLogger; -import org.geysermc.geyser.command.CommandManager; +import org.geysermc.geyser.api.command.Command; +import org.geysermc.geyser.api.network.AuthType; import org.geysermc.geyser.command.GeyserCommand; +import org.geysermc.geyser.command.GeyserCommandManager; import org.geysermc.geyser.dump.BootstrapDumpInfo; import org.geysermc.geyser.ping.GeyserLegacyPingPassthrough; -import org.geysermc.geyser.session.auth.AuthType; import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.geyser.GeyserBootstrap; import org.geysermc.geyser.configuration.GeyserConfiguration; @@ -142,7 +143,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { public void startGeyser(MinecraftServer server) { this.server = server; - if (this.geyserConfig.getRemote().getAddress().equalsIgnoreCase("auto")) { + if (this.geyserConfig.getRemote().address().equalsIgnoreCase("auto")) { this.geyserConfig.setAutoconfiguredRemote(true); String ip = server.getServerIp(); int port = ((GeyserServerPortGetter) server).geyser$getServerPort(); @@ -153,12 +154,12 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { } if (geyserConfig.getBedrock().isCloneRemotePort()) { - geyserConfig.getBedrock().setPort(geyserConfig.getRemote().getPort()); + geyserConfig.getBedrock().setPort(geyserConfig.getRemote().port()); } Optional floodgate = FabricLoader.getInstance().getModContainer("floodgate"); boolean floodgatePresent = floodgate.isPresent(); - if (geyserConfig.getRemote().getAuthType() == AuthType.FLOODGATE && !floodgatePresent) { + if (geyserConfig.getRemote().authType() == AuthType.FLOODGATE && !floodgatePresent) { geyserLogger.severe(GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.not_installed") + " " + GeyserLocale.getLocaleStringLog("geyser.bootstrap.floodgate.disabling")); return; } else if (geyserConfig.isAutoconfiguredRemote() && floodgatePresent) { @@ -169,7 +170,8 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { geyserConfig.loadFloodgate(this, floodgate.orElse(null)); - this.connector = GeyserImpl.start(PlatformType.FABRIC, this); + this.connector = GeyserImpl.load(PlatformType.FABRIC, this); + GeyserImpl.start(); // shrug this.geyserPingPassthrough = GeyserLegacyPingPassthrough.init(connector); @@ -180,13 +182,13 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { // Start command building // Set just "geyser" as the help command GeyserFabricCommandExecutor helpExecutor = new GeyserFabricCommandExecutor(connector, - connector.getCommandManager().getCommands().get("help"), !playerCommands.contains("help")); + (GeyserCommand) connector.commandManager().getCommands().get("help"), !playerCommands.contains("help")); commandExecutors.add(helpExecutor); LiteralArgumentBuilder builder = net.minecraft.server.command.CommandManager.literal("geyser").executes(helpExecutor); // Register all subcommands as valid - for (Map.Entry command : connector.getCommandManager().getCommands().entrySet()) { - GeyserFabricCommandExecutor executor = new GeyserFabricCommandExecutor(connector, command.getValue(), + for (Map.Entry command : connector.commandManager().getCommands().entrySet()) { + GeyserFabricCommandExecutor executor = new GeyserFabricCommandExecutor(connector, (GeyserCommand) command.getValue(), !playerCommands.contains(command.getKey())); commandExecutors.add(executor); builder.then(net.minecraft.server.command.CommandManager.literal(command.getKey()).executes(executor)); @@ -216,7 +218,7 @@ public class GeyserFabricMod implements ModInitializer, GeyserBootstrap { } @Override - public CommandManager getGeyserCommandManager() { + public GeyserCommandManager getGeyserCommandManager() { return geyserCommandManager; } diff --git a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/FabricCommandSender.java b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/FabricCommandSender.java index 57f877637..20dee1b21 100644 --- a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/FabricCommandSender.java +++ b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/FabricCommandSender.java @@ -29,11 +29,11 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.command.CommandSender; +import org.geysermc.geyser.command.GeyserCommandSource; import org.geysermc.geyser.text.ChatColor; import org.geysermc.platform.fabric.GeyserFabricMod; -public class FabricCommandSender implements CommandSender { +public class FabricCommandSender implements GeyserCommandSource { private final ServerCommandSource source; @@ -66,7 +66,7 @@ public class FabricCommandSender implements CommandSender { // Workaround for our commands because fabric doesn't have native permissions for (GeyserFabricCommandExecutor executor : GeyserFabricMod.getInstance().getCommandExecutors()) { - if (executor.getCommand().getPermission().equals(s)) { + if (executor.getCommand().permission().equals(s)) { return executor.canRun(source); } } diff --git a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/GeyserFabricCommandExecutor.java b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/GeyserFabricCommandExecutor.java index c1d8ebc29..07b8bd519 100644 --- a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/GeyserFabricCommandExecutor.java +++ b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/GeyserFabricCommandExecutor.java @@ -29,15 +29,17 @@ import com.mojang.brigadier.Command; import com.mojang.brigadier.context.CommandContext; import net.minecraft.server.command.ServerCommandSource; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.command.CommandExecutor; import org.geysermc.geyser.command.GeyserCommand; +import org.geysermc.geyser.command.GeyserCommandExecutor; import org.geysermc.geyser.session.GeyserSession; import org.geysermc.geyser.text.ChatColor; import org.geysermc.geyser.text.GeyserLocale; import org.geysermc.platform.fabric.GeyserFabricMod; import org.geysermc.platform.fabric.GeyserFabricPermissions; -public class GeyserFabricCommandExecutor extends CommandExecutor implements Command { +import java.util.Collections; + +public class GeyserFabricCommandExecutor extends GeyserCommandExecutor implements Command { private final GeyserCommand command; /** @@ -46,7 +48,7 @@ public class GeyserFabricCommandExecutor extends CommandExecutor implements Comm private final boolean requiresPermission; public GeyserFabricCommandExecutor(GeyserImpl connector, GeyserCommand command, boolean requiresPermission) { - super(connector); + super(connector, Collections.singletonMap(command.name(), command)); this.command = command; this.requiresPermission = requiresPermission; } @@ -70,12 +72,12 @@ public class GeyserFabricCommandExecutor extends CommandExecutor implements Comm sender.sendMessage(GeyserLocale.getLocaleStringLog("geyser.bootstrap.command.permission_fail")); return 0; } - if (this.command.getName().equals("reload")) { + if (this.command.name().equals("reload")) { GeyserFabricMod.getInstance().setReloading(true); } if (command.isBedrockOnly() && session == null) { - sender.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.bootstrap.command.bedrock_only", sender.getLocale())); + sender.sendMessage(ChatColor.RED + GeyserLocale.getPlayerLocaleString("geyser.bootstrap.command.bedrock_only", sender.locale())); return 0; } command.execute(session, sender, new String[0]); diff --git a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/GeyserFabricCommandManager.java b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/GeyserFabricCommandManager.java index d548aa823..feaf40130 100644 --- a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/GeyserFabricCommandManager.java +++ b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/command/GeyserFabricCommandManager.java @@ -26,16 +26,16 @@ package org.geysermc.platform.fabric.command; import org.geysermc.geyser.GeyserImpl; -import org.geysermc.geyser.command.CommandManager; +import org.geysermc.geyser.command.GeyserCommandManager; -public class GeyserFabricCommandManager extends CommandManager { +public class GeyserFabricCommandManager extends GeyserCommandManager { public GeyserFabricCommandManager(GeyserImpl connector) { super(connector); } @Override - public String getDescription(String command) { + public String description(String command) { return ""; } } diff --git a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/world/GeyserFabricWorldManager.java b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/world/GeyserFabricWorldManager.java index 5a66f6ae8..40c7fd302 100644 --- a/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/world/GeyserFabricWorldManager.java +++ b/bootstrap/fabric/src/main/java/org/geysermc/platform/fabric/world/GeyserFabricWorldManager.java @@ -124,10 +124,9 @@ public class GeyserFabricWorldManager extends GeyserWorldManager { @Override public boolean hasPermission(GeyserSession session, String permission) { - // Workaround for our commands because fabric doesn't have native permissions for (GeyserFabricCommandExecutor executor : GeyserFabricMod.getInstance().getCommandExecutors()) { - if (executor.getCommand().getPermission().equals(permission)) { + if (executor.getCommand().permission().equals(permission)) { return executor.canRun(getPlayer(session).getCommandSource()); } }