From c4c3f888f5ceb05e527d8585cf5e0396c647c4a2 Mon Sep 17 00:00:00 2001 From: Wesley1808 <74668381+Wesley1808@users.noreply.github.com> Date: Tue, 22 Oct 2024 19:18:39 +0200 Subject: [PATCH] Update to 1.21.2 --- build.gradle | 2 +- gradle.properties | 16 +++--- gradle/wrapper/gradle-wrapper.properties | 2 +- .../advancedchat/impl/data/Json.java | 5 +- .../impl/interfaces/IServerPlayer.java | 24 ++++----- .../advancedchat/impl/utils/Permission.java | 2 +- .../advancedchat/mixins/MsgCommandMixin.java | 4 +- .../advancedchat/mixins/PlayerListMixin.java | 6 --- .../ServerGamePacketListenerImplMixin.java | 4 +- .../mixins/ServerPlayerMixin.java | 52 +++++++++---------- src/main/resources/fabric.mod.json | 2 +- 11 files changed, 56 insertions(+), 63 deletions(-) diff --git a/build.gradle b/build.gradle index bca53bb..9a54b64 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'fabric-loom' version '1.6-SNAPSHOT' + id 'fabric-loom' version '1.8-SNAPSHOT' id 'maven-publish' } diff --git a/gradle.properties b/gradle.properties index fcea405..5f8bd9d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -2,21 +2,21 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties -minecraft_version=1.21 -loader_version=0.15.11 +minecraft_version=1.21.2 +loader_version=0.16.7 # Mod Properties -mod_version=1.6 +mod_version=1.7 maven_group=me.wesley1808 archives_base_name=advancedchat # API dependencies -fabric_version=0.100.1+1.21 -placeholder_api_version=2.4.0-pre.2+1.21 +fabric_version=0.106.1+1.21.2 +placeholder_api_version=2.5.0+1.21.2 playerdata_api_version=0.6.0+1.21 -predicate_api_version=0.5.1+1.21 +predicate_api_version=0.6.0+1.21.2 permission_api_version=0.3.1 # Other dependencies -styledchat_version=2.6.0+1.21 -vanish_version=1.5.5+1.21 +styledchat_version=2.7.0+1.21.2 +vanish_version=1.5.7+1.21.2-rc2 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 48c0a02..1e2fbf0 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/src/main/java/me/wesley1808/advancedchat/impl/data/Json.java b/src/main/java/me/wesley1808/advancedchat/impl/data/Json.java index 5be1449..394abe6 100644 --- a/src/main/java/me/wesley1808/advancedchat/impl/data/Json.java +++ b/src/main/java/me/wesley1808/advancedchat/impl/data/Json.java @@ -6,6 +6,7 @@ import me.wesley1808.advancedchat.impl.channels.Channels; import me.wesley1808.advancedchat.impl.channels.ChatChannel; import net.minecraft.core.Registry; +import net.minecraft.core.RegistryAccess; import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvent; @@ -22,7 +23,7 @@ public class Json { public static final Gson CONFIG = new GsonBuilder() .registerTypeHierarchyAdapter(Pattern.class, new PatternSerializer()) - .registerTypeHierarchyAdapter(MinecraftPredicate.class, GsonPredicateSerializer.INSTANCE) + .registerTypeHierarchyAdapter(MinecraftPredicate.class, GsonPredicateSerializer.create(RegistryAccess.fromRegistryOfRegistries(BuiltInRegistries.REGISTRY))) .registerTypeHierarchyAdapter(SoundEvent.class, new RegistrySerializer<>(BuiltInRegistries.SOUND_EVENT)) .disableHtmlEscaping() .setPrettyPrinting() @@ -66,7 +67,7 @@ public T deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext if (json.isJsonPrimitive()) { ResourceLocation location = ResourceLocation.tryParse(json.getAsString()); if (location != null) { - return this.registry.get(location); + return this.registry.getValue(location); } } return null; diff --git a/src/main/java/me/wesley1808/advancedchat/impl/interfaces/IServerPlayer.java b/src/main/java/me/wesley1808/advancedchat/impl/interfaces/IServerPlayer.java index a0fa8d9..9640569 100644 --- a/src/main/java/me/wesley1808/advancedchat/impl/interfaces/IServerPlayer.java +++ b/src/main/java/me/wesley1808/advancedchat/impl/interfaces/IServerPlayer.java @@ -9,41 +9,41 @@ public interface IServerPlayer { - ClientboundSetActionBarTextPacket getActionBarPacket(); + ClientboundSetActionBarTextPacket advancedchat$getActionBarPacket(); @Nullable - PlayerChatMessage getLastChatMessage(); + PlayerChatMessage advancedchat$getLastChatMessage(); - void setLastChatMessage(PlayerChatMessage message); + void advancedchat$setLastChatMessage(PlayerChatMessage message); @Nullable - UUID getReplyTarget(); + UUID advancedchat$getReplyTarget(); - void setReplyTarget(UUID uuid); + void advancedchat$setReplyTarget(UUID uuid); - void delayNextPacket(); + void advancedchat$delayNextPacket(); - void updateActionBarPacket(); + void advancedchat$updateActionBarPacket(); @Nullable static PlayerChatMessage getLastChatMessage(ServerPlayer player) { - return ((IServerPlayer) player).getLastChatMessage(); + return ((IServerPlayer) player).advancedchat$getLastChatMessage(); } static void setLastChatMessage(ServerPlayer player, PlayerChatMessage message) { - ((IServerPlayer) player).setLastChatMessage(message); + ((IServerPlayer) player).advancedchat$setLastChatMessage(message); } @Nullable static UUID getReplyTarget(ServerPlayer player) { - return ((IServerPlayer) player).getReplyTarget(); + return ((IServerPlayer) player).advancedchat$getReplyTarget(); } static void setReplyTarget(ServerPlayer player, UUID uuid) { - ((IServerPlayer) player).setReplyTarget(uuid); + ((IServerPlayer) player).advancedchat$setReplyTarget(uuid); } static void updateActionBarPacket(ServerPlayer player) { - ((IServerPlayer) player).updateActionBarPacket(); + ((IServerPlayer) player).advancedchat$updateActionBarPacket(); } } diff --git a/src/main/java/me/wesley1808/advancedchat/impl/utils/Permission.java b/src/main/java/me/wesley1808/advancedchat/impl/utils/Permission.java index 48590a5..9ba28a6 100644 --- a/src/main/java/me/wesley1808/advancedchat/impl/utils/Permission.java +++ b/src/main/java/me/wesley1808/advancedchat/impl/utils/Permission.java @@ -21,7 +21,7 @@ public static boolean check(SharedSuggestionProvider source, String perm, int le } public static boolean check(ServerPlayer source, String perm, int level) { - return Permissions.check(source, perm, level); + return Permissions.check(source.createCommandSourceStack(), perm, level); } public static Predicate require(String perm, int level) { diff --git a/src/main/java/me/wesley1808/advancedchat/mixins/MsgCommandMixin.java b/src/main/java/me/wesley1808/advancedchat/mixins/MsgCommandMixin.java index 03a3b6f..52a38d9 100644 --- a/src/main/java/me/wesley1808/advancedchat/mixins/MsgCommandMixin.java +++ b/src/main/java/me/wesley1808/advancedchat/mixins/MsgCommandMixin.java @@ -16,7 +16,6 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; -import org.spongepowered.asm.mixin.injection.callback.LocalCapture; import java.util.Collection; @@ -25,13 +24,12 @@ public class MsgCommandMixin { @Inject( method = "method_13463", - locals = LocalCapture.CAPTURE_FAILHARD, at = @At( value = "INVOKE", target = "Lnet/minecraft/commands/arguments/MessageArgument;resolveChatMessage(Lcom/mojang/brigadier/context/CommandContext;Ljava/lang/String;Ljava/util/function/Consumer;)V" ) ) - private static void advancedchat$verifyNotIgnored(CommandContext context, CallbackInfoReturnable cir, Collection targets) throws CommandSyntaxException { + private static void advancedchat$verifyNotIgnored(CommandContext context, CallbackInfoReturnable cir, @Local(ordinal = 0) Collection targets) throws CommandSyntaxException { Util.throwIfIgnored(context.getSource(), targets); } diff --git a/src/main/java/me/wesley1808/advancedchat/mixins/PlayerListMixin.java b/src/main/java/me/wesley1808/advancedchat/mixins/PlayerListMixin.java index f5a6981..de602e6 100644 --- a/src/main/java/me/wesley1808/advancedchat/mixins/PlayerListMixin.java +++ b/src/main/java/me/wesley1808/advancedchat/mixins/PlayerListMixin.java @@ -5,13 +5,10 @@ import me.wesley1808.advancedchat.impl.utils.Util; import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.PlayerChatMessage; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList; import org.jetbrains.annotations.Nullable; -import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; @@ -21,9 +18,6 @@ @Mixin(PlayerList.class) public class PlayerListMixin { - @Shadow - @Final - private MinecraftServer server; @Inject(method = "broadcastChatMessage(Lnet/minecraft/network/chat/PlayerChatMessage;Ljava/util/function/Predicate;Lnet/minecraft/server/level/ServerPlayer;Lnet/minecraft/network/chat/ChatType$Bound;)V", at = @At("HEAD"), cancellable = true) private void advancedchat$hideChatMessage(PlayerChatMessage message, Predicate predicate, ServerPlayer sender, ChatType.Bound bound, CallbackInfo ci) { diff --git a/src/main/java/me/wesley1808/advancedchat/mixins/ServerGamePacketListenerImplMixin.java b/src/main/java/me/wesley1808/advancedchat/mixins/ServerGamePacketListenerImplMixin.java index e2fb543..4f22ef8 100644 --- a/src/main/java/me/wesley1808/advancedchat/mixins/ServerGamePacketListenerImplMixin.java +++ b/src/main/java/me/wesley1808/advancedchat/mixins/ServerGamePacketListenerImplMixin.java @@ -62,10 +62,10 @@ public void send(Packet packet, @Nullable PacketSendListener packetSendListen super.send(packet, packetSendListener); if (Config.instance().actionbar && this.player instanceof IServerPlayer player) { - Packet current = player.getActionBarPacket(); + Packet current = player.advancedchat$getActionBarPacket(); if (current != null && current != packet && Util.isOverlayPacket(packet)) { // Prevents the channel overlay packets from overriding other overlays from the server. - player.delayNextPacket(); + player.advancedchat$delayNextPacket(); } } } diff --git a/src/main/java/me/wesley1808/advancedchat/mixins/ServerPlayerMixin.java b/src/main/java/me/wesley1808/advancedchat/mixins/ServerPlayerMixin.java index 0bff165..adea7d4 100644 --- a/src/main/java/me/wesley1808/advancedchat/mixins/ServerPlayerMixin.java +++ b/src/main/java/me/wesley1808/advancedchat/mixins/ServerPlayerMixin.java @@ -32,15 +32,15 @@ public abstract class ServerPlayerMixin extends Player implements IServerPlayer public ServerGamePacketListenerImpl connection; @Unique @Nullable - private ClientboundSetActionBarTextPacket actionBarPacket; + private ClientboundSetActionBarTextPacket advancedchat$actionBarPacket; @Unique @Nullable - private PlayerChatMessage lastChatMessage; + private PlayerChatMessage advancedchat$lastChatMessage; @Unique @Nullable - private UUID replyTarget; + private UUID advancedchat$replyTarget; @Unique - private long nextPacketTime; + private long advancedchat$nextPacketTime; public ServerPlayerMixin(Level level, BlockPos blockPos, float f, GameProfile gameProfile) { super(level, blockPos, f, gameProfile); @@ -48,14 +48,14 @@ public ServerPlayerMixin(Level level, BlockPos blockPos, float f, GameProfile ga @Inject(method = "", at = @At(value = "TAIL")) private void advancedchat$onInit(MinecraftServer minecraftServer, ServerLevel serverLevel, GameProfile gameProfile, ClientInformation clientInformation, CallbackInfo ci) { - this.updateActionBarPacket(); + this.advancedchat$updateActionBarPacket(); } @Override public boolean startRiding(Entity entity, boolean bl) { if (super.startRiding(entity, bl)) { // Prevents the channel overlay packets from overriding the vehicle mount overlay. - this.delayNextPacket(); + this.advancedchat$delayNextPacket(); return true; } return false; @@ -66,14 +66,14 @@ public boolean startRiding(Entity entity, boolean bl) { Config config = Config.instance(); if (config.actionbar) { if (this.tickCount % config.actionbarUpdateInterval == 0) { - this.updateActionBarPacket(); + this.advancedchat$updateActionBarPacket(); } - if (this.actionBarPacket != null) { + if (this.advancedchat$actionBarPacket != null) { long time = System.currentTimeMillis(); - if (this.nextPacketTime <= time) { - this.connection.send(this.actionBarPacket); - this.nextPacketTime = time + 1000; + if (this.advancedchat$nextPacketTime <= time) { + this.connection.send(this.advancedchat$actionBarPacket); + this.advancedchat$nextPacketTime = time + 1000; } } } @@ -81,46 +81,46 @@ public boolean startRiding(Entity entity, boolean bl) { @Nullable @Override - public ClientboundSetActionBarTextPacket getActionBarPacket() { - return this.actionBarPacket; + public ClientboundSetActionBarTextPacket advancedchat$getActionBarPacket() { + return this.advancedchat$actionBarPacket; } @Nullable @Override - public PlayerChatMessage getLastChatMessage() { - return this.lastChatMessage; + public PlayerChatMessage advancedchat$getLastChatMessage() { + return this.advancedchat$lastChatMessage; } @Override - public void setLastChatMessage(PlayerChatMessage lastChatMessage) { - this.lastChatMessage = lastChatMessage; + public void advancedchat$setLastChatMessage(PlayerChatMessage lastChatMessage) { + this.advancedchat$lastChatMessage = lastChatMessage; } @Nullable @Override - public UUID getReplyTarget() { - return this.replyTarget; + public UUID advancedchat$getReplyTarget() { + return this.advancedchat$replyTarget; } @Override - public void setReplyTarget(@Nullable UUID uuid) { - this.replyTarget = uuid; + public void advancedchat$setReplyTarget(@Nullable UUID uuid) { + this.advancedchat$replyTarget = uuid; } @Override - public void delayNextPacket() { - this.nextPacketTime = System.currentTimeMillis() + 3000; + public void advancedchat$delayNextPacket() { + this.advancedchat$nextPacketTime = System.currentTimeMillis() + 3000; } @Override - public void updateActionBarPacket() { + public void advancedchat$updateActionBarPacket() { ServerPlayer player = (ServerPlayer) (Object) this; AdvancedChatData data = DataManager.get(player); if (data.channel == null) { - this.actionBarPacket = null; + this.advancedchat$actionBarPacket = null; return; } - this.actionBarPacket = new ClientboundSetActionBarTextPacket(data.channel.getActionBarText(player)); + this.advancedchat$actionBarPacket = new ClientboundSetActionBarTextPacket(data.channel.getActionBarText(player)); } } diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 31931c4..007e1b0 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -24,7 +24,7 @@ ], "depends": { "fabricloader": ">=0.15.0", - "minecraft": ">=1.21-" + "minecraft": ">=1.21.2-" }, "suggests": { "styledchat": "*"