Jump to content
  • 0

Topzone Vote Reward Help


Question

Posted (edited)

hi, some 1 help my, topzone vote reward is old and he don't worck, i use freya client... this is the code
 
 
package com.l2jserver.gameserver.instancemanager;
   
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
   
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.Announcements;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
   
public class TopZone
{
   private static Logger _log = Logger.getLogger(AutoVoteRewardManager.class.getName());
      
   private static final int initialCheck  = Config.TOPZONE_VOTE_SYSTEM_START_TIME * 1000;
   private static final int delayForCheck = Config.TOPZONE_VOTE_SYSTEM_CHECK_TIME * 1000;
   private int votesneed;
  
   private static List<String> _ips = new ArrayList<String>();
   private static int lastVoteCount = 0;
     
   private TopZone()
   {
       _log.info("AutoVoteRewardManager: Vote reward system initiated.");
       if (Config.TOPZONE_VOTE_SYSTEM_DATABASE_SAVE)
           load();
       ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
   }
     
   private class AutoReward implements Runnable
   {
       @Override
public void run()
       {
           int votes = getVotes();
           _log.info("AutoVoteRewardManager: Current Votes: " + getVotes());
           _log.info("AutoVoteRewardManager: Votes needed: "+(getLastVoteCount()+Config.TOPZONE_VOTE_SYSTEM_COUNT));
           _log.info("AutoVoteRewardManager: Next Check in: "+(delayForCheck/1000)+" sec.");
           Announcements.getInstance().announceToAll("Vote for us in HopZone!");
          
           if (votes >= getLastVoteCount() + Config.TOPZONE_VOTE_SYSTEM_COUNT)
           {
            Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
               {
                   for (L2PcInstance onlinePlayer : pls)
                   {
                       if (onlinePlayer.isOnline() && !onlinePlayer.getClient().isDetached() && !_ips.contains(onlinePlayer.getClient().getConnection().getInetAddress().getHostAddress()))
                       {
                        String[] parase = Config.TOPZONE_VOTE_SYSTEM_ITEM_ID.split(",");
                        String[] parase3 = Config.TOPZONE_VOTE_SYSTEM_ITEM_COUNT.split(",");
                        for(int o = 0; o <parase.length; o++){
                         int parase2 = Integer.parseInt(parase[o]);
                         int parase4 = Integer.parseInt(parase3[o]);
                           for (int i = 0; i < parase.length; i++)
                           {
                               onlinePlayer.addItem("vote_reward", parase2, parase4, onlinePlayer, true);
                           }
                        }
                           _ips.add(onlinePlayer.getClient().getConnection().getInetAddress().getHostAddress());
                       }
                   }
               }
               _log.info("AutoVoteRewardManager: All players has been rewared!");
               Announcements.getInstance().announceToAll("Thanks for vote, you has been rewarded!");
               setLastVoteCount(getLastVoteCount() + Config.TOPZONE_VOTE_SYSTEM_COUNT);
           }
               
           if (getLastVoteCount() == 0)
           {
               setLastVoteCount(votes);
           }
           else if ((getLastVoteCount() + Config.TOPZONE_VOTE_SYSTEM_COUNT) - votes > Config.TOPZONE_VOTE_SYSTEM_COUNT || votes > (getLastVoteCount() + Config.TOPZONE_VOTE_SYSTEM_COUNT))
           {
               setLastVoteCount(votes);
           }
           votesneed = (getLastVoteCount()+Config.TOPZONE_VOTE_SYSTEM_COUNT) - votes;
           if(votesneed == 0){
            votesneed = Config.TOPZONE_VOTE_SYSTEM_COUNT;
           }
           Announcements.getInstance().announceToAll("Need " + votesneed + " votes more to reward all players.");
           _ips.clear();
       }
   }
     
   private int getVotes()
   {
       URL url = null;
       InputStreamReader isr = null;
       BufferedReader in = null;
       try
       {
           url = new URL(Config.TOPZONE_VOTE_SYSTEM_PAGE);
           URLConnection con = url.openConnection();
           con.addRequestProperty("User-Agent", "Mozilla/4.76");
           isr = new InputStreamReader(con.getInputStream());
           in = new BufferedReader(isr);
           String inputLine;
           while ((inputLine = in.readLine()) != null)
           {
            if(Config.TOPZONE_VOTE_SYSTEM_HOPZONE == false){
            //TopZone
            if(inputLine.contains("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\">")){
            String i = inputLine.replace("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\">", "");
            i = i.replace("</font></b></div></td></tr>", "");
            i = i.trim();
            int o = Integer.parseInt(i);
            return Integer.valueOf(o);
            }
            } else {
                          //for hopzone
               if (inputLine.contains("Anonymous User Votes"))
                   return Integer.valueOf(inputLine.split(">")[2].replace("</span", ""));
 
               }
           }
       }
       catch (IOException e)
       {
           _log.warning("AutoVoteRewardHandler: "+e);
       }
       finally
       {
           try
           {
               in.close();
           }
           catch (IOException e)
           {}
           try
           {
               isr.close();
           }
           catch (IOException e)
           {}
       }
       return 0;
   }
     
   private void setLastVoteCount(int voteCount)
   {
       lastVoteCount = voteCount;
   }
     
   private int getLastVoteCount()
   {
       return lastVoteCount;
   }
  
   private void load()
   {
       int votes = 0;
       Connection con = null;
       try
       {
           con = L2DatabaseFactory.getInstance().getConnection();
           PreparedStatement statement = con.prepareStatement("SELECT vote FROM votes LIMIT 1");
           ResultSet rset = statement.executeQuery();
           while (rset.next())
           {
               votes = rset.getInt("vote");
           }
           rset.close();
           statement.close();
       }
       catch (Exception e)
       {
           _log.log(Level.WARNING, "data error on vote: ", e);
       }
       finally
       {
           L2DatabaseFactory.close(con);
       }
     
       setLastVoteCount(votes);
   }
  
   public void save()
   {
       Connection con = null;
       try
       {
           con = L2DatabaseFactory.getInstance().getConnection();
           PreparedStatement statement = con.prepareStatement("UPDATE votes SET vote = ? WHERE id=1");
           statement.setInt(1, getLastVoteCount());
           statement.execute();
           statement.close();
       }
       catch (Exception e)
       {
           _log.log(Level.WARNING, "data error on vote: ", e);
       }
       finally
       {
           L2DatabaseFactory.close(con);
       }
   }
 
   public static TopZone getInstance()
   {
       return SingletonHolder._instance;
   }
     
   @SuppressWarnings("synthetic-access")
   private static class SingletonHolder
   {
       protected static final TopZone _instance = new TopZone();
   }
}

Edited by davidBm

3 answers to this question

Recommended Posts

  • 0
Posted

For God's sake.. It's like 10th topic about that problem .. Just check request section topics, there should be at least 2 topics on current page.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • @Maxtor @Celestine @Atom  why not block this gypsy?
    • We appreciate your feedback and want to make the service even better! If you have used our services and are ready to share your experience (any — positive or constructive), leave a review on Trustpilot and receive $1 as a thank-you. Link: https://www.trustpilot.com/review/socnet.pro How to receive the bonus: 1. Go to Trustpilot and leave your review 2. Send us a screenshot confirming the publication and a screenshot of your authorized account with the username matching the review. 3. Specify which store should receive the $1 bonus. Depending on the store, your username/email may be required. Your feedback helps us grow and makes the project better for every community member. Thank you for staying with us! Terms: The promotion applies to one unique user. Multi-accounting is not allowed. Active project links: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. We want to present to you the current list of promotions and special offers for purchasing products and services of our service: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 on your store balance or a 10–20% discount — just write your username after registering on our website using the template “SEND ME BONUS, MY USERNAME IS...” — you must post this in our forum thread! 3. Get $1 for the first trial launch of the SMM Panel: just open a ticket with the subject “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • We appreciate your feedback and want to make the service even better! If you have used our services and are ready to share your experience (any — positive or constructive), leave a review on Trustpilot and receive $1 as a thank-you. Link: https://www.trustpilot.com/review/socnet.pro How to receive the bonus: 1. Go to Trustpilot and leave your review 2. Send us a screenshot confirming the publication and a screenshot of your authorized account with the username matching the review. 3. Specify which store should receive the $1 bonus. Depending on the store, your username/email may be required. Your feedback helps us grow and makes the project better for every community member. Thank you for staying with us! Terms: The promotion applies to one unique user. Multi-accounting is not allowed. Active project links: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. We want to present to you the current list of promotions and special offers for purchasing products and services of our service: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 on your store balance or a 10–20% discount — just write your username after registering on our website using the template “SEND ME BONUS, MY USERNAME IS...” — you must post this in our forum thread! 3. Get $1 for the first trial launch of the SMM Panel: just open a ticket with the subject “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • We appreciate your feedback and want to make the service even better! If you have used our services and are ready to share your experience (any — positive or constructive), leave a review on Trustpilot and receive $1 as a thank-you. Link: https://www.trustpilot.com/review/socnet.pro How to receive the bonus: 1. Go to Trustpilot and leave your review 2. Send us a screenshot confirming the publication and a screenshot of your authorized account with the username matching the review. 3. Specify which store should receive the $1 bonus. Depending on the store, your username/email may be required. Your feedback helps us grow and makes the project better for every community member. Thank you for staying with us! Terms: The promotion applies to one unique user. Multi-accounting is not allowed. Active project links: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. We want to present to you the current list of promotions and special offers for purchasing products and services of our service: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 on your store balance or a 10–20% discount — just write your username after registering on our website using the template “SEND ME BONUS, MY USERNAME IS...” — you must post this in our forum thread! 3. Get $1 for the first trial launch of the SMM Panel: just open a ticket with the subject “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • We appreciate your feedback and want to make the service even better! If you have used our services and are ready to share your experience (any — positive or constructive), leave a review on Trustpilot and receive $1 as a thank-you. Link: https://www.trustpilot.com/review/socnet.pro How to receive the bonus: 1. Go to Trustpilot and leave your review 2. Send us a screenshot confirming the publication and a screenshot of your authorized account with the username matching the review. 3. Specify which store should receive the $1 bonus. Depending on the store, your username/email may be required. Your feedback helps us grow and makes the project better for every community member. Thank you for staying with us! Terms: The promotion applies to one unique user. Multi-accounting is not allowed. Active project links: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. We want to present to you the current list of promotions and special offers for purchasing products and services of our service: 1. You can use a promo code for your first purchase: SOCNET (15% discount) 2. Get $1 on your store balance or a 10–20% discount — just write your username after registering on our website using the template “SEND ME BONUS, MY USERNAME IS...” — you must post this in our forum thread! 3. Get $1 for the first trial launch of the SMM Panel: just open a ticket with the subject “Get Trial Bonus” on our website (Support). 4. Weekly Telegram Stars giveaways in our Telegram channel and in our bot for purchasing stars! News: ➡ Telegram channel: https://t.me/accsforyou_shop ➡ WhatsApp channel: https://chat.whatsapp.com/K8rBy500nA73z27PxgaJUw?mode=ems_copy_t ➡ Discord server: https://discord.gg/y9AStFFsrh Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock