mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-18 21:32:56 +01:00
chore: delete Entity#setUuid
and AsyncPlayerPreLoginEvent#setUuid
This commit is contained in:
parent
37f466c207
commit
b9616e6035
@ -143,7 +143,7 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev
|
|||||||
private final EventNode<EntityEvent> eventNode;
|
private final EventNode<EntityEvent> eventNode;
|
||||||
private final Set<Permission> permissions = new CopyOnWriteArraySet<>();
|
private final Set<Permission> permissions = new CopyOnWriteArraySet<>();
|
||||||
|
|
||||||
protected UUID uuid;
|
private final UUID uuid;
|
||||||
private boolean isActive; // False if entity has only been instanced without being added somewhere
|
private boolean isActive; // False if entity has only been instanced without being added somewhere
|
||||||
protected boolean removed;
|
protected boolean removed;
|
||||||
|
|
||||||
@ -666,19 +666,6 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev
|
|||||||
return uuid;
|
return uuid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes the internal entity UUID, mostly unsafe.
|
|
||||||
*
|
|
||||||
* @param uuid the new entity uuid
|
|
||||||
*/
|
|
||||||
public void setUuid(@NotNull UUID uuid) {
|
|
||||||
if (instance != null) {
|
|
||||||
instance.getEntityTracker().changeUuid(this, this.uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.uuid = uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns false just after instantiation, set to true after calling {@link #setInstance(Instance)}.
|
* Returns false just after instantiation, set to true after calling {@link #setInstance(Instance)}.
|
||||||
*
|
*
|
||||||
|
@ -36,7 +36,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.temporal.TemporalUnit;
|
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -568,7 +567,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
|||||||
*/
|
*/
|
||||||
public void setTeam(@Nullable Team team) {
|
public void setTeam(@Nullable Team team) {
|
||||||
if (this.team == team) return;
|
if (this.team == team) return;
|
||||||
String member = this instanceof Player player ? player.getUsername() : uuid.toString();
|
String member = this instanceof Player player ? player.getUsername() : getUuid().toString();
|
||||||
if (this.team != null) {
|
if (this.team != null) {
|
||||||
this.team.removeMember(member);
|
this.team.removeMember(member);
|
||||||
}
|
}
|
||||||
|
@ -229,7 +229,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
private final PlayerVehicleInformation vehicleInformation = new PlayerVehicleInformation();
|
private final PlayerVehicleInformation vehicleInformation = new PlayerVehicleInformation();
|
||||||
|
|
||||||
// Adventure
|
// Adventure
|
||||||
private Identity identity;
|
private final Identity identity;
|
||||||
private final Pointers pointers;
|
private final Pointers pointers;
|
||||||
|
|
||||||
// Resource packs
|
// Resource packs
|
||||||
@ -544,7 +544,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
this.instance.getEntityTracker().nearbyEntitiesByChunkRange(respawnPosition, settings.getEffectiveViewDistance(),
|
this.instance.getEntityTracker().nearbyEntitiesByChunkRange(respawnPosition, settings.getEffectiveViewDistance(),
|
||||||
EntityTracker.Target.ENTITIES, entity -> {
|
EntityTracker.Target.ENTITIES, entity -> {
|
||||||
// Skip refreshing self with a new viewer
|
// Skip refreshing self with a new viewer
|
||||||
if (!entity.getUuid().equals(uuid) && entity.isViewer(this)) {
|
if (!entity.getUuid().equals(getUuid()) && entity.isViewer(this)) {
|
||||||
entity.updateNewViewer(this);
|
entity.updateNewViewer(this);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -2238,7 +2238,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @NotNull HoverEvent<ShowEntity> asHoverEvent(@NotNull UnaryOperator<ShowEntity> op) {
|
public @NotNull HoverEvent<ShowEntity> asHoverEvent(@NotNull UnaryOperator<ShowEntity> op) {
|
||||||
return HoverEvent.showEntity(ShowEntity.showEntity(EntityType.PLAYER, this.uuid, this.displayName));
|
return HoverEvent.showEntity(ShowEntity.showEntity(EntityType.PLAYER, getUuid(), this.displayName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -2382,13 +2382,6 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
|||||||
return this.pointers;
|
return this.pointers;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setUuid(@NotNull UUID uuid) {
|
|
||||||
super.setUuid(uuid);
|
|
||||||
// update identity
|
|
||||||
this.identity = Identity.identity(uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPlayer() {
|
public boolean isPlayer() {
|
||||||
return true;
|
return true;
|
||||||
|
@ -19,13 +19,11 @@ public class AsyncPlayerPreLoginEvent implements PlayerEvent {
|
|||||||
private final LoginPluginMessageProcessor pluginMessageProcessor;
|
private final LoginPluginMessageProcessor pluginMessageProcessor;
|
||||||
|
|
||||||
private String username;
|
private String username;
|
||||||
private UUID playerUuid;
|
|
||||||
|
|
||||||
public AsyncPlayerPreLoginEvent(@NotNull Player player, @NotNull LoginPluginMessageProcessor pluginMessageProcessor) {
|
public AsyncPlayerPreLoginEvent(@NotNull Player player, @NotNull LoginPluginMessageProcessor pluginMessageProcessor) {
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.pluginMessageProcessor = pluginMessageProcessor;
|
this.pluginMessageProcessor = pluginMessageProcessor;
|
||||||
this.username = player.getUsername();
|
this.username = player.getUsername();
|
||||||
this.playerUuid = player.getUuid();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,16 +52,7 @@ public class AsyncPlayerPreLoginEvent implements PlayerEvent {
|
|||||||
*/
|
*/
|
||||||
@NotNull
|
@NotNull
|
||||||
public UUID getPlayerUuid() {
|
public UUID getPlayerUuid() {
|
||||||
return playerUuid;
|
return player.getUuid();
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Changes the player uuid.
|
|
||||||
*
|
|
||||||
* @param playerUuid the new player uuid
|
|
||||||
*/
|
|
||||||
public void setPlayerUuid(@NotNull UUID playerUuid) {
|
|
||||||
this.playerUuid = playerUuid;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -62,11 +62,6 @@ public sealed interface EntityTracker permits EntityTrackerImpl {
|
|||||||
<T extends Entity> void move(@NotNull Entity entity, @NotNull Point newPoint,
|
<T extends Entity> void move(@NotNull Entity entity, @NotNull Point newPoint,
|
||||||
@NotNull Target<T> target, @Nullable Update<T> update);
|
@NotNull Target<T> target, @Nullable Update<T> update);
|
||||||
|
|
||||||
/**
|
|
||||||
* Called whenever the entity's uuid changes, can be called async
|
|
||||||
*/
|
|
||||||
void changeUuid(@NotNull Entity entity, UUID oldUuid);
|
|
||||||
|
|
||||||
@UnmodifiableView <T extends Entity> Collection<T> chunkEntities(int chunkX, int chunkZ, @NotNull Target<T> target);
|
@UnmodifiableView <T extends Entity> Collection<T> chunkEntities(int chunkX, int chunkZ, @NotNull Target<T> target);
|
||||||
|
|
||||||
@UnmodifiableView
|
@UnmodifiableView
|
||||||
|
@ -138,12 +138,6 @@ final class EntityTrackerImpl implements EntityTracker {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void changeUuid(@NotNull Entity entity, UUID oldUuid) {
|
|
||||||
entriesByEntityUuid.remove(oldUuid);
|
|
||||||
entriesByEntityUuid.put(entity.getUuid(), new EntityTrackerEntry(entity, entity.getPosition()));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public @Unmodifiable <T extends Entity> Collection<T> chunkEntities(int chunkX, int chunkZ, @NotNull Target<T> target) {
|
public @Unmodifiable <T extends Entity> Collection<T> chunkEntities(int chunkX, int chunkZ, @NotNull Target<T> target) {
|
||||||
final TargetEntry<Entity> entry = targetEntries[target.ordinal()];
|
final TargetEntry<Entity> entry = targetEntries[target.ordinal()];
|
||||||
|
@ -233,9 +233,6 @@ public final class ConnectionManager {
|
|||||||
if (!player.getUsername().equals(eventUsername)) {
|
if (!player.getUsername().equals(eventUsername)) {
|
||||||
player.setUsernameField(eventUsername);
|
player.setUsernameField(eventUsername);
|
||||||
}
|
}
|
||||||
if (!player.getUuid().equals(eventUuid)) {
|
|
||||||
player.setUuid(eventUuid);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Wait for pending login plugin messages
|
// Wait for pending login plugin messages
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package net.minestom.server.network;
|
package net.minestom.server.network;
|
||||||
|
|
||||||
import net.minestom.server.network.player.PlayerConnection;
|
import net.minestom.server.network.player.PlayerConnection;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -22,5 +23,5 @@ public interface UuidProvider {
|
|||||||
* @param username the username given by the connection
|
* @param username the username given by the connection
|
||||||
* @return the new {@link UUID} for the player
|
* @return the new {@link UUID} for the player
|
||||||
*/
|
*/
|
||||||
UUID provide(PlayerConnection playerConnection, String username);
|
@NotNull UUID provide(@NotNull PlayerConnection playerConnection, @NotNull String username);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user