This commit is contained in:
dfsek
2021-07-15 13:24:05 -07:00
parent 34e78ab55e
commit 95e6479505
7 changed files with 73 additions and 18 deletions
@@ -2,6 +2,7 @@ package com.dfsek.terra.addons.biome;
import com.dfsek.terra.addons.biome.holder.PaletteHolder;
import com.dfsek.terra.addons.biome.holder.PaletteHolderLoader;
import com.dfsek.terra.addons.biome.slant.SlantHolder;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.addon.TerraAddon;
import com.dfsek.terra.api.addon.annotations.Addon;
@@ -21,7 +22,8 @@ public class BiomeConfigAddon extends TerraAddon implements EventListener {
@Override
public void initialize() {
main.getEventManager().registerListener(this, this);
main.applyLoader(PaletteHolder.class, new PaletteHolderLoader());
main.applyLoader(PaletteHolder.class, new PaletteHolderLoader())
.applyLoader(SlantHolder.class, (t, o, l) -> null);
}
public void onPackLoad(ConfigPackPreLoadEvent event) {
@@ -0,0 +1,29 @@
package com.dfsek.terra.addons.structure;
import com.dfsek.terra.api.TerraPlugin;
import com.dfsek.terra.api.addon.TerraAddon;
import com.dfsek.terra.api.addon.annotations.Addon;
import com.dfsek.terra.api.addon.annotations.Author;
import com.dfsek.terra.api.addon.annotations.Version;
import com.dfsek.terra.api.event.EventListener;
import com.dfsek.terra.api.event.events.config.ConfigPackPreLoadEvent;
import com.dfsek.terra.api.injection.annotations.Inject;
import com.dfsek.terra.api.structure.ConfiguredStructure;
@Addon("config-structure")
@Version("1.0.0")
@Author("Terra")
public class StructureAddon extends TerraAddon implements EventListener {
@Inject
private TerraPlugin main;
@Override
public void initialize() {
main.getEventManager().registerListener(this, this);
main.applyLoader(ConfiguredStructure.class, (t, o, l) -> null);
}
public void onConfigLoad(ConfigPackPreLoadEvent event) {
}
}
@@ -36,8 +36,12 @@ public class OpenRegistryImpl<T> implements OpenRegistry<T> {
@Override
public T load(AnnotatedType type, Object o, ConfigLoader configLoader) throws LoadException {
T obj = get((String) o);
StringBuilder keys = new StringBuilder("[");
objects.keySet().forEach(key -> keys.append(key + ", "));
if(obj == null)
throw new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o + "\" was found in this registry.");
throw new LoadException("No such " + type.getType().getTypeName() + " matching \"" + o + "\" was found in this registry. Registry contains items: " + keys.substring(0, keys.length()-2) + "]");
return obj;
}