[Help] Votifier API not working?

Discussion in 'Plugin Development' started by War-Realms, Feb 4, 2014.

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

    War-Realms

    So I've coded my own vote listener for my server and I know I've coded it correctly and everything should be working. I have two classes Main, and VoteListener.

    I have my main class:
    Code:java
    1. package me.hbc.main;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.plugin.java.JavaPlugin;
    5.  
    6. public class Main extends JavaPlugin
    7. {
    8. @Override
    9. public void onEnable()
    10. {
    11. System.out.println("LrListener has been enabled!");
    12. Bukkit.getServer().getPluginManager().registerEvents(new VoteListener(this), this);
    13. }
    14.  
    15. @Override
    16. public void onDisable()
    17. {
    18. System.out.println("LrListener has been disabled!");
    19. }
    20. }


    And I also have my VoteListener class:
    Code:java
    1. package me.hbc.main;
    2.  
    3. import java.util.ArrayList;
    4.  
    5. import org.bukkit.Bukkit;
    6. import org.bukkit.Material;
    7. import org.bukkit.entity.Player;
    8. import org.bukkit.event.EventHandler;
    9. import org.bukkit.event.Listener;
    10. import org.bukkit.inventory.ItemStack;
    11.  
    12. import com.vexsoftware.votifier.model.Vote;
    13. import com.vexsoftware.votifier.model.VotifierEvent;
    14.  
    15. public class VoteListener implements Listener
    16. {
    17. Main plugin;
    18. ArrayList<String> offlinep = new ArrayList<String>();
    19.  
    20. public VoteListener(Main plugin)
    21. {
    22. this.plugin = plugin;
    23. }
    24.  
    25. @EventHandler
    26. public void onPlayerVote(VotifierEvent e)
    27. {
    28. Vote v = e.getVote();
    29. System.out.println("Received: " + v);
    30. Bukkit.getServer().broadcastMessage(v.getUsername() + " has voted on " + v.getServiceName());
    31. Player p = Bukkit.getServer().getPlayer(v.getUsername());
    32. if (p == null)
    33. {
    34. System.out.println(p + " Isn't online. This player is now being added to the ArrayList!");
    35. offlinep.add(v.getUsername());
    36. return;
    37. }
    38. if (offlinep.contains(p))
    39. {
    40. p.getInventory().addItem(new ItemStack(Material.DIAMOND, 5));
    41. Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give " + p + " 1000");
    42. offlinep.remove(p);
    43. return;
    44. }
    45.  
    46. p.getInventory().addItem(new ItemStack(Material.DIAMOND, 5));
    47. Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), "eco give " + p + " 1000");
    48. return;
    49. }
    50. }
    51.  


    So here is the problem when I went to minestatus to test my vote listener I receive no information to the console or neither did I receive any information when I went to vote myself. It did not broadcast a message to the server stating that I vote nor did I receive my items. Any help?
     
  2. Offline

    Superckl1

    My first question is if Votifier is set up correctly. Second, add logs throughout the listener to know if it gets stuck somewhere.
     
  3. Offline

    Goblom

    War-Realms Votifier addons are not plugins, they are added classes that are put in the votifier plugin directory.

    You need to implement VoteListener instead of listener compile with Votifier as a dependency and place the CLASS (not JAR) inside the votifier plugin directory. You also do not need your Main class.

    That is my understanding on how to create a Votifier addon.
     
Thread Status:
Not open for further replies.

Share This Page