fix missing ArrayType and add tabcompletion to vanilla loot tables

This commit is contained in:
Julian Krings 2024-10-06 18:27:48 +02:00
parent db14861b40
commit f6a354b890
5 changed files with 35 additions and 1 deletions

View File

@ -22,6 +22,7 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.loader.IrisRegistrant; import com.volmit.iris.core.loader.IrisRegistrant;
import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.annotations.*; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.functions.StructureKeyFunction;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.json.JSONObject; import com.volmit.iris.util.json.JSONObject;
import com.volmit.iris.util.plugin.VolmitSender; import com.volmit.iris.util.plugin.VolmitSender;

View File

@ -129,6 +129,7 @@ public class IrisObjectPlacement {
@ArrayType(min = 1, type = IrisObjectLoot.class) @ArrayType(min = 1, type = IrisObjectLoot.class)
@Desc("The loot tables to apply to these objects") @Desc("The loot tables to apply to these objects")
private KList<IrisObjectLoot> loot = new KList<>(); private KList<IrisObjectLoot> loot = new KList<>();
@ArrayType(min = 1, type = IrisObjectVanillaLoot.class)
@Desc("The vanilla loot tables to apply to these objects") @Desc("The vanilla loot tables to apply to these objects")
private KList<IrisObjectVanillaLoot> vanillaLoot = new KList<>(); private KList<IrisObjectVanillaLoot> vanillaLoot = new KList<>();
@Desc("Whether the given loot tables override any and all other loot tables available in the dimension, region or biome.") @Desc("Whether the given loot tables override any and all other loot tables available in the dimension, region or biome.")

View File

@ -3,6 +3,7 @@ package com.volmit.iris.engine.object;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.data.cache.AtomicCache; import com.volmit.iris.engine.data.cache.AtomicCache;
import com.volmit.iris.engine.object.annotations.*; import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.engine.object.annotations.functions.LootTableKeyFunction;
import com.volmit.iris.util.collection.KList; import com.volmit.iris.util.collection.KList;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Data; import lombok.Data;
@ -23,6 +24,7 @@ public class IrisObjectVanillaLoot {
private KList<IrisBlockData> filter = new KList<>(); private KList<IrisBlockData> filter = new KList<>();
@Desc("Exactly match the block data or not") @Desc("Exactly match the block data or not")
private boolean exact = false; private boolean exact = false;
@RegistryListFunction(LootTableKeyFunction.class)
@Desc("The vanilla loot table key") @Desc("The vanilla loot table key")
@Required @Required
private String name; private String name;

View File

@ -0,0 +1,30 @@
package com.volmit.iris.engine.object.annotations.functions;
import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.engine.framework.ListFunction;
import com.volmit.iris.util.collection.KList;
import org.bukkit.NamespacedKey;
import org.bukkit.loot.LootTables;
import java.util.Arrays;
import java.util.stream.Collectors;
public class LootTableKeyFunction implements ListFunction<IrisData, KList<String>> {
@Override
public String key() {
return "loot-table-key";
}
@Override
public String fancyName() {
return "LootTable Key";
}
@Override
public KList<String> apply(IrisData data) {
return Arrays.stream(LootTables.values())
.map(LootTables::getKey)
.map(NamespacedKey::toString)
.collect(Collectors.toCollection(KList::new));
}
}

View File

@ -1,4 +1,4 @@
package com.volmit.iris.engine.object.annotations; package com.volmit.iris.engine.object.annotations.functions;
import com.volmit.iris.core.loader.IrisData; import com.volmit.iris.core.loader.IrisData;
import com.volmit.iris.core.nms.INMS; import com.volmit.iris.core.nms.INMS;