mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-27 02:49:15 +00:00
让事情变得更加美好
This commit is contained in:
@@ -160,6 +160,7 @@ warning.config.item.model.select.local_time.missing_pattern: "<yellow>Issue foun
|
||||
warning.config.item.model.special.missing_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'type' argument for model 'minecraft:special'.</yellow>"
|
||||
warning.config.item.model.special.invalid_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is using an invalid type '<arg:2>' for model 'minecraft:special'.</yellow>"
|
||||
warning.config.item.model.special.banner.missing_color: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'color' argument for special model 'minecraft:banner'.</yellow>"
|
||||
warning.config.item.model.special.bed.missing_texture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'texture' argument for special model 'minecraft:bed'.</yellow>"
|
||||
warning.config.item.model.special.sign.missing_wood_type: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'wood-type' argument for special model 'minecraft:hanging_sign'/'minecraft:standing_sign'.</yellow>"
|
||||
warning.config.item.model.special.sign.missing_texture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'texture' argument for special model 'minecraft:hanging_sign'/'minecraft:standing_sign'.</yellow>"
|
||||
warning.config.item.model.special.chest.missing_texture: "<yellow>Issue found in file <arg:0> - The item '<arg:1>' is missing the required 'texture' argument for special model 'minecraft:chest'.</yellow>"
|
||||
@@ -173,6 +174,7 @@ warning.config.block.missing_state: "<yellow>Issue found in file <arg:0> - The b
|
||||
warning.config.block.state.property.missing_type: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'type' argument for property '<arg:2>'.</yellow>"
|
||||
warning.config.block.state.property.invalid_type: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using the invalid type argument '<arg:2>' for property '<arg:3>'.</yellow>"
|
||||
warning.config.block.state.property.integer.invalid_range: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using the invalid 'range' argument '<arg:2>' for integer property '<arg:3>'. Correct syntax: 1~2.</yellow>"
|
||||
warning.config.block.state.property.invalid_format: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is using an invalid block state property format '<arg:2>'.</yellow>"
|
||||
warning.config.block.state.missing_real_id: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'id' argument for 'state'. 'id' is the serverside block id which is unique for each type of block state. If you create a serverside side block with 'note_block' and id 30, then the real block id would be 'craftengine:note_block_30'.</yellow>"
|
||||
warning.config.block.state.missing_state: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'state' argument for 'state'.</yellow>"
|
||||
warning.config.block.state.missing_properties: "<yellow>Issue found in file <arg:0> - The block '<arg:1>' is missing the required 'properties' section for 'states'.</yellow>"
|
||||
|
||||
@@ -160,6 +160,7 @@ warning.config.item.model.select.local_time.missing_pattern: "<yellow>在文件
|
||||
warning.config.item.model.special.missing_type: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的 'minecraft:special' 模型缺少必需的 'type' 参数</yellow>"
|
||||
warning.config.item.model.special.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的 'minecraft:special' 模型使用了无效类型 '<arg:2>'</yellow>"
|
||||
warning.config.item.model.special.banner.missing_color: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的 'minecraft:banner' 特殊模型缺少必需的 'color' 参数</yellow>"
|
||||
warning.config.item.model.special.bed.missing_texture: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的 'minecraft:bed' 特殊模型缺少必需的 'texture' 参数</yellow>"
|
||||
warning.config.item.model.special.sign.missing_wood_type: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的 'minecraft:hanging_sign'/'minecraft:standing_sign' 特殊模型缺少必需的 'wood-type' 参数</yellow>"
|
||||
warning.config.item.model.special.sign.missing_texture: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的 'minecraft:hanging_sign'/'minecraft:standing_sign' 特殊模型缺少必需的 'texture' 参数</yellow>"
|
||||
warning.config.item.model.special.chest.missing_texture: "<yellow>在文件 <arg:0> 发现问题 - 物品 '<arg:1>' 的 'minecraft:chest' 特殊模型缺少必需的 'texture' 参数</yellow>"
|
||||
@@ -173,6 +174,7 @@ warning.config.block.missing_state: "<yellow>在文件 <arg:0> 发现问题 -
|
||||
warning.config.block.state.property.missing_type: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的属性 '<arg:2>' 缺少必需的 'type' 参数</yellow>"
|
||||
warning.config.block.state.property.invalid_type: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的属性 '<arg:3>' 使用了无效的类型参数 '<arg:2>'</yellow>"
|
||||
warning.config.block.state.property.integer.invalid_range: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的整数属性 '<arg:3>' 使用了无效的范围参数 '<arg:2>' 正确语法: 1~2</yellow>"
|
||||
warning.config.block.state.property.invalid_format: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 使用了无效的方块状态属性格式 '<arg:2>'.</yellow>"
|
||||
warning.config.block.state.missing_real_id: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'state' 缺少必需的 'id' 参数 该 ID 是服务端方块 ID 用于唯一标识每种方块状态类型</yellow>"
|
||||
warning.config.block.state.missing_state: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'state' 缺少必需的 'state' 参数</yellow>"
|
||||
warning.config.block.state.missing_properties: "<yellow>在文件 <arg:0> 发现问题 - 方块 '<arg:1>' 的 'states' 缺少必需的 'properties' 段落</yellow>"
|
||||
|
||||
@@ -331,7 +331,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
// check duplicated config
|
||||
if (byId.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.duplicate", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.duplicate");
|
||||
}
|
||||
// read block settings
|
||||
BlockSettings settings = BlockSettings.fromMap(MiscUtils.castToMap(section.getOrDefault("settings", Map.of()), false));
|
||||
@@ -343,13 +343,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
Map<String, Property<?>> properties;
|
||||
Map<String, Integer> appearances;
|
||||
Map<String, VariantState> variants;
|
||||
Object stateObj = section.get("state");
|
||||
if (stateObj == null) {
|
||||
stateObj = section.get("states");
|
||||
}
|
||||
if (stateObj == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.missing_state", path, id);
|
||||
}
|
||||
Object stateObj = ResourceConfigUtils.requireNonNullOrThrow(ResourceConfigUtils.get(section, "state", "states"), "warning.config.block.missing_state");
|
||||
Map<String, Object> stateSection = MiscUtils.castToMap(stateObj, true);
|
||||
|
||||
// single state
|
||||
@@ -357,7 +351,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
properties = Map.of();
|
||||
int internalId = ResourceConfigUtils.getAsInt(stateSection.getOrDefault("id", -1), "id");
|
||||
if (internalId < 0) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.missing_real_id", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.missing_real_id");
|
||||
}
|
||||
|
||||
Pair<Key, Integer> pair = parseAppearanceSection(id, stateSection);
|
||||
@@ -368,7 +362,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
Key internalBlockId = Key.of(CraftEngine.NAMESPACE, internalBlock);
|
||||
int internalBlockRegistryId = Optional.ofNullable(internalId2StateId.get(internalBlockId)).orElse(-1);
|
||||
if (internalBlockRegistryId == -1) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.invalid_real_id", path, id,
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.invalid_real_id",
|
||||
internalBlock,
|
||||
String.valueOf(registeredRealBlockSlots.get(pair.left()) - 1));
|
||||
}
|
||||
@@ -377,13 +371,13 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
// properties
|
||||
Map<String, Object> propertySection = MiscUtils.castToMap(stateSection.get("properties"), true);
|
||||
if (propertySection == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.missing_properties", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.missing_properties");
|
||||
}
|
||||
properties = parseProperties(propertySection);
|
||||
// appearance
|
||||
Map<String, Object> appearancesSection = MiscUtils.castToMap(stateSection.get("appearances"), true);
|
||||
if (appearancesSection == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.missing_appearances", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.missing_appearances");
|
||||
}
|
||||
appearances = new HashMap<>();
|
||||
Map<String, Key> tempTypeMap = new HashMap<>();
|
||||
@@ -398,7 +392,7 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
// variants
|
||||
Map<String, Object> variantsSection = MiscUtils.castToMap(stateSection.get("variants"), true);
|
||||
if (variantsSection == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.missing_variants", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.missing_variants");
|
||||
}
|
||||
variants = new HashMap<>();
|
||||
for (Map.Entry<String, Object> variantEntry : variantsSection.entrySet()) {
|
||||
@@ -407,17 +401,17 @@ public class BukkitBlockManager extends AbstractBlockManager {
|
||||
String variantName = variantEntry.getKey();
|
||||
String appearance = (String) variantSection.get("appearance");
|
||||
if (appearance == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.variant.missing_appearance", path, id, variantName);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.variant.missing_appearance", variantName);
|
||||
}
|
||||
if (!appearances.containsKey(appearance)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.variant.invalid_appearance", path, id, variantName, appearance);
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.variant.invalid_appearance", variantName, appearance);
|
||||
}
|
||||
int internalId = ResourceConfigUtils.getAsInt(variantSection.getOrDefault("id", -1), "id");
|
||||
Key baseBlock = tempTypeMap.get(appearance);
|
||||
Key internalBlockId = Key.of(CraftEngine.NAMESPACE, baseBlock.value() + "_" + internalId);
|
||||
int internalBlockRegistryId = Optional.ofNullable(internalId2StateId.get(internalBlockId)).orElse(-1);
|
||||
if (internalBlockRegistryId == -1) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.invalid_real_id", path, id,
|
||||
throw new LocalizedResourceConfigException("warning.config.block.state.invalid_real_id",
|
||||
internalBlockId.toString(),
|
||||
String.valueOf(registeredRealBlockSlots.getOrDefault(baseBlock, 1) - 1));
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import net.momirealms.craftengine.core.block.UpdateOption;
|
||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||
import net.momirealms.craftengine.core.item.context.BlockPlaceContext;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.Direction;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
@@ -158,10 +157,7 @@ public class ConcretePowderBlockBehavior extends FallingBlockBehavior {
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
float hurtAmount = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("hurt-amount", -1f), "hurt-amount");
|
||||
int hurtMax = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-hurt", -1), "max-hurt");
|
||||
String solidBlock = (String) arguments.get("solid-block");
|
||||
if (solidBlock == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.concrete.missing_solid", new NullPointerException("No `solid-block` specified for concrete powder block behavior"));
|
||||
}
|
||||
String solidBlock = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("solid-block"), "warning.config.block.behavior.concrete.missing_solid");
|
||||
return new ConcretePowderBlockBehavior(block, hurtAmount, hurtMax, Key.of(solidBlock));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import net.momirealms.craftengine.core.loot.LootContext;
|
||||
import net.momirealms.craftengine.core.loot.number.NumberProvider;
|
||||
import net.momirealms.craftengine.core.loot.number.NumberProviders;
|
||||
import net.momirealms.craftengine.core.loot.parameter.LootParameters;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.RandomUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.util.Tuple;
|
||||
@@ -169,10 +168,7 @@ public class CropBlockBehavior extends BushBlockBehavior {
|
||||
@Override
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
Tuple<List<Object>, Set<Object>, Set<String>> tuple = readTagsAndState(arguments, false);
|
||||
Property<Integer> ageProperty = (Property<Integer>) block.getProperty("age");
|
||||
if (ageProperty == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.crop.missing_age", new IllegalArgumentException("age property not set for crop"));
|
||||
}
|
||||
Property<Integer> ageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("age"), "warning.config.block.behavior.crop.missing_age");
|
||||
int minGrowLight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("light-requirement", 9), "light-requirement");
|
||||
float growSpeed = ResourceConfigUtils.getAsFloat(arguments.getOrDefault("grow-speed", 0.125f), "grow-speed");
|
||||
boolean isBoneMealTarget = (boolean) arguments.getOrDefault("is-bone-meal-target", true);
|
||||
|
||||
@@ -14,9 +14,9 @@ import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||
import net.momirealms.craftengine.core.block.properties.Property;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.loot.parameter.LootParameters;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.Direction;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.core.util.VersionHelper;
|
||||
import net.momirealms.craftengine.core.util.context.ContextHolder;
|
||||
import net.momirealms.craftengine.core.world.BlockPos;
|
||||
@@ -173,14 +173,8 @@ public class LeavesBlockBehavior extends WaterLoggedBlockBehavior {
|
||||
public static class Factory implements BlockBehaviorFactory {
|
||||
@Override
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
Property<Boolean> persistent = (Property<Boolean>) block.getProperty("persistent");
|
||||
if (persistent == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.leaves.missing_persistent", new NullPointerException("persistent property not set for block " + block.id()));
|
||||
}
|
||||
Property<Integer> distance = (Property<Integer>) block.getProperty("distance");
|
||||
if (distance == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.leaves.missing_distance", new NullPointerException("distance property not set for block " + block.id()));
|
||||
}
|
||||
Property<Boolean> persistent = (Property<Boolean>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("persistent"), "warning.config.block.behavior.leaves.missing_persistent");
|
||||
Property<Integer> distance = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("distance"), "warning.config.block.behavior.leaves.missing_distance");
|
||||
Property<Boolean> waterlogged = (Property<Boolean>) block.getProperty("waterlogged");
|
||||
int actual = distance.possibleValues().get(distance.possibleValues().size() - 1);
|
||||
return new LeavesBlockBehavior(block, actual, distance, persistent, waterlogged);
|
||||
|
||||
@@ -10,7 +10,6 @@ import net.momirealms.craftengine.core.block.UpdateOption;
|
||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||
import net.momirealms.craftengine.core.block.properties.Property;
|
||||
import net.momirealms.craftengine.core.plugin.CraftEngine;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.RandomUtils;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
@@ -141,14 +140,8 @@ public class SaplingBlockBehavior extends BushBlockBehavior {
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
String feature = (String) arguments.get("feature");
|
||||
if (feature == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.sapling.missing_feature", new IllegalArgumentException("'feature' is required for sapling block behavior"));
|
||||
}
|
||||
Property<Integer> stageProperty = (Property<Integer>) block.getProperty("stage");
|
||||
if (stageProperty == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.sapling.missing_stage", new IllegalArgumentException("stage property not set for sapling"));
|
||||
}
|
||||
String feature = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("feature"), "warning.config.block.behavior.sapling.missing_feature");
|
||||
Property<Integer> stageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("stage"), "warning.config.block.behavior.sapling.missing_stage");
|
||||
double boneMealSuccessChance = ResourceConfigUtils.getAsDouble(arguments.getOrDefault("bone-meal-success-chance", 0.45), "bone-meal-success-chance");
|
||||
Tuple<List<Object>, Set<Object>, Set<String>> tuple = readTagsAndState(arguments, false);
|
||||
return new SaplingBlockBehavior(block, Key.of(feature), stageProperty, tuple.left(), tuple.mid(), tuple.right(), boneMealSuccessChance,
|
||||
|
||||
@@ -2,8 +2,8 @@ package net.momirealms.craftengine.bukkit.block.behavior;
|
||||
|
||||
import net.momirealms.craftengine.core.block.CustomBlock;
|
||||
import net.momirealms.craftengine.core.block.behavior.BlockBehaviorFactory;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.Key;
|
||||
import net.momirealms.craftengine.core.util.ResourceConfigUtils;
|
||||
import net.momirealms.craftengine.shared.block.BlockBehavior;
|
||||
|
||||
import java.util.Map;
|
||||
@@ -25,10 +25,7 @@ public class StrippableBlockBehavior extends BukkitBlockBehavior {
|
||||
|
||||
@Override
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
String stripped = (String) arguments.get("stripped");
|
||||
if (stripped == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.strippable.missing_stripped", new IllegalArgumentException("'stripped' is required for strippable block behavior"));
|
||||
}
|
||||
String stripped = ResourceConfigUtils.requireNonEmptyStringOrThrow(arguments.get("stripped"), "warning.config.block.behavior.strippable.missing_stripped");
|
||||
return new StrippableBlockBehavior(block, Key.of(stripped));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,6 @@ import net.momirealms.craftengine.core.block.properties.IntegerProperty;
|
||||
import net.momirealms.craftengine.core.block.properties.Property;
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.loot.parameter.LootParameters;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.util.*;
|
||||
import net.momirealms.craftengine.core.util.context.ContextHolder;
|
||||
import net.momirealms.craftengine.core.world.BlockPos;
|
||||
@@ -199,10 +198,7 @@ public class SugarCaneBlockBehavior extends BushBlockBehavior {
|
||||
@Override
|
||||
public BlockBehavior create(CustomBlock block, Map<String, Object> arguments) {
|
||||
Tuple<List<Object>, Set<Object>, Set<String>> tuple = readTagsAndState(arguments, false);
|
||||
Property<Integer> ageProperty = (Property<Integer>) block.getProperty("age");
|
||||
if (ageProperty == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.block.behavior.sugar_cane.missing_age", new IllegalArgumentException("'age' property not set for sugar cane block behavior"));
|
||||
}
|
||||
Property<Integer> ageProperty = (Property<Integer>) ResourceConfigUtils.requireNonNullOrThrow(block.getProperty("age"), "warning.config.block.behavior.sugar_cane.missing_age");
|
||||
int maxHeight = ResourceConfigUtils.getAsInt(arguments.getOrDefault("max-height", 3), "max-height");
|
||||
List<String> nearbyLiquids = MiscUtils.getAsStringList(arguments.getOrDefault("required-adjacent-liquids", List.of()));
|
||||
boolean nearWater = nearbyLiquids.contains("water");
|
||||
|
||||
@@ -240,7 +240,7 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
@Override
|
||||
public void parseSection(Pack pack, Path path, Key id, Map<String, Object> section) {
|
||||
if (customItems.containsKey(id)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.duplicate", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.item.duplicate");
|
||||
}
|
||||
|
||||
// register for recipes
|
||||
@@ -249,16 +249,16 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
.register(new ResourceKey<>(BuiltInRegistries.OPTIMIZED_ITEM_ID.key().location(), id), id));
|
||||
|
||||
boolean isVanillaItem = id.namespace().equals("minecraft") && Registry.MATERIAL.get(new NamespacedKey(id.namespace(), id.value())) != null;
|
||||
String materialStringId = (String) section.get("material");
|
||||
if (isVanillaItem)
|
||||
String materialStringId;
|
||||
if (isVanillaItem) {
|
||||
materialStringId = id.value();
|
||||
if (materialStringId == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.missing_material", path, id);
|
||||
} else {
|
||||
materialStringId = ResourceConfigUtils.requireNonEmptyStringOrThrow(section.get("material"), "warning.config.item.missing_material");
|
||||
}
|
||||
|
||||
Material material = MaterialUtils.getMaterial(materialStringId);
|
||||
if (material == null) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.invalid_material", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.item.invalid_material", materialStringId);
|
||||
}
|
||||
|
||||
Key materialId = Key.of(material.getKey().namespace(), material.getKey().value());
|
||||
@@ -391,11 +391,11 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
// check conflict
|
||||
Map<Integer, Key> conflict = cmdConflictChecker.computeIfAbsent(materialId, k -> new HashMap<>());
|
||||
if (conflict.containsKey(customModelData)) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.custom_model_data_conflict", path, id, String.valueOf(customModelData), conflict.get(customModelData).toString());
|
||||
throw new LocalizedResourceConfigException("warning.config.item.custom_model_data_conflict", String.valueOf(customModelData), conflict.get(customModelData).toString());
|
||||
}
|
||||
|
||||
if (customModelData > 16_777_216) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.bad_custom_model_data", path, id, String.valueOf(customModelData));
|
||||
throw new LocalizedResourceConfigException("warning.config.item.bad_custom_model_data", String.valueOf(customModelData));
|
||||
}
|
||||
|
||||
conflict.put(customModelData, id);
|
||||
@@ -439,7 +439,7 @@ public class BukkitItemManager extends AbstractItemManager<ItemStack> {
|
||||
}
|
||||
}
|
||||
if (!hasModel) {
|
||||
throw new LocalizedResourceConfigException("warning.config.item.missing_model_id", path, id);
|
||||
throw new LocalizedResourceConfigException("warning.config.item.missing_model_id");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,10 +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;
|
||||
import net.momirealms.craftengine.core.util.*;
|
||||
import net.momirealms.craftengine.core.util.context.ContextHolder;
|
||||
import net.momirealms.craftengine.core.world.Vec3d;
|
||||
import org.bukkit.Bukkit;
|
||||
@@ -109,10 +106,7 @@ public class BukkitVanillaLootManager extends AbstractVanillaLootManager impleme
|
||||
|
||||
@Override
|
||||
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");
|
||||
}
|
||||
String type = ResourceConfigUtils.requireNonEmptyStringOrThrow(section.get("type"), "warning.config.vanilla_loot.missing_type");
|
||||
VanillaLoot.Type typeEnum;
|
||||
try {
|
||||
typeEnum = VanillaLoot.Type.valueOf(type.toUpperCase(Locale.ENGLISH));
|
||||
|
||||
Reference in New Issue
Block a user