Jump to content
  • 0

Vote Reward Problem Fix dont work!


Question

Posted

Γεια σας παιδια εχω θεμα με το "VOTE REWARD" απο topzone. Δοκιμασα τα φιξ που προτινουν καποιοι αλλα το δικο μου δεν εχει καν αυτες τις γραμμες του κωδικα εχω αυτο εδω....

======================================
confings
===================================

# Vote reward for Topzone.
AllowTopzoneVoteReward = True
# Vote reward server link.
TopzoneServerLink = http://l2topzone.com/lineage2/server-info/6296/L2ToxiccomProMMORPG.html/
# First page of servers list link.
TopzoneFirstPageLink = http://l2topzone.com/lineage2/server-list/top.html/
# Votes for next reward needed.
TopzoneVotesDifference = 5
# Rank needed for server to be on first page.
TopzoneFirstPageRankNeeded = 15
# Minutes between rewards.
# Eg. You put 5 it checks every 5 minutes for reward.
TopzoneRewardCheckTime = 5
# Small reward(s).
TopzoneSmallReward = 57,100000000;
# Big reward(s).
TopzoneBigReward = 3470,1;
# Hopzone reward max dual boxes reward.
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
TopzoneDuaboxesAllowed = 1
# Game server console report.
# If set to true, game server console will get a report of
# current vote count, votes needed for next reward and votes needed for first page.
AllowTopzoneGameServerReport = True

================================================
Config.java
=================================================
    
    public static boolean ALLOW_TOPZONE_VOTE_REWARD;
    public static String TOPZONE_SERVER_LINK;
    public static String TOPZONE_FIRST_PAGE_LINK;
    public static int TOPZONE_VOTES_DIFFERENCE;
    public static int TOPZONE_FIRST_PAGE_RANK_NEEDED;
    public static int TOPZONE_REWARD_CHECK_TIME;
public static Map<Integer, Integer> TOPZONE_SMALL_REWARD = new FastMap<Integer, Integer>();
public static Map<Integer, Integer> TOPZONE_BIG_REWARD = new FastMap<Integer, Integer>();
public static int TOPZONE_DUALBOXES_ALLOWED;
    public static boolean ALLOW_TOPZONE_GAME_SERVER_REPORT;






                ALLOW_TOPZONE_VOTE_REWARD = Boolean.parseBoolean(elcardia.getProperty("AllowTopzoneVoteReward", "false"));
                TOPZONE_SERVER_LINK = elcardia.getProperty("TopzoneServerLink", "http://l2.topzone.net/lineage2/details/74078/L2World-Servers/");
                TOPZONE_FIRST_PAGE_LINK = elcardia.getProperty("TopzoneFirstPageLink", "http://l2.topzone.net/lineage2/");
                TOPZONE_VOTES_DIFFERENCE = Integer.parseInt(elcardia.getProperty("TopzoneVotesDifference", "5"));
               	TOPZONE_FIRST_PAGE_RANK_NEEDED = Integer.parseInt(elcardia.getProperty("TopzoneFirstPageRankNeeded", "15"));
               	TOPZONE_REWARD_CHECK_TIME = Integer.parseInt(elcardia.getProperty("TopzoneRewardCheckTime", "5"));
                String TOPZONE_SMALL_REWARD_VALUE = elcardia.getProperty("TopzoneSmallReward", "57,100000000;");
                String[] topzone_small_reward_splitted_1 = TOPZONE_SMALL_REWARD_VALUE.split(";");
                for (String i : topzone_small_reward_splitted_1)
                {
                	String[] topzone_small_reward_splitted_2 = i.split(",");
                	TOPZONE_SMALL_REWARD.put(Integer.parseInt(topzone_small_reward_splitted_2[0]), Integer.parseInt(topzone_small_reward_splitted_2[1]));
                }
                String TOPZONE_BIG_REWARD_VALUE = elcardia.getProperty("TopzoneBigReward", "3470,1;");
                String[] topzone_big_reward_splitted_1 = TOPZONE_BIG_REWARD_VALUE.split(";");
                for (String i : topzone_big_reward_splitted_1)
                {
                	String[] topzone_big_reward_splitted_2 = i.split(",");
                	TOPZONE_BIG_REWARD.put(Integer.parseInt(topzone_big_reward_splitted_2[0]), Integer.parseInt(topzone_big_reward_splitted_2[1]));
                }
                TOPZONE_DUALBOXES_ALLOWED = Integer.parseInt(elcardia.getProperty("TopzoneDualboxesAllowed", "1"));
                ALLOW_TOPZONE_GAME_SERVER_REPORT = Boolean.parseBoolean(elcardia.getProperty("AllowTopzoneGameServerReport", "false"));






===================================================
GameServer.java
===================================================

	if (Config.ALLOW_TOPZONE_VOTE_REWARD)
	{
		VoteRewardTopzone.getInstance();
	}




==================================================================
VoteRewardTopzone.java
==================================================================
/*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation, either version 3 of the License, or (at your option) any later
* version.
* 
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
* 
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
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 VoteRewardTopzone
{
// Configurations.
private static String topzoneUrl = Config.TOPZONE_SERVER_LINK;
private static String page1Url = Config.TOPZONE_FIRST_PAGE_LINK;
private static int voteRewardVotesDifference = Config.TOPZONE_VOTES_DIFFERENCE;
private static int firstPageRankNeeded = Config.TOPZONE_FIRST_PAGE_RANK_NEEDED;
private static int checkTime = 60*1000*Config.TOPZONE_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()
{
	topzoneUrl = Config.TOPZONE_SERVER_LINK;
	page1Url = Config.TOPZONE_FIRST_PAGE_LINK;
	voteRewardVotesDifference = Config.TOPZONE_VOTES_DIFFERENCE;
	firstPageRankNeeded = Config.TOPZONE_FIRST_PAGE_RANK_NEEDED;
	checkTime = 60*1000*Config.TOPZONE_REWARD_CHECK_TIME;
}

public static void getInstance()
{
	System.out.println("Vote reward system initialized.");
	ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
	{
		@Override
		public void run()
		{
			if (Config.ALLOW_TOPZONE_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().announceToAll("Vote reward: Current vote count is "+currentVotes+".");
		Announcements.getInstance().announceToAll("Vote reward: We need "+((lastVotes+voteRewardVotesDifference)-currentVotes)+" vote(s) for reward.");
		if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
		{
			System.out.println("Server votes on topzone: "+currentVotes);
			System.out.println("Votes needed for reward: "+((lastVotes+voteRewardVotesDifference)-currentVotes));
		}
		if (firstPageVotes-lastVotes <= 0)
		{
			Announcements.getInstance().announceToAll("Vote reward: We are in the first page of topzone, so the reward will be big.");
			if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server is on the first page of topzone.");
			}
		}
		else
		{
			Announcements.getInstance().announceToAll("Vote reward: We need "+(firstPageVotes-lastVotes)+" vote(s) to get to the first page of topzone for big reward.");
			if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
			}
		}
		Announcements.getInstance().announceToAll("Vote reward: Type .menu to see what the big and what the small reward is.");
		return;
	}

	if (currentVotes >= lastVotes+voteRewardVotesDifference)
	{
		Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
		if (firstPageVotes-currentVotes <= 0)
		{
			if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes on topzone: "+currentVotes);
				System.out.println("Server is on the first page of topzone.");
				System.out.println("Votes needed for next reward: "+((currentVotes+voteRewardVotesDifference)-currentVotes));
			}
			Announcements.getInstance().announceToAll("Vote reward: Everyone has been rewarded with big reward.");
			Announcements.getInstance().announceToAll("Vote reward: Current vote count is "+currentVotes+".");
			Announcements.getInstance().announceToAll("Vote reward: Type .menu to see what the big and what the small reward is.");
			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.TOPZONE_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.TOPZONE_BIG_REWARD.keySet())
					{
						p.addItem("Vote reward.", i, Config.TOPZONE_BIG_REWARD.get(i), p, true);
					}
				}
				else
				{
					p.sendMessage("Already "+Config.TOPZONE_DUALBOXES_ALLOWED+" character(s) of your ip have been rewarded, so this character won't be rewarded.");
				}
			}
			playerIps.clear();
		}
		else
		{
			if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes on topzone: "+currentVotes);
				System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
				System.out.println("Votes needed for next reward: "+((currentVotes+voteRewardVotesDifference)-currentVotes));
			}
			Announcements.getInstance().announceToAll("Vote reward: Everyone has been rewarded with small reward.");
			Announcements.getInstance().announceToAll("Vote reward: Current vote count is "+currentVotes+".");
			Announcements.getInstance().announceToAll("Vote reward: We need "+(firstPageVotes-currentVotes)+" vote(s) to get to the first page of topzone for big reward.");
			Announcements.getInstance().announceToAll("Vote reward: Type .menu to see what the big and what the small reward is.");
			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.TOPZONE_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.TOPZONE_SMALL_REWARD.keySet())
					{
						p.addItem("Vote reward.", i, Config.TOPZONE_SMALL_REWARD.get(i), p, true);
					}
				}
				else
				{
					p.sendMessage("Already "+Config.TOPZONE_DUALBOXES_ALLOWED+" character(s) of your ip have been rewarded, so this character won't be rewarded.");
				}
			}
			playerIps.clear();
		}

		lastVotes = currentVotes;
	}
	else
	{
		if (firstPageVotes-currentVotes <= 0)
		{
			if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes on topzone: "+currentVotes);
				System.out.println("Server is on the first page of topzone.");
				System.out.println("Votes needed for next reward: "+((lastVotes+voteRewardVotesDifference)-currentVotes));
			}
			Announcements.getInstance().announceToAll("Vote reward: Current vote count is "+currentVotes+".");
			Announcements.getInstance().announceToAll("Vote reward: We need "+((lastVotes+voteRewardVotesDifference)-currentVotes)+" vote(s) for big reward.");
			Announcements.getInstance().announceToAll("Vote reward: Type .menu to see what the big and what the small reward is.");
		}
		else
		{
			if (Config.ALLOW_TOPZONE_GAME_SERVER_REPORT)
			{
				System.out.println("Server votes on topzone: "+currentVotes);
				System.out.println("Server votes needed for first page: "+(firstPageVotes-lastVotes));
				System.out.println("Votes needed for next reward: "+((lastVotes+voteRewardVotesDifference)-currentVotes));
			}
			Announcements.getInstance().announceToAll("Vote reward: Current vote count is "+currentVotes+".");
			Announcements.getInstance().announceToAll("Vote reward: We need "+((lastVotes+voteRewardVotesDifference)-currentVotes)+" vote(s) for small reward.");
			Announcements.getInstance().announceToAll("Vote reward: We need "+(firstPageVotes-currentVotes)+" vote(s) to get to the first page of topzone for big reward.");
			Announcements.getInstance().announceToAll("Vote reward: Type .menu to see what the big and what the small reward is.");
		}
	}
}

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("<td><div align=\"center\">"+firstPageRankNeeded+"</div></td>"))
			{
				i++;
			}
			if (line.contains("<td><div align=\"center\">") && i == 1)
			{
				i++;
			}
			if (line.contains("<td><div align=\"center\">") && i == 2)
			{
				i = 0;
				int votes = Integer.valueOf(line.split(">")[2].replace("</div", ""));
				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(topzoneUrl).openConnection();
		con.addRequestProperty("User-Agent", "Mozilla/4.76");
		isr = new InputStreamReader(con.getInputStream());
		br = new BufferedReader(isr);

		boolean got = false;

		String line;
		while ((line = br.readLine()) != null)
		{
			if (line.contains("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\"") && !got)
			{
				got = true;
				int votes = Integer.valueOf(line.split("=\"font-size:14px;color:#018BC1;\">")[1].replace("</font></b></div></td></tr>", ""));
				return votes;
			}
		}

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

	return -1;
}
}

1 answer to this question

Recommended Posts

  • 0
Posted (edited)

Αυτο εδω :

private static int getVotes()
    {
        InputStreamReader isr = null;
        BufferedReader br = null;
        
        
try
        {
            URLConnection con = new URL(topzoneUrl).openConnection();
            con.addRequestProperty("User-Agent", "Mozilla/4.76");
            isr = new InputStreamReader(con.getInputStream());
            br = new BufferedReader(isr);
            
            
boolean got = false;
            
            
String line;
            while ((line = br.readLine()) != null)
            {
                if (line.contains("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\"") && !got)
                {
                    got = true;
                    int votes = Integer.valueOf(line.split("=\"font-size:14px;color:#018BC1;\">")[1].replace("</font></b></div></td></tr>", ""));
                    return votes;
                }
            }
            
            br
.close();
            isr.close();
        }

καντω ετσι:

private static int getVotes()

{
int votes = -1;
URL url = null;
URLConnection con = null;
InputStream is = null;
InputStreamReader isr = null;
BufferedReader in = null;
try
{
url = new URL(Config.TOPZONE_SERVER_LINK);
con = url.openConnection();    
con.addRequestProperty("User-Agent", "Mozilla/4.76");
is = con.getInputStream();
isr = new InputStreamReader(is);    
in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null)
{
if (inputLine.contains("Votes:"))
{
String votesLine = in.readLine() ;
 
votes = Integer.valueOf(votesLine.split(">")[5].replace("</font", ""));
break;
}
}
}
catch (Exception e)
{
Εδω αν θες βαλε ενα δικο σου σφαλμα πχ announce,log console οτι θες...
}
finally
{
if(in!=null)
try
{
in.close();
}
catch(IOException e1)
{
e1.printStackTrace();
}
if(isr!=null)
try
{
isr.close();
}
catch(IOException e1)
{
e1.printStackTrace();
}
if(is!=null)
try
{
is.close();
}
catch(IOException e1)
{
e1.printStackTrace();
}
}
return -1;
}
Edited by Kwstakis

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

    • Hello community, I’d like to share an improved version of the L2smr editor for StaticMeshes, focused on solving some workflow issues I found in the original tool. CreditsThis project is based on the original acmi/L2smr repository https://github.com/acmi/L2smr , created by acmi, and I updated it to Java 17 with some additional features. Issues in the original L2smr Too many windows: each StaticMesh opened in a new one → cluttered desktop. No search: navigating through hundreds of StaticMeshActors was slow and tedious. Added improvements Flexible views Single Window Mode: reuse one window instead of opening new ones. Multiple Window Mode: still available for those who prefer having several views open simultaneously. Real-time Search Field Instant filtering as you type. Case-insensitive search. “Reset” button to quickly clear the search.     Installation and Execution: Clone the repository: git clone https://github.com/Jeep12/l2smr.git cd l2smr        2.Build the project:   ./gradlew build        3. Run the application:     ./run.bat      Or simply double-click on run.bat.     The run.bat script automatically extracts JavaFX from the included javafx-17.0.2.zip file in the javafx/ directory, sets up the required libraries, and launches the application. You don’t    need to install JavaFX separately.      Repository: https://github.com/Jeep12/l2smr     Maybe these features already existed in another version or fork, and they might not be very big changes, but since I didn’t know about them and found them necessary, I decided to          implement them myself and wanted to share them.      
    • no....Mobius L2Clientdat and L2FileEditor can do that...but still cant works with TaiWanese Grand Crusade ,especially Armorgrp.dat and Armorgrp-Classic.dat
    • L2GOLD - Halcyon x45 Project Classic Interlude   C6 - Classic Interlude: Protocol 110     Is a complete copy of L2Gold in Classic [110 Protocol] with L2OFF files.   Fully L2Gold Features - Daily Quest - Daily Mining Quest - Ancient Weapons -Refine System  -Rebirth System -Fully configurable everything you want -Gold stats/Gold skills/Gold items working 100% -Zones 100% alike  -Unique donations system (npc or voicedcommand .donate) - On Enchant success announcement ( if +16 for weapon, 8 for armor , 7 for jewel) - Announce of Castle Lord - Announce of Hero  - Olympiad Max A grade - Olympiad Buffs on matches changed to Gold Alike - Working fully Dreadbane   - AI Mods: Static Time for RB   Automated Events: Squash Watermelon RB Event High rate  (those are fully automated)   Server is running a Test Server: Online to anyone can test it.   Game Client: https://www.mediafire.com/file/1d8xe18rvgi04lx/L2_Classic_Interlude_Client_V2.rar/file   Game Patch: https://www.mediafire.com/file/3z4b8ezy93h2z1g/L2Halcyon+Gold+Patch.rar/file   GM Accounts: ID: root pass root [ accounts go from  root1 until root20 ]   Regular Accounts Registrations: http://84.247.164.27/?page=register   Some Screenshots: https://imgur.com/a/o7TxzTN   Contact me here via PM (only serious buyers).    Price of the product: Fully Server Pack + Source ( 250 Euros )
    • ✨ A Service with Vibes  Vibe SMS ✨   Vibe SMS is not just a platform for working with numbers. We’ve built it to be simple, convenient, and stress-free, so your tasks get done without hassle. We value real communication: we listen to your ideas, provide support, and make sure everyone feels calm and confident. With us, you’re not just a client  you’re part of a space built on trust, support, and a human touch. Vibe SMS is a place where people matter and where we create an atmosphere you’ll want to stay in.   Website link — https://vibe-sms.net/ Our Telegram channel — https://t.me/vibe_sms
  • 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