Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.skions.skivote;
- import java.util.Random;
- import org.bukkit.Bukkit;
- import org.bukkit.ChatColor;
- import org.bukkit.Material;
- import org.bukkit.World;
- import org.bukkit.entity.Player;
- import org.bukkit.event.Listener;
- import org.bukkit.inventory.ItemStack;
- import com.vexsoftware.votifier.model.VotifierEvent;
- public class VoteCheck implements Listener {
- public void voteMade(VotifierEvent event) {
- String name = event.getVote().getUsername();
- if(Bukkit.getPlayer(name).isOnline()) {
- Player player = Bukkit.getPlayer(name);
- if(player.getWorld().getName().equalsIgnoreCase("Survival") || player.getWorld().getName().equalsIgnoreCase("SurvivalSpawn")) {
- World world = player.getWorld();
- ItemStack prize = randomPrize();
- ItemStack special = specialPrize();
- player.getInventory().addItem(prize);
- for(Player players : world.getPlayers()) {
- if(prize.getType() == Material.EMERALD) {
- players.sendMessage(ChatColor.GREEN + name + " has voted and recieved " + prize.getAmount() + " emeralds!");
- }
- else if(prize.getType() == Material.DIAMOND) {
- players.sendMessage(ChatColor.GREEN + name + " has voted and recieved " + prize.getAmount() + " diamonds!");
- }
- else if(prize.getType() == Material.IRON_INGOT) {
- players.sendMessage(ChatColor.GREEN + name + " has voted and recieved " + prize.getAmount() + " iron!");
- }
- else if(prize.getType() == Material.GOLD_INGOT) {
- players.sendMessage(ChatColor.GREEN + name + " has voted and recieved " + prize.getAmount() + " gold!");
- }
- }
- if(special != null) {
- player.getInventory().addItem(special);
- for(Player players : world.getPlayers()) {
- if(special.getType() == Material.DIAMOND) {
- players.sendMessage(ChatColor.GOLD + name + " got lucky and won the special prize of " + special.getAmount() + " diamonds!");
- }
- else if(special.getType() == Material.EMERALD) {
- players.sendMessage(ChatColor.GOLD + name + " got lucky and won the special prize of " + special.getAmount() + " emeralds!");
- }
- else if(special.getType() == Material.DIAMOND_BLOCK) {
- players.sendMessage(ChatColor.GOLD + name + " got lucky and won the special prize of " + special.getAmount() + " diamond blocks!");
- }
- else if(special.getType() == Material.EMERALD_BLOCK) {
- players.sendMessage(ChatColor.GOLD + name + " got lucky and won the special prize of " + special.getAmount() + " emerald blocks!");
- }
- }
- }
- }
- }
- }
- public ItemStack randomPrize() {
- ItemStack prize = null;
- Random r = new Random();
- int random = r.nextInt(4);
- if(random == 0) {
- int randAmount = r.nextInt(5) + 1;
- prize = new ItemStack(Material.EMERALD, randAmount);
- }
- else if(random == 1) {
- int randAmount = r.nextInt(5) + 1;
- prize = new ItemStack(Material.DIAMOND, randAmount);
- }
- else if(random == 2) {
- int randAmount = r.nextInt(20) + 1;
- prize = new ItemStack(Material.IRON_INGOT, randAmount);
- }
- else if(random == 3) {
- int randAmount = r.nextInt(20) + 1;
- prize = new ItemStack(Material.GOLD_INGOT, randAmount);
- }
- return prize;
- }
- public ItemStack specialPrize() {
- ItemStack prize = null;
- Random r = new Random();
- int random = r.nextInt(1000) + 1;
- if(random <= 5) {
- prize = new ItemStack(Material.EMERALD, 64);
- }
- else if(random <= 10 && random >= 6) {
- prize = new ItemStack(Material.DIAMOND, 64);
- }
- else if(random == 1000) {
- prize = new ItemStack(Material.EMERALD_BLOCK, 64);
- }
- else if(random == 999) {
- prize = new ItemStack(Material.DIAMOND_BLOCK, 64);
- }
- return prize;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement