mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Implement pointer feature
This commit is contained in:
parent
e7e0d4cb0d
commit
b1f72faa67
@ -6,6 +6,7 @@ import net.kyori.adventure.bossbar.BossBar;
|
||||
import net.kyori.adventure.identity.Identified;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.inventory.Book;
|
||||
import net.kyori.adventure.pointer.Pointers;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.sound.SoundStop;
|
||||
import net.kyori.adventure.text.Component;
|
||||
@ -182,6 +183,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
|
||||
// Adventure
|
||||
private Identity identity;
|
||||
private Pointers pointers;
|
||||
|
||||
public Player(@NotNull UUID uuid, @NotNull String username, @NotNull PlayerConnection playerConnection) {
|
||||
super(EntityType.PLAYER, uuid);
|
||||
@ -2533,6 +2535,19 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
return this.identity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Pointers pointers() {
|
||||
if (this.pointers == null) {
|
||||
this.pointers = Pointers.builder()
|
||||
.withDynamic(Identity.UUID, this::getUuid)
|
||||
.withDynamic(Identity.NAME, this::getUsername)
|
||||
.withDynamic(Identity.DISPLAY_NAME, this::getDisplayName)
|
||||
.build();
|
||||
}
|
||||
|
||||
return this.pointers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUuid(@NotNull UUID uuid) {
|
||||
super.setUuid(uuid);
|
||||
|
@ -1,6 +1,8 @@
|
||||
package net.minestom.server.instance;
|
||||
|
||||
import com.google.common.collect.Queues;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.pointer.Pointers;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
import net.minestom.server.Tickable;
|
||||
import net.minestom.server.UpdateManager;
|
||||
@ -107,6 +109,9 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
||||
// Pathfinder
|
||||
private final PFInstanceSpace instanceSpace = new PFInstanceSpace(this);
|
||||
|
||||
// Adventure
|
||||
private Pointers pointers = null;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
*
|
||||
@ -1114,4 +1119,15 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
||||
public PFInstanceSpace getInstanceSpace() {
|
||||
return instanceSpace;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Pointers pointers() {
|
||||
if (this.pointers == null) {
|
||||
this.pointers = Pointers.builder()
|
||||
.withDynamic(Identity.UUID, this::getUniqueId)
|
||||
.build();
|
||||
}
|
||||
|
||||
return this.pointers;
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package net.minestom.server.scoreboard;
|
||||
|
||||
import com.google.common.collect.MapMaker;
|
||||
import net.kyori.adventure.identity.Identity;
|
||||
import net.kyori.adventure.pointer.Pointers;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.minestom.server.MinecraftServer;
|
||||
@ -73,6 +75,9 @@ public class Team implements PacketGroupingAudience {
|
||||
private final Set<Player> playerMembers = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());
|
||||
private boolean isPlayerMembersUpToDate;
|
||||
|
||||
// Adventure
|
||||
private Pointers pointers;
|
||||
|
||||
/**
|
||||
* Default constructor to creates a team.
|
||||
*
|
||||
@ -587,4 +592,16 @@ public class Team implements PacketGroupingAudience {
|
||||
|
||||
return this.playerMembers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Pointers pointers() {
|
||||
if (this.pointers == null) {
|
||||
this.pointers = Pointers.builder()
|
||||
.withDynamic(Identity.NAME, this::getTeamName)
|
||||
.withDynamic(Identity.DISPLAY_NAME, this::getTeamDisplayName)
|
||||
.build();
|
||||
}
|
||||
|
||||
return this.pointers;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user