mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2025-07-04 00:45:57 +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 String id;
|
||||||
private final LinkedHashMap<Location, StructureBuffer> cache;
|
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;
|
Parser parser;
|
||||||
try {
|
try {
|
||||||
parser = new Parser(IOUtils.toString(inputStream));
|
parser = new Parser(IOUtils.toString(inputStream));
|
||||||
@ -53,11 +53,7 @@ public class StructureScript {
|
|||||||
.addFunction("loot", new LootFunctionBuilder(main, lootRegistry))
|
.addFunction("loot", new LootFunctionBuilder(main, lootRegistry))
|
||||||
.addFunction("entity", new EntityFunctionBuilder(main));
|
.addFunction("entity", new EntityFunctionBuilder(main));
|
||||||
|
|
||||||
try {
|
block = parser.parse();
|
||||||
block = parser.parse();
|
|
||||||
} catch(ParseException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
this.id = parser.getID();
|
this.id = parser.getID();
|
||||||
this.cache = new LinkedHashMap<Location, StructureBuffer>() {
|
this.cache = new LinkedHashMap<Location, StructureBuffer>() {
|
||||||
@Override
|
@Override
|
||||||
|
@ -154,15 +154,21 @@ public class ConfigPack implements LoaderRegistrar {
|
|||||||
varScope.create(var.getKey()).setValue(var.getValue());
|
varScope.create(var.getKey()).setValue(var.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
loader.open("structures/data", ".tesf").then(streams -> streams.forEach(stream -> {
|
loader.open("structures/data", ".tesf").thenEntries(entries -> {
|
||||||
StructureScript structureScript = new StructureScript(stream, main, scriptRegistry, lootRegistry, checkCache);
|
for(Map.Entry<String, InputStream> entry : entries) {
|
||||||
scriptRegistry.add(structureScript.getId(), structureScript);
|
try {
|
||||||
})).close().open("structures/loot", ".json").thenEntries(entries -> {
|
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) {
|
for(Map.Entry<String, InputStream> entry : entries) {
|
||||||
try {
|
try {
|
||||||
lootRegistry.add(entry.getKey(), new LootTable(IOUtils.toString(entry.getValue(), StandardCharsets.UTF_8), main));
|
lootRegistry.add(entry.getKey(), new LootTable(IOUtils.toString(entry.getValue(), StandardCharsets.UTF_8), main));
|
||||||
} catch(ParseException | IOException | NullPointerException e) {
|
} 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();
|
}).close();
|
||||||
|
@ -31,7 +31,8 @@ public class FolderLoader extends Loader {
|
|||||||
try(Stream<Path> paths = Files.walk(newPath.toPath())) {
|
try(Stream<Path> paths = Files.walk(newPath.toPath())) {
|
||||||
paths.filter(Files::isRegularFile).filter(file -> file.toString().toLowerCase().endsWith(extension)).forEach(file -> {
|
paths.filter(Files::isRegularFile).filter(file -> file.toString().toLowerCase().endsWith(extension)).forEach(file -> {
|
||||||
try {
|
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) {
|
} catch(FileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,8 @@ public class ZIPLoader extends Loader {
|
|||||||
ZipEntry entry = entries.nextElement();
|
ZipEntry entry = entries.nextElement();
|
||||||
if(!entry.isDirectory() && entry.getName().startsWith(directory) && entry.getName().endsWith(extension)) {
|
if(!entry.isDirectory() && entry.getName().startsWith(directory) && entry.getName().endsWith(extension)) {
|
||||||
try {
|
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) {
|
} catch(IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.dfsek.terra.bukkit.generator;
|
package com.dfsek.terra.bukkit.generator;
|
||||||
|
|
||||||
|
import com.dfsek.terra.TerraWorld;
|
||||||
import com.dfsek.terra.api.platform.TerraPlugin;
|
import com.dfsek.terra.api.platform.TerraPlugin;
|
||||||
import com.dfsek.terra.api.platform.generator.GeneratorWrapper;
|
import com.dfsek.terra.api.platform.generator.GeneratorWrapper;
|
||||||
import com.dfsek.terra.api.platform.world.Chunk;
|
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.bukkit.world.BukkitBiomeGrid;
|
||||||
import com.dfsek.terra.config.lang.LangUtil;
|
import com.dfsek.terra.config.lang.LangUtil;
|
||||||
import com.dfsek.terra.debug.Debug;
|
import com.dfsek.terra.debug.Debug;
|
||||||
import com.dfsek.terra.generation.MasterChunkGenerator;
|
|
||||||
import com.dfsek.terra.population.CavePopulator;
|
import com.dfsek.terra.population.CavePopulator;
|
||||||
import com.dfsek.terra.population.FloraPopulator;
|
import com.dfsek.terra.population.FloraPopulator;
|
||||||
import com.dfsek.terra.population.OrePopulator;
|
import com.dfsek.terra.population.OrePopulator;
|
||||||
@ -64,7 +64,7 @@ public class BukkitChunkGeneratorWrapper extends ChunkGenerator implements Gener
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void fixChunk(Chunk c) {
|
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());
|
popMap.get(c.getWorld()).checkNeighbors(c.getX(), c.getZ(), c.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user