Jump to content

Recommended Posts

Posted

As l2topzone.com updated it's source and hopzone's vote reward does not work for topzone too here is a vote reward,

 

 package net.sf.l2j.gameserver.model;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.InetAddress;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.util.Collection;

import javolution.util.FastList;

import net.sf.l2j.Config;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.GmListTable;
import net.sf.l2j.gameserver.ThreadPoolManager;
import net.sf.l2j.gameserver.model.L2ItemInstance;
import net.sf.l2j.gameserver.model.L2World;
import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage;
import net.sf.l2j.gameserver.serverpackets.ExShowScreenMessage.SMPOS;


public class TopzoneVoteRewardHandler
{
private int	lastVoteCount = 0;
private int	initialCheck = 60 * 1000;														
private int	delayForCheck = 300 * 1000;														
private int	votesForReward = 5;
private int	maxRewardStack = 500;

@SuppressWarnings("synthetic-access")
private TopzoneVoteRewardHandler()
{
	System.out.println("Topzone Vote Reward System activated.");
	ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
}

private class AutoReward implements Runnable
{
	public void run()
	{
		System.out.println("Topzone Vote Count Check.");
		if (Config.TOPZONE_VOTE_REWARD1_ID == 0 || Config.TOPZONE_VOTE_REWARD1_COUNT == 0)
		{
			GmListTable.broadcastMessageToGMs("The rewards aren't Identified. Please take a look.");
			return;
		}
		int newVoteCount = getVotes(Config.TOPZONE_VOTE_HTML_PATCH);
		System.out.println("newVoteCount:"+newVoteCount);
		System.out.println("getLastVoteCount:"+getLastVoteCount());
		if (newVoteCount != 0 && getLastVoteCount() != 0 && newVoteCount >= getLastVoteCount() + votesForReward)
		{
			FastList<InetAddress> ip = new FastList<InetAddress>();
			Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();
			for (L2PcInstance player : pls)
			{
				if (player != null)
				{
					L2ItemInstance item1 = player.getInventory().getItemByItemId(Config.TOPZONE_VOTE_REWARD1_ID);
					if (item1 == null || item1.getCount() < maxRewardStack)
					{
						InetAddress ipc = player.getClient().getConnection().getSocketChannel().socket().getInetAddress();

						if(ip.contains(ipc))
							continue;

						ip.add(ipc);
						player.addItem("reward", Config.TOPZONE_VOTE_REWARD1_ID, Config.TOPZONE_VOTE_REWARD1_COUNT, player, true);
						player.sendMessage("Keep Voting For Us.Rewards given.");
					}
				}
			}	
			setLastVoteCount(getLastVoteCount()+ votesForReward);
		}

		Announcements.getInstance().announceToAll("L2Godrich TopZone : " + newVoteCount + " Votes.");
		Announcements.getInstance().announceToAll("Next reward will be on : " + (getLastVoteCount()+ votesForReward) + " Votes.");
		Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers();

		if (getLastVoteCount() == 0)
		{
			setLastVoteCount(newVoteCount);
		}
	}
}

static int getVotes(String urlString)
{
	String htmlText = "";
	boolean startAdd = false;
	int voteCount = 0;
	boolean ok = false;
	try
	{
		URL pageToDisplay;
		pageToDisplay = new URL(urlString);
		URLConnection conn = pageToDisplay.openConnection();
		conn.connect();				
		InputStream in = conn.getInputStream();
		BufferedReader br = new BufferedReader(new InputStreamReader(in));
		htmlText = "";
		while(!ok)
		{
			String newLine = br.readLine();
			if (newLine == null)
			{
				ok = true;
			}
			else 
			{
				if (htmlText.length() < 110000)
				{
					if (!startAdd && newLine.indexOf(">Votes<") > 0) 
						startAdd = true;
					if (startAdd && newLine.indexOf(">Uptime<") > 0) 
						startAdd = false;
					if (startAdd) 
						htmlText = htmlText+newLine;
					if (htmlText.length() > 10 && !startAdd) 
						ok = true;					     
				}
			}
		}
		br.close();
	}
	catch (MalformedURLException mfe)
	{
	} 
	catch (IOException e)
	{ 
	}
	htmlText = htmlText.substring(htmlText.indexOf("font-size")+ 31);
	htmlText = htmlText.substring(0,htmlText.indexOf("</font>"));
	try
	{
		voteCount = Integer.parseInt(htmlText);
	}
	catch (NumberFormatException a)
	{
		voteCount = 0;
	}
        return voteCount;
}

private void setLastVoteCount(int voteCount)
{
	lastVoteCount = voteCount;
}

private int getLastVoteCount()
{
	return lastVoteCount;
}

public static TopzoneVoteRewardHandler getInstance()
{
	return SingletonHolder._instance;
}

@SuppressWarnings("synthetic-access")
private static class SingletonHolder
{
	protected static final TopzoneVoteRewardHandler _instance = new TopzoneVoteRewardHandler();
}
}

 

Config.java

public static boolean TOPZONE_VOTE_ENABLE;
public static String TOPZONE_VOTE_HTML_PATCH;
public static int TOPZONE_VOTE_REWARD1_ID;
public static int TOPZONE_VOTE_REWARD2_ID;
public static int TOPZONE_VOTE_REWARD1_COUNT;
public static int TOPZONE_VOTE_REWARD2_COUNT;




TOPZONE_VOTE_ENABLE = Boolean.parseBoolean(Customs.getProperty("TopzoneVoteEnable", "False"));
    			PROTECTED_GAMESERVER = Boolean.parseBoolean(Customs.getProperty("ProtectGameServerWithPassword", "False"));
                TOPZONE_VOTE_HTML_PATCH = Customs.getProperty("TopzoneVoteHtmlPatch", "Null");
			TOPZONE_VOTE_REWARD1_COUNT = Integer.parseInt(Customs.getProperty("TopzoneVoteReward1Count", "1000"));
			TOPZONE_VOTE_REWARD2_COUNT = Integer.parseInt(Customs.getProperty("TopzoneVoteReward2Count", "1000"));
			TOPZONE_VOTE_REWARD1_ID = Integer.parseInt(Customs.getProperty("TopzoneVoteReward1Id", "57"));
			TOPZONE_VOTE_REWARD2_ID = Integer.parseInt(Customs.getProperty("TopzoneVoteReward2Id", "57"));
    			

Do not forget to register this on gameserver.

 

Credits: me

 

PS: it's tested.

  • 2 months later...
  • 2 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



  • Posts

    • Sell ready interlude server files, with all popular features and tested, stable source + fully functional premium geodata for free.   Features include: Events: DM CTF TVT LM Dressme system Custom Buffer GM Shop Custom community board Donation manager  Auto Farm   Album: sell c6 — ImgBB   Test Server online: Patch link: https://drive.google.com/file/d/1mvEbv9XESsvfWwc638xFyyzyESeE2U95/view?usp=drive_link Auto acc create and auto admin   Price: 300$. Discord: l2retro
    • Faltan demasiados archivos,  y lógicas en clases claves como L2pcInstance, entre otras. si bien muchas cosas están y el flujo es valorable.  Gracias por tu esfuerzo es bastante... pero realmente no esta completo el código, falta que subas todas las modificaciones en clases colaterales... podrías intentar subir un diff de todo el mod  completo de tu pack y bueno ahí si que cada uno adapte... pero faltan muchas cosas, dudo que haya gente que lo haya echo funcionar con esto... 
    • I know people who have fully bypassed and reversed AAC. One day, they might even release the full source code, but for now, they’re still making money off it. I won’t name anyone, but it’s clear that there aren’t any truly solid anticheats for Lineage2. As I’ve said before, kernel level anticheats are the only real solution. Anything that runs as Internal and injects gets flagged, and your account ends up getting kicked or banned. That’s just how most games handle it nowadays. To TL;DR the whole thing cheating will always exist because there are people out there smart enough to bypass any protection and run private cheats. Public cheats are always detected eventually, so I don’t see any point in buying AAC, especially when they claim it blocks adr, which simply isn’t true.
    • 🌐 Website: https://l2adonis.com 📅 GRAND OPENING: July 18, 2025 – 20:00 (UTC+2) 💬 Discord: https://discord.com/invite/tZBj8JxAwx 🚫 No auto-farm • No auto-macro • No pay-to-win • No custom   Some Basic Info's (More detalied info's on website)  EXP/SP: x25  Adena: x15  Drop: x15  Spoil: x15  Seal Stones: x15  Raid Boss Drop: x10  Epic Boss Drop: x1  Manor: x10  Safe Enchant: +4  Max Enchant: +16  Normal Scroll Chance: 50%  Blessed Scroll Chance: 66% (If enchant fail item remain +4)  Buff Slots (30+4 extra with Divine Inspiration)  Dances/Songs Slots 14  Auto-learn skills  ⚔️ Real PvP • Real Progression • Retail-like experience JOIN NOW and relive the real L2 experience!
    • Discord         :  utchiha_market Telegram        : https://t.me/utchiha_market Auto Buy Store  : https://utchihamkt.mysellauth.com/ Not sure if we’re legit? Check Our server — real reviews, real buyers https://discord.gg/uthciha-servicess  | https://campsite.bio/utchihaamkt
  • 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