mirror of
https://github.com/songoda/UltimateKits.git
synced 2024-11-26 12:15:13 +01:00
Change chance to allow double values.
This commit is contained in:
parent
167f681e6f
commit
815598d0d2
@ -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) {
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user