Debug generator error

This commit is contained in:
Jesse Boyd 2018-07-27 10:56:53 +10:00
parent 1b08d54be0
commit 2d98da47cf
No known key found for this signature in database
GPG Key ID: 59F1DE6293AF6E1F

View File

@ -8,6 +8,7 @@ import cn.nukkit.event.Listener;
import cn.nukkit.level.Level; import cn.nukkit.level.Level;
import cn.nukkit.level.format.FullChunk; import cn.nukkit.level.format.FullChunk;
import cn.nukkit.level.generator.Generator; import cn.nukkit.level.generator.Generator;
import cn.nukkit.level.generator.Normal;
import cn.nukkit.metadata.MetadataValue; import cn.nukkit.metadata.MetadataValue;
import cn.nukkit.plugin.Plugin; import cn.nukkit.plugin.Plugin;
import cn.nukkit.plugin.PluginBase; import cn.nukkit.plugin.PluginBase;
@ -36,6 +37,7 @@ import com.plotsquared.nukkit.uuid.LowerOfflineUUIDWrapper;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import java.io.File; import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.util.*; import java.util.*;
public final class NukkitMain extends PluginBase implements Listener, IPlotMain { public final class NukkitMain extends PluginBase implements Listener, IPlotMain {
@ -294,18 +296,19 @@ public final class NukkitMain extends PluginBase implements Listener, IPlotMain
} }
HashMap<String, Object> map = new HashMap<String, Object>(); HashMap<String, Object> map = new HashMap<String, Object>();
map.put("world", world); map.put("world", world);
try { Class<? extends Generator> gen = Generator.getGenerator(name);
Class<? extends Generator> gen = Generator.getGenerator(name); if (gen != null) {
if (gen != null) { try {
Generator instance = gen.getConstructor(Map.class).newInstance(map); Generator instance = gen.getConstructor(Map.class).newInstance(map);
if (instance instanceof GeneratorWrapper) { if (instance instanceof GeneratorWrapper) {
return (GeneratorWrapper<?>) instance; return (GeneratorWrapper<?>) instance;
} }
map.put("generator", instance); map.put("generator", instance);
return new NukkitPlotGenerator(map); return new NukkitPlotGenerator(map);
} catch (Throwable e) {
System.out.println("Failed to create generator for " + name + " | " + gen);
e.printStackTrace();
} }
} catch (Throwable e) {
e.printStackTrace();
} }
return new NukkitHybridGen(map); return new NukkitHybridGen(map);
} }