From 7eb5c1fcba3e7b7ee7e7c6b81edd55031c7ef34c Mon Sep 17 00:00:00 2001 From: BlueZeeKing Date: Thu, 21 Sep 2023 12:52:51 -0400 Subject: [PATCH] Update to 1.20.2 --- gradle.properties | 8 +++--- .../icker/factions/api/persistents/User.java | 27 ++++++++++++------- .../io/icker/factions/core/ChatManager.java | 9 +++---- .../mixin/ServerPlayNetworkHandlerMixin.java | 20 +++++--------- .../mixin/ServerPlayerEntityMixin.java | 17 ++++-------- src/main/resources/fabric.mod.json | 2 +- 6 files changed, 39 insertions(+), 44 deletions(-) diff --git a/gradle.properties b/gradle.properties index af7ec7bb..d305ae79 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,17 +1,17 @@ org.gradle.jvmargs=-Xmx2G # Fabric Properties -minecraft_version=1.20.1 -yarn_mappings=1.20.1+build.10 +minecraft_version=1.20.2 +yarn_mappings=1.20.2+build.1 loader_version=0.14.22 # Mod Properties -mod_version = 2.5.1 +mod_version = 2.5.2 maven_group = io.icker archives_base_name = factions # Dependencies -fabric_version=0.89.0+1.20.1 +fabric_version=0.89.0+1.20.2 lucko_permissions_version=0.3-SNAPSHOT dynmap_api_version=3.7-SNAPSHOT papi_version=2.1.3+1.20.1 diff --git a/src/main/java/io/icker/factions/api/persistents/User.java b/src/main/java/io/icker/factions/api/persistents/User.java index 3d85bbda..6beadc60 100644 --- a/src/main/java/io/icker/factions/api/persistents/User.java +++ b/src/main/java/io/icker/factions/api/persistents/User.java @@ -1,17 +1,16 @@ package io.icker.factions.api.persistents; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.UUID; -import java.util.stream.Collectors; -import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import io.icker.factions.api.events.FactionEvents; import io.icker.factions.database.Database; import io.icker.factions.database.Field; import io.icker.factions.database.Name; +import io.icker.factions.util.WorldUtils; +import net.minecraft.server.network.ServerPlayerEntity; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.*; +import java.util.stream.Collectors; @Name("User") public class User { @@ -49,7 +48,6 @@ public enum SoundMode { public boolean autoclaim = false; public boolean bypass = false; - public String language = "en_us"; private User spoof; @@ -150,6 +148,17 @@ public static void audit() { }); } + @Nullable + public String getLanguage() { + ServerPlayerEntity player = WorldUtils.server.getPlayerManager().getPlayer(this.id); + + if (player == null) { + return null; + } + + return player.getClientOptions().language(); + } + public static void save() { Database.save(User.class, STORE.values().stream().toList()); } diff --git a/src/main/java/io/icker/factions/core/ChatManager.java b/src/main/java/io/icker/factions/core/ChatManager.java index 921487ce..b48e6f3d 100644 --- a/src/main/java/io/icker/factions/core/ChatManager.java +++ b/src/main/java/io/icker/factions/core/ChatManager.java @@ -1,8 +1,5 @@ package io.icker.factions.core; -import java.util.UUID; -import java.util.concurrent.CompletableFuture; - import io.icker.factions.FactionsMod; import io.icker.factions.api.persistents.Faction; import io.icker.factions.api.persistents.User; @@ -12,13 +9,15 @@ import net.minecraft.text.Text; import net.minecraft.util.Formatting; +import java.util.UUID; + public class ChatManager { public static void register() { ServerMessageDecoratorEvent.EVENT.register(ServerMessageDecoratorEvent.CONTENT_PHASE, (sender, message) -> { if (sender != null && FactionsMod.CONFIG.DISPLAY.MODIFY_CHAT) { - return CompletableFuture.completedFuture(ChatManager.handleMessage(sender, message.getString())); + return ChatManager.handleMessage(sender, message.getString()); } - return CompletableFuture.completedFuture(message); + return message; }); } diff --git a/src/main/java/io/icker/factions/mixin/ServerPlayNetworkHandlerMixin.java b/src/main/java/io/icker/factions/mixin/ServerPlayNetworkHandlerMixin.java index 64e2405b..d72d57b4 100644 --- a/src/main/java/io/icker/factions/mixin/ServerPlayNetworkHandlerMixin.java +++ b/src/main/java/io/icker/factions/mixin/ServerPlayNetworkHandlerMixin.java @@ -1,20 +1,13 @@ package io.icker.factions.mixin; -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; - import io.icker.factions.api.events.PlayerEvents; import io.icker.factions.api.persistents.User; import io.icker.factions.util.Message; +import io.icker.factions.util.WorldUtils; import net.minecraft.entity.Entity; import net.minecraft.network.message.SignedMessage; import net.minecraft.network.packet.c2s.play.PlayerInteractEntityC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerMoveC2SPacket; -import net.minecraft.server.MinecraftServer; import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; @@ -22,16 +15,17 @@ import net.minecraft.util.Hand; import net.minecraft.util.math.Vec3d; import net.minecraft.world.World; +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; @Mixin(ServerPlayNetworkHandler.class) public class ServerPlayNetworkHandlerMixin { @Shadow public ServerPlayerEntity player; - @Final - @Shadow - private MinecraftServer server; - @Inject(method = "onPlayerMove", at = @At("HEAD")) public void onPlayerMove(PlayerMoveC2SPacket packet, CallbackInfo ci) { PlayerEvents.ON_MOVE.invoker().onMove(player); @@ -48,7 +42,7 @@ public void handleDecoratedMessage(SignedMessage signedMessage, CallbackInfo ci) new Message("You can't send a message to faction chat if you aren't in a faction.") .fail().hover("Click to switch to global chat") .click("/factions settings chat global") - .send(server.getPlayerManager().getPlayer(signedMessage.link().sender()), + .send(WorldUtils.server.getPlayerManager().getPlayer(signedMessage.link().sender()), false); ci.cancel(); diff --git a/src/main/java/io/icker/factions/mixin/ServerPlayerEntityMixin.java b/src/main/java/io/icker/factions/mixin/ServerPlayerEntityMixin.java index 87c0955c..8c7bdaea 100644 --- a/src/main/java/io/icker/factions/mixin/ServerPlayerEntityMixin.java +++ b/src/main/java/io/icker/factions/mixin/ServerPlayerEntityMixin.java @@ -1,10 +1,5 @@ package io.icker.factions.mixin; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; -import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import io.icker.factions.FactionsMod; import io.icker.factions.api.events.PlayerEvents; import io.icker.factions.api.persistents.Faction; @@ -14,12 +9,16 @@ import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; import net.minecraft.entity.damage.DamageSource; -import net.minecraft.network.packet.c2s.play.ClientSettingsC2SPacket; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.Text; import net.minecraft.util.ActionResult; import net.minecraft.util.Formatting; import net.minecraft.world.World; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(ServerPlayerEntity.class) public abstract class ServerPlayerEntityMixin extends LivingEntity { @@ -28,12 +27,6 @@ protected ServerPlayerEntityMixin(EntityType entityType, super(entityType, world); } - @Inject(at = @At("HEAD"), method = "setClientSettings") - public void setClientSettings(ClientSettingsC2SPacket packet, CallbackInfo info) { - User member = User.get(((ServerPlayerEntity) (Object) this).getUuid()); - member.language = packet.language(); - } - @Inject(at = @At("HEAD"), method = "onDeath") public void onDeath(DamageSource source, CallbackInfo info) { Entity entity = source.getSource(); diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index db966770..14f13511 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -30,7 +30,7 @@ "depends": { "fabricloader": ">=0.13.3", - "minecraft": "1.20.X", + "minecraft": ">=1.20.2", "java": ">=17", "fabric-api": "*" },