Solved Votifier Event not working

Discussion in 'Spigot Plugin Development' started by DecisionsYT, May 19, 2016.

Thread Status:
Not open for further replies.
  1. Hey!

    When I vote (The info on the website IS correct) my plugins in-built vote listener is NOT working.

    Any suggestions??

    Code (Text):
    package Events;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;

    import com.vexsoftware.votifier.model.Vote;
    import com.vexsoftware.votifier.model.VotifierEvent;

    import de.Herbystar.TTA.TTA_Methods;
    import me.DecisionsYT.Main;

    public class VoteListener implements Listener {

       
       
    Main plugin;
       
        public VoteListener(Main passedPlugin) {
            this.plugin = passedPlugin;
        }
       
       
        @EventHandler
        public void onPlayerVote(VotifierEvent e) {
            Vote vote = e.getVote();
            Player player = Bukkit.getServer().getPlayer(vote.getUsername());
           
            if (plugin.getConfig().getBoolean("Vote-Listener-Enabled")) {
               
                if (player == null) {
                    return;
                }
               
                Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Vote-Broadcast").replace("{player}", vote.getUsername()).replace("{service}", vote.getServiceName())));
                player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Vote-Player-Message").replace("{player}", vote.getUsername()).replace("{service}", vote.getServiceName())));
                TTA_Methods.sendTitle(player, ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Vote-Title")).replace("{player}", player.getName()), 20, 40, 20, ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Vote-Subtitle")).replace("{player}", player.getName()), 30, 50, 30);
           
                for(String text : plugin.getConfig().getStringList("Console-Ran-Commands")) {
                    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), text.replace("{player}", player.getName()));
                }
            }
           
            if (!plugin.getConfig().getBoolean("Vote-Listener-Enabled")) {
                return;
            }
           
        }
       
       
    }
     
     
  2. I did register events, now looking at the link.
     
  3. When adding "implements VoteListener", it doesn't have any suggestions and gives an error. I've tried this in both my main class and the class (shown above) that handles votes.
     
  4. EDIT: Oops forgot the class name change
     
  5. Hmm... Still nothing is happening.

    CODE:

    Code (Text):
    package Events;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;

    import com.vexsoftware.votifier.model.Vote;
    import com.vexsoftware.votifier.model.VoteListener;
    import com.vexsoftware.votifier.model.VotifierEvent;

    import de.Herbystar.TTA.TTA_Methods;
    import me.DecisionsYT.Main;

    public class VoteHandler implements VoteListener, Listener {

       
       
    Main plugin;
       
        public VoteHandler(Main passedPlugin) {
            this.plugin = passedPlugin;
        }
       
       
        public void voteMade(Vote vote) {
            System.out.println("Received: " + vote);
        }
       
        @EventHandler
        public void onPlayerVote(VotifierEvent e) {
            Vote vote = e.getVote();
            Player player = Bukkit.getServer().getPlayer(vote.getUsername());
           
            if (plugin.getConfig().getBoolean("Vote-Listener-Enabled")) {
               
                if (player == null) {
                    return;
                }
               
                Bukkit.broadcastMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Vote-Broadcast").replace("{player}", vote.getUsername()).replace("{service}", vote.getServiceName())));
                player.sendMessage(ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Vote-Player-Message").replace("{player}", vote.getUsername()).replace("{service}", vote.getServiceName())));
                TTA_Methods.sendTitle(player, ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Vote-Title")).replace("{player}", player.getName()), 20, 40, 20, ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Vote-Subtitle")).replace("{player}", player.getName()), 30, 50, 30);
           
                for(String text : plugin.getConfig().getStringList("Console-Ran-Commands")) {
                    Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), text.replace("{player}", player.getName()));
                }
            }
           
            if (!plugin.getConfig().getBoolean("Vote-Listener-Enabled")) {
                return;
            }
           
        }
       
       
    }
     
     
  6. Never mind, got it working!

    I guess test votes dont work
     
Thread Status:
Not open for further replies.