mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +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
@@ -25,6 +25,17 @@ public class CarbonPlayerBukkit extends CarbonPlayerCommon {
|
|||||||
super(username, displayName, uuid, Identity.identity(uuid));
|
super(username, displayName, uuid, Identity.identity(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void displayName(final @Nullable Component displayName) {
|
||||||
|
super.displayName(displayName);
|
||||||
|
|
||||||
|
final Player player = this.player();
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
player.displayName(displayName);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NonNull Audience audience() {
|
public @NonNull Audience audience() {
|
||||||
final Player player = this.player();
|
final Player player = this.player();
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import net.kyori.adventure.audience.Audience;
|
|||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||||
import org.spongepowered.api.Sponge;
|
import org.spongepowered.api.Sponge;
|
||||||
import org.spongepowered.api.data.Keys;
|
import org.spongepowered.api.data.Keys;
|
||||||
import org.spongepowered.api.data.type.HandTypes;
|
import org.spongepowered.api.data.type.HandTypes;
|
||||||
@@ -24,6 +25,19 @@ public class CarbonPlayerSponge extends CarbonPlayerCommon {
|
|||||||
super(username, displayName, uuid, Identity.identity(uuid));
|
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
|
@Override
|
||||||
public @NonNull Audience audience() {
|
public @NonNull Audience audience() {
|
||||||
return this.player()
|
return this.player()
|
||||||
|
|||||||
Reference in new issue
Block a user