Suppress stacktraces thrown when migrating worlds.yml. Fixes #700.
This commit is contained in:
parent
1db555581b
commit
cced74d4b0
2
pom.xml
2
pom.xml
|
@ -198,7 +198,7 @@
|
|||
<dependency>
|
||||
<groupId>me.main__.util</groupId>
|
||||
<artifactId>SerializationConfig</artifactId>
|
||||
<version>1.6</version>
|
||||
<version>1.6a</version>
|
||||
<type>jar</type>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
|
|
|
@ -216,6 +216,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||
getDataFolder().mkdirs();
|
||||
// Setup our Debug Log
|
||||
debugLog = new DebugLog("Multiverse-Core", getDataFolder() + File.separator + "debug.log");
|
||||
debugLog.setStandardLogger(LOGGER);
|
||||
SerializationConfig.initLogging(debugLog);
|
||||
// Setup our BlockSafety
|
||||
this.blockSafety = new SimpleBlockSafety(this);
|
||||
// Setup our LocationManipulation
|
||||
|
@ -347,7 +349,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||
} finally {
|
||||
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
||||
}
|
||||
|
||||
System.out.println(MultiverseCoreConfiguration.isSet());
|
||||
this.migrateWorldConfig();
|
||||
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||
|
||||
|
@ -431,7 +433,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||
boolean wasChanged = false;
|
||||
Map<String, Object> newValues = new LinkedHashMap<String, Object>(values.size());
|
||||
for (Map.Entry<String, Object> entry : values.entrySet()) {
|
||||
this.log(Level.INFO, "Migrating: " + entry.getKey());
|
||||
this.log(Level.FINE, "Migrating: " + entry.getKey());
|
||||
if (entry.getValue() instanceof MVWorld) {
|
||||
// fine
|
||||
newValues.put(entry.getKey(), entry.getValue());
|
||||
|
@ -747,13 +749,10 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||
public static void staticLog(Level level, String msg) {
|
||||
if (level == Level.FINE && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 1) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
return;
|
||||
} else if (level == Level.FINER && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 2) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
return;
|
||||
} else if (level == Level.FINEST && MultiverseCoreConfiguration.getInstance().getGlobalDebug() >= 3) {
|
||||
staticDebugLog(Level.INFO, msg);
|
||||
return;
|
||||
} else if (level != Level.FINE && level != Level.FINER && level != Level.FINEST) {
|
||||
LOGGER.log(level, String.format("%s %s", LOG_TAG, msg));
|
||||
debugLog.log(level, String.format("%s %s", LOG_TAG, msg));
|
||||
|
@ -768,8 +767,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||
* @param msg The message
|
||||
*/
|
||||
public static void staticDebugLog(Level level, String msg) {
|
||||
LOGGER.log(level, "[MVCore-Debug] " + msg);
|
||||
debugLog.log(level, "[MVCore-Debug] " + msg);
|
||||
debugLog.log(level, msg);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,12 @@
|
|||
package com.onarandombox.MultiverseCore;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.onarandombox.MultiverseCore.api.MultiverseCoreConfig;
|
||||
|
||||
import me.main__.util.SerializationConfig.NoSuchPropertyException;
|
||||
import me.main__.util.SerializationConfig.Property;
|
||||
import me.main__.util.SerializationConfig.SerializationConfig;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Our configuration.
|
||||
*/
|
||||
|
@ -22,6 +21,13 @@ public class MultiverseCoreConfiguration extends SerializationConfig implements
|
|||
MultiverseCoreConfiguration.instance = instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return True if the static instance of config is set.
|
||||
*/
|
||||
public static boolean isSet() {
|
||||
return instance != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the statically saved instance.
|
||||
* @return The statically saved instance.
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
package com.onarandombox.MultiverseCore.utils;
|
||||
|
||||
import com.onarandombox.MultiverseCore.MultiverseCoreConfiguration;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
|
@ -26,6 +28,7 @@ import java.util.logging.Logger;
|
|||
public class DebugLog extends Logger {
|
||||
|
||||
private FileHandler fh;
|
||||
private Logger standardLog = null;
|
||||
|
||||
/**
|
||||
* Creates a new debug logger.
|
||||
|
@ -35,7 +38,6 @@ public class DebugLog extends Logger {
|
|||
*/
|
||||
public DebugLog(String logger, String file) {
|
||||
super(logger, null);
|
||||
|
||||
try {
|
||||
this.fh = new FileHandler(file, true);
|
||||
this.setUseParentHandlers(false);
|
||||
|
@ -53,6 +55,30 @@ public class DebugLog extends Logger {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies the logger to use to send debug messages to as the debug logger itself only sends messages to a file.
|
||||
*
|
||||
* @param logger Logger to send debug messages to.
|
||||
*/
|
||||
public void setStandardLogger(Logger logger) {
|
||||
this.standardLog = logger;
|
||||
}
|
||||
|
||||
/**
|
||||
* Log a message at a certain level.
|
||||
*
|
||||
* @param level The log-{@link Level}.
|
||||
* @param msg the message.
|
||||
*/
|
||||
public void log(Level level, String msg) {
|
||||
if (MultiverseCoreConfiguration.isSet() && MultiverseCoreConfiguration.getInstance().getGlobalDebug() > 0) {
|
||||
if (standardLog != null) {
|
||||
standardLog.log(level, "[MVCore-Debug] " + msg);
|
||||
}
|
||||
super.log(level, "[MVCore-Debug] " + msg);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Our log-{@link Formatter}.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue