mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 22:15:45 +00:00
don't persist temporary nicknames
This commit is contained in:
1 parent
3b1987b5a2
commit
f866157d97
5 files changed
+61
-3
No files matched your search
+3
-2
@@ -38,13 +38,13 @@ public class BukkitPlayerJoinListener implements Listener {
|
||||
final CarbonPlayer player = result.player();
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask((Plugin) this.carbonChat, () -> {
|
||||
if (player.displayName() != null) {
|
||||
if (player.hasCustomDisplayName()) {
|
||||
player.displayName(player.displayName());
|
||||
} else {
|
||||
final @Nullable Component nickname = this.createDefaultNickname(player);
|
||||
|
||||
if (nickname != null) {
|
||||
player.displayName(nickname);
|
||||
player.temporaryDisplayName(nickname);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -52,6 +52,7 @@ public class BukkitPlayerJoinListener implements Listener {
|
||||
}
|
||||
|
||||
private @Nullable Component createDefaultNickname(final CarbonPlayer player) {
|
||||
// TODO: command to re-calculate and apply default nicknames
|
||||
if (BukkitCapabilities.vaultEnabled()) {
|
||||
final Chat vaultChat = Objects.requireNonNull(BukkitCapabilities.chat());
|
||||
final Player bukkitPlayer = Bukkit.getPlayer(player.uuid());
|
||||
|
||||
@@ -57,11 +57,31 @@ public final class CarbonPlayerBukkit extends CarbonPlayerCommon implements Forw
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void temporaryDisplayName(@Nullable Component displayName) {
|
||||
this.carbonPlayer.temporaryDisplayName(displayName);
|
||||
|
||||
final @Nullable Player player = this.player();
|
||||
|
||||
if (player != null) {
|
||||
// Update player's name in chat
|
||||
player.displayName(displayName);
|
||||
|
||||
// Update player's name in the tab player list
|
||||
player.playerListName(displayName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String username() {
|
||||
return this.carbonPlayer.username();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomDisplayName() {
|
||||
return this.carbonPlayer.hasCustomDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable Component displayName() {
|
||||
// if (this.carbonPlayer.displayName() != null) {
|
||||
|
||||
Reference in new issue
Block a user