Skip to content

Commit

Permalink
feat: Add a new displayTime option to the config
Browse files Browse the repository at this point in the history
  • Loading branch information
heyxmirko committed May 7, 2024
1 parent 55987f7 commit 6f0e9df
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>me.lukyn76</groupId>
<artifactId>ImageFireworksPro</artifactId>
<version>1.1.3</version>
<version>1.1.4</version>
<packaging>jar</packaging>

<name>ImageFireworksPro</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public class ImageFirework {
private String name;
private String imageName;
private int customModelData;
private int displayTime;


public String getName() {
Expand All @@ -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);
Expand Down Expand Up @@ -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);

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}
Expand Down
3 changes: 2 additions & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ Fireworks:
dog:
name: "Dog"
imageName: "dog.png"
customModelData: 1000
customModelData: 1000
displayTime: 3 # in seconds

0 comments on commit 6f0e9df

Please sign in to comment.