Skip to content

Commit

Permalink
Use getGameProfile().getName() for player name on Fabric
Browse files Browse the repository at this point in the history
  • Loading branch information
AuroraLS3 committed Jan 7, 2024
1 parent fa1ec4f commit 28f3f35
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.netty.channel.unix.DomainSocketAddress;
import net.minecraft.server.dedicated.MinecraftDedicatedServer;
import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;

import java.net.*;
import java.util.Optional;
Expand All @@ -45,12 +46,12 @@ public UUID getUUID() {

@Override
public String getName() {
return player.getNameForScoreboard();
return player.getGameProfile().getName();
}

@Override
public Optional<String> getDisplayName() {
return Optional.of(player.getDisplayName().getString());
return Optional.ofNullable(player.getDisplayName()).map(Text::getString);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package net.playeranalytics.plan.gathering.listeners.events.mixin;

import com.djrapitops.plan.commands.use.*;
import com.mojang.authlib.GameProfile;
import net.minecraft.entity.Entity;
import net.minecraft.server.command.ServerCommandSource;
import net.minecraft.server.network.ServerPlayerEntity;
Expand Down Expand Up @@ -58,7 +59,7 @@ public MessageBuilder buildMessage() {

@Override
public Optional<String> getPlayerName() {
return getPlayer().map(ServerPlayerEntity::getNameForScoreboard);
return getPlayer().map(ServerPlayerEntity::getGameProfile).map(GameProfile::getName);
}

@Override
Expand Down

0 comments on commit 28f3f35

Please sign in to comment.