mirror of
https://github.com/StarWishsama/Slimefun4.git
synced 2024-09-20 03:35:51 +00:00
Fixed SlimefunStartup#randomize(int) and #chance(int, int)
This commit is contained in:
parent
c3e9717bdb
commit
00adbf84d7
@ -507,10 +507,12 @@ public class SlimefunStartup extends JavaPlugin {
|
||||
}
|
||||
|
||||
public static int randomize(int max) {
|
||||
if (max < 1) return 0;
|
||||
return CSCoreLib.randomizer().nextInt(max);
|
||||
}
|
||||
|
||||
public static boolean chance(int max, int percentage) {
|
||||
if (max < 1) return 0;
|
||||
return CSCoreLib.randomizer().nextInt(max) <= percentage;
|
||||
}
|
||||
|
||||
|
@ -87,7 +87,7 @@ public class TalismanListener implements Listener {
|
||||
if ((Boolean) Slimefun.getItemValue("MAGICIAN_TALISMAN", "allow-enchantments." + en.getName() + ".level." + i) && en.canEnchantItem(e.getItem())) enchantments.add(en.getName() + "-" + i);
|
||||
}
|
||||
}
|
||||
String enchant = enchantments.get(SlimefunStartup.randomize((enchantments.size() < 0) ? enchantments.size() : 0));
|
||||
String enchant = enchantments.get(SlimefunStartup.randomize(enchantments.size());
|
||||
e.getEnchantsToAdd().put(Enchantment.getByName(enchant.split("-")[0]), Integer.parseInt(enchant.split("-")[1]));
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user