Jump to content

Question

Posted

γεια σας παίδες έχω πρόβλημα το  vot manager vazo link apo server mia fora to topzone doulepse menta den exei ksanadoulepsi to hopzone oute kapios na me help ti na kanw thex L2jFrozenShot00dfgdf000.jpg

Recommended Posts

  • 0
Posted

Hello, did you even read post i have provide you?

I have told exactly what you need to do there....

You must change in your config your link with the new link provided in your myhome section reward. Link must looks like this :  http://l2topzone.com/tv.php?id= YOUR SERVER ID

Then you must make your java code to read that link correctly.

This mean you need to replace few line in this code you have share with us.

protected int getTopZoneVotes()

{

int votes = -1;

URL url = null;

URLConnection con = null;

InputStream is = null;

InputStreamReader isr = null;

BufferedReader in = null;

try

{

url = new URL(PowerPakConfig.VOTES_SITE_TOPZONE_URL);

con = url.openConnection();

con.addRequestProperty("User-Agent", "L2TopZone");

is = con.getInputStream();

isr = new InputStreamReader(is);

in = new BufferedReader(isr);

String inputLine;

while ((inputLine = in.readLine()) != null)

{

if (inputLine.contains("Votes"))

{

votes = Integer.valueOf(inputLine.split(">")[3].replace("</div", ""));

break;

}

}

Replace with this one :

protected int getTopZoneVotes()

{

int votes = -1;

URL url = null;

URLConnection con = null;

InputStream is = null;

InputStreamReader isr = null;

BufferedReader in = null;

try

{

url = new URL(PowerPakConfig.VOTES_SITE_TOPZONE_URL);

con = url.openConnection();

con.addRequestProperty("User-Agent", "L2TopZone");

is = con.getInputStream();

isr = new InputStreamReader(is);

in = new BufferedReader(isr);

String inputLine;

while ((inputLine = in.readLine()) != null)

{

votes = Integer.valueOf(inputLine);

break;

}

Check again what is the difference between what you have share with us and what i have provide you. And make the same for all your code where you have get votes.

 

Good luck.

  • 0
Posted
package com.l2jfrozen.gameserver.handler;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Set;

import org.apache.log4j.Level;
import org.apache.log4j.Logger;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.WebClient;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.model.entity.Announcements;
import com.l2jfrozen.gameserver.powerpak.PowerPakConfig;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;

public class AutoVoteRewardHandler
{
	protected static final Logger LOGGER = Logger.getLogger(AutoVoteRewardHandler.class);
	
	private int _l2networkVotesCount = 0;
	private int hopzoneVotesCount = 0;
	private int topzoneVotesCount = 0;
	protected List<String> already_rewarded;
	
	protected static boolean l2network = false;
	protected static boolean topzone = false;
	protected static boolean hopzone = false;
	
	private WebClient webClient;
	
	private AutoVoteRewardHandler()
	{
		LOGGER.info("Vote Reward System Initiated.");
		
		if (hopzone)
		{
			webClient = new WebClient(BrowserVersion.CHROME);
			webClient.getOptions().setThrowExceptionOnFailingStatusCode(false);
			webClient.getOptions().setThrowExceptionOnScriptError(false);
			webClient.getOptions().setPrintContentOnFailingStatusCode(false);
			
			int hopzone_votes = getHopZoneVotes();
			
			if (hopzone_votes == -1)
			{
				hopzone_votes = 0;
			}
			
			setHopZoneVoteCount(hopzone_votes);
		}
		
		if (l2network)
		{
			int l2network_votes = getL2NetworkVotes();
			
			if (l2network_votes == -1)
			{
				l2network_votes = 0;
			}
			
			setL2NetworkVoteCount(l2network_votes);
		}
		
		if (topzone)
		{
			int topzone_votes = getTopZoneVotes();
			
			if (topzone_votes == -1)
			{
				topzone_votes = 0;
			}
			
			setTopZoneVoteCount(topzone_votes);
		}
		
		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), PowerPakConfig.VOTES_SYSYEM_INITIAL_DELAY, PowerPakConfig.VOTES_SYSYEM_STEP_DELAY);
	}
	
	protected class AutoReward implements Runnable
	{
		@Override
		public void run()
		{
			final int minutes = (PowerPakConfig.VOTES_SYSYEM_STEP_DELAY / 1000) / 60;
			
			if (hopzone)
			{
				final int hopzone_votes = getHopZoneVotes();
				
				if (hopzone_votes != -1)
				{
					LOGGER.info("Server Has on HopZone: " + hopzone_votes + " Votes!");
					Announcements.getInstance().gameAnnounceToAll("[VOTE] Votes on Hopzone " + hopzone_votes);

					if (hopzone_votes != 0 && hopzone_votes >= getHopZoneVoteCount() + PowerPakConfig.VOTES_FOR_REWARD)
					{
						already_rewarded = new ArrayList<>();
						
						final Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
						
						Announcements.getInstance().gameAnnounceToAll("[VOTE] Great Work! Check your inventory for Reward!!");
						
						// L2ItemInstance item;
						for (final L2PcInstance player : pls)
						{
							if (player != null && !player.isInOfflineMode() && player.isOnline() == 1)
							{
								if (player._active_boxes <= 1 || (player._active_boxes > 1 && checkSingleBox(player)))
								{
									
									final Set<Integer> items = PowerPakConfig.VOTES_REWARDS_LIST.keySet();
									for (final Integer i : items)
									{
										// item = player.getInventory().getItemByItemId(i);
										
										// TODO: check on maxstack for item
										player.addItem("reward", i, PowerPakConfig.VOTES_REWARDS_LIST.get(i), player, true);
										
									}
									
								}
							}
						}
						setHopZoneVoteCount(hopzone_votes);
					}
					Announcements.getInstance().gameAnnounceToAll("[VOTE] Next Reward in " + minutes + " minutes at " + (getHopZoneVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) + " votes");
					Announcements.getInstance().gameAnnounceToAll("[VOTE] " + PowerPakConfig.SERVER_WEB_SITE);
				}
				
			}
			
			if (topzone && hopzone && PowerPakConfig.VOTES_SYSYEM_STEP_DELAY > 0)
				try
				{
					Thread.sleep(PowerPakConfig.VOTES_SYSYEM_STEP_DELAY / 2);
				}
				catch (final InterruptedException e)
				{
					if (Config.ENABLE_ALL_EXCEPTIONS)
						e.printStackTrace();
				}
			
			if (topzone)
			{
				final int topzone_votes = getTopZoneVotes();
				
				if (topzone_votes != -1)
				{
					
					LOGGER.info("Server on TopZone have: " + topzone_votes);
					
					Announcements.getInstance().gameAnnounceToAll("[VOTE] Votes on Topzone " + topzone_votes);
					
					if (topzone_votes != 0 && topzone_votes >= getTopZoneVoteCount() + PowerPakConfig.VOTES_FOR_REWARD)
					{
						already_rewarded = new ArrayList<>();
						
						final Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();

						Announcements.getInstance().gameAnnounceToAll("[VOTE] Great Work! Check your inventory for Reward!!");
						
						// L2ItemInstance item;
						for (final L2PcInstance player : pls)
						{
							if (player != null && !player.isInOfflineMode() && player.isOnline() == 1)
							{
								if (player._active_boxes <= 1 || (player._active_boxes > 1 && checkSingleBox(player)))
								{
									
									final Set<Integer> items = PowerPakConfig.VOTES_REWARDS_LIST.keySet();
									for (final Integer i : items)
									{
										// item = player.getInventory().getItemByItemId(i);
										
										// TODO: check on maxstack for item
										player.addItem("reward", i, PowerPakConfig.VOTES_REWARDS_LIST.get(i), player, true);
										
									}
									
								}
							}
						}
						setTopZoneVoteCount(topzone_votes);
					}
						Announcements.getInstance().gameAnnounceToAll("[VOTE] Next Reward in " + minutes + " minutes at " + (getTopZoneVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) + " votes");
						Announcements.getInstance().gameAnnounceToAll("[VOTE] " + PowerPakConfig.SERVER_WEB_SITE);
					}
				
			}
			
			if (topzone && hopzone && l2network && PowerPakConfig.VOTES_SYSYEM_STEP_DELAY > 0)
			{
				try
				{
					Thread.sleep(PowerPakConfig.VOTES_SYSYEM_STEP_DELAY / 2);
				}
				catch (final InterruptedException e)
				{
					if (Config.ENABLE_ALL_EXCEPTIONS)
						e.printStackTrace();
				}
			}
			
			if (l2network)
			{
				final int l2network_votes = getL2NetworkVotes();
				
				if (l2network_votes != -1)
				{
					LOGGER.info("Server L2NETWORK Votes: " + l2network_votes);
					
					Announcements.getInstance().gameAnnounceToAll("[VOTE] Votes on L2Network " + l2network_votes);
					
					if (l2network_votes != 0 && l2network_votes >= getL2NetworkVoteCount() + PowerPakConfig.VOTES_FOR_REWARD)
					{
						already_rewarded = new ArrayList<>();
						
						final Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
						
						Announcements.getInstance().gameAnnounceToAll("[VOTE] Great Work! Check your inventory for Reward!!");
						
						// L2ItemInstance item;
						for (final L2PcInstance player : pls)
						{
							if (player != null && !player.isInOfflineMode() && player.isOnline() == 1)
							{
								if (player._active_boxes <= 1 || (player._active_boxes > 1 && checkSingleBox(player)))
								{
									final Set<Integer> items = PowerPakConfig.VOTES_REWARDS_LIST.keySet();
									for (final Integer i : items)
									{
										// item = player.getInventory().getItemByItemId(i);
										
										// TODO: check on maxstack for item
										player.addItem("reward", i, PowerPakConfig.VOTES_REWARDS_LIST.get(i), player, true);
									}
								}
							}
						}
						setL2NetworkVoteCount(l2network_votes);
					}
						Announcements.getInstance().gameAnnounceToAll("[VOTE] Next Reward in " + minutes + " minutes at " + (getL2NetworkVoteCount() + PowerPakConfig.VOTES_FOR_REWARD) + " votes");
						Announcements.getInstance().gameAnnounceToAll("[VOTE] " + PowerPakConfig.SERVER_WEB_SITE);
				}
			}
			
		}
	}
	
	protected boolean checkSingleBox(final L2PcInstance player)
	{
		
		if (player.getClient() != null && player.getClient().getConnection() != null && !player.getClient().getConnection().isClosed() && !player.isInOfflineMode())
		{
			
			final String playerip = player.getClient().getConnection().getInetAddress().getHostAddress();
			
			if (already_rewarded.contains(playerip))
				return false;
			already_rewarded.add(playerip);
			return true;
		}
		
		// if no connection (maybe offline shop) dnt reward
		return false;
	}
	
	protected int getHopZoneVotes()
	{
		int votes = -1;
		try
		{
			final HtmlPage page = webClient.getPage(PowerPakConfig.VOTES_SITE_HOPZONE_URL);
			
			String fullPage = page.asXml();
			int constrainA = fullPage.indexOf("rank anonymous tooltip") + 24;
			String voteSection = fullPage.substring(constrainA);
			int constrainB = voteSection.indexOf("span") - 2;
			voteSection = voteSection.substring(0, constrainB).trim();
			votes = Integer.parseInt(voteSection);
			
		}
		catch (final Exception e)
		{
			LOGGER.warn("[AutoVoteReward] Server HOPZONE is offline or something is wrong in link", e);
			//Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] HOPZONE is offline. We will check reward as it will be online again");
		}
		finally
		{
			webClient.closeAllWindows();
		}
		return votes;
	}
	
	protected int getTopZoneVotes()
	{
		int votes = -1;
		URL url = null;
		URLConnection con = null;
		InputStream is = null;
		InputStreamReader isr = null;
		BufferedReader in = null;
		try
		{
			url = new URL(PowerPakConfig.VOTES_SITE_TOPZONE_URL);
			con = url.openConnection();
			con.addRequestProperty("User-Agent", "L2TopZone");
			is = con.getInputStream();
			isr = new InputStreamReader(is);
			in = new BufferedReader(isr);
			String inputLine;
			while ((inputLine = in.readLine()) != null)
			{
			votes = Integer.valueOf(inputLine);
			break;
			}
		}
		catch (final Exception e)
		{
			LOGGER.warn("[AutoVoteReward] Server TOPZONE is offline or something is wrong in link");
			//Announcements.getInstance().gameAnnounceToAll("[AutoVoteReward] TOPZONE is offline. We will check reward as it will be online again");
			// e.printStackTrace();
		}
		finally
		{
			if (in != null)
				try
				{
					in.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
			if (isr != null)
				try
				{
					isr.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
			if (is != null)
				try
				{
					is.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
		}
		return votes;
	}
	
	protected int getL2NetworkVotes()
	{
		int votes = -1;
		URL url = null;
		URLConnection con = null;
		InputStream is = null;
		InputStreamReader isr = null;
		BufferedReader in = null;

		try
		{
			url = new URL(PowerPakConfig.VOTES_SITE_L2NETWORK_URL);
			con = url.openConnection();
			con.addRequestProperty("User-Agent", "L2Network");
			is = con.getInputStream();
			isr = new InputStreamReader(is);
			in = new BufferedReader(isr);
			String inputLine;
			while ((inputLine = in.readLine()) != null)
			{
				if (inputLine.contains("color:#e7ebf2"))
				{
					votes = Integer.valueOf(inputLine.split(">")[2].replace("</b", ""));
					break;
				}
			}
		}
		catch (final Exception e)
		{
			LOGGER.warn("[AutoVoteReward] Server L2NETWORK is offline or something is wrong in link");
			// e.printStackTrace();
		}
		finally
		{
			if (in != null)
				try
				{
					in.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
			if (isr != null)
				try
				{
					isr.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
			if (is != null)
				try
				{
					is.close();
				}
				catch (final IOException e1)
				{
					e1.printStackTrace();
				}
		}
		return votes;
	}
	
	protected void setHopZoneVoteCount(final int voteCount)
	{
		hopzoneVotesCount = voteCount;
	}
	
	protected int getHopZoneVoteCount()
	{
		return hopzoneVotesCount;
	}
	
	protected void setTopZoneVoteCount(final int voteCount)
	{
		topzoneVotesCount = voteCount;
	}
	
	protected int getTopZoneVoteCount()
	{
		return topzoneVotesCount;
	}
	
	protected void setL2NetworkVoteCount(final int voteCount)
	{
		_l2networkVotesCount = voteCount;
	}
	
	protected int getL2NetworkVoteCount()
	{
		return _l2networkVotesCount;
	}
	
	public static AutoVoteRewardHandler getInstance()
	{
		Logger.getLogger("com.gargoylesoftware").setLevel(Level.OFF);
		if (PowerPakConfig.VOTES_SITE_HOPZONE_URL != null && !PowerPakConfig.VOTES_SITE_HOPZONE_URL.equals(""))
		{
			hopzone = true;
		}
		
		if (PowerPakConfig.VOTES_SITE_TOPZONE_URL != null && !PowerPakConfig.VOTES_SITE_TOPZONE_URL.equals(""))
		{
			topzone = true;
		}
		
		if (PowerPakConfig.VOTES_SITE_L2NETWORK_URL != null && !PowerPakConfig.VOTES_SITE_L2NETWORK_URL.equals(""))
		{
			l2network = true;
		}
		if (topzone || hopzone || l2network)
			return SingletonHolder._instance;
		return null;
	}
	
	@SuppressWarnings("synthetic-access")
	private static class SingletonHolder
	{
		protected static final AutoVoteRewardHandler _instance = new AutoVoteRewardHandler();
	}
}
package com.l2jfrozen.gameserver.model.actor.instance;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.ai.CtrlIntention;
import com.l2jfrozen.gameserver.datatables.sql.ItemTable;
import com.l2jfrozen.gameserver.model.votereward.VoteMain;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.ItemList;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import javolution.text.TextBuilder;

public class L2VoteManagerInstance
  extends L2FolkInstance
{
  public L2VoteManagerInstance(int objectId, L2NpcTemplate template)
  {
    super(objectId, template);
  }
  
  @Override
public void onBypassFeedback(L2PcInstance player, String command)
  {
    if (player == null) {
      return;
    }
    if (command.startsWith("votehopzone"))
    {
      VoteMain.hopvote(player);
    }
    if (command.startsWith("votetopzone"))
    {
      VoteMain.topvote(player);
    }
    if ((command.startsWith("rewards")) && VoteMain.hasVotedHop() && VoteMain.hasVotedTop())
    {
      showRewardsHtml(player);
    }
    
    if ((command.startsWith("reward1")) && VoteMain.hasVotedHop() && VoteMain.hasVotedTop())
    {
      player.getInventory().addItem("reward", Config.VOTE_REWARD_ID1, Config.VOTE_REWARD_AMOUNT1, player, null);
      player.sendMessage("Thanks you for votes. Take your reward.");
      player.sendPacket(new ItemList(player, true));
      VoteMain.setHasNotVotedHop(player);
      VoteMain.setHasNotVotedTop(player);
      VoteMain.setTries(player, VoteMain.getTries(player) + 1);
    }
    
    if ((command.startsWith("reward2")) && VoteMain.hasVotedHop() && VoteMain.hasVotedTop())
    {
      player.getInventory().addItem("reward", Config.VOTE_REWARD_ID2, Config.VOTE_REWARD_AMOUNT2, player, null);
      player.sendMessage("Thanks you for votes. Take your reward.");
      player.sendPacket(new ItemList(player, true));
      VoteMain.setHasNotVotedHop(player);
      VoteMain.setHasNotVotedTop(player);
      VoteMain.setTries(player, VoteMain.getTries(player) + 1);
    }
    
    if ((command.startsWith("reward3")) && VoteMain.hasVotedHop() && VoteMain.hasVotedTop())
    {
      player.getInventory().addItem("reward", Config.VOTE_REWARD_ID3, Config.VOTE_REWARD_AMOUNT3, player, null);
      player.sendMessage("Thanks you for votes. Take your reward.");
      player.sendPacket(new ItemList(player, true));
      VoteMain.setHasNotVotedHop(player);
      VoteMain.setHasNotVotedTop(player);
      VoteMain.setTries(player, VoteMain.getTries(player) + 1);
    }
    
    if ((command.startsWith("reward4")) && VoteMain.hasVotedHop() && VoteMain.hasVotedTop())
    {
      player.getInventory().addItem("reward", Config.VOTE_REWARD_ID4, Config.VOTE_REWARD_AMOUNT4, player, null);
      player.sendMessage("Thanks you for votes. Take your reward.");
      player.sendPacket(new ItemList(player, true));
      VoteMain.setHasNotVotedHop(player);
      VoteMain.setHasNotVotedTop(player);
      VoteMain.setTries(player, VoteMain.getTries(player) + 1);
    }
  }
  
  @Override
public void onAction(L2PcInstance player)
  {
    if (this != player.getTarget())
    {
      player.setTarget(this);
      
      player.sendPacket(new MyTargetSelected(getObjectId(), 0));
      
      player.sendPacket(new ValidateLocation(this));
    }
    else if (!canInteract(player))
    {
      player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, this);
    }
    else
    {
      showHtmlWindow(player);
    }
    player.sendPacket(ActionFailed.STATIC_PACKET);
  }
  
  public void showHtmlWindow(L2PcInstance activeChar)
  {
    VoteMain.hasVotedHop(activeChar);
    VoteMain.hasVotedTop(activeChar);
    
    TextBuilder tb = new TextBuilder();
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    
    tb.append("<html><head><title>Vote reward Panel</title></head><body><center><br><br>");
    tb.append("<table bgcolor=\"FFFFFF\"><tr><td align=\"center\"><font color=\"00ff99\">Who's voting now: </font>" + VoteMain.whosVoting() + "</td></tr>");
    tb.append("<tr><td align=\"center\"><font color=\"00ffff\">Tries left: </font>" + VoteMain.getTries(activeChar) + "</td></tr>");
    tb.append("<tr><td align=\"center\"><font color=\"00ffff\">Max seconds until vote: </font>" + Config.SECS_TO_VOTE + "(s)</td></tr>");
    if (Config.VOTE_REWARD_ID1 > 0)
    {
      tb.append("<tr><td align=\"center\"><font color=\"00ffff\">1) " + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID1).getName() + ":</font> " + Config.VOTE_REWARD_AMOUNT1 + "</td></tr>");
    }
    if (Config.VOTE_REWARD_ID2 > 0)
    {
      tb.append("<tr><td align=\"center\"><font color=\"00ffff\">2) " + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID2).getName() + ":</font> " + Config.VOTE_REWARD_AMOUNT2 + "</td></tr>");
    }
    if (Config.VOTE_REWARD_ID3 > 0)
    {
      tb.append("<tr><td align=\"center\"><font color=\"00ffff\">2) " + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID3).getName() + ":</font> " + Config.VOTE_REWARD_AMOUNT3 + "</td></tr>");
    }
    if (Config.VOTE_REWARD_ID4 > 0) 
    {
      tb.append("<tr><td align=\"center\"><font color=\"00ffff\">2) " + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID4).getName() + ":</font> " + Config.VOTE_REWARD_AMOUNT4 + "</td></tr>");
    }
    tb.append("<tr><td align=\"center\"><font color=\"FF6600\">You can vote in Hopzone at " + VoteMain.hopCd(activeChar) + "</font></td></tr>");
    tb.append("<tr><td align=\"center\"><font color=\"FF6600\">You can vote in Topzone at " + VoteMain.topCd(activeChar) + "</font></td></tr>");
    tb.append("</table>");
    tb.append("</center><br><br>");
    tb.append("<center>");
    if ((VoteMain.hasVotedHop()) && (!VoteMain.hasVotedTop()))
    {
      tb.append("<td><font color = \"00FF00\">For reward you must vote on TOPZONE TOO!</font></td>");
      tb.append("<td><button value=\"Vote Topzone\" action=\"bypass -h npc_" + getObjectId() + "_votetopzone\" width=\"94\" height=\"21\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\"></td>");
    }
    else if ((!VoteMain.hasVotedHop()) && (VoteMain.hasVotedTop()))
    {
      tb.append("<td><font color = \"00FF00\">For reward you must vote on HOPZONE TOO!</font></td>");
      tb.append("<td><button value=\"Vote Hopzone\" action=\"bypass -h npc_" + getObjectId() + "_votehopzone\" width=\"94\" height=\"21\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\"></td>");
    }
    else if ((!VoteMain.hasVotedHop()) && (!VoteMain.hasVotedTop()))
    {
      tb.append("<td><button value=\"Vote Hopzone\" action=\"bypass -h npc_" + getObjectId() + "_votehopzone\" width=\"94\" height=\"21\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\"></td>");
      tb.append("<td><button value=\"Vote Topzone\" action=\"bypass -h npc_" + getObjectId() + "_votetopzone\" width=\"94\" height=\"21\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\"></td>");
    }
    else
    {
      tb.append("<td><button value=\"Take The REWARD\" action=\"bypass -h npc_" + getObjectId() + "_rewards\" width=\"94\" height=\"21\" back=\"L2UI_ch3.bigbutton_over\" fore=\"L2UI_ch3.bigbutton\"></td>");
    }
    tb.append("<table width=200>");
    if (!VoteMain.hasVotedHop())
    {
      tb.append("<tr>");
      tb.append("<td align=\"center\"><font color=\"FF6600\">Hopzone Status: </font><font color=\"00FFFF\">NOT VOTED.</font></td>");
      tb.append("</tr>");
    }
    else
    {
      tb.append("<tr>");
      tb.append("<td align=\"center\"><font color=\"FF6600\">Hopzone Status: </font><font color=\"FF00FF\">VOTED.</font></td>");
      tb.append("</tr>");
    }
    if (!VoteMain.hasVotedTop())
    {
      tb.append("<tr>");
      tb.append("<td align=\"center\"><font color=\"FF6600\">Topzone Status: </font><font color=\"00FFFF\">NOT VOTED.</font></td>");
      tb.append("</tr>");
    }
    else
    {
      tb.append("<tr>");
      tb.append("<td align=\"center\"><font color=\"FF6600\">Topzone Status: </font><font color=\"FF00FF\">VOTED.</font></td>");
      tb.append("</tr>");
    }
    tb.append("</table>");
    tb.append("<br><br>");
    tb.append("<table width=200>");
    tb.append("<tr><td align=\"center\"><font color=\"FF6600\">Your total votes in general: </font>" + VoteMain.getTotalVotes(activeChar) + "</td></tr>");
    tb.append("<tr><td align=\"center\"><font color=\"FF6600\">Players voted in general: </font>" + VoteMain.getBigTotalVotes(activeChar) + "</td></tr>");
    tb.append("</table>");
    tb.append("</center>");
    tb.append("</body></html>");
    
    html.setHtml(tb.toString());
    activeChar.sendPacket(html);
  }
  
  public void showRewardsHtml(L2PcInstance player)
  {
    TextBuilder tb = new TextBuilder();
    NpcHtmlMessage html = new NpcHtmlMessage(1);
    
    tb.append("<html><head><title>Vote Reward Panel</title></head><body>");
    tb.append("<center>");
    tb.append("<table width=\"250\" cellpadding=\"5\" bgcolor=\"000000\">");
    tb.append("<tr>");
    tb.append("<td width=\"45\" valign=\"top\" align=\"center\"><img src=\"L2ui_ch3.menubutton4\" width=\"38\" height=\"38\"></td>");
    tb.append("<td valign=\"top\"><font color=\"FF6600\">Vote Panel</font>");
    tb.append("<br1><font color=\"00FF00\">" + player.getName() + "</font>, get your reward here.</td>");
    tb.append("</tr>");
    tb.append("</table>");
    tb.append("</center>");
    tb.append("<center>");
    tb.append("<td valign=\"top\"><font color=\"FF6600\">Choose your reward " + player.getName() + ".</font>");
    if (Config.VOTE_REWARD_ID1 > 0) {
      tb.append("<button value=\"Item:" + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID1).getName() + "   Amount:" + Config.VOTE_REWARD_AMOUNT1 + "\" action=\"bypass -h npc_" + getObjectId() + "_reward1\" width=204 height=20>");
    }
    if (Config.VOTE_REWARD_ID2 > 0) {
      tb.append("<button value=\"Item:" + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID2).getName() + "   Amount:" + Config.VOTE_REWARD_AMOUNT2 + "\" action=\"bypass -h npc_" + getObjectId() + "_reward2\" width=204 height=20>");
    }
    if (Config.VOTE_REWARD_ID3 > 0) {
      tb.append("<button value=\"Item:" + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID3).getName() + "   Amount:" + Config.VOTE_REWARD_AMOUNT3 + "\" action=\"bypass -h npc_" + getObjectId() + "_reward3\" width=204 height=20>");
    }
    if (Config.VOTE_REWARD_ID4 > 0) {
      tb.append("<button value=\"Item:" + ItemTable.getInstance().getTemplate(Config.VOTE_REWARD_ID4).getName() + "   Amount:" + Config.VOTE_REWARD_AMOUNT4 + "\" action=\"bypass -h npc_" + getObjectId() + "_reward4\" width=204 height=20>");
    }
    tb.append("</center>");
    
    tb.append("</body></html>");
    
    html.setHtml(tb.toString());
    player.sendPacket(html);
  }
}

package com.l2jfrozen.gameserver.model.votereward;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.SocketTimeoutException;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;

import com.l2jfrozen.Config;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;
import com.l2jfrozen.gameserver.network.serverpackets.CreatureSay;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.util.database.L2DatabaseFactory;

/**
 * @Rework Katara
 */
public class VoteMain
{
	private static boolean hasVotedHop;
	private static boolean hasVotedTop;
	static boolean Problemontop = false;
	static boolean Problemonhop = false;
	
	public VoteMain()
	{
	}
	
	public static void load()
	{
		System.out.println("Vote Reward Per Person Started Successfully.");
		TriesResetTask.getInstance();
	}
	
	protected static int getHopZoneVotes()
	{
		URL url = null;
		InputStreamReader isr = null;
		BufferedReader in = null;
		try
		{
			url = new URL(Config.VOTE_LINK_HOPZONE);
			HttpURLConnection con = (HttpURLConnection) url.openConnection();
			HttpURLConnection.setFollowRedirects(false);
			con.setConnectTimeout(10 * 1000);
			con.addRequestProperty("user-agent", "fake googlebot");
			con.connect();
			isr = new InputStreamReader(con.getInputStream());
			in = new BufferedReader(isr);
			String inputLine;
			while ((inputLine = in.readLine()) != null)
			{
				if (inputLine.contains("rank anonymous tooltip"))
				{
					return Integer.valueOf(inputLine.split(">")[2].replace("</span", ""));
				}
			}
		}
		catch (IOException e)
		{
			System.out.println("[Hopzone-Vote Manager] I can't connect on Hopzone site...");
			Problemonhop = true;
		}
		return 0;
	}
	
	protected static int getTopZoneVotes()
	{
		URL url = null;
		InputStreamReader isr = null;
		BufferedReader in = null;
		try
		{
			try
			{
				url = new URL(Config.VOTE_LINK_TOPZONE);
				HttpURLConnection con = (HttpURLConnection) url.openConnection();
				HttpURLConnection.setFollowRedirects(false);
				con.setConnectTimeout(5 * 1000);
				con.addRequestProperty("User-Agent", "L2TopZone");
				con.connect();
				isr = new InputStreamReader(con.getInputStream());
				in = new BufferedReader(isr);
			}
			catch (SocketTimeoutException e)
			{
				System.out.println("[Topzone-Vote Manager] I can't connect on TOPZONE site...");
				Problemontop = true;
				return 0;
			}
			 
			String inputLine;
			while ((inputLine = in.readLine()) != null)
			{
				if (inputLine.contains("Votes:"))
				{
					for (int i=-1; i>2; i++)
						inputLine = in.readLine();

					Problemontop = false;
					return Integer.valueOf(inputLine.split(">")[3].replace("</div", ""));
				}
			}
		}	
	catch (IOException e)
		{
			e.printStackTrace();
			System.out.println("[Topzone-Vote Manager] I can't connect on Topzone site...");
			Problemontop = true;
		}
		return 0;
	}
	
	public static String hopCd(L2PcInstance player)
	{
		long hopCdMs = 0;
		long voteDelay = 43200000L;
		PreparedStatement statement = null;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			statement = con.prepareStatement("SELECT lastVoteHopzone FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());
			
			ResultSet rset = statement.executeQuery();
			
			while (rset.next())
			{
				hopCdMs = rset.getLong("lastVoteHopzone");
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
		
		Date resultdate = new Date(hopCdMs + voteDelay);
		return sdf.format(resultdate);
	}
	
	public static String topCd(L2PcInstance player)
	{
		long topCdMs = 0;
		long voteDelay = 43200000L;
		PreparedStatement statement = null;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			statement = con.prepareStatement("SELECT lastVoteTopzone FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());
			
			ResultSet rset = statement.executeQuery();
			
			while (rset.next())
			{
				topCdMs = rset.getLong("lastVoteTopzone");
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		SimpleDateFormat sdf = new SimpleDateFormat("MMM dd,yyyy HH:mm");
		
		Date resultdate = new Date(topCdMs + voteDelay);
		return sdf.format(resultdate);
	}
	
	public static String whosVoting()
	{
		for (L2PcInstance voter : L2World.getInstance().getAllPlayers())
		{
			if (voter.isVoting())
			{
				return voter.getName();
			}
		}
		return "None";
	}
	
	public static void hopvote(final L2PcInstance player)
	{
		long lastVoteHopzone = 0L;
		long voteDelay = 43200000L;
		final int firstvoteshop;
		int votesmessage = 0;
		
		firstvoteshop = getHopZoneVotes();
		votesmessage = getHopZoneVotes();
		
		class hopvotetask implements Runnable
		{
			private final L2PcInstance p;
			
			public hopvotetask(L2PcInstance player)
			{
				p = player;
			}
			
			@Override
			public void run()
			{
				if(Problemonhop == true)
				{
					p.setIsVoting(false);
					VoteMain.setHasVotedHop(p);
					p.sendMessage("Thank you for voting for us!");
					//Announcements.getInstance().gameAnnounceToAll("[Vote Manager] Vote 4 Us on HOPZONE.");
					VoteMain.updateLastVoteHopzone(p);
					Problemonhop = false;
					System.out.println("I have error on topzone but i will give the reward... Please check me katara.");
				}
				else
				{
					if (firstvoteshop < getHopZoneVotes())
					{
						p.setIsVoting(false);
						VoteMain.setHasVotedHop(player);
						p.sendMessage("Thank you for voting for us!");
						//Announcements.getInstance().gameAnnounceToAll("[Vote Manager] Vote 4 Us on HOPZONE.");
						VoteMain.updateLastVoteHopzone(p);
						VoteMain.updateVotes(p);
					}
					else
					{
						p.setIsVoting(false);
						p.sendMessage("You did not vote on hopzone. Please try again later...");
						VoteMain.setTries(player, VoteMain.getTries(p) - 1);
					}
				}
			}
		}
		
		PreparedStatement statement = null;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			statement = con.prepareStatement("SELECT lastVoteHopzone FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());
			
			ResultSet rset = statement.executeQuery();
			
			while (rset.next())
			{
				lastVoteHopzone = rset.getLong("lastVoteHopzone");
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		
		if (getTries(player) <= 0)
		{
			player.sendMessage("Due to your multiple failures in voting you lost your chance to vote today");
		}
		else if (((lastVoteHopzone + voteDelay) < System.currentTimeMillis()) && (getTries(player) > 0))
		{
			for (L2PcInstance j : L2World.getInstance().getAllPlayers())
			{
				if (j.isVoting())
				{
					player.sendMessage("Someone is already voting.Wait for your turn please!");
					return;
				}
			}
			
			player.setIsVoting(true);
			//ExShowScreenMessageOnBroad screen = new ExShowScreenMessageOnBroad("GO at Website and vote on HOPZONE, " + player.getName(), 20000, SMPOS.TOP_CENTER, true);
			//player.sendPacket(screen);
			CreatureSay cs = new CreatureSay(player.getObjectId(), 3, "Hopzone system","Current votes are "+votesmessage+", careful with your vote!");
			player.sendPacket(cs);
			player.sendMessage("You have " + Config.SECS_TO_VOTE + " seconds.Hurry!");
			ThreadPoolManager.getInstance().scheduleGeneral(new hopvotetask(player), Config.SECS_TO_VOTE * 1000);
		}
		else if ((getTries(player) <= 0) && ((lastVoteHopzone + voteDelay) < System.currentTimeMillis()))
		{
			for (L2PcInstance j : L2World.getInstance().getAllPlayers())
			{
				if (j.isVoting())
				{
					player.sendMessage("Someone is already voting.Wait for your turn please!");
					return;
				}
			}
			
			player.setIsVoting(true);
			//ExShowScreenMessageOnBroad screen = new ExShowScreenMessageOnBroad("GO at Website and vote on HOPZONE, " + player.getName(), 20000, SMPOS.TOP_CENTER, true);
			//player.sendPacket(screen);
			CreatureSay cs = new CreatureSay(player.getObjectId(), 3, "Hopzone system","Current votes are "+votesmessage+", careful with your vote!");
			player.sendPacket(cs);
			player.sendMessage("You have " + Config.SECS_TO_VOTE + " seconds.Hurry!");
			ThreadPoolManager.getInstance().scheduleGeneral(new hopvotetask(player), Config.SECS_TO_VOTE * 1000);
			
		}
		else
		{
			player.sendMessage("12 hours have to pass till you are able to vote again.");
		}
		
	}
	
	public static void topvote(final L2PcInstance player)
	{
		long lastVoteTopzone = 0L;
		long voteDelay = 43200000L;
		final int firstvotestop;
		int votesmessage = 0;
		
		firstvotestop = getTopZoneVotes();
		votesmessage = getTopZoneVotes();
		
		class topvotetask implements Runnable
		{
			private final L2PcInstance p;
			
			public topvotetask(L2PcInstance player)
			{
				p = player;
			}
			
			@Override
			public void run()
			{
				if(Problemontop == true)
				{
					p.setIsVoting(false);
					VoteMain.setHasVotedTop(p);
					p.sendMessage("Thank you for voting for us!");
					//Announcements.getInstance().gameAnnounceToAll("[Vote Manager] Vote 4 Us on TOPZONE.");
					VoteMain.updateLastVoteTopzone(p);
					Problemontop = false;
					System.out.println("I have error on topzone but i will give the reward... Please check me katara.");
				}
				else
				{
					if (firstvotestop < getTopZoneVotes())
					{
						p.setIsVoting(false);
						VoteMain.setHasVotedTop(p);
						p.sendMessage("Thank you for voting for us!");
						//Announcements.getInstance().gameAnnounceToAll("[Vote Manager] Vote 4 Us on TOPZONE.");
						VoteMain.updateLastVoteTopzone(p);
						VoteMain.updateVotes(p);
					}
					else
					{
						p.setIsVoting(false);
						p.sendMessage("You did not vote on topzone. Please try again later...");
						VoteMain.setTries(p, VoteMain.getTries(p) - 1);
					}
				}
			}
		}
		
		PreparedStatement statement = null;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			statement = con.prepareStatement("SELECT lastVoteTopzone FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());
			
			ResultSet rset = statement.executeQuery();
			
			while (rset.next())
			{
				lastVoteTopzone = rset.getLong("lastVoteTopzone");
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		
		if (getTries(player) <= 0)
		{
			player.sendMessage("Due to your multiple failures in voting you lost your chance to vote today");
		}
		else if ((getTries(player) <= 0) && ((lastVoteTopzone + voteDelay) < System.currentTimeMillis()))
		{
			for (L2PcInstance j : L2World.getInstance().getAllPlayers())
			{
				if (j.isVoting())
				{
					player.sendMessage("Someone is already voting.Wait for your turn please!");
					return;
				}
			}
			player.setIsVoting(true);
			//ExShowScreenMessageOnBroad screen = new ExShowScreenMessageOnBroad("GO at Website and vote on TOPZONE, " + player.getName(), 20000, SMPOS.TOP_CENTER, true);
			//player.sendPacket(screen);
			CreatureSay cs = new CreatureSay(player.getObjectId(), 3, "Topzone system","Current votes are "+votesmessage+", careful with your vote!");
			player.sendPacket(cs);
			player.sendMessage("You have " + Config.SECS_TO_VOTE + " seconds.Hurry!");
			ThreadPoolManager.getInstance().scheduleGeneral(new topvotetask(player), Config.SECS_TO_VOTE * 1000);
		}
		else if (((lastVoteTopzone + voteDelay) < System.currentTimeMillis()) && (getTries(player) > 0))
		{
			for (L2PcInstance j : L2World.getInstance().getAllPlayers())
			{
				if (j.isVoting())
				{
					player.sendMessage("Someone is already voting.Wait for your turn please!");
					return;
				}
			}
			player.setIsVoting(true);
			//ExShowScreenMessageOnBroad screen = new ExShowScreenMessageOnBroad("GO at Website and vote on TOPZONE, " + player.getName(), 20000, SMPOS.TOP_CENTER, true);
			//player.sendPacket(screen);
			CreatureSay cs = new CreatureSay(player.getObjectId(), 3, "Topzone system","Current votes are "+votesmessage+", careful with your vote!");
			player.sendPacket(cs);
			player.sendMessage("You have " + Config.SECS_TO_VOTE + " seconds.Hurry!");
			ThreadPoolManager.getInstance().scheduleGeneral(new topvotetask(player), Config.SECS_TO_VOTE * 1000);
		}
		else
		{
			player.sendMessage("12 hours have to pass till you are able to vote again.");
		}
		
	}
	
	public static void hasVotedHop(L2PcInstance player)
	{
		int hasVotedHop = -1;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT hasVotedHop FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());
			
			ResultSet rset = statement.executeQuery();
			
			while (rset.next())
			{
				hasVotedHop = rset.getInt("hasVotedHop");
			}
			
			if (hasVotedHop == 1)
			{
				setHasVotedHop(true);
			}
			else if (hasVotedHop == 0)
			{
				setHasVotedHop(false);
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static void hasVotedTop(L2PcInstance player)
	{
		int hasVotedTop = -1;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT hasVotedTop FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());
			
			ResultSet rset = statement.executeQuery();
			
			while (rset.next())
			{
				hasVotedTop = rset.getInt("hasVotedTop");
			}
			
			if (hasVotedTop == 1)
			{
				setHasVotedTop(true);
			}
			else if (hasVotedTop == 0)
			{
				setHasVotedTop(false);
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static void updateVotes(L2PcInstance activeChar)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET totalVotes=? WHERE obj_Id=?");

			statement.setInt(1, getTotalVotes(activeChar) + 1);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static void setHasVotedHop(L2PcInstance activeChar)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET hasVotedHop=? WHERE obj_Id=?");
			
			statement.setInt(1, 1);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static void setHasVotedTop(L2PcInstance activeChar)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET hasVotedTop=? WHERE obj_Id=?");
			statement.setInt(1, 1);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
	}
	}
	
	public static void setHasNotVotedHop(L2PcInstance activeChar)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET hasVotedHop=? WHERE obj_Id=?");
			statement.setInt(1, 0);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static void setHasNotVotedTop(L2PcInstance activeChar)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET hasVotedTop=? WHERE obj_Id=?");
			statement.setInt(1, 0);
			statement.setInt(2, activeChar.getObjectId());
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static int getTries(L2PcInstance player)
	{
		int tries = -1;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT tries FROM characters WHERE obj_Id=?");
		 statement.setInt(1, player.getObjectId());
		 for (ResultSet rset = statement.executeQuery(); rset.next();)
			{
				tries = rset.getInt("tries");
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		return tries;
	}
	
	public static void setTries(L2PcInstance player, int tries)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET tries=? WHERE obj_Id=?");
			statement.setInt(1, tries);
			statement.setInt(2, player.getObjectId());
			statement.execute();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static int getTotalVotes(L2PcInstance player)
	{
		int totalVotes = 0;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT totalVotes FROM characters WHERE obj_Id=?");
			statement.setInt(1, player.getObjectId());
			ResultSet rset = statement.executeQuery();
			while (rset.next())
			{	
				totalVotes = rset.getInt("totalVotes");
			}
			rset.close();
			statement.close();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		return totalVotes;
	}
	
	public static int getBigTotalVotes(L2PcInstance player)
	{
		int bigTotalVotes = -1;
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("SELECT SUM(totalVotes) FROM characters");
			for (ResultSet rset = statement.executeQuery(); rset.next();)
			{
				bigTotalVotes = rset.getInt("SUM(totalVotes)");
			}
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
		return bigTotalVotes;
	}
	
	public static void updateLastVoteHopzone(L2PcInstance player)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET lastVoteHopzone=? WHERE obj_Id=?");
			statement.setLong(1, System.currentTimeMillis());
			statement.setInt(2, player.getObjectId());
			statement.execute();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	public static void updateLastVoteTopzone(L2PcInstance player)
	{
		try (Connection con = L2DatabaseFactory.getInstance().getConnection())
		{
			PreparedStatement statement = con.prepareStatement("UPDATE characters SET lastVoteTopzone=? WHERE obj_Id=?");
			statement.setLong(1, System.currentTimeMillis());
			statement.setInt(2, player.getObjectId());
			statement.execute();
		}
		catch (Exception e)
		{
			e.printStackTrace();
		}
	}
	
	// Getters and Setters
	public static boolean hasVotedHop()
	{
		return hasVotedHop;
	}
	
	public static void setHasVotedHop(boolean hasVotedHop)
	{
		VoteMain.hasVotedHop = hasVotedHop;
	}
	
	public static boolean hasVotedTop()
	{
		return hasVotedTop;
	}
	
	public static void setHasVotedTop(boolean hasVotedTop)
	{
		VoteMain.hasVotedTop = hasVotedTop;
	}
}
package com.l2jfrozen.gameserver.model.votereward;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.Calendar;

import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.util.database.L2DatabaseFactory;

public class TriesResetTask
{	
	public TriesResetTask()
	{
	}
	
	public static void getInstance()
	{
		ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
		{
			@Override
			public void run()
			{
				try (Connection con = L2DatabaseFactory.getInstance().getConnection())
				{
					PreparedStatement statement = con.prepareStatement("UPDATE characters SET tries=?");
					
					statement.setInt(1, 3);
					statement.execute();
					statement.close();
				}
				catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		}, getValidationTime());
	}
	
	private static long getValidationTime()
	{
		Calendar cld = Calendar.getInstance();
		cld.set(11, 12);
		cld.set(12, 1);
		long time = cld.getTimeInMillis();
		if ((System.currentTimeMillis() - time) <= 0L)
		{
			long delay = cld.getTimeInMillis() - System.currentTimeMillis();
			return delay;
		}
		return 0L;
	}
}

that's all I have to clip than vote opium anyone desires to help thex

  • 0
Posted

I have also told you on private message what you need to do but seams that you are equal with 0 at java... you don't know even basic things.....

 

You have the same situation here what I replay above....

while ((inputLine = in.readLine()) != null)
			{
				if (inputLine.contains("Votes:"))
				{
					for (int i=-1; i>2; i++)
						inputLine = in.readLine();
 
					Problemontop = false;
					return Integer.valueOf(inputLine.split(">")[3].replace("</div", ""));
				}
			}

Replace it with  

while ((inputLine = in.readLine()) != null)
{
					Problemontop = false;
					return Integer.valueOf(inputLine);
}
  • 0
Posted

Locked .

 

Δεν νομιζω να νοιάζει κανέναν ποιανού είναι το pack .

Guest
This topic is now closed to further replies.


  • Posts

    • Hello MxC community, i want to buy client dev / patch maker services for the client of salvation. Im using L2jeternity multiprotocol (h5-salvation 140). I want a Patch full optimized for the h5 content. Everything that is not needed must be removed, as well as some textures like maps for example should be also adjusted to h5 content. If you know anyone that can take the job feel free to contact me here or in Discord. Only professional work.   Discord: ch4osroxas   Thank you very much!
    • Hi dude, i`m in the same way of nawaro, leaning how to edit interfaces, could u help me too?
    • General Trackers :   IPTorrents invite IPTorrents account 1 tb TorrentLeech invite Torrentleech account 1 tb buffer  InTheShaDow ( ITS ) account Acid-lounge invite Torrentday invite Crnaberza account Abn.Lol account Limit-of-eden account Norbits account Xspeeds account Xspeeds invite Bemaniso invite Wigornot account Bithumen invite Filelist account Funfile invite AvistaZ invite Potuk.net invite ResurrectThe.Net invite GrabThe.Info invite Greek-Team invite LinkoManija invite Fano.in account tracker.czech-server.com Speed.cd invite Arab-torrents.net account Arabscene.me account Scenetime account 4thd.xyz invite Btarg.com.ar account Dedbit invite Estone.cc account Speedapp invite Finvip invite Fluxzone account GigaTorrents account Gimmepeers account Haidan.video invite Mojblink account Mycarpathians invite Newinsane.info account Oscarworld.xyz account Peers.FM invite Pt.msg.vg account Ransackedcrew account Redemption invite Scene-rush account Seedfile.io invite Teracod invite Torrent.ai account Torrentmasters invite Ttsweb invite X-files invite X-ite invite Ncore account TorrentHR account Rptorrents account BwTorrents account Superbits invite Krazyzone account Immortalseed account Tntracker invite Pt.eastgame.org account Bitturk account Rstorrent account Tracker.btnext invite Torrent-turk.de account BeiTai.PT account Pt.keepfrds account 52pt.site account Pthome account Torrentseeds account Aystorrent account Blues-brothers.biz invite Divteam account Thesceneplace invite CinemaMovies.pl account Brasiltracker account Patiodebutacas account Newheaven.nl account  Swarmazon.club invite Bc-reloaded account Crazyspirits account Silentground invite Omg.wtftrackr invite Milkie.cc invite Breathetheword invite Madsrevolution account Chilebt account Yubraca account Uniongang.tv account Frboard account Exvagos account Diablotorrent account Microbit account Carp-hunter.hu account Majomparade.eu account Theshinning.me account Youiv.info account Dragonworld-reloaded account Sharewood.tv account Partis.si account Digitalcore.club invite Fuzer.me account R3vuk.wtf invite Ztracker account 1 tb buffer 3changtrai account Best-core.info account Bitsite.us account Eliteunitedcrew invite Exitorrent.org account Tophos invite Torrent.lt account Sktorrent.eu account Oshen account Blackhattorrent account Pirata.digital account Esharenet account Ohmenarikgi.la Pirate-share account Immortuos account Kiesbits account Cliente.amigos-share.club account Broadcity invite Ilovetorzz account Torrentbytes account Polishsource account Portugas invite Shareisland account ArabaFenice account Hudbt.hust.edu.cn account Audiences account Nanyangpt account Pt.sjtu.edu.cn account Pt.zhixing.bjtu.edu.cn account Byr.pt invite Ptfiles invite Red-bits account Pt.hdpost.top account Irrenhaus.dyndns.dk (NewPropaganda) account Mnvv2.info (MaxNewVision V2) account 1ptba.com account Spidertk.top account Film-paleis account Generation-free account Aftershock-tracker account Twilightsdreams account Back-ups.me invite Sor-next.tk ( Spirit Of Revolution ) account Tfa.tf ( The Falling Angels ) account Hdmayi account S-f-p.dyndns.dk ( Share Friends Projekt ) account Unlimitz.biz account Pttime account St-tracker.eu account New-retro.eu account Zbbit account Tigers-dl.net account Jptvts.us account Lat-team account Club.hares.top account Falkonvision-team account Concen account Drugari account T.ceskeforum account Peeratiko.org account Zamunda.se account Central-torrent.eu account h-o-d.org account Torrentleech.pl account Demonoid invite Lst.gg account Fakedoor.store account LaidBackManor account Vrbsharezone.co.uk invite Torrenteros account Arenaelite account Datascene account Tracker.0day.community Tapochek.net invite Ptchina invite Lesaloon account Exyusubs account Therebels.tv account Ubits.club invite Zmpt.cc account Turktorrent.us account Dasunerwarte account Hawke.uno account Monikadesign account Fearnopeer account Alpharatio account Wukongwendao.top account Chinapyg account Azusa.wiki account Yggtorrent.top account Torrentdd account Cyanbug.net invite Hhanclub.top account Wintersakura.net account Xthor account Tctg.pm account Finelite invite Agsvpt.com account Pt.0ff.cc invite Qingwapt.com account Xingtan.one account Ptcafe.club invite Theoldschool.cc account W-o-t.pro account Coastal-crew.bounceme.net account Darkpeers.org account Pianyuan.org account Seedpool.org  account Tempelbox account Pt.itzmx.com account Capybarabr.com account Itatorrents.xyz  account Letseed.org account The-new-fun.com  account Malayabits.cc account Trellas.me account Yu-scene.net account Futuretorrent.org account Bitpt.cn account Tocashare.biz  account Videoteka.org  account White-angel.hu account Xbytesv2.li account   Movies Trackers :   Anthelion account Pixelhd account Cinemageddon account DVDSeed account Cinemageddon account Cinemaz account Retroflix account Classix-unlimited - invite Movie-Torrentz (m2g.link) invite Punck-tracker.net account Tmghub account Tb-asian account Cathode-ray.tube account Greatposterwall account Telly account Arabicsource.net account Upload.cx account Crabpt.vip invite Onlyencodes.cc account Exyusubs account Hellashut.net invite Nordichd.sytes.net invite Locadora.cc account   HD Trackers :   Blutopia buffered account Hd-olimpo buffered account Hdf.world account Torrentland.li account HdSky account Hdchina account Chdbits account Totheglory account Hdroute account Hdhome account TorrentCCF aka et8.org account 3DTorrents invite HD-Torrents account Bit-HDTV account HDME.eu invite Hdarea.co account Asiancinema.me account JoyHD invite HDSpace invite CrazyHD invite Bluebird-hd invite Htpt.cc account Hdtime invite Ourbits.club account Hd4fans account Siambit account Privatehd account Springsunday account Tjupt account Hdcity.leniter invite Ccfbits account Discfan account Pt.btschool.club account Ptsbao.club invite Hdzone.me invite Danishbytes account Zonaq.pw account Tracker.tekno3d account Arabp2p account Hd-united account Reelflix.xyz account Hdatmos.club account Anasch.cc invite Tigris-t account Nethd.org account Hd.ai invite Hitpt.com account Hdmonkey account Dragonhd.xyz account Hdclub.eu account Forum.bluraycd.com account Carpt account Hdfun.me invite Pt.hdupt invite Puntotorrent account Ultrahd account Rousi.zip account Bearbit account Hdturk.club account Asiandvdclub account Star-space.net account Nordicq.org account Hdkyl.in account Utp.to account Music Trackers : Dicmusic account Music-Vid account Open.cd account LzTr account ProAudioTorrents invite Jpopsuki invite TranceTraffic invite Audionews invite Kraytracker invite Libble.me invite Losslessclub invite Indietorrents.com invite Dimeadozen account Funkytorrents invite Karaokedl account zombtracker.the-zomb account Concertos account Sugoimusic account Satclubbing.club invite Metal.iplay invite Psyreactor invite Panda.cd account Adamsfile account Freehardmusic account Tracker.hqmusic.vn accouunt Twilightzoom account 3 tb buffer Hiresmusic account Metalguru account Musictorrents.org account Musebootlegs.com invite Zappateers.com account Jungleland.dnsalias.com account Naftamusic account   E-Learning Trackers :   Thevault account BitSpyder invite Brsociety account Learnbits invite Myanonamouse account Libranet account 420Project account Learnflakes account Pt.soulvoice.club account P2pelite account Aaaaarg.fail invite Ebooks-shares.org account Abtorrents account Pt.tu88.men invite Docspedia.world invite   TV-Trackers :   Skipthecommericals Cryptichaven account TV-Vault invite Shazbat.TV account Myspleen account Tasmanit.es invite Tvstore.me account Tvchaosuk account Jptv.club account Tvroad.info   XXX - Porn Trackers :   FemdomCult account Pornbay account Pussytorrents account Adult-cinema-network account Bootytape account 1 Tb buffer Exoticaz account Bitporn account Kufirc account Gaytorrent.ru invite Nicept account Gay-torrents.org invite Ourgtn account Pt.hdbd.us account BitSexy account Happyfappy.org account Kamept.com account Lesbians4u.org account   Gaming Trackers :   Mteam.fr account BitGamer invite Retrowithin invite Gamegamept account   Cartoon/Anime/Comic Trackers :   Animeworld account Oldtoons.world account U2.dmhy account CartoonChaos invite Animetorrents account Mononoke account Totallykids.tv account Bakabt.me invite Revanime account Ansktracker account Tracker.shakaw.com.br invite Bt.mdan.org account Skyey2.com account Animetracker.cc Adbt.it.cx invite Tracker.uniotaku.com account Mousebits.com account   Sports Trackers :   MMA-Tracker invite T3nnis.tv invite AcrossTheTasman account RacingForMe invite Sportscult invite Ultimatewrestlingtorrents account Worldboxingvideoarchive invite CyclingTorrents account Xtremewrestlingtorrents account Tc-boxing invite Mma-torrents account Aussierul invite Xwt-classics account Racing4everyone account Talk.tenyardtracker account Stalker.societyglitch invite Extremebits invite Rgfootball.net account F1carreras.xyz account   Software/Apps Trackers :   Brokenstones account Appzuniverse invite Teamos.xyz account Macbb.org account   Graphics Trackers:   Forum.Cgpersia account Gfxpeers account Forum.gfxdomain account   Documentary Trackers:   Forums.mvgroup account   Others   Fora.snahp.eu account Board4all.biz account Filewarez.tv account Makingoff.org/forum account Xrel.to account Undergunz.su account Corebay account Endoftheinter.net ( EOTI ) account Thismight.be invite Skull.facefromouter.space account Avxhm.se (AvaxHome) account Ssdforum account Notfake.vip account Intotheinter.net account Tildes.net invite Thetoonz account Usinavirtual account Hdclasico invite HispaShare account Valentine.wtf account Adit-hd account Forum-andr.net account Warezforums account Justanothermusic.site account Forbiddenlibrary.moe account Senturion.to account Movieparadise account Militaryzone account Dcdnet.ru account Sftdevils.net account Heavy-r.com account New-team.org account Ddl.tv account Filewarez.club account Hispamula.org account Hubwarez.tv account   NZB :   Ninjacentral.co.za account Tabula-rasa.pw account Drunkenslug account Drunkenslug invite Usenet-4all account Brothers-of-Usenet account Dognzb.cr invite Kleverig account Nzb.cat account Nzbplanet.net invite Ng4you.com account Nzbsa.co.za account Bd25.eu account NZB.to account Samuraiplace account Abhdtv.net account Abook.link account Comix.pw account House-of-usenet Secretbinaries.net account Vnext.to account Stockboxx.top account Sky-of-use.net account   Prices start from 3 $ to 100 $   Payment methods: Crypto, Neteller, Webmoney, Revolut   If you want to buy something send me a pm or contact me on:   Email: morrison2102@gmail.com   Discord: LFC4LIFE#4173   Telegram: https://t.me/LFC4LIFE4173   Skype: morrison2102@hotmail.com
    • these are all my interfaces)
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..

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