mirror of
https://github.com/Minestom/Minestom.git
synced 2025-02-14 19:32:17 +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 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
|
||||
protected boolean removed;
|
||||
|
||||
@ -666,19 +666,6 @@ public class Entity implements Viewable, Tickable, Schedulable, Snapshotable, Ev
|
||||
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)}.
|
||||
*
|
||||
|
@ -36,7 +36,6 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.temporal.TemporalUnit;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -568,7 +567,7 @@ public class LivingEntity extends Entity implements EquipmentHandler {
|
||||
*/
|
||||
public void setTeam(@Nullable Team team) {
|
||||
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) {
|
||||
this.team.removeMember(member);
|
||||
}
|
||||
|
@ -229,7 +229,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
private final PlayerVehicleInformation vehicleInformation = new PlayerVehicleInformation();
|
||||
|
||||
// Adventure
|
||||
private Identity identity;
|
||||
private final Identity identity;
|
||||
private final Pointers pointers;
|
||||
|
||||
// Resource packs
|
||||
@ -544,7 +544,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
this.instance.getEntityTracker().nearbyEntitiesByChunkRange(respawnPosition, settings.getEffectiveViewDistance(),
|
||||
EntityTracker.Target.ENTITIES, entity -> {
|
||||
// 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);
|
||||
}
|
||||
});
|
||||
@ -2238,7 +2238,7 @@ public class Player extends LivingEntity implements CommandSender, Localizable,
|
||||
|
||||
@Override
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUuid(@NotNull UUID uuid) {
|
||||
super.setUuid(uuid);
|
||||
// update identity
|
||||
this.identity = Identity.identity(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayer() {
|
||||
return true;
|
||||
|
@ -19,13 +19,11 @@ public class AsyncPlayerPreLoginEvent implements PlayerEvent {
|
||||
private final LoginPluginMessageProcessor pluginMessageProcessor;
|
||||
|
||||
private String username;
|
||||
private UUID playerUuid;
|
||||
|
||||
public AsyncPlayerPreLoginEvent(@NotNull Player player, @NotNull LoginPluginMessageProcessor pluginMessageProcessor) {
|
||||
this.player = player;
|
||||
this.pluginMessageProcessor = pluginMessageProcessor;
|
||||
this.username = player.getUsername();
|
||||
this.playerUuid = player.getUuid();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -54,16 +52,7 @@ public class AsyncPlayerPreLoginEvent implements PlayerEvent {
|
||||
*/
|
||||
@NotNull
|
||||
public UUID getPlayerUuid() {
|
||||
return playerUuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changes the player uuid.
|
||||
*
|
||||
* @param playerUuid the new player uuid
|
||||
*/
|
||||
public void setPlayerUuid(@NotNull UUID playerUuid) {
|
||||
this.playerUuid = playerUuid;
|
||||
return player.getUuid();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -62,11 +62,6 @@ public sealed interface EntityTracker permits EntityTrackerImpl {
|
||||
<T extends Entity> void move(@NotNull Entity entity, @NotNull Point newPoint,
|
||||
@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
|
||||
|
@ -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
|
||||
public @Unmodifiable <T extends Entity> Collection<T> chunkEntities(int chunkX, int chunkZ, @NotNull Target<T> target) {
|
||||
final TargetEntry<Entity> entry = targetEntries[target.ordinal()];
|
||||
|
@ -233,9 +233,6 @@ public final class ConnectionManager {
|
||||
if (!player.getUsername().equals(eventUsername)) {
|
||||
player.setUsernameField(eventUsername);
|
||||
}
|
||||
if (!player.getUuid().equals(eventUuid)) {
|
||||
player.setUuid(eventUuid);
|
||||
}
|
||||
}
|
||||
|
||||
// Wait for pending login plugin messages
|
||||
|
@ -1,6 +1,7 @@
|
||||
package net.minestom.server.network;
|
||||
|
||||
import net.minestom.server.network.player.PlayerConnection;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@ -22,5 +23,5 @@ public interface UuidProvider {
|
||||
* @param username the username given by the connection
|
||||
* @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