mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-02 14:38:26 +01:00
Catch exceptions in instance/chunk/entity ticks
This commit is contained in:
parent
2bdc403fd0
commit
9db185f8a1
@ -14,7 +14,8 @@ import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.*;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.concurrent.locks.LockSupport;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.function.LongConsumer;
|
||||
@ -102,8 +103,13 @@ public final class UpdateManager {
|
||||
*/
|
||||
private void serverTick(long tickStart) {
|
||||
// Tick all instances
|
||||
MinecraftServer.getInstanceManager().getInstances().forEach(instance ->
|
||||
instance.tick(tickStart));
|
||||
MinecraftServer.getInstanceManager().getInstances().forEach(instance -> {
|
||||
try {
|
||||
instance.tick(tickStart);
|
||||
} catch (Exception e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
}
|
||||
});
|
||||
// Tick all chunks (and entities inside)
|
||||
this.threadProvider.updateAndAwait(tickStart);
|
||||
|
||||
|
@ -133,7 +133,11 @@ public abstract class ThreadProvider {
|
||||
final Chunk chunk = chunkEntry.chunk;
|
||||
if (!ChunkUtils.isLoaded(chunk))
|
||||
return;
|
||||
chunk.tick(time);
|
||||
try {
|
||||
chunk.tick(time);
|
||||
} catch (Exception e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
}
|
||||
final var entities = chunkEntry.entities;
|
||||
if (!entities.isEmpty()) {
|
||||
for (Entity entity : entities) {
|
||||
@ -142,7 +146,11 @@ public abstract class ThreadProvider {
|
||||
// #acquire() callbacks should be called here
|
||||
lock.lock();
|
||||
}
|
||||
entity.tick(time);
|
||||
try {
|
||||
entity.tick(time);
|
||||
} catch (Exception e) {
|
||||
MinecraftServer.getExceptionManager().handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user