Change chance to allow double values.

This commit is contained in:
DoctaEnkoda 2020-04-23 09:39:00 -04:00 committed by Brianna
parent 167f681e6f
commit 815598d0d2
2 changed files with 6 additions and 5 deletions

View File

@ -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) {

View File

@ -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;
}