Estou tentando fazer um plugin de tesouros, mas nao estou conseguindo fazer, por exemplo, o tesouro nivel 1: tem 1% de chance, o nivel 2: tem 0,5% de chance e assim por diante.. cada vez mais dificil.
Codigo:
package me.SprintTesouro.Eventos;
import com.gmail.nossr50.datatypes.skills.SkillType;
import com.gmail.nossr50.events.experience.McMMOPlayerXpGainEvent;
import java.util.Random;
import me.SprintTesouro.Methods;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.event.Listener;
public class Espadas implements Listener
{
public Espadas() {}
@org.bukkit.event.EventHandler
public void onUse(McMMOPlayerXpGainEvent e)
{
SkillType skill = e.getSkill();
int levelskill = e.getSkillLevel();
if ((skill.equals(SkillType.SWORDS)) &&
(levelskill >= Methods.getCfg().getInt("Skills.Espadas.Nivel_Necessario_Nivel_1"))) {
Random rand = new Random();
int percent = rand.nextInt(100);
if (percent <= Methods.getCfg().getInt("Skills.Espadas.Nivel_Chance_1")) {
Methods.givebau(e.getPlayer(), "1");
return;
}
}
if (levelskill >= Methods.getCfg().getInt("Skills.Espadas.Nivel_Necessario_Nivel_2")) {
Random rand = new Random();
int percent = rand.nextInt(100);
if (percent <= Methods.getCfg().getInt("Skills.Espadas.Nivel_Chance_2")) {
Methods.givebau(e.getPlayer(), "2");
return;
}
}
if (levelskill >= Methods.getCfg().getInt("Skills.Espadas.Nivel_Necessario_Nivel_3")) {
Random rand = new Random();
int percent = rand.nextInt(100);
if (percent <= Methods.getCfg().getInt("Skills.Espadas.Nivel_Chance_3")) {
Methods.givebau(e.getPlayer(), "3");
return;
}
}
}
}