From 6f0e9dfa21d465141b9b05d8fab93a3675e1ccd3 Mon Sep 17 00:00:00 2001 From: heyxmirko Date: Tue, 7 May 2024 20:32:32 +0200 Subject: [PATCH] feat: Add a new `displayTime` option to the config --- README.MD | 1 + pom.xml | 2 +- .../lukyn76/imagefireworkspro/core/ImageFirework.java | 11 ++++++++++- .../lukyn76/imagefireworkspro/util/ConfigManager.java | 5 +++++ src/main/resources/config.yml | 3 ++- 5 files changed, 19 insertions(+), 3 deletions(-) diff --git a/README.MD b/README.MD index cedb1ef..b79024b 100644 --- a/README.MD +++ b/README.MD @@ -22,6 +22,7 @@ Fireworks: name: "Display Name" imageName: "filename.png" customModelData: 1234 + displayTime: 3 # in seconds ``` 3. Reload the config with command `/ifp reload` diff --git a/pom.xml b/pom.xml index 1f5b6ad..2618299 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ me.lukyn76 ImageFireworksPro - 1.1.3 + 1.1.4 jar ImageFireworksPro diff --git a/src/main/java/me/lukyn76/imagefireworkspro/core/ImageFirework.java b/src/main/java/me/lukyn76/imagefireworkspro/core/ImageFirework.java index 6d1785c..eb48049 100644 --- a/src/main/java/me/lukyn76/imagefireworkspro/core/ImageFirework.java +++ b/src/main/java/me/lukyn76/imagefireworkspro/core/ImageFirework.java @@ -15,6 +15,7 @@ public class ImageFirework { private String name; private String imageName; private int customModelData; + private int displayTime; public String getName() { @@ -41,6 +42,14 @@ public void setCustomModelData(int customModelData) { this.customModelData = customModelData; } + public int getDisplayTime() { + return displayTime; + } + + public void setDisplayTime(int displayTime) { + this.displayTime = displayTime; + } + public void explode(Location location, double yawRotation) throws IOException { location.getWorld().playSound(location, Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR, 10F, 1F); displayImage(location, yawRotation); @@ -89,7 +98,7 @@ private void displayImage(Location explodeLocation, double yawRotation) throws I } }, 0L, 3L); - Bukkit.getScheduler().runTaskLater(plugin, taskId::cancel, 3 * 20L); + Bukkit.getScheduler().runTaskLater(plugin, taskId::cancel, displayTime * 20L); } } diff --git a/src/main/java/me/lukyn76/imagefireworkspro/util/ConfigManager.java b/src/main/java/me/lukyn76/imagefireworkspro/util/ConfigManager.java index 42e9c08..33ee11a 100644 --- a/src/main/java/me/lukyn76/imagefireworkspro/util/ConfigManager.java +++ b/src/main/java/me/lukyn76/imagefireworkspro/util/ConfigManager.java @@ -24,8 +24,12 @@ public static ImageFirework getImageFirework(int customModelData) { firework.setName(fireworkSection.getString("name")); firework.setImageName(fireworkSection.getString("imageName")); firework.setCustomModelData(fireworkSection.getInt("customModelData")); + firework.setDisplayTime(fireworkSection.getInt("displayTime", 3)); return firework; + + // help me write a commit message under this line that I added a new option displaytime to the config + // Add a new option displayTime to the config that allows to set the display time of the firework } } return null; @@ -41,6 +45,7 @@ public static ImageFirework getImageFirework(String id) { firework.setName(fireworkSection.getString("name")); firework.setImageName(fireworkSection.getString("imageName")); firework.setCustomModelData(fireworkSection.getInt("customModelData")); + firework.setDisplayTime(fireworkSection.getInt("displayTime")); return firework; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 702ea02..c790fe0 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -2,4 +2,5 @@ Fireworks: dog: name: "Dog" imageName: "dog.png" - customModelData: 1000 \ No newline at end of file + customModelData: 1000 + displayTime: 3 # in seconds \ No newline at end of file