Rankup Check Listener
Scorpion edited this page 4 years ago

//Lets listen for a rankup //Im not good with listener names...dont mind that @EventHandler public void onCustomBuyAttempt(RankupCheckEvent e) {

//Lets grab the player
Player player = e.getPlayer();
//Lets grab the rank
String rank = e.getRank(); //Lets say its "Owner"

if (!rank.equals("Owner")) return;

//Now that we have our rank and player, and we know the rank is "Owner"
//We dont want to give the rank away so easily...

//We want the player to be operator and cancel if he isn't
//in this case we just need to check if he's not op.
if (!player.isOp()) {
    //Okay he's not an operator...
    //With this listener you can "set" cancel message, provided you specify a name(usually plugin name)
    e.setPluginRequester(this.getName()); //The name of this plugin
    e.setCancelMessage("Not an operator"); //the reason why we cancel it
    e.setCancelled(true); //actually cancel it.
    //Done! they can not gain the rank unless they are operator and are told why.
}

}