If the debug level is >= 1: stacktrace
This commit is contained in:
parent
a8040abd52
commit
4a66a2f5bb
|
@ -80,6 +80,7 @@ import com.onarandombox.MultiverseCore.utils.MVPlayerSession;
|
||||||
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
import com.onarandombox.MultiverseCore.utils.SimpleBlockSafety;
|
||||||
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
import com.onarandombox.MultiverseCore.utils.SimpleLocationManipulation;
|
||||||
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
import com.onarandombox.MultiverseCore.utils.SimpleSafeTTeleporter;
|
||||||
|
import com.onarandombox.MultiverseCore.utils.UnsafeCallWrapper;
|
||||||
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
import com.onarandombox.MultiverseCore.utils.VaultHandler;
|
||||||
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
import com.onarandombox.MultiverseCore.utils.WorldManager;
|
||||||
import com.pneumaticraft.commandhandler.CommandHandler;
|
import com.pneumaticraft.commandhandler.CommandHandler;
|
||||||
|
@ -218,6 +219,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
private BlockSafety blockSafety;
|
private BlockSafety blockSafety;
|
||||||
private LocationManipulation locationManipulation;
|
private LocationManipulation locationManipulation;
|
||||||
private SafeTTeleporter safeTTeleporter;
|
private SafeTTeleporter safeTTeleporter;
|
||||||
|
private UnsafeCallWrapper unsafeCallWrapper;
|
||||||
|
|
||||||
private File serverFolder = new File(System.getProperty("user.dir"));
|
private File serverFolder = new File(System.getProperty("user.dir"));
|
||||||
|
|
||||||
|
@ -238,6 +240,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
this.locationManipulation = new SimpleLocationManipulation();
|
this.locationManipulation = new SimpleLocationManipulation();
|
||||||
// Setup our SafeTTeleporter
|
// Setup our SafeTTeleporter
|
||||||
this.safeTTeleporter = new SimpleSafeTTeleporter(this);
|
this.safeTTeleporter = new SimpleSafeTTeleporter(this);
|
||||||
|
this.unsafeCallWrapper = new UnsafeCallWrapper(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1285,4 +1288,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
||||||
public Buscript getScriptAPI() {
|
public Buscript getScriptAPI() {
|
||||||
return buscript;
|
return buscript;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public UnsafeCallWrapper getUnsafeCallWrapper() {
|
||||||
|
return this.unsafeCallWrapper;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,15 +1,18 @@
|
||||||
package com.onarandombox.MultiverseCore.utils;
|
package com.onarandombox.MultiverseCore.utils;
|
||||||
|
|
||||||
import com.dumptruckman.minecraft.util.Logging;
|
import com.dumptruckman.minecraft.util.Logging;
|
||||||
|
import com.onarandombox.MultiverseCore.api.Core;
|
||||||
|
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wraps calls that could result in exceptions that are not Multiverse's fault.
|
* Wraps calls that could result in exceptions that are not Multiverse's fault.
|
||||||
*/
|
*/
|
||||||
public final class UnsafeCallWrapper {
|
public class UnsafeCallWrapper {
|
||||||
private UnsafeCallWrapper() {
|
private final Core core;
|
||||||
throw new UnsupportedOperationException();
|
|
||||||
|
public UnsafeCallWrapper(Core core) {
|
||||||
|
this.core = core;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -23,7 +26,7 @@ public final class UnsafeCallWrapper {
|
||||||
* @param <T> The type of the return value.
|
* @param <T> The type of the return value.
|
||||||
* @return The return value or null if the call failed.
|
* @return The return value or null if the call failed.
|
||||||
*/
|
*/
|
||||||
public static <T> T wrap(Callable<T> callable, String plugin, String action, Object... formatArgs) {
|
public <T> T wrap(Callable<T> callable, String plugin, String action, Object... formatArgs) {
|
||||||
try {
|
try {
|
||||||
// We're ready to catch you! JUMP!
|
// We're ready to catch you! JUMP!
|
||||||
return callable.call();
|
return callable.call();
|
||||||
|
@ -31,8 +34,10 @@ public final class UnsafeCallWrapper {
|
||||||
Object[] actualFormatArgs = new Object[formatArgs.length + 1];
|
Object[] actualFormatArgs = new Object[formatArgs.length + 1];
|
||||||
System.arraycopy(formatArgs, 0, actualFormatArgs, 0, formatArgs.length);
|
System.arraycopy(formatArgs, 0, actualFormatArgs, 0, formatArgs.length);
|
||||||
actualFormatArgs[formatArgs.length] = t;
|
actualFormatArgs[formatArgs.length] = t;
|
||||||
Logging.warning(action, actualFormatArgs);
|
Logging.warning(action, actualFormatArgs);
|
||||||
Logging.warning("This is a bug in %s, NOT a bug in Multiverse!", plugin);
|
Logging.warning("This is a bug in %s, NOT a bug in Multiverse!", plugin);
|
||||||
|
if (core.getMVConfig().getGlobalDebug() >= 1)
|
||||||
|
t.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -251,7 +251,7 @@ public class WorldManager implements MVWorldManager {
|
||||||
if (myPlugin == null) {
|
if (myPlugin == null) {
|
||||||
return null;
|
return null;
|
||||||
} else {
|
} else {
|
||||||
return UnsafeCallWrapper.wrap(new Callable<ChunkGenerator>() {
|
return plugin.getUnsafeCallWrapper().wrap(new Callable<ChunkGenerator>() {
|
||||||
@Override
|
@Override
|
||||||
public ChunkGenerator call() throws Exception {
|
public ChunkGenerator call() throws Exception {
|
||||||
return myPlugin.getDefaultWorldGenerator(worldName, generatorID);
|
return myPlugin.getDefaultWorldGenerator(worldName, generatorID);
|
||||||
|
@ -379,7 +379,7 @@ public class WorldManager implements MVWorldManager {
|
||||||
|
|
||||||
boolean generatorSuccess = true;
|
boolean generatorSuccess = true;
|
||||||
if ((world.getGenerator() != null) && (!world.getGenerator().equals("null")))
|
if ((world.getGenerator() != null) && (!world.getGenerator().equals("null")))
|
||||||
generatorSuccess = null != UnsafeCallWrapper.wrap(new Callable<Object>() {
|
generatorSuccess = null != plugin.getUnsafeCallWrapper().wrap(new Callable<Object>() {
|
||||||
@Override
|
@Override
|
||||||
public Object call() throws Exception {
|
public Object call() throws Exception {
|
||||||
creator.generator(world.getGenerator());
|
creator.generator(world.getGenerator());
|
||||||
|
|
Loading…
Reference in New Issue