mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-31 04:46:37 +00:00
测试家具配置
This commit is contained in:
@@ -151,9 +151,15 @@ warning.config.loot_table.wrong_pools_type: "<yellow>Issue found in file <arg:0>
|
||||
warning.config.loot_table.wrong_conditions_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'conditions' should be a map list, current type: '<arg:2>'.</yellow>"
|
||||
warning.config.loot_table.wrong_functions_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'functions' should be a map list, current type: '<arg:2>'.</yellow>"
|
||||
warning.config.loot_table.wrong_entries_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, 'entries' should be a map list, current type: '<arg:2>'.</yellow>"
|
||||
warning.config.loot_table.function.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the functions is missing the required argument 'type'.</yellow>"
|
||||
warning.config.loot_table.function.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the functions is using an invalid function type '<arg:2>'.</yellow>"
|
||||
warning.config.loot_table.function.apply_bonus.lack_enchantment: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'apply_bonus' is missing the required argument 'enchantment'.</yellow>"
|
||||
warning.config.loot_table.function.apply_bonus.lack_formula: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'apply_bonus' is missing the required argument 'formula'.</yellow>"
|
||||
warning.config.loot_table.function.drop_exp.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'drop_exp' is missing the required argument 'count'.</yellow>"
|
||||
warning.config.loot_table.function.set_count.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, function 'set_count' is missing the required argument 'count'.</yellow>"
|
||||
warning.config.loot_table.entry.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the entries is missing the required argument 'type'.</yellow>"
|
||||
warning.config.loot_table.entry.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the entries is using an invalid entry type '<arg:2>'.</yellow>"
|
||||
warning.config.loot_table.entry.exp.lack_count: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, entry 'exp' is missing the required argument 'count'.</yellow>"
|
||||
warning.config.loot_table.entry.item.lack_item: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, entry 'item' is missing the required argument 'item'.</yellow>"
|
||||
warning.config.loot_table.entry.item.lack_item: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, entry 'item' is missing the required argument 'item'.</yellow>"
|
||||
warning.config.loot_table.condition.lack_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the conditions is missing the required argument 'type'.</yellow>"
|
||||
warning.config.loot_table.condition.invalid_type: "<yellow>Issue found in file <arg:0> - '<arg:1>' has a misconfigured loot table, one of the conditions is using an invalid condition type '<arg:2>'.</yellow>"
|
||||
@@ -22,6 +22,7 @@ import org.bukkit.*;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.persistence.PersistentDataType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.joml.Vector3f;
|
||||
@@ -205,7 +206,17 @@ public class BukkitFurnitureManager extends AbstractFurnitureManager {
|
||||
e.setId(id);
|
||||
throw e;
|
||||
}
|
||||
CustomFurniture furniture = new CustomFurniture(id, settings, placements, lootMap == null ? null : LootTable.fromMap(lootMap));
|
||||
|
||||
// get loot table
|
||||
LootTable<ItemStack> lootTable;
|
||||
try {
|
||||
lootTable = lootMap == null ? null : LootTable.fromMap(lootMap);
|
||||
} catch (LocalizedResourceConfigException e) {
|
||||
e.setPath(path);
|
||||
e.setId(id);
|
||||
throw e;
|
||||
}
|
||||
CustomFurniture furniture = new CustomFurniture(id, settings, placements, lootTable);
|
||||
byId.put(id, furniture);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.craftengine.core.loot.condition;
|
||||
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
|
||||
import net.momirealms.craftengine.core.registry.Holder;
|
||||
import net.momirealms.craftengine.core.registry.Registries;
|
||||
@@ -89,14 +90,13 @@ public class LootConditions {
|
||||
public static LootCondition fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new NullPointerException("condition type cannot be null");
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.lack_type", new NullPointerException("condition type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
LootConditionFactory factory = BuiltInRegistries.LOOT_CONDITION_FACTORY.getValue(key);
|
||||
if (factory == null) {
|
||||
throw new IllegalArgumentException("Unknown loot condition type: " + type);
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.condition.invalid_type", new IllegalArgumentException("Unknown loot condition type: " + type), type);
|
||||
}
|
||||
return factory.create(map);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.momirealms.craftengine.core.loot.entry;
|
||||
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
|
||||
import net.momirealms.craftengine.core.registry.Holder;
|
||||
import net.momirealms.craftengine.core.registry.Registries;
|
||||
@@ -41,12 +42,12 @@ public class LootEntryContainers {
|
||||
public static <T> LootEntryContainer<T> fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new NullPointerException("loot entry type cannot be null");
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.lack_type", new NullPointerException("loot entry type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
LootEntryContainerFactory<T> factory = (LootEntryContainerFactory<T>) BuiltInRegistries.LOOT_ENTRY_CONTAINER_FACTORY.getValue(key);
|
||||
if (factory == null) {
|
||||
throw new IllegalArgumentException("Unknown loot entry type: " + type);
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.entry.invalid_type", new IllegalArgumentException("Unknown loot entry type: " + type), type);
|
||||
}
|
||||
return factory.create(map);
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package net.momirealms.craftengine.core.loot.function;
|
||||
|
||||
import net.momirealms.craftengine.core.item.Item;
|
||||
import net.momirealms.craftengine.core.loot.LootContext;
|
||||
import net.momirealms.craftengine.core.plugin.locale.LocalizedResourceConfigException;
|
||||
import net.momirealms.craftengine.core.registry.BuiltInRegistries;
|
||||
import net.momirealms.craftengine.core.registry.Holder;
|
||||
import net.momirealms.craftengine.core.registry.Registries;
|
||||
@@ -69,12 +70,12 @@ public class LootFunctions {
|
||||
public static <T> LootFunction<T> fromMap(Map<String, Object> map) {
|
||||
String type = (String) map.get("type");
|
||||
if (type == null) {
|
||||
throw new NullPointerException("function type cannot be null");
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.lack_type", new NullPointerException("function type cannot be null"));
|
||||
}
|
||||
Key key = Key.withDefaultNamespace(type, "craftengine");
|
||||
LootFunctionFactory<T> factory = (LootFunctionFactory<T>) BuiltInRegistries.LOOT_FUNCTION_FACTORY.getValue(key);
|
||||
if (factory == null) {
|
||||
throw new IllegalArgumentException("Unknown function type: " + type);
|
||||
throw new LocalizedResourceConfigException("warning.config.loot_table.function.invalid_type", new IllegalArgumentException("Unknown function type: " + type), type);
|
||||
}
|
||||
return factory.create(map);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user