fromMap(Map, ?> map) {
+ return Optional
+ .ofNullable(Objects.toString(map.get("id"), null))
+ .flatMap(CraftEngineCustomBlock::fromId);
+ }
+
+ @Override
+ public void execute(AOneBlock addon, Block block) {
+ try {
+ block.setType(Material.AIR);
+ CraftEngineBlocks.place(block.getLocation(), Key.of(blockId), false);
+ } catch (Exception e) {
+ BentoBox.getInstance().logError("Could not place CraftEngine block " + blockId + ": " + e.getMessage());
+ block.setType(Material.STONE);
+ }
+ }
+}
diff --git a/src/test/java/world/bentobox/aoneblock/oneblocks/customblock/CraftEngineCustomBlockTest.java b/src/test/java/world/bentobox/aoneblock/oneblocks/customblock/CraftEngineCustomBlockTest.java
new file mode 100644
index 0000000..cd35d31
--- /dev/null
+++ b/src/test/java/world/bentobox/aoneblock/oneblocks/customblock/CraftEngineCustomBlockTest.java
@@ -0,0 +1,30 @@
+package world.bentobox.aoneblock.oneblocks.customblock;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.LinkedHashMap;
+import java.util.Map;
+
+import org.junit.jupiter.api.Test;
+
+/**
+ * Unit tests for {@link CraftEngineCustomBlock#fromMap(Map)}.
+ *
+ * Because CraftEngine is an optional runtime dependency, the {@code fromId}
+ * path cannot be exercised without a live server. These tests cover the
+ * map-parsing entry point and the factory registration in
+ * {@link world.bentobox.aoneblock.oneblocks.OneBlockCustomBlockCreator}.
+ */
+class CraftEngineCustomBlockTest {
+
+ @Test
+ void fromMapReturnsEmptyWhenIdMissing() {
+ Map map = new LinkedHashMap<>();
+ map.put("type", "craftengine");
+ // no "id" key
+
+ var result = CraftEngineCustomBlock.fromMap(map);
+
+ assertTrue(result.isEmpty(), "Should return empty when 'id' is missing");
+ }
+}