mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
Set display names on platforms
This commit is contained in:
1 parent
6a829cf599
commit
3818957b56
2 files changed
+25
No files matched your search
@@ -5,6 +5,7 @@ import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.data.Keys;
|
||||
import org.spongepowered.api.data.type.HandTypes;
|
||||
@@ -24,6 +25,19 @@ public class CarbonPlayerSponge extends CarbonPlayerCommon {
|
||||
super(username, displayName, uuid, Identity.identity(uuid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void displayName(final @Nullable Component displayName) {
|
||||
super.displayName(displayName);
|
||||
|
||||
this.player().ifPresent(player -> {
|
||||
if (displayName != null) {
|
||||
player.offer(Keys.CUSTOM_NAME, displayName);
|
||||
} else {
|
||||
player.remove(Keys.CUSTOM_NAME);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Audience audience() {
|
||||
return this.player()
|
||||
|
||||
Reference in new issue
Block a user