From c6bffc4b482723759c7446527e801fa2edf39073 Mon Sep 17 00:00:00 2001 From: Shinare Date: Fri, 11 Jul 2025 14:41:18 +0300 Subject: [PATCH] Added support for custom potion effects in loot chests --- .gitignore | 1 + pom.xml | 2 +- .../commands/loot_chest_command.java | 25 ++++++++++++++++++- src/main/resources/plugin.yml | 4 +-- 4 files changed, 28 insertions(+), 4 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..eb5a316 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +target diff --git a/pom.xml b/pom.xml index 3142cba..426b5b1 100644 --- a/pom.xml +++ b/pom.xml @@ -3,7 +3,7 @@ com.zivilon DungeonTools - 1.4 + 1.5 jar DungeonTools diff --git a/src/main/java/com/zivilon/dungeontools/commands/loot_chest_command.java b/src/main/java/com/zivilon/dungeontools/commands/loot_chest_command.java index a415ab9..56fd11b 100644 --- a/src/main/java/com/zivilon/dungeontools/commands/loot_chest_command.java +++ b/src/main/java/com/zivilon/dungeontools/commands/loot_chest_command.java @@ -161,6 +161,29 @@ public class loot_chest_command implements CommandExecutor { } } + // Parse CustomPotionEffects + if (custom_item_section.contains("CustomPotionEffects")) { + List> potion_effects = custom_item_section.getMapList("CustomPotionEffects"); + NBTList effects_NBT = new NBTList(); + for (Map effect_map : potion_effects) { + NBTCompound effect_NBT = new NBTCompound(); + if (effect_map.containsKey("Id")) { + effect_NBT.put("Id", ((Number) effect_map.get("Id")).byteValue()); + } + if (effect_map.containsKey("Amplifier")) { + effect_NBT.put("Amplifier", ((Number) effect_map.get("Amplifier")).byteValue()); + } + if (effect_map.containsKey("Duration")) { + effect_NBT.put("Duration", ((Number) effect_map.get("Duration")).intValue()); + } + if (effect_map.containsKey("ShowParticles")) { + effect_NBT.put("ShowParticles", (Boolean) effect_map.get("ShowParticles")); + } + effects_NBT.add(effect_NBT); + } + tag_NBT.put("CustomPotionEffects", effects_NBT); + } + ConfigurationSection enchantments_section = custom_item_section.getConfigurationSection("enchantments"); if (enchantments_section != null) { NBTList ench_NBT = new NBTList(); @@ -324,4 +347,4 @@ public class loot_chest_command implements CommandExecutor { } return true; } -} \ No newline at end of file +} diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b51a00e..0d14d89 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,8 +1,8 @@ main: com.zivilon.dungeontools.DungeonTools name: DungeonTools author: Shinare -version: 1.4 -depend: [FakePlayer] +version: 1.5 +depend: [FakePlayer, PowerNBT] commands: loot_chest: description: Creates a loot chest in specified location