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

    • MoMoProxy has updated more static residential proxies for USA location, anyone interested in can view: https://momoproxy.com/static-residential-proxies
    • This post originally appeared on MmoGah.   Dear Exiles, here's a detailed guide for Path of Exile 3.26 Gauntlet, tailored for beginners and focused on the top 5 builds that balance survivability, damage, and ease of gearing in the Hardcore Solo Self-Found (HCSSF) environment. This guide goes deep into mechanics, gear, leveling, and strategy—no fluff, just actionable insights.       What Is the Gauntlet in PoE 3.26? The Gauntlet is a community-run event, often organized by Zizaran, which pushes players into a brutal version of the game:   ● Hardcore Solo Self-Found (HCSSF): No trading, no partying, no outside help. ● Global Modifiers: Increased monster damage, life, elemental penetration, extra projectiles, and more. ● Limited Portals: Only 3 portals per boss kill count toward points. ● Custom Ascendancies: In 3.26, the Fishia League introduces new ascendancy classes like Ancestral Commander and Servant of Arakali.   The goal? Survive, level up, kill bosses, and earn points for prizes. But first, you need a build that won't crumble under pressure.   Top 5 Builds for Gauntlet Beginners These builds are chosen for their tankiness, simplicity, and ability to progress through the campaign and early maps with minimal gear.   1. Raise Zombie Puppeteer (Necromancer) Why It Works: Minions absorb damage, keeping you safe. Scales well with minimal gear. Strong bossing potential with high zombie levels.   Core Mechanics: Uses Raise Zombie as the main damage source. Strength stacking boosts zombie power. Animate Guardian adds utility and buffs.   Defensive Layers: Minions tank hits. Block chance from gear and passive tree. Energy shield and life stacking.   Leveling Tips: Use Summon Skeletons and Raise Zombie early. Prioritize +minion gem levels and strength gear. Transition to spectres and Animate Guardian by Act 5.   Pros: Safe, ranged playstyle. Easy to gear in SSF. Strong boss damage.   Cons: Minion AI can be clunky. Damage may taper off in the late game without investment.   2. Power Siphon Mines (Scavenger Saboteur) Why It Works: Ranged mine playstyle avoids direct damage. One-button mechanics for comfort. Fast leveling and strong suppression.   Core Mechanics: Power Siphon linked to mines for remote detonation. Uses High-Impact Mine Support and Minefield Support. Cloak of Flames for early damage scaling.   Defensive Layers: High evasion and suppression. Life stacking and stun immunity. Arctic Armor and Flesh and Stone for mitigation.   Leveling Tips: Start with Stormblast Mine or Explosive Trap. Switch to Power Siphon at level 28. Use Smoke Mine and Flame Dash for mobility.   Pros: Safe ranged playstyle. Low gear dependency. Comfortable mechanics.   Cons: Mines require setup. It can feel clunky without proper gem links.   3. Ice Nova Archmage (Hierophant) Why It Works: Combines Mind Over Matter (MoM) with mana stacking. Strong AoE and single-target damage. Good defenses and smooth leveling.   Core Mechanics: Ice Nova cast on Frostbolt for double damage. Archmage Support scales damage with mana. Hierophant ascendancy boosts mana and endurance charges.   Defensive Layers: MoM absorbs damage via mana. High armor and resistances. Chill and freeze for crowd control.   Leveling Tips: Start with Holy Flame Totem or Rolling Magma. Switch to Ice Nova after Act 3. Stack mana and use Clarity early.   Pros: Strong defenses and damage. Scales well into the endgame. Beginner-friendly caster setup.   Cons: Requires mana management. Squishy if not geared properly.   4. Explosive Arrow Ballista (Ancestral Commander) Why It Works: Totems do the work while you stay safe. Easy to gear and scale. Great for campaign progression.   Core Mechanics: Explosive Arrow linked to Ballista Totem Support. Totems stack arrows for massive explosions. Ancestral Commander ascendancy grants endurance charges and slam synergy.   Defensive Layers: Totems absorb aggro. High life and resistances. Fortify from gear or ascendancy.   Leveling Tips: Use Caustic Arrow or Split Arrow early. Switch to Explosive Arrow at level 28. Prioritize attack speed and totem placement.   Pros: Safe, passive playstyle. Strong single-target damage. Easy to respec and adapt.   Cons: Totem AI can be slow. Requires positioning for optimal damage.   5. Lightning Strike Daughter of Oshabi Why It Works: High energy shield and shrine buffs. Converts physical damage to chaos. Fast, clear, and strong bossing.   Core Mechanics: Lightning Strike with pure energy shield gear. Oath of the Magi node doubles armor defenses. Ghost Dance for ES sustain.   Defensive Layers: 10,000+ energy shield. Suppression and resist caps. Stun immunity and chaos conversion.   Leveling Tips: Use Smite or Molten Strike early. Transition to Lightning Strike with ES gear. Stack shrine buffs and movement speed.   Pros: Tanky and fast. Handles tier 17 maps. Good for face-tanking bosses.   Cons: Requires ES gear early. Shrine RNG can affect consistency.   Beginner Tips for Gauntlet Success Campaign Strategy: Overlevel before boss fights. Cap resistances ASAP. Use movement skills to dodge mechanics. Practice Acts 1, 4, and 9—they're deadly.   Gear Prioritization: Life and resistances > damage. Movement speed on boots. Vendor recipes for gear upgrades.   Flask Setup: 1 Instant Life Flask 1 Granite Flask 1 Jade Flask 1 Quicksilver Flask 1 Utility Flask (e.g., Sulphur or Basalt)   Passive Tree Tips: Prioritize life nodes early. Take suppression and block nodes. Avoid complex mechanics—simplicity wins.   Mapping and Bossing Strategy Mapping: Use fast-clearing skills. Avoid risky map mods. Keep portals in reserve.   Bossing: Learn boss mechanics. Use Sniper's Mark or Assassin's Mark. Position mercenaries or totems strategically.   Final Thoughts The Gauntlet is unforgiving, but with the right build and mindset, you can push deep into the event—even as a beginner. Focus on survivability, learn from each death, and don't be afraid to restart. Every run teaches you something new.
    • SocNet x Dolphin Anty Partnership — Reaching New Heights Together! We’re excited to announce our new partnership with the anti-detect browser Dolphin Anty! Thank you for your trust and support — it's because of you that we continue to grow, expand, and bring even more value and opportunities to our customers. This partnership with Dolphin Anty offers more convenience, security, and flexibility for your work and automation needs. Read more on Dolphin Anty’s official blog: https://dolphin-anty.com/blog/en/socnet-and-dolphin-anty/ We’re also looking for new suppliers! — Snapchat accounts — Reddit accounts with karma — LinkedIn accounts with connections Contact us via DM or support to discuss terms — we’re always open to partnership proposals! Explore our online store: ➡ Accounts: Telegram, Facebook, Reddit, Twitter (X), Instagram, YouTube, TikTok, Discord, VK, LinkedIn, GitHub, Snapchat, Gmail, and emails (Outlook, Firstmail, Rambler, Onet, Gazeta, GMX, Yahoo, Proton, Web.de), Google Voice, Google Ads ➡ Premium Subscriptions: Telegram Premium, Twitter X Premium, YouTube Premium, Spotify Premium, Netflix Premium, Discord Nitro, ChatGPT Plus/PRO, XBOX Game Pass ➡ Additional Services: Telegram Stars, proxies (IPv4, IPv6, ISP, Mobile), VPNs (Outline, WireGuard, others), VDS/RDP servers To celebrate the partnership, use promo code DOLPHIN15 for 15% off in our online store! SMM Panel Services: ➡ Use our SMM Panel to boost: Facebook, Instagram, Telegram, Spotify, SoundCloud, YouTube, Reddit, Threads, Kick, Discord, LinkedIn, Likee, VK, Twitch, Kwai, website traffic, TikTok, TrustPilot, Apple Music, TripAdvisor, Snapchat, and more. Get $1 Trial Credit for your first SMM Panel launch: Just submit a support ticket titled "Get Trial Bonus" on our website. ➡ Go to the SMM Panel (clickable) or contact support via bot. Our Key Products: ➡ Online Store: Click ➡ Telegram Store Bot: Click ➡ SMM Panel: Click Payment methods: bank cards · crypto · other popular methods Returning customers get extra discounts & promo codes! Support Contacts: ➡ Telegram: https://t.me/solomon_bog ➡ Discord: https://discord.gg/y9AStFFsrh ➡ WhatsApp: https://wa.me/79051904467 ➡ ✉ Email: solomonbog@socnet.store ➡ Telegram Channel: https://t.me/accsforyou_shop You can also use these contacts to: — consult about bulk purchases — propose partnerships (our partners: https://socnet.bgng.io/partners ) — become a supplier SocNet — Digital Goods & Premium Subscriptions 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