diff --git a/changelog.md b/changelog.md index ce7b09f..e004a34 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +------------------------------------------------------ +Version 3.0.1 +------------------------------------------------------ +- Fixed impersonator's names appearing as "Faked(Faked)" for operators when the `opRevealImpersonations` gamerule is off + ------------------------------------------------------ Version 3.0.0 ------------------------------------------------------ diff --git a/gradle.properties b/gradle.properties index d738c8a..1176e14 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,7 +13,7 @@ jb_annotations_version = 23.0.0 apiguardian_version = 1.1.2 # Mod Properties -mod_version = 3.0.0 +mod_version = 3.0.1 maven_group = org.ladysnake archives_base_name = impersonate diff --git a/src/main/java/org/ladysnake/impersonate/impl/ImpersonateTextContent.java b/src/main/java/org/ladysnake/impersonate/impl/ImpersonateTextContent.java index a32ee33..4e4e7cd 100644 --- a/src/main/java/org/ladysnake/impersonate/impl/ImpersonateTextContent.java +++ b/src/main/java/org/ladysnake/impersonate/impl/ImpersonateTextContent.java @@ -34,6 +34,7 @@ import org.jetbrains.annotations.Nullable; import org.ladysnake.impersonate.Impersonator; +import java.util.Objects; import java.util.Optional; public class ImpersonateTextContent implements RecipientAwareTextContent { @@ -52,8 +53,9 @@ public static TextContent get(PlayerEntity player) { public static TextContent get(PlayerEntity player, boolean reveal) { Impersonator impersonator = Impersonator.get(player); String fakeName = impersonator.getEditedProfile().getName(); - String trueText = String.format("%s(%s)", fakeName, player.getGameProfile().getName()); - return new ImpersonateTextContent(trueText, fakeName, reveal); + String trueName = player.getGameProfile().getName(); + String trueText = String.format("%s(%s)", fakeName, trueName); + return new ImpersonateTextContent(trueText, fakeName, reveal && !Objects.equals(fakeName, trueName)); } private ImpersonateTextContent(String trueText, String fakedText, boolean revealed) { diff --git a/src/main/java/org/ladysnake/impersonate/impl/mixin/PlayerEntityMixin.java b/src/main/java/org/ladysnake/impersonate/impl/mixin/PlayerEntityMixin.java index e543f31..68b652a 100644 --- a/src/main/java/org/ladysnake/impersonate/impl/mixin/PlayerEntityMixin.java +++ b/src/main/java/org/ladysnake/impersonate/impl/mixin/PlayerEntityMixin.java @@ -17,6 +17,7 @@ */ package org.ladysnake.impersonate.impl.mixin; +import com.llamalad7.mixinextras.injector.ModifyReturnValue; import com.mojang.authlib.GameProfile; import net.minecraft.entity.EntityType; import net.minecraft.entity.LivingEntity; @@ -34,7 +35,6 @@ import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.Unique; import org.spongepowered.asm.mixin.injection.At; -import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin(PlayerEntity.class) @@ -78,12 +78,13 @@ public void impersonate_disableCape() { dataTracker.set(PLAYER_MODEL_PARTS, newModelMask); } - @Inject(method = "getName", at = @At("RETURN"), cancellable = true) - private void fakeName(CallbackInfoReturnable cir) { + @ModifyReturnValue(method = "getName", at = @At("RETURN")) + private Text fakeName(Text original) { PlayerEntity self = ((PlayerEntity) (Object) this); if (Impersonator.get(self).isImpersonating()) { // if the client is aware that there is an impersonation, they should display it - cir.setReturnValue(MutableText.of(ImpersonateTextContent.get(self, getWorld().isClient))); + return MutableText.of(ImpersonateTextContent.get(self, getWorld().isClient)); } + return original; } }