From 7128c9d80ddadd9fd3c1e8d5d7d72dbae3c73fd0 Mon Sep 17 00:00:00 2001 From: IzzelAliz Date: Sat, 9 Jul 2022 22:56:06 +0800 Subject: [PATCH] Update to forge 40.1.59 --- README.md | 2 +- .../arclight/common/mixin/core/commands/CommandsMixin.java | 7 +++++-- .../mixin/core/network/ServerPlayNetHandlerMixin.java | 6 ++++-- .../mixin/core/server/dedicated/DedicatedServerMixin.java | 2 +- build.gradle | 2 +- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5e824bb7..a5a696ed 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ A Bukkit server implementation utilizing Mixin. | Minecraft | Forge | Status | Build | | :----: |:-------:| :---: | :---: | -| 1.18.x | 40.1.31 | ACTIVE | [![1.18 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-18?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-18) | +| 1.18.x | 40.1.59 | ACTIVE | [![1.18 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-18?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-18) | | 1.17.x | 37.1.0 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.17/1.0.2) | [![1.17 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-17?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-17) | | 1.16.x | 36.2.26 | ACTIVE | [![1.16 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-16?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-16) | | 1.15.x | 31.2.48 | [LEGACY](https://github.com/IzzelAliz/Arclight/releases/tag/1.15/1.0.19) | [![1.15 Status](https://img.shields.io/appveyor/build/IzzelAliz/arclight-15?style=flat-square)](https://ci.appveyor.com/project/IzzelAliz/arclight-15) | diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandsMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandsMixin.java index 1b100580..5d6de087 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandsMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/commands/CommandsMixin.java @@ -11,8 +11,10 @@ import io.izzel.arclight.common.mod.util.BukkitDispatcher; import net.minecraft.commands.CommandSourceStack; import net.minecraft.commands.Commands; import net.minecraft.commands.SharedSuggestionProvider; +import net.minecraft.commands.synchronization.SuggestionProviders; import net.minecraft.network.protocol.game.ClientboundCommandsPacket; import net.minecraft.server.level.ServerPlayer; +import net.minecraftforge.server.command.CommandHelper; import org.bukkit.Bukkit; import org.bukkit.event.player.PlayerCommandSendEvent; import org.spigotmc.SpigotConfig; @@ -57,11 +59,12 @@ public abstract class CommandsMixin { RootCommandNode vanillaRoot = new RootCommandNode<>(); Commands vanillaCommands = ((MinecraftServerBridge) player.server).bridge$getVanillaCommands(); map.put(vanillaCommands.getDispatcher().getRoot(), vanillaRoot); - this.fillUsableCommands(vanillaCommands.getDispatcher().getRoot(), vanillaRoot, player.createCommandSourceStack(), map); + // FORGE: Use our own command node merging method to handle redirect nodes properly, see issue #7551 + CommandHelper.mergeCommandNode(vanillaCommands.getDispatcher().getRoot(), vanillaRoot, map, player.createCommandSourceStack(), ctx -> 0, suggest -> SuggestionProviders.safelySwap((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); RootCommandNode node = new RootCommandNode<>(); map.put(this.dispatcher.getRoot(), node); - this.fillUsableCommands(this.dispatcher.getRoot(), node, player.createCommandSourceStack(), map); + CommandHelper.mergeCommandNode(this.dispatcher.getRoot(), node, map, player.createCommandSourceStack(), ctx -> 0, suggest -> SuggestionProviders.safelySwap((com.mojang.brigadier.suggestion.SuggestionProvider) (com.mojang.brigadier.suggestion.SuggestionProvider) suggest)); LinkedHashSet set = new LinkedHashSet<>(); for (CommandNode child : node.getChildren()) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java index 8983c89e..0d81c205 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/network/ServerPlayNetHandlerMixin.java @@ -999,7 +999,8 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB return null; } String message = String.format(queueEvent.getFormat(), queueEvent.getPlayer().getDisplayName(), queueEvent.getMessage()); - Component component = ForgeHooks.onServerChatEvent(handler, queueEvent.getMessage(), ForgeHooks.newChatWithLinks(message)); + var event = ForgeHooks.onServerChatEvent(handler, queueEvent.getMessage(), ForgeHooks.newChatWithLinks(message), queueEvent.getMessage(), ForgeHooks.newChatWithLinks(message)); + var component = event == null ? null : event.getComponent(); if (component == null) return null; Bukkit.getConsoleSender().sendMessage(CraftChatMessage.fromComponent(component)); if (((LazyPlayerSet) queueEvent.getRecipients()).isLazy()) { @@ -1040,7 +1041,8 @@ public abstract class ServerPlayNetHandlerMixin implements ServerPlayNetHandlerB @Override protected Void evaluate() { // this is called on main thread - Component component = ForgeHooks.onServerChatEvent(handler, event.getMessage(), chatWithLinks); + var chatEvent = ForgeHooks.onServerChatEvent(handler, event.getMessage(), chatWithLinks, event.getMessage(), chatWithLinks); + var component = chatEvent != null ? chatEvent.getComponent() : null; if (component == null) return null; Bukkit.getConsoleSender().sendMessage(CraftChatMessage.fromComponent(component)); if (((LazyPlayerSet) event.getRecipients()).isLazy()) { diff --git a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/dedicated/DedicatedServerMixin.java b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/dedicated/DedicatedServerMixin.java index 3bb34b91..ac2cb024 100644 --- a/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/dedicated/DedicatedServerMixin.java +++ b/arclight-common/src/main/java/io/izzel/arclight/common/mixin/core/server/dedicated/DedicatedServerMixin.java @@ -110,7 +110,7 @@ public abstract class DedicatedServerMixin extends MinecraftServerMixin { } if (!threads.isEmpty()) { ArclightMod.LOGGER.debug("Threads {} not shutting down", String.join(", ", threads)); - ArclightMod.LOGGER.warn("{} threads not shutting down correctly, force exiting", threads.size()); + ArclightMod.LOGGER.info("{} threads not shutting down correctly, force exiting", threads.size()); } System.exit(0); } diff --git a/build.gradle b/build.gradle index b01f2dca..f7466b0e 100644 --- a/build.gradle +++ b/build.gradle @@ -14,7 +14,7 @@ allprojects { ext { agpVersion = '1.23' minecraftVersion = '1.18.2' - forgeVersion = '40.1.31' + forgeVersion = '40.1.59' apiVersion = '1.2.6' toolsVersion = '1.3.+' mixinVersion = '0.8.5'