1
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:
Poslovitch 2017-08-12 13:24:16 +02:00
parent c3e9717bdb
commit 00adbf84d7
2 changed files with 3 additions and 1 deletions

View File

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

View File

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