Random Potion Effect Spigot?

3 Antworten

Random r = new Random();
int i = r.nextInt(10);
//Generiert eine zufällige Zahl unter 10

if(i == 1) { //Fragt ab ob die Zahl 1 ist, wahrscheinlichkeit: 10%
player.addPotionEffect(PotionEffectType.BLINDNESS, 100, 0);
}
if(i == 2) { //Fragt ab ob die Zahl 2 ist, wahrscheinlichkeit: 10%
player.addPotionEffect(PotionEffectType.ABSORPTION, 100, 0);
}
if(i == 3) {
player.addPotionEffect(PotionEffectType.NIGHT_VISION, 100, 0);
}
...
...
...

Random random = new Random();
PotionEffectType[] values = PotionEffectType.values();
PotionEffectType random = values[random.nextInt(values.size())];