Vote Rewards

Discussion in 'Plugin Development' started by Joshuak52, Apr 24, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    Joshuak52

    I am trying to make my server a vote rewards plugin to bump up the votes, but for some reason this doesn't seem to work??

    Vote Event
    Code:java
    1. @EventHandler
    2. public void onPlayerVote(VotifierEvent e) {
    3. Vote v = e.getVote();
    4. Random object = new Random();
    5. int voting;
    6.  
    7. for(int counter =1; counter<=1;counter++) {
    8. voting = 1+object.nextInt(2);
    9.  
    10. if(voting == 1) {
    11. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "vote1 " + v.getUsername());
    12. } else if(voting == 2) {
    13. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "vote2 " + v.getUsername());
    14. }
    15. }
    16. }


    Vote1 command
    Code:java
    1. if(cmd.getName().equalsIgnoreCase("vote1")) {
    2. if (args.length == 0) {
    3. sender.sendMessage(ChatColor.RED + "Please specify a player!");
    4. return true;
    5. }
    6. final Player target = Bukkit.getServer().getPlayer(args[0]);
    7. if (target == null) {
    8. sender.sendMessage(ChatColor.RED + "Could not find player " + args[0] + ".");
    9. return true;
    10. }
    11. Random object = new Random();
    12. int voting;
    13. for(int counter =1; counter<=1;counter++) {
    14. voting = 1+object.nextInt(2);
    15.  
    16. if(voting == 1) {
    17. Bukkit.broadcastMessage("test 1" );
    18. } else if(voting == 2) {
    19. Bukkit.broadcastMessage("Test 2");
    20. }
    21. }


    Vote2 command
    Code:java
    1. if (args.length == 0) {
    2. sender.sendMessage(ChatColor.RED + "Please specify a player!");
    3. return true;
    4. }
    5. final Player target = Bukkit.getServer().getPlayer(args[0]);
    6. if (target == null) {
    7. sender.sendMessage(ChatColor.RED + "Could not find player " + args[0] + ".");
    8. return true;
    9. }
    10. Random object = new Random();
    11. int voting;
    12. for(int counter =1; counter<=1;counter++) {
    13. voting = 1+object.nextInt(2);
    14.  
    15. if(voting == 1) {
    16. Bukkit.broadcastMessage("test2 1" );
    17. } else if(voting == 2) {
    18. Bukkit.broadcastMessage("Test2 2");
    19. }
    20. }
     
  2. Offline

    Deleted user

    Exceptions? Be specific.
     
  3. Offline

    Joshuak52

    @Joiner When they vote it just doesn't do anything.
     
  4. Offline

    Slikey

    Maybe you have a problem with the votifier port. Have you checked your settings on the plugin and the vote-page?
     
  5. Offline

    Joshuak52

    @Slikey It's the plugin. It worked without the voterewards
     
  6. Offline

    Slikey

    Joshuak52 So the VotifierEvent is fired?

    Please remove this line.. It has no effect..
    Code:
    for(int counter =1; counter<=1;counter++) {
     
  7. Offline

    Joshuak52

    @Slikey That is what i'm asking why is it not fired and using the commands to give items
     
  8. Offline

    Slikey

    Joshuak52 If the votifier-event is not fired, there must be something wrong with your settings.. If you use
    Code:
    @EventHandler
    public void onPlayerVote(VotifierEvent e) {
        Bukkit.broadcastMessage("vote");
    }
    and the msg doesn't appera, you either didn't register your EventHandler or your votifier-settings are wrong or the website has a problem on their votifier-vote handling
     
  9. Offline

    Joshuak52

    @Slikey Ok the event is fired, so why is my code not working? All votifier settings is done with websites and I know that for a fact
     
  10. Offline

    Slikey

    Have you checked if Bukkit finds a player by name? I think that Bukkit deprecated the getPlayer(String) method for a reason of UUID.. Maybe this method always return null now.. I am not sure..

    and have you removed this line? "for(int counter =1; counter<=1;counter++){"

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  11. Offline

    Gater12

    Joshuak52 Slikey
    Try using getPlayerExact() It is, too, deprecated to raise awareness of UUIDs but it should be gone in 1.8 if not already.
     
    Slikey likes this.
  12. Offline

    Joshuak52

    Gater12 I am on 1.7.2 so there isn't any UDIDs right?
    @Slikey Yeah

    Don't know if to early but bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  13. Offline

    Joshuak52

  14. Offline

    Joshuak52

    bump, someone please help

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
Thread Status:
Not open for further replies.

Share This Page