mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-08 17:37:42 +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.Identified;
|
||||||
import net.kyori.adventure.identity.Identity;
|
import net.kyori.adventure.identity.Identity;
|
||||||
import net.kyori.adventure.inventory.Book;
|
import net.kyori.adventure.inventory.Book;
|
||||||
|
import net.kyori.adventure.pointer.Pointers;
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
import net.kyori.adventure.sound.SoundStop;
|
import net.kyori.adventure.sound.SoundStop;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
@ -182,6 +183,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
|
|
||||||
// Adventure
|
// Adventure
|
||||||
private Identity identity;
|
private Identity identity;
|
||||||
|
private Pointers pointers;
|
||||||
|
|
||||||
public Player(@NotNull UUID uuid, @NotNull String username, @NotNull PlayerConnection playerConnection) {
|
public Player(@NotNull UUID uuid, @NotNull String username, @NotNull PlayerConnection playerConnection) {
|
||||||
super(EntityType.PLAYER, uuid);
|
super(EntityType.PLAYER, uuid);
|
||||||
@ -2533,6 +2535,19 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
return this.identity;
|
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
|
@Override
|
||||||
public void setUuid(@NotNull UUID uuid) {
|
public void setUuid(@NotNull UUID uuid) {
|
||||||
super.setUuid(uuid);
|
super.setUuid(uuid);
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
package net.minestom.server.instance;
|
package net.minestom.server.instance;
|
||||||
|
|
||||||
import com.google.common.collect.Queues;
|
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.MinecraftServer;
|
||||||
import net.minestom.server.Tickable;
|
import net.minestom.server.Tickable;
|
||||||
import net.minestom.server.UpdateManager;
|
import net.minestom.server.UpdateManager;
|
||||||
@ -107,6 +109,9 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
|||||||
// Pathfinder
|
// Pathfinder
|
||||||
private final PFInstanceSpace instanceSpace = new PFInstanceSpace(this);
|
private final PFInstanceSpace instanceSpace = new PFInstanceSpace(this);
|
||||||
|
|
||||||
|
// Adventure
|
||||||
|
private Pointers pointers = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
*
|
*
|
||||||
@ -1114,4 +1119,15 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
|||||||
public PFInstanceSpace getInstanceSpace() {
|
public PFInstanceSpace getInstanceSpace() {
|
||||||
return instanceSpace;
|
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;
|
package net.minestom.server.scoreboard;
|
||||||
|
|
||||||
import com.google.common.collect.MapMaker;
|
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.Component;
|
||||||
import net.kyori.adventure.text.format.NamedTextColor;
|
import net.kyori.adventure.text.format.NamedTextColor;
|
||||||
import net.minestom.server.MinecraftServer;
|
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 final Set<Player> playerMembers = Collections.newSetFromMap(new MapMaker().weakKeys().makeMap());
|
||||||
private boolean isPlayerMembersUpToDate;
|
private boolean isPlayerMembersUpToDate;
|
||||||
|
|
||||||
|
// Adventure
|
||||||
|
private Pointers pointers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor to creates a team.
|
* Default constructor to creates a team.
|
||||||
*
|
*
|
||||||
@ -587,4 +592,16 @@ public class Team implements PacketGroupingAudience {
|
|||||||
|
|
||||||
return this.playerMembers;
|
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