Fix connection loop

This commit is contained in:
themode 2021-02-25 15:35:31 +01:00
parent 77ed13abd9
commit 7da3a16978
2 changed files with 3 additions and 5 deletions

View File

@ -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);
}

View File

@ -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