From 2e5679491c62c1993eaef5a2803717b5774a9223 Mon Sep 17 00:00:00 2001 From: Ben Woo <30431861+benwoo1110@users.noreply.github.com> Date: Thu, 21 Sep 2023 11:36:55 +0800 Subject: [PATCH] Remove UnsafeCallWrapper as now we use varv Try --- .../core/utils/UnsafeCallWrapper.java | 49 ------------------- .../multiverse/core/inject/InjectionTest.kt | 7 --- 2 files changed, 56 deletions(-) delete mode 100644 src/main/java/org/mvplugins/multiverse/core/utils/UnsafeCallWrapper.java diff --git a/src/main/java/org/mvplugins/multiverse/core/utils/UnsafeCallWrapper.java b/src/main/java/org/mvplugins/multiverse/core/utils/UnsafeCallWrapper.java deleted file mode 100644 index 2620452f..00000000 --- a/src/main/java/org/mvplugins/multiverse/core/utils/UnsafeCallWrapper.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.mvplugins.multiverse.core.utils; - -import java.util.concurrent.Callable; - -import com.dumptruckman.minecraft.util.Logging; -import jakarta.inject.Inject; -import org.jvnet.hk2.annotations.Service; - -import org.mvplugins.multiverse.core.config.MVCoreConfig; - -/** - * Wraps calls that could result in exceptions that are not Multiverse's fault. - */ -@Service -public class UnsafeCallWrapper { - private final MVCoreConfig config; - - @Inject - public UnsafeCallWrapper(MVCoreConfig configProvider) { - this.config = configProvider; - } - - /** - * Wraps calls that could result in exceptions that are not Multiverse's fault. - * - * @param callable The potentially unsafe call. - * @param plugin The plugin that's probably the culprit. - * @param action What MV was attempting to do (error message, format string). - * @param formatArgs The formatting arguments for the error message. - * The exception that was thrown will be appended to these objects. - * @param The type of the return value. - * @return The return value or null if the call failed. - */ - public T wrap(Callable callable, String plugin, String action, Object... formatArgs) { - try { - // We're ready to catch you! JUMP! - return callable.call(); - } catch (Throwable t) { - Object[] actualFormatArgs = new Object[formatArgs.length + 1]; - System.arraycopy(formatArgs, 0, actualFormatArgs, 0, formatArgs.length); - actualFormatArgs[formatArgs.length] = t; - Logging.warning(action, actualFormatArgs); - Logging.warning("This is a bug in %s, NOT a bug in Multiverse!", plugin); - if (config.getGlobalDebug() >= 1) - t.printStackTrace(); - return null; - } - } -} diff --git a/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt b/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt index 47a50458..d667baf4 100644 --- a/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt +++ b/src/test/java/org/mvplugins/multiverse/core/inject/InjectionTest.kt @@ -16,7 +16,6 @@ import org.mvplugins.multiverse.core.teleportation.SimpleBlockSafety import org.mvplugins.multiverse.core.teleportation.SimpleLocationManipulation import org.mvplugins.multiverse.core.teleportation.SimpleSafeTTeleporter import org.mvplugins.multiverse.core.teleportation.TeleportQueue -import org.mvplugins.multiverse.core.utils.UnsafeCallWrapper import org.mvplugins.multiverse.core.utils.metrics.MetricsConfigurator import org.mvplugins.multiverse.core.world.WorldManager import kotlin.test.* @@ -61,12 +60,6 @@ class InjectionTest : TestWithMockBukkit() { assertNotNull(multiverseCore.getService(TeleportQueue::class.java)) } - @Test - @Ignore - fun `UnsafeCallWrapper is available as a service`() { - assertNotNull(multiverseCore.getService(UnsafeCallWrapper::class.java)) - } - @Test fun `MVWorldManager is available as a service`() { assertNotNull(multiverseCore.getService(WorldManager::class.java))