mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-21 18:15:26 +01:00
Remove UnsafeCallWrapper as now we use varv Try
This commit is contained in:
parent
6611ec4457
commit
2e5679491c
@ -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 <T> The type of the return value.
|
||||
* @return The return value or null if the call failed.
|
||||
*/
|
||||
public <T> T wrap(Callable<T> 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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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))
|
||||
|
Loading…
Reference in New Issue
Block a user