Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- tMan.register(new Runnable() {
- @Override
- public void run() {
- try {
- PreparedStatement ps = null;
- ResultSet rs = null;
- for (Channel ch : Server.getInstance().getAllChannels())
- for (MapleCharacter player : ch.getPlayerStorage().getAllCharacters()) {
- int sites = 3; // Add up the sum of the site IDs and subtract to get which site is leftover (only works if there are 2 voting sites)
- ps = DatabaseConnection.getConnection().prepareStatement("SELECT siteid,account,date from votingrecords WHERE account = ?");
- ps.setString(1, player.getClient().getAccountName());
- rs = ps.executeQuery();
- if (!rs.next()) {
- player.dropMessage("You can vote for the first time!");
- continue;
- } do {
- long lastvote = rs.getInt("date");
- int siteid = rs.getInt("siteid");
- if (siteid == 1 && player.canVoteGTOP(lastvote))
- player.dropMessage("You can now vote for GTOP100!");
- else if (siteid == 2 && player.canVoteUltimate(lastvote))
- player.dropMessage("You can now vote for UltimatePrivateServers!");
- sites -= siteid;
- } while (rs.next());
- if (sites > 0)
- player.dropMessage("You can now vote for " + (sites == 1 ? "GTOP100" : "UltimatePrivateServers") + "!");
- }
- ps.close();
- rs.close();
- } catch (Exception e) {
- System.out.println("Vote checker failed");
- }
- }
- }, 60000, 10000);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement