Jump to content

Recommended Posts

Posted

Have anyone else problem with the votes from Hopzone?

I don't know why but my votereward system don't take the votes anymore..

 

 

Anyone knows something?

 

Thanks in advance!

Posted

show me the code then i will be able to help you.

I mean, it was working before, but now not.

Not only for me, a friend has the same.

I wanted to know if someone else who have a server, if they can get the Hopzone votes or not?

 

 
package net.sf.l2j.gameserver.model.entity;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;

import javolution.util.FastMap;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
/**
* @author Anarchy
*
*/
public class HopzoneVoteReward
{
// Configurations.
private static String hopzoneUrl = Config.HOPZONE_SERVER_LINK;
private static String page1Url = Config.HOPZONE_FIRST_PAGE_LINK;
private static int voteRewardVotesDifference = Config.HOPZONE_VOTES_DIFFERENCE;
private static int firstPageRankNeeded = Config.HOPZONE_FIRST_PAGE_RANK_NEEDED;
private static int checkTime = 60*1000*Config.HOPZONE_REWARD_CHECK_TIME;

// Don't-touch variables.
private static int lastVotes = 0;
private static FastMap<String, Integer> playerIps = new FastMap<String, Integer>();

public static void updateConfigurations()
{
	hopzoneUrl = Config.HOPZONE_SERVER_LINK;
	page1Url = Config.HOPZONE_FIRST_PAGE_LINK;
	voteRewardVotesDifference = Config.HOPZONE_VOTES_DIFFERENCE;
	firstPageRankNeeded = Config.HOPZONE_FIRST_PAGE_RANK_NEEDED;
	checkTime = 60*1000*Config.HOPZONE_REWARD_CHECK_TIME;
}

public static void getInstance()
{
	System.out.println("[Hopzone Vote Reward] Initialized D:");
	ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
	{
		@Override
		public void run()
		{
			if (Config.ALLOW_HOPZONE_VOTE_REWARD)
			{
				reward();
			}
			else
			{
				return;
			}
		}
	}, checkTime/2, checkTime);
}

private static void reward()
{
	int firstPageVotes = getFirstPageRankVotes();
	int currentVotes = getVotes();

	if (firstPageVotes == -1 || currentVotes == -1)
	{
		if (firstPageVotes == -1)
		{
			System.out.println("There was a problem on getting votes from server with rank "+firstPageRankNeeded+".");
		}
		if (currentVotes == -1)
		{
			System.out.println("There was a problem on getting server votes.");
		}

		return;
	}

	if (lastVotes == 0)
	{
		lastVotes = currentVotes;
		Announcements.getInstance().announceHopzone("Current vote count: "+currentVotes+" | Next reward: "+((currentVotes+voteRewardVotesDifference)));
		if (Config.ALLOW_HOPZONE_GAME_SERVER_REPORT)
		{
			System.out.println("Server votes on hopzone: "+currentVotes);
			System.out.println("Votes needed for reward: "+((lastVotes+voteRewardVotesDifference)));
		}
		if (firstPageVotes-lastVotes <= 0)
		{
			Announcements.getInstance().announceHopzone("Because we are on the front page, players will have a larger reward than usual! Keep it up!");
			if (Config.ALLOW_HOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server is on the first page of hopzone.");
			}
		}
		else
		{
			Announcements.getInstance().announceHopzone("We need "+((lastVotes+voteRewardVotesDifference))+" vote(s) for a large reward!");
			if (Config.ALLOW_HOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
			}
		}
		return;
	}

	if (currentVotes >= lastVotes+voteRewardVotesDifference)
	{
		Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
		if (firstPageVotes-currentVotes <= 0)
		{
			if (Config.ALLOW_HOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes on hopzone: "+currentVotes);
				System.out.println("Server is on the first page of hopzone.");
				System.out.println("Votes needed for next reward: "+((currentVotes+voteRewardVotesDifference)));
			}
			Announcements.getInstance().announceHopzone("Because we are on the front page, players will have a larger reward than usual! Keep it up!");
			Announcements.getInstance().announceHopzone("Current vote count: "+currentVotes+" | Next reward: "+((currentVotes+voteRewardVotesDifference)));

			for (L2PcInstance p : pls)
			{
				boolean canReward = false;
				String pIp = p.getClient().getConnection().getInetAddress().getHostAddress();
				if (playerIps.containsKey(pIp))
				{
					int count = playerIps.get(pIp);
					if (count < Config.HOPZONE_DUALBOXES_ALLOWED)
					{
						playerIps.remove(pIp);
						playerIps.put(pIp, count+1);
						canReward = true;
					}
				}
				else
				{
					canReward = true;
					playerIps.put(pIp, 1);
				}
				if (canReward)
				{
					for (int i : Config.HOPZONE_BIG_REWARD.keySet())
					{
						p.addItem("Vote reward.", i, Config.HOPZONE_BIG_REWARD.get(i), p, true);
					}
				}
				else
				{
					p.sendMessage(""+Config.HOPZONE_DUALBOXES_ALLOWED+" character(s) of your IP have already been rewarded, so this character won't be rewarded.");
				}
			}
			playerIps.clear();
		}
		else
		{
			if (Config.ALLOW_HOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes on Hopzone: "+currentVotes);
				System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
				System.out.println("Votes needed for next reward: "+((currentVotes+voteRewardVotesDifference)));
			}
			Announcements.getInstance().announceHopzone("All online players have been rewarded. Keep it up! (larger reward if server is on front page)");
			Announcements.getInstance().announceHopzone("Current vote count: "+currentVotes+" | Next reward: "+((currentVotes+voteRewardVotesDifference)));
			for (L2PcInstance p : pls)
			{
				boolean canReward = false;
				String pIp = p.getClient().getConnection().getInetAddress().getHostAddress();
				if (playerIps.containsKey(pIp))
				{
					int count = playerIps.get(pIp);
					if (count < Config.HOPZONE_DUALBOXES_ALLOWED)
					{
						playerIps.remove(pIp);
						playerIps.put(pIp, count+1);
						canReward = true;
					}
				}
				else
				{
					canReward = true;
					playerIps.put(pIp, 1);
				}
				if (canReward)
				{
					for (int i : Config.HOPZONE_SMALL_REWARD.keySet())
					{
						p.addItem("Vote reward.", i, Config.HOPZONE_SMALL_REWARD.get(i), p, true);
					}
				}
				else
				{
					p.sendMessage(""+Config.HOPZONE_DUALBOXES_ALLOWED+" characters of your IP have already been rewarded, so this character won't be rewarded.");
				}
			}
			playerIps.clear();
		}

		lastVotes = currentVotes;
	}
	else
	{
		if (firstPageVotes-currentVotes <= 0)
		{
			if (Config.ALLOW_HOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes on hopzone: "+currentVotes);
				System.out.println("Server is on the first page of hopzone.");
				System.out.println("Votes needed for next reward: "+((lastVotes+voteRewardVotesDifference)));
			}
			Announcements.getInstance().announceHopzone("Current vote count: "+currentVotes+" | Next reward: "+((currentVotes+voteRewardVotesDifference)));
			Announcements.getInstance().announceHopzone("We need "+((lastVotes+voteRewardVotesDifference))+" vote(s) for a large reward!");
		}
		else
		{
			if (Config.ALLOW_HOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes on hopzone: "+currentVotes);
				System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
				System.out.println("Votes needed for next reward: "+((lastVotes+voteRewardVotesDifference)));
			}
			Announcements.getInstance().announceHopzone("Current vote count: "+currentVotes+" | Next reward: "+((currentVotes+voteRewardVotesDifference)));
			Announcements.getInstance().announceHopzone("We need "+((lastVotes+voteRewardVotesDifference))+" vote(s) for a large reward!");

		}
	}
}

private static int getFirstPageRankVotes()
{
	InputStreamReader isr = null;
	BufferedReader br = null;

	try
	{
		URLConnection con = new URL(page1Url).openConnection();
		con.addRequestProperty("User-Agent", "Mozilla/4.76");
		isr = new InputStreamReader(con.getInputStream());
		br = new BufferedReader(isr);

		String line;
		int i = 0;
		while ((line = br.readLine()) != null)
		{
			if (line.contains("<span class=\"no\">"+firstPageRankNeeded+"</span>"))
			{
				i++;
			}
			if (line.contains("Anonymous Votes") && i == 1)
			{
				i = 0;
				int votes = Integer.valueOf(line.split(">")[1].replace("</span", ""));
				return votes;
			}
		}

		br.close();
		isr.close();
	}
	catch (Exception e)
	{
		System.out.println(e);
		System.out.println("Error while getting server vote count.");
	}

	return -1;
}

private static int getVotes()
{
	InputStreamReader isr = null;
	BufferedReader br = null;

	try
	{
		URLConnection con = new URL(hopzoneUrl).openConnection();
		con.addRequestProperty("User-Agent", "Mozilla/4.76");
		isr = new InputStreamReader(con.getInputStream());
		br = new BufferedReader(isr);

		String line;
		while ((line = br.readLine()) != null)
		{
			if (line.contains("Anonymous User Votes"))
			{
				int votes = Integer.valueOf(line.split(">")[2].replace("</span", ""));
				return votes;
			}
		}

		br.close();
		isr.close();
	}
	catch (Exception e)
	{
		System.out.println(e);
		System.out.println("Error while getting server vote count.");
	}

	return -1;
}
}

Create an account or sign in to comment

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

Create an account

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

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Posts

    • Download Here: https://sitehunterus.blogspot.com/2025/12/exelo-combo-tool-v2.html VirusTotal https://www.virustotal.com/gui/file/2acd067847ee092c7986f55c9f77620d89505d1c0bda34a0ee8f55b9c2905c11?nocache=1 Visit my Blogger list to download 100% free software https://www.freetoolss.com/ https://blackhat8.blogspot.com/ https://hack-crack9.blogspot.com/ https://hackernoons.blogspot.com/ https://sharetools99.blogspot.com/
    • Care to detail why ?   L2JHellas probably got the same issue, it's inherent to L2J if you don't rework Player intentions (and solving it with a Config < 500 attack is stupid, if it works for attack it works for other types of desires), also last time I checked L2JHellas he was using my changesets to fix its own stuff (which is ok, copy-paste my knownlist system which is 10y old is fine, but don't say it will act different since it's literally the same sub-system).   About Lucera code source isn't available so it's easy to say it's better, internally you got no clue what is happening and RU forks got the "feeling" to get everything, but everything is half done, everytime I put an eye on such sources (whatever based on l2ru, they only know how to copy-paste each other).   In the other hand, you seem to use aCis since years (I think I see your name since a decade, and you still use it since you made this topic :   Be a little more appreciative about the work done, it's not only mine but my community aswell, and if you find something, consider to report rather than getting such an idiotic behavior.   I understand you're not forced to share any type of fixes, and than people tend to feel superior when they fix something than aCis didn't yet fix. The thing is, for each bug you found, I found and fixed 10x more than you.   409 is way beyond 382 in all possible ways, if you believe the versus good for you, but don't make ppl believe it's the case, because it's not. There's at least 400+ fixed issues (and that's counting 10 issues by revision, which is kinda low) and entire new systems (spawns, SCHs, pathfind, whole AI implemented, Desire system,...).
    • better than using 409... Search for L2jHellas or Lucera and you won't have any headaches.
  • 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