mirror of
https://github.com/Xiao-MoMi/craft-engine.git
synced 2025-12-19 15:09:15 +00:00
添加防呆
This commit is contained in:
@@ -399,6 +399,9 @@ public class ItemSettings {
|
||||
registerFactory("equippable", (value -> {
|
||||
Map<String, Object> args = MiscUtils.castToMap(value, false);
|
||||
EquipmentData data = EquipmentData.fromMap(args);
|
||||
if (data.assetId() == null) {
|
||||
throw new IllegalArgumentException("Please move 'equippable' option to 'data' section.");
|
||||
}
|
||||
ComponentBasedEquipment componentBasedEquipment = ComponentBasedEquipment.FACTORY.create(data.assetId(), args);
|
||||
((AbstractItemManager<?>) CraftEngine.instance().itemManager()).addOrMergeEquipment(componentBasedEquipment);
|
||||
ItemEquipment itemEquipment = new ItemEquipment(Tristate.FALSE, data, componentBasedEquipment);
|
||||
|
||||
@@ -8,11 +8,11 @@ public abstract class AbstractEquipment implements Equipment {
|
||||
protected final Key assetId;
|
||||
|
||||
protected AbstractEquipment(Key assetId) {
|
||||
this.assetId = Objects.requireNonNull(assetId, "assetId cannot be null");
|
||||
this.assetId = Objects.requireNonNull(assetId, "asset-id cannot be null");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Key assetId() {
|
||||
return assetId;
|
||||
return this.assetId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -143,5 +143,21 @@ public class ComponentBasedEquipment extends AbstractEquipment implements Suppli
|
||||
return dyeData;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull String toString() {
|
||||
return "Layer{" +
|
||||
"texture='" + texture + '\'' +
|
||||
", data=" + data +
|
||||
", usePlayerTexture=" + usePlayerTexture +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "ComponentBasedEquipment{" +
|
||||
"layers=" + this.layers +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1915,6 +1915,11 @@ public abstract class AbstractPackManager implements PackManager {
|
||||
|
||||
private void processComponentBasedEquipment(ComponentBasedEquipment componentBasedEquipment, Path generatedPackPath) {
|
||||
Key assetId = componentBasedEquipment.assetId();
|
||||
if (assetId == null) {
|
||||
this.plugin.logger().severe("Asset id is null for equipment " + componentBasedEquipment);
|
||||
return;
|
||||
}
|
||||
|
||||
if (Config.packMaxVersion().isAtOrAbove(MinecraftVersions.V1_21_4)) {
|
||||
Path equipmentPath = generatedPackPath
|
||||
.resolve("assets")
|
||||
|
||||
Reference in New Issue
Block a user