mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +01:00
Don't lazily initialise pointers
This commit is contained in:
parent
81afe75756
commit
dd82635c6f
@ -183,7 +183,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
|
||||
// Adventure
|
||||
private Identity identity;
|
||||
private Pointers pointers;
|
||||
private final Pointers pointers;
|
||||
|
||||
public Player(@NotNull UUID uuid, @NotNull String username, @NotNull PlayerConnection playerConnection) {
|
||||
super(EntityType.PLAYER, uuid);
|
||||
@ -212,6 +212,11 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
playerConnectionInit();
|
||||
|
||||
this.identity = Identity.identity(uuid);
|
||||
this.pointers = Pointers.builder()
|
||||
.withDynamic(Identity.UUID, this::getUuid)
|
||||
.withDynamic(Identity.NAME, this::getUsername)
|
||||
.withDynamic(Identity.DISPLAY_NAME, this::getDisplayName)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -2550,14 +2555,6 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
|
||||
@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;
|
||||
}
|
||||
|
||||
|
@ -110,7 +110,7 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
||||
private final PFInstanceSpace instanceSpace = new PFInstanceSpace(this);
|
||||
|
||||
// Adventure
|
||||
private Pointers pointers = null;
|
||||
private final Pointers pointers;
|
||||
|
||||
/**
|
||||
* Creates a new instance.
|
||||
@ -127,6 +127,10 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
||||
this.worldBorder = new WorldBorder(this);
|
||||
|
||||
this.eventNode = EventNode.value("instance-" + uniqueId, EventFilter.INSTANCE, this::equals);
|
||||
|
||||
this.pointers = Pointers.builder()
|
||||
.withDynamic(Identity.UUID, this::getUniqueId)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1122,12 +1126,6 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
||||
|
||||
@Override
|
||||
public @NotNull Pointers pointers() {
|
||||
if (this.pointers == null) {
|
||||
this.pointers = Pointers.builder()
|
||||
.withDynamic(Identity.UUID, this::getUniqueId)
|
||||
.build();
|
||||
}
|
||||
|
||||
return this.pointers;
|
||||
}
|
||||
}
|
@ -76,7 +76,7 @@ public class Team implements PacketGroupingAudience {
|
||||
private boolean isPlayerMembersUpToDate;
|
||||
|
||||
// Adventure
|
||||
private Pointers pointers;
|
||||
private final Pointers pointers;
|
||||
|
||||
/**
|
||||
* Default constructor to creates a team.
|
||||
@ -96,6 +96,11 @@ public class Team implements PacketGroupingAudience {
|
||||
this.suffix = Component.empty();
|
||||
|
||||
this.members = new CopyOnWriteArraySet<>();
|
||||
|
||||
this.pointers = Pointers.builder()
|
||||
.withDynamic(Identity.NAME, this::getTeamName)
|
||||
.withDynamic(Identity.DISPLAY_NAME, this::getTeamDisplayName)
|
||||
.build();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -595,13 +600,6 @@ public class Team implements PacketGroupingAudience {
|
||||
|
||||
@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