mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-03 23:17:48 +01:00
Made InstanceManager#unregisterInstance thread-safe
This commit is contained in:
parent
670887f7b3
commit
45cc1dd2c7
@ -111,15 +111,17 @@ public final class InstanceManager {
|
||||
public void unregisterInstance(Instance instance) {
|
||||
Check.stateCondition(!instance.getPlayers().isEmpty(), "You cannot unregister an instance with players");
|
||||
|
||||
// Unload all chunks
|
||||
if (instance instanceof InstanceContainer) {
|
||||
InstanceContainer instanceContainer = (InstanceContainer) instance;
|
||||
instanceContainer.scheduledChunksToRemove.addAll(instanceContainer.getChunks());
|
||||
instanceContainer.UNSAFE_unloadChunks();
|
||||
}
|
||||
synchronized (instance) {
|
||||
// Unload all chunks
|
||||
if (instance instanceof InstanceContainer) {
|
||||
InstanceContainer instanceContainer = (InstanceContainer) instance;
|
||||
instanceContainer.scheduledChunksToRemove.addAll(instanceContainer.getChunks());
|
||||
instanceContainer.UNSAFE_unloadChunks();
|
||||
}
|
||||
|
||||
instance.setRegistered(false);
|
||||
this.instances.remove(instance);
|
||||
instance.setRegistered(false);
|
||||
this.instances.remove(instance);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user