mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-03 16:35:50 +00:00
fix terrascript loading logging
This commit is contained in:
parent
a51727b636
commit
6bac82da25
@ -35,7 +35,7 @@ public class StructureScript {
|
||||
private final String id;
|
||||
private final LinkedHashMap<Location, StructureBuffer> cache;
|
||||
|
||||
public StructureScript(InputStream inputStream, TerraPlugin main, ScriptRegistry registry, LootRegistry lootRegistry, CheckCache cache) {
|
||||
public StructureScript(InputStream inputStream, TerraPlugin main, ScriptRegistry registry, LootRegistry lootRegistry, CheckCache cache) throws ParseException {
|
||||
Parser parser;
|
||||
try {
|
||||
parser = new Parser(IOUtils.toString(inputStream));
|
||||
@ -53,11 +53,7 @@ public class StructureScript {
|
||||
.addFunction("loot", new LootFunctionBuilder(main, lootRegistry))
|
||||
.addFunction("entity", new EntityFunctionBuilder(main));
|
||||
|
||||
try {
|
||||
block = parser.parse();
|
||||
} catch(ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
block = parser.parse();
|
||||
this.id = parser.getID();
|
||||
this.cache = new LinkedHashMap<Location, StructureBuffer>() {
|
||||
@Override
|
||||
|
@ -154,15 +154,21 @@ public class ConfigPack implements LoaderRegistrar {
|
||||
varScope.create(var.getKey()).setValue(var.getValue());
|
||||
}
|
||||
|
||||
loader.open("structures/data", ".tesf").then(streams -> streams.forEach(stream -> {
|
||||
StructureScript structureScript = new StructureScript(stream, main, scriptRegistry, lootRegistry, checkCache);
|
||||
scriptRegistry.add(structureScript.getId(), structureScript);
|
||||
})).close().open("structures/loot", ".json").thenEntries(entries -> {
|
||||
loader.open("structures/data", ".tesf").thenEntries(entries -> {
|
||||
for(Map.Entry<String, InputStream> entry : entries) {
|
||||
try {
|
||||
StructureScript structureScript = new StructureScript(entry.getValue(), main, scriptRegistry, lootRegistry, checkCache);
|
||||
scriptRegistry.add(structureScript.getId(), structureScript);
|
||||
} catch(com.dfsek.terra.api.structures.parser.exceptions.ParseException e) {
|
||||
throw new LoadException("Unable to load script \"" + entry.getKey() + "\"", e);
|
||||
}
|
||||
}
|
||||
}).close().open("structures/loot", ".json").thenEntries(entries -> {
|
||||
for(Map.Entry<String, InputStream> entry : entries) {
|
||||
try {
|
||||
lootRegistry.add(entry.getKey(), new LootTable(IOUtils.toString(entry.getValue(), StandardCharsets.UTF_8), main));
|
||||
} catch(ParseException | IOException | NullPointerException e) {
|
||||
throw new LoadException("Unable to load loot", e);
|
||||
throw new LoadException("Unable to load loot table \"" + entry.getKey() + "\"", e);
|
||||
}
|
||||
}
|
||||
}).close();
|
||||
|
@ -31,7 +31,8 @@ public class FolderLoader extends Loader {
|
||||
try(Stream<Path> paths = Files.walk(newPath.toPath())) {
|
||||
paths.filter(Files::isRegularFile).filter(file -> file.toString().toLowerCase().endsWith(extension)).forEach(file -> {
|
||||
try {
|
||||
streams.put(newPath.toURI().relativize(file.toUri()).getPath(), new FileInputStream(file.toFile()));
|
||||
String rel = newPath.toPath().relativize(file).toString();
|
||||
streams.put(rel, new FileInputStream(file.toFile()));
|
||||
} catch(FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ public class ZIPLoader extends Loader {
|
||||
ZipEntry entry = entries.nextElement();
|
||||
if(!entry.isDirectory() && entry.getName().startsWith(directory) && entry.getName().endsWith(extension)) {
|
||||
try {
|
||||
streams.put(entry.getName(), file.getInputStream(entry));
|
||||
String rel = entry.getName().substring(directory.length() + 1);
|
||||
streams.put(rel, file.getInputStream(entry));
|
||||
} catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package com.dfsek.terra.bukkit.generator;
|
||||
|
||||
import com.dfsek.terra.TerraWorld;
|
||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||
import com.dfsek.terra.api.platform.generator.GeneratorWrapper;
|
||||
import com.dfsek.terra.api.platform.world.Chunk;
|
||||
@ -9,7 +10,6 @@ import com.dfsek.terra.bukkit.world.BukkitAdapter;
|
||||
import com.dfsek.terra.bukkit.world.BukkitBiomeGrid;
|
||||
import com.dfsek.terra.config.lang.LangUtil;
|
||||
import com.dfsek.terra.debug.Debug;
|
||||
import com.dfsek.terra.generation.MasterChunkGenerator;
|
||||
import com.dfsek.terra.population.CavePopulator;
|
||||
import com.dfsek.terra.population.FloraPopulator;
|
||||
import com.dfsek.terra.population.OrePopulator;
|
||||
@ -64,7 +64,7 @@ public class BukkitChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
||||
}
|
||||
|
||||
public static synchronized void fixChunk(Chunk c) {
|
||||
if(!(c.getWorld().getGenerator() instanceof MasterChunkGenerator)) throw new IllegalArgumentException();
|
||||
if(!TerraWorld.isTerraWorld(c.getWorld())) throw new IllegalArgumentException();
|
||||
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user