First download our everythingrs-api.jar from here and include it into your project.
After adding the everything-rs.jar into your project the next step is to create an account, once the account is created you must register onto the toplist as we use the toplist data in many of our api's.
Go to your main panel at https://everythingrs.com/account . You should now see your voting URL in the "Your API Pages" section
(OPTIONAL) If you wish to embed the script on your website you can add the code below directly onto your website. Change "yoursubdomain" to the one that was provided to you
This part is for PI & Ruse but can easily be changed to work with any server. If you have a request for a specific server let me know and I can add it to the tutorial.
Add the code below into Commands.java and you're all done!
For Other Servers - The script is compatible with any base, if you however need help adding it to a specific one, leave a link to the base and I'll add it to the tutorial.
if (playerCommand.startsWith("reward")) {
String[] args = playerCommand.split(" ");
if (args.length == 1) {
c.sendMessage("Please use [::reward id], [::reward id amount], or [::reward id all].");
return;
}
final String playerName = c.playerName;
final String id = args[1];
final String amount = args.length == 3 ? args[2] : "1";
com.everythingrs.vote.Vote.service.execute(new Runnable() {
@Override
public void run() {
try {
com.everythingrs.vote.Vote[] reward = com.everythingrs.vote.Vote.reward("secret_key",
playerName, id, amount);
if (reward[0].message != null) {
c.sendMessage(reward[0].message);
return;
}
c.getItems().addItem(reward[0].reward_id, reward[0].give_amount);
c.sendMessage(
"Thank you for voting! You now have " + reward[0].vote_points + " vote points.");
} catch (Exception e) {
c.sendMessage("Api Services are currently offline. Please check back shortly");
e.printStackTrace();
}
}
});
}
switch (parser.getCommand()) {
Add
case "reward":
if (!parser.hasNext(1)) {
player.send(new SendMessage("Please use [::reward id], [::reward id amount], or [::reward id all]."));
return true;
}
final String playerName = player.getUsername();
final String id = parser.nextString();
final String rewardAmount = parser.hasNext(1) ? parser.nextString() : "1";
com.everythingrs.vote.Vote.service.execute(new Runnable() {
@Override
public void run() {
try {
com.everythingrs.vote.Vote[] reward = com.everythingrs.vote.Vote.reward("secret_key", playerName, id, rewardAmount);
if (reward[0].message != null) {
player.send(new SendMessage(reward[0].message));
return;
}
player.getInventory().add(new Item(reward[0].reward_id, reward[0].give_amount));
player.send(new SendMessage("Thank you for voting! You now have " + reward[0].vote_points + " vote points."));
} catch (Exception e) {
player.send(new SendMessage("Api Services are currently offline. Please check back shortly"));
e.printStackTrace();
}
}
});
return true;
private static void playerCommands(final Player player, String[] command, String wholeCommand) {
Add
Code for Ruse
if (command[0].startsWith("reward")) {
if (command.length == 1) {
player.getPacketSender().sendMessage("Please use [::reward id], [::reward id amount], or [::reward id all].");
return;
}
final String playerName = player.getUsername();
final String id = command[1];
final String amount = command.length == 3 ? command[2] : "1";
com.everythingrs.vote.Vote.service.execute(new Runnable() {
@Override
public void run() {
try {
com.everythingrs.vote.Vote[] reward = com.everythingrs.vote.Vote.reward("secret_key",
playerName, id, amount);
if (reward[0].message != null) {
player.getPacketSender().sendMessage(reward[0].message);
return;
}
player.getInventory().add(reward[0].reward_id, reward[0].give_amount);
player.getPacketSender().sendMessage("Thank you for voting! You now have " + reward[0].vote_points + " vote points.");
} catch (Exception e) {
player.getPacketSender().sendMessage("Api Services are currently offline. Please check back shortly");
e.printStackTrace();
}
}
});
}
Adding and Removing Items: Manage your voting rewards easily by visiting the "Voting Dashboard" at https://everythingrs.com/account/vote/manage.
Adding a Reward: Once you are in the Voting Dashboard, go to the "Add new reward" section and enter the necessary information such as item ID, name, points, and amount.
Removing a Reward: Simply press the red "x" button to remove a reward.
Voting System: The voting script operates on a point system where players receive a set number of points for each vote they cast on the toplist.
Claiming a Reward: Type ::reward x in-game to claim a reward using your accumulated points.