Hey guys. So since you only get 5-6 chances with votifier, I just want to make sure I didn't make any mistakes in my code. So if anyone who has worked with votifer could look over this real quick, that would be awesome Code:java @EventHandler(priority = EventPriority.NORMAL) public void onVote(com.vexsoftware.votifier.model.VotifierEvent event) { Vote vote = event.getVote(); String s = vote.getUsername().toLowerCase(); FileConfiguration fc = plugin.playerFile(s); if (fc.getString(s + ".votes") == null) { fc.set(s + ".votes", 1); } else { fc.set(s + ".votes", fc.getInt(s + ".votes") + 1); } try { fc.save(plugin.playerData(s)); } catch (IOException exception) { exception.printStackTrace(); } Player player = Bukkit.getServer().getPlayer(vote.getUsername()); for (String ss : plugin.getConfig().getConfigurationSection("votes.").getKeys(false)) { int i = fc.getInt(s + ".votes"); if (Integer.parseInt(ss) == i) { if (player != null) { for (String command : plugin.getConfig().getStringList("votes." + ss + ".commands")) { Bukkit.getServer().dispatchCommand(Bukkit.getServer().getConsoleSender(), command.replace("/", "")); } } else { List<String> strings = plugin.getConfig().getStringList("votes." + ss + ".commands"); for (String command : plugin.getConfig().getStringList("votes." + ss + ".commands")) { strings.add(command); } fc.set(s + ".pending-commands", null); fc.set(s + ".pending", true); fc.set(s + ".pending-commands", strings); try { fc.save(plugin.playerData(s)); } catch (IOException e) { e.printStackTrace(); } } } } } Resetting every month: Code:java public int getDayOfMonth(Date aDate) { Calendar cal = Calendar.getInstance(); cal.setTime(aDate); return cal.get(Calendar.DAY_OF_MONTH); } public void clearVotes() { Date date = new Date(); if (getDayOfMonth(date) == 2){ getConfig().set("set-next-vote", true); saveConfig(); } if (getDayOfMonth(date) == 1 && getConfig().getBoolean("set-next-vote")) { String path = getDataFolder().getAbsolutePath(); String plugins = path.substring(0, path.lastIndexOf(File.separator)); File users = new File(plugins + File.separator + "LOLPlugin", "userdata"); getConfig().set("set-next-vote", false); if (users.exists()) { for (File file : users.listFiles()) { String s = file.getName().toLowerCase(); YamlConfiguration config = YamlConfiguration.loadConfiguration(file); try { config.set(s + ".votes", 0); config.set(s + ".votes", false); config.set(s + ".pending-commands", null); config.save(file); } catch (IOException ex) { ex.printStackTrace(); } } } } }
Blah1 it seems to look fine although not fully checked. just one question why do you use a static reference in your event? this I mean: Code: public void onVote(com.vexsoftware.votifier.model.VotifierEvent event) {
xize The name of my class is VotifierEvent and they were conflicting. So if run this right now it *should* work?