From 7b059cde0e94fc2b857fce2b335cb0372c53002f Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Sat, 31 May 2025 08:51:56 +0200 Subject: [PATCH] Add customModelData to Velocity SWItem --- .../src/de/steamwar/inventory/SWItem.java | 3 +++ .../src/de/steamwar/velocitycore/inventory/SWItem.java | 9 +++++++++ 2 files changed, 12 insertions(+) diff --git a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java index 2220c471..b368332d 100644 --- a/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java +++ b/SpigotCore/SpigotCore_Main/src/de/steamwar/inventory/SWItem.java @@ -142,6 +142,9 @@ public class SWItem { loreArray.forEach(jsonElement -> lore.add(jsonElement.getAsString())); item.setLore(lore); } + + if (itemJson.has("customModelData")) + item.setCustomModelData(itemJson.get("customModelData").getAsInt()); return item; } diff --git a/VelocityCore/src/de/steamwar/velocitycore/inventory/SWItem.java b/VelocityCore/src/de/steamwar/velocitycore/inventory/SWItem.java index c2db126f..ec3b6f40 100644 --- a/VelocityCore/src/de/steamwar/velocitycore/inventory/SWItem.java +++ b/VelocityCore/src/de/steamwar/velocitycore/inventory/SWItem.java @@ -42,6 +42,7 @@ public class SWItem { @Getter private InvCallback callback; private int color = 0; + private int customModelData = 0; public SWItem(String material, Message title) { this.material = material.toUpperCase(); @@ -64,6 +65,11 @@ public class SWItem { return this; } + public SWItem setCustomModelData(int customModelData) { + this.customModelData = customModelData; + return this; + } + public JsonObject writeToString(Chatter player, int position) { JsonObject object = new JsonObject(); object.addProperty("material", material); @@ -84,6 +90,9 @@ public class SWItem { } object.add("lore", array); } + if (customModelData > 0) { + object.addProperty("customModelData", customModelData); + } return object; }