mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-04 23:47:59 +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.List;
|
||||||
import java.util.Queue;
|
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.concurrent.locks.LockSupport;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.function.LongConsumer;
|
import java.util.function.LongConsumer;
|
||||||
@ -102,8 +103,13 @@ public final class UpdateManager {
|
|||||||
*/
|
*/
|
||||||
private void serverTick(long tickStart) {
|
private void serverTick(long tickStart) {
|
||||||
// Tick all instances
|
// Tick all instances
|
||||||
MinecraftServer.getInstanceManager().getInstances().forEach(instance ->
|
MinecraftServer.getInstanceManager().getInstances().forEach(instance -> {
|
||||||
instance.tick(tickStart));
|
try {
|
||||||
|
instance.tick(tickStart);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MinecraftServer.getExceptionManager().handleException(e);
|
||||||
|
}
|
||||||
|
});
|
||||||
// Tick all chunks (and entities inside)
|
// Tick all chunks (and entities inside)
|
||||||
this.threadProvider.updateAndAwait(tickStart);
|
this.threadProvider.updateAndAwait(tickStart);
|
||||||
|
|
||||||
|
@ -133,7 +133,11 @@ public abstract class ThreadProvider {
|
|||||||
final Chunk chunk = chunkEntry.chunk;
|
final Chunk chunk = chunkEntry.chunk;
|
||||||
if (!ChunkUtils.isLoaded(chunk))
|
if (!ChunkUtils.isLoaded(chunk))
|
||||||
return;
|
return;
|
||||||
chunk.tick(time);
|
try {
|
||||||
|
chunk.tick(time);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MinecraftServer.getExceptionManager().handleException(e);
|
||||||
|
}
|
||||||
final var entities = chunkEntry.entities;
|
final var entities = chunkEntry.entities;
|
||||||
if (!entities.isEmpty()) {
|
if (!entities.isEmpty()) {
|
||||||
for (Entity entity : entities) {
|
for (Entity entity : entities) {
|
||||||
@ -142,7 +146,11 @@ public abstract class ThreadProvider {
|
|||||||
// #acquire() callbacks should be called here
|
// #acquire() callbacks should be called here
|
||||||
lock.lock();
|
lock.lock();
|
||||||
}
|
}
|
||||||
entity.tick(time);
|
try {
|
||||||
|
entity.tick(time);
|
||||||
|
} catch (Exception e) {
|
||||||
|
MinecraftServer.getExceptionManager().handleException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user