Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void shoot(@NotNull Point from, @NotNull Point to, double power, double s

this.setInstance(instance, new Pos(from.x(), from.y(), from.z(), yaw, pitch)).whenComplete((result, throwable) -> {
if (throwable != null) {
throwable.printStackTrace();
MinecraftServer.getExceptionManager().handleException(throwable);
} else {
this.setVelocity(v);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@

import net.minestom.server.MinecraftServer;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Manages the handling of exceptions.
*/
public final class ExceptionManager {

private static final Logger LOGGER = LoggerFactory.getLogger(ExceptionManager.class);

private ExceptionHandler exceptionHandler;

/**
Expand All @@ -18,7 +22,7 @@ public final class ExceptionManager {
public void handleException(Throwable e) {
if (e instanceof OutOfMemoryError) {
// OOM should be handled manually
e.printStackTrace();
LOGGER.error("OOM error", e);
MinecraftServer.stopCleanly();
return;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.minestom.server.extras.velocity;

import net.minestom.server.MinecraftServer;
import net.minestom.server.extras.MojangAuth;
import net.minestom.server.network.NetworkBuffer;
import net.minestom.server.utils.validate.Check;
Expand Down Expand Up @@ -66,7 +67,7 @@ public static boolean checkIntegrity(@NotNull NetworkBuffer buffer) {
return false;
}
} catch (NoSuchAlgorithmException | InvalidKeyException e) {
e.printStackTrace();
MinecraftServer.getExceptionManager().handleException(e);
}
final int version = buffer.read(VAR_INT);
return version == SUPPORTED_FORWARDING_VERSION;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ private void loadBlockEntities(Chunk loadedChunk, ChunkReader chunkReader) {
try (NBTWriter writer = new NBTWriter(Files.newOutputStream(levelPath))) {
writer.writeNamed("", nbt);
} catch (IOException e) {
e.printStackTrace();
MinecraftServer.getExceptionManager().handleException(e);
}
return AsyncUtils.VOID_FUTURE;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.ints.IntArraySet;
import it.unimi.dsi.fastutil.ints.IntSet;
import net.minestom.server.MinecraftServer;
import net.minestom.server.instance.Chunk;
import net.minestom.server.instance.Instance;
import net.minestom.server.instance.InstanceContainer;
Expand Down Expand Up @@ -193,7 +194,7 @@ private void singleThreadFlush(Instance instance, Chunk chunk, @Nullable ChunkBa
if (inverse != null) inverse.readyLatch.countDown();
updateChunk(instance, chunk, sections, callback, safeCallback);
} catch (Exception e) {
e.printStackTrace();
MinecraftServer.getExceptionManager().handleException(e);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void start() {
final SocketChannel client = serverSocket.accept();
worker.receiveConnection(client);
} catch (IOException e) {
e.printStackTrace();
MinecraftServer.getExceptionManager().handleException(e);
}
});
} catch (IOException e) {
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/net/minestom/server/tag/TagNbtSeparator.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package net.minestom.server.tag;

import net.minestom.server.MinecraftServer;
import net.minestom.server.exception.ExceptionManager;
import org.jglrxavpok.hephaistos.nbt.NBT;
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
import org.jglrxavpok.hephaistos.nbt.NBTList;
Expand Down Expand Up @@ -74,7 +76,7 @@ private static void convert(List<String> path, String key, NBT nbt, Consumer<Ent
}
consumer.accept(makeEntry(path, Tag.class.cast(tag), List.of(values)));
} catch (Exception e) {
e.printStackTrace();
MinecraftServer.getExceptionManager().handleException(e);
consumer.accept(makeEntry(path, Tag.NBT(key), nbt));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public static void start() {
try {
terminal = TerminalBuilder.terminal();
} catch (IOException e) {
e.printStackTrace();
MinecraftServer.getExceptionManager().handleException(e);
}
reader = LineReaderBuilder.builder()
.completer(new MinestomCompleter())
Expand Down Expand Up @@ -65,7 +65,7 @@ public static void stop() {
try {
terminal.close();
} catch (IOException e) {
e.printStackTrace();
MinecraftServer.getExceptionManager().handleException(e);
}
reader = null;
}
Expand Down