Paper/patches/api/0007-Paper-Utils.patch

32 lines
1003 B
Diff
Raw Normal View History

2021-06-11 14:02:28 +02:00
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Sat, 23 Feb 2019 11:26:21 -0500
Subject: [PATCH] Paper Utils
diff --git a/src/main/java/com/destroystokyo/paper/util/SneakyThrow.java b/src/main/java/com/destroystokyo/paper/util/SneakyThrow.java
new file mode 100644
index 0000000000000000000000000000000000000000..fbcd82b513b4cb9839f9d2b38d9c6c73148e30a6
2021-06-11 14:02:28 +02:00
--- /dev/null
+++ b/src/main/java/com/destroystokyo/paper/util/SneakyThrow.java
@@ -0,0 +1,19 @@
2021-06-11 14:02:28 +02:00
+package com.destroystokyo.paper.util;
+
+import org.jetbrains.annotations.ApiStatus;
+import org.jspecify.annotations.NullMarked;
2021-06-11 14:02:28 +02:00
+
+@ApiStatus.Internal
+@NullMarked
+public final class SneakyThrow {
2021-06-11 14:02:28 +02:00
+
+ public static void sneaky(final Throwable exception) {
+ SneakyThrow.throwSneaky(exception);
2021-06-11 14:02:28 +02:00
+ }
+
+ @SuppressWarnings("unchecked")
+ private static <T extends Throwable> void throwSneaky(final Throwable exception) throws T {
2021-06-11 14:02:28 +02:00
+ throw (T) exception;
+ }
+
+}