mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 16:37:38 +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
|
// Adventure
|
||||||
private Identity identity;
|
private Identity identity;
|
||||||
private Pointers pointers;
|
private final 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);
|
||||||
@ -212,6 +212,11 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
playerConnectionInit();
|
playerConnectionInit();
|
||||||
|
|
||||||
this.identity = Identity.identity(uuid);
|
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
|
@Override
|
||||||
public @NotNull Pointers pointers() {
|
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;
|
return this.pointers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
|||||||
private final PFInstanceSpace instanceSpace = new PFInstanceSpace(this);
|
private final PFInstanceSpace instanceSpace = new PFInstanceSpace(this);
|
||||||
|
|
||||||
// Adventure
|
// Adventure
|
||||||
private Pointers pointers = null;
|
private final Pointers pointers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a new instance.
|
* Creates a new instance.
|
||||||
@ -127,6 +127,10 @@ public abstract class Instance implements BlockModifier, Tickable, EventHandler<
|
|||||||
this.worldBorder = new WorldBorder(this);
|
this.worldBorder = new WorldBorder(this);
|
||||||
|
|
||||||
this.eventNode = EventNode.value("instance-" + uniqueId, EventFilter.INSTANCE, this::equals);
|
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
|
@Override
|
||||||
public @NotNull Pointers pointers() {
|
public @NotNull Pointers pointers() {
|
||||||
if (this.pointers == null) {
|
|
||||||
this.pointers = Pointers.builder()
|
|
||||||
.withDynamic(Identity.UUID, this::getUniqueId)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.pointers;
|
return this.pointers;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -76,7 +76,7 @@ public class Team implements PacketGroupingAudience {
|
|||||||
private boolean isPlayerMembersUpToDate;
|
private boolean isPlayerMembersUpToDate;
|
||||||
|
|
||||||
// Adventure
|
// Adventure
|
||||||
private Pointers pointers;
|
private final Pointers pointers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default constructor to creates a team.
|
* Default constructor to creates a team.
|
||||||
@ -96,6 +96,11 @@ public class Team implements PacketGroupingAudience {
|
|||||||
this.suffix = Component.empty();
|
this.suffix = Component.empty();
|
||||||
|
|
||||||
this.members = new CopyOnWriteArraySet<>();
|
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
|
@Override
|
||||||
public @NotNull Pointers pointers() {
|
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;
|
return this.pointers;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user