BenCodez / VotifierPlus

Fork of votifier
14 stars 6 forks source link

VotifierEvent not firing on 1.20.4 #48

Closed GNUGradyn closed 4 months ago

GNUGradyn commented 7 months ago

Hello. I'm developing a plugin that needs to receive votes. I installed the plugin, added your dependency, setup the port forward and all that. I added this to my onEnable

getServer().getPluginManager()
        .registerEvents(new VoteListener(), this);

and the VoteListener class

public class VoteListener implements Listener {

    @EventHandler(priority= EventPriority.NORMAL)
    public void onVotifierEvent(VotifierEvent event) {
        Vote vote = event.getVote();
        Logger.getAnonymousLogger().info("Received vote for " + vote.getUsername());
        Player player = Bukkit.getPlayer(vote.getUsername());
        try (Session session = DbFactory.getSessionFactory().openSession()) {
            HibernateCriteriaBuilder builder = session.getCriteriaBuilder();
            JpaCriteriaQuery query = builder.createQuery(Votes.class);
            JpaRoot root = query.from(Votes.class);
            session.beginTransaction();
            query.select(root);
            query.where(
                    builder.equal(root.get("UserGuid"), player.getUniqueId())
            );
            List results = session.createQuery(query).getResultList();
            Votes votes;
            if (results.stream().count() == 0)
                votes = new Votes(player.getUniqueId(), 0);
            else votes = (Votes) results.get(0);
            votes.SetVotes(votes.GetVotes() + 1);
            votes.SetVoteTokens(votes.GetVoteTokens() + 1);
            session.saveOrUpdate(votes);
            session.getTransaction().commit();
        } catch (Throwable e) {
            throw e;
        }
    }
}

However neither the minestatus votifier tester nor the in game test command trigger the logger or a breakpoint in the event handler. I am positive the port forward and all that is working because I get an error about the vote not being signed when I just punch the ip/port into my browser

BenCodez commented 7 months ago

Wanna test by installing votingplugin and see if it triggers votingplugin?

GNUGradyn commented 7 months ago

I will try that. I also tried nuvotifier with no code changes which worked

BenCodez commented 7 months ago

Which version of votifierplus you used?