From 7da3a1697861751c82e3017560237bac3b5c39d7 Mon Sep 17 00:00:00 2001 From: themode Date: Thu, 25 Feb 2021 15:35:31 +0100 Subject: [PATCH] Fix connection loop --- src/main/java/net/minestom/server/entity/Entity.java | 2 -- src/main/java/net/minestom/server/entity/Player.java | 6 +++--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/main/java/net/minestom/server/entity/Entity.java b/src/main/java/net/minestom/server/entity/Entity.java index b4ce6973e..018c28d37 100644 --- a/src/main/java/net/minestom/server/entity/Entity.java +++ b/src/main/java/net/minestom/server/entity/Entity.java @@ -843,11 +843,9 @@ public class Entity implements Viewable, EventHandler, DataContainer, Permission * Changes the entity instance. * * @param instance the new instance of the entity - * @deprecated Use {@link Entity#setInstance(Instance, Position)} instead. * @throws NullPointerException if {@code instance} is null * @throws IllegalStateException if {@code instance} has not been registered in {@link InstanceManager} */ - @Deprecated public void setInstance(@NotNull Instance instance) { setInstance(instance, this.position); } diff --git a/src/main/java/net/minestom/server/entity/Player.java b/src/main/java/net/minestom/server/entity/Player.java index f63c2b837..7c287bf8b 100644 --- a/src/main/java/net/minestom/server/entity/Player.java +++ b/src/main/java/net/minestom/server/entity/Player.java @@ -733,7 +733,7 @@ public class Player extends LivingEntity implements CommandSender { * @param spawnPosition the position to teleport the player * @param firstSpawn true if this is the player first spawn */ - private void spawnPlayer(@NotNull Instance instance, @Nullable Position spawnPosition, + private void spawnPlayer(@NotNull Instance instance, @NotNull Position spawnPosition, boolean firstSpawn, boolean updateChunks) { // Clear previous instance elements if (!firstSpawn) { @@ -741,9 +741,9 @@ public class Player extends LivingEntity implements CommandSender { this.viewableEntities.forEach(entity -> entity.removeViewer(this)); } - super.setInstance(instance); + super.setInstance(instance, spawnPosition); - if (spawnPosition != null && !position.isSimilar(spawnPosition)) { + if (!position.isSimilar(spawnPosition)) { teleport(spawnPosition); } else if (updateChunks) { // Send newly visible chunks to player once spawned in the instance