mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 12:56:28 +00:00
差不多了
This commit is contained in:
@@ -16,6 +16,7 @@ import net.momirealms.craftengine.core.pack.LoadingSequence;
|
||||
import net.momirealms.craftengine.core.pack.Pack;
|
||||
import net.momirealms.craftengine.core.plugin.config.ConfigSectionParser;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.EnumUtils;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.MiscUtils;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
@@ -110,9 +111,14 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
String type = (String) section.get("type");
|
||||
if (type == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.vanilla_loot.missing_type", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.vanilla_loot.missing_type");
|
||||
}
|
||||
VanillaLoot.Type typeEnum;
|
||||
try {
|
||||
typeEnum = VanillaLoot.Type.valueOf(type.toUpperCase(Locale.ENGLISH));
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new LocalizedResourceConfigException("warning.config.vanilla_loot.invalid_type", type, EnumUtils.toString(VanillaLoot.Type.values()));
|
||||
}
|
||||
VanillaLoot.Type typeEnum = VanillaLoot.Type.valueOf(type.toUpperCase(Locale.ENGLISH));
|
||||
boolean override = (boolean) section.getOrDefault("override", false);
|
||||
List<String> targets = MiscUtils.getAsStringList(section.getOrDefault("target", List.of()));
|
||||
LootTable<?> lootTable = LootTable.fromMap(MiscUtils.castToMap(section.get("loot"), false));
|
||||
@@ -122,14 +128,14 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme
|
||||
if (target.endsWith("]") && target.contains("[")) {
|
||||
java.lang.Object blockState = BlockStateUtils.blockDataToBlockState(Bukkit.createBlockData(target));
|
||||
if (blockState == Reflections.instance$Blocks$AIR$defaultState) {
|
||||
throw new LocalizedResourceConfigException("warning.config.vanilla_loot.block.invalid_target", path, id, target);
|
||||
throw new LocalizedResourceConfigException("warning.config.vanilla_loot.block.invalid_target", target);
|
||||
}
|
||||
VanillaLoot vanillaLoot = blockLoots.computeIfAbsent(BlockStateUtils.blockStateToId(blockState), k -> new VanillaLoot(VanillaLoot.Type.BLOCK));
|
||||
vanillaLoot.addLootTable(lootTable);
|
||||
} else {
|
||||
for (Object blockState : BlockStateUtils.getAllVanillaBlockStates(Key.of(target))) {
|
||||
if (blockState == Reflections.instance$Blocks$AIR$defaultState) {
|
||||
throw new LocalizedResourceConfigException("warning.config.vanilla_loot.block.invalid_target", path, id, target);
|
||||
throw new LocalizedResourceConfigException("warning.config.vanilla_loot.block.invalid_target", target);
|
||||
}
|
||||
VanillaLoot vanillaLoot = blockLoots.computeIfAbsent(BlockStateUtils.blockStateToId(blockState), k -> new VanillaLoot(VanillaLoot.Type.BLOCK));
|
||||
if (override) vanillaLoot.override(true);
|
||||
|
||||
Reference in New Issue
Block a user