mirror of
https://github.com/PolyhedralDev/Terra.git
synced 2026-11-30 01:44:28 +00:00
fix: make config pack registration thread-safe
This commit is contained in:
1 parent
bebcb775fc
commit
2f36b2d5c4
5 files changed
+413
-45
No files matched your search
+4
-1
@@ -40,6 +40,8 @@ public class TerraScriptAddon implements AddonInitializer {
|
||||
.then(event -> {
|
||||
CheckedRegistry<Structure> structureRegistry = event.getPack().getOrCreateRegistry(Structure.class);
|
||||
CheckedRegistry<LootTable> lootRegistry = event.getPack().getOrCreateRegistry(LootTable.class);
|
||||
// Pack registries must not be created from worker threads.
|
||||
CheckedRegistry<FunctionBuilder> functionRegistry = event.getPack().getOrCreateRegistry(FunctionBuilder.class);
|
||||
try {
|
||||
FileUtil.filesWithExtension(event.getPack().getRootPath(), ".tesf")
|
||||
.entrySet()
|
||||
@@ -53,11 +55,12 @@ public class TerraScriptAddon implements AddonInitializer {
|
||||
platform,
|
||||
structureRegistry,
|
||||
lootRegistry,
|
||||
event.getPack().getOrCreateRegistry(FunctionBuilder.class));
|
||||
functionRegistry);
|
||||
} catch(ParseException | IOException e) {
|
||||
throw new RuntimeException("Failed to load script \"" + entry.getKey() + "\"", e);
|
||||
}
|
||||
})
|
||||
.toList()
|
||||
.forEach(structureRegistry::register);
|
||||
} catch(IOException e) {
|
||||
throw new RuntimeException("Error occurred while reading config pack files", e);
|
||||
|
||||
Reference in new issue
Block a user