Post: Adding extra rewards for Donators within your Vote4Rewards
03-09-2015, 10:34 PM #1
Stunz
Former Staff
(adsbygoogle = window.adsbygoogle || []).push({});
Firstly you're going to search for your existing command, head over to Commands.java
Then search for your claim/check command using Cntrl/Control/Command + F.
My command for vote checking and giving rewards is ::claim so I'll search for " "claim" "
This pulls up:
    
if (playerCommand.equalsIgnoreCase("claim")) {
try {
VoteReward reward = Server.vote.hasVoted(c.playerName.replaceAll(" ", "_"));
if(reward != null){
switch(reward.getReward()){
case 0:
c.getItems().addItem(995, 1000000);
break;

default:
c.sendMessage("Reward not found.");
break;
}
c.sendMessage("Thank you for voting.");
} else {
c.sendMessage("You have no items waiting for you.");
}
} catch (Exception e){
c.sendMessage("[RuneProject] Error: #SQLvoting; contact @red@ Max with this error!.");
}
}

Now for creating a variable that will check for the players rank and give items accordingly.
If you look at the code you will notice the reward is working inside a case number, this specific case has the ID of 0.
     case 0: 

Inside is the reward for all players, which will be the reward for regular players after we have finished.
I'm going to give my donators 2x the reward because I'm a nice guy.. So I'm going to create the following variable below the prementioned 'case 0'

     if (c.playerRights == 6) {

}

Inside of the variable is the execution if the above condition is true, as my donator rank is of the integer 6, the inside code will be executed, but there is nothing there, yet!

Inside I am going to add the double reward for donators:

     if (c.playerRights == 6){
c.getItems().addItem(995, 2000000);
}

Now if the client user has the player Rights/Rank of 6 which is the donator rank on my server(Yours may be different) it will get the item Item ID 995(Coins) and an amount of 2000000(2 Million) and add it to their inventory.

But wait, if we replace everything inside case 0: with what I have just written only donators will be rewarded? That's where we add the Else statement.
So we give everyone ELSE the usual reward.
     
if (c.playerRights == 6){
c.getItems().addItem(995, 2000000);
} else {
c.getItems().addItem(995, 1000000);
}


To finish off, we will remove everything that was inside of Case 0, and add our new conditional code.
It should look like this.
    
if (playerCommand.equalsIgnoreCase("claim")) {
try {
VoteReward reward = Server.vote.hasVoted(c.playerName.replaceAll(" ", "_"));
if(reward != null){
switch(reward.getReward()){
case 0:
if (c.playerRights == 6){
c.getItems().addItem(995, 2000000);
} else {
c.getItems().addItem(995, 1000000);
}
break;

default:
c.sendMessage("Reward not found.");
break;
}
c.sendMessage("Thank you for voting.");
} else {
c.sendMessage("You have no items waiting for you.");
}
} catch (Exception e){
c.sendMessage("[RuneProject] Error: #SQLvoting; contact @red@ Max with this error!.");
}
}

You can also have it announced to the community by adding:
     
PlayerHandler.announce("[SERVER] "+c.playerName+" has voted");

under every reward.
(adsbygoogle = window.adsbygoogle || []).push({});

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo