From 815598d0d2c2cab2241d0cd8cc1a340378b3653e Mon Sep 17 00:00:00 2001 From: DoctaEnkoda Date: Thu, 23 Apr 2020 09:39:00 -0400 Subject: [PATCH] Change chance to allow double values. --- src/main/java/com/songoda/ultimatekits/kit/Kit.java | 2 +- src/main/java/com/songoda/ultimatekits/kit/KitItem.java | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/songoda/ultimatekits/kit/Kit.java b/src/main/java/com/songoda/ultimatekits/kit/Kit.java index 69bb9fc..cebb5ce 100644 --- a/src/main/java/com/songoda/ultimatekits/kit/Kit.java +++ b/src/main/java/com/songoda/ultimatekits/kit/Kit.java @@ -322,7 +322,7 @@ public class Kit { int canChoose = 0; for (KitItem item : innerContents) { if (itemGiveAmount == 0) break; - int ch = canChoose++ == forceSelect || item.getChance() == 0 ? 100 : item.getChance(); + double ch = canChoose++ == forceSelect || item.getChance() == 0 ? 100 : item.getChance(); double rand = Math.random() * 100; if (rand < ch || ch == 100) { diff --git a/src/main/java/com/songoda/ultimatekits/kit/KitItem.java b/src/main/java/com/songoda/ultimatekits/kit/KitItem.java index 689b0df..e8b3993 100644 --- a/src/main/java/com/songoda/ultimatekits/kit/KitItem.java +++ b/src/main/java/com/songoda/ultimatekits/kit/KitItem.java @@ -22,7 +22,7 @@ public class KitItem { private KitContent content; private String displayName, displayLore = null; private Material displayItem = null; - private int chance = 0; + private double chance = 0; public KitItem(String line) { if (line.contains(";") && !line.startsWith("{")) { @@ -77,7 +77,8 @@ public class KitItem { switch (option) { case "chance": - chance = Integer.parseInt(value); + //chance = Integer.parseInt(value); + chance = Double.parseDouble(value); break; case "display-item": displayItem = Material.valueOf(value); @@ -116,11 +117,11 @@ public class KitItem { return compileOptions() + ";" + this.content.getSerialized(); } - public int getChance() { + public double getChance() { return chance == 0 ? 100 : chance; } - public void setChance(int chance) { + public void setChance(double chance) { this.chance = chance; }