Jump to content
  • 0

[Help] Vote Reward


Question

Posted

Hi, i am triying to make it works but.. nothing can help me plz?.

 

dibujogim.jpg

 

Uploaded with ImageShack.us

 

package L2j.Infinity.gameserver.model.entity;

 

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

import java.net.URL;

import java.util.ArrayList;

import java.util.Collection;

import java.net.URLConnection;

 

import L2j.Infinity.ExternalConfig;

import L2j.Infinity.gameserver.Announcements;

import L2j.Infinity.gameserver.ThreadPoolManager;

import L2j.Infinity.gameserver.model.L2ItemInstance;

import L2j.Infinity.gameserver.model.L2World;

import L2j.Infinity.gameserver.model.actor.instance.L2PcInstance;

 

public class AutoVoteRewardHandler

{

private final String HOPZONE = ExternalConfig.WEBSITE_SERVER_LINK;

// 60 * 1000(1000milliseconds = 1 second) = 60seconds

private final int initialCheck = 60 * 1000;

// 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes

private final int delayForCheck = 1800 * 1000;

private final int[] itemId = {ExternalConfig.ITEM_ID};

private final int[] itemCount = {ExternalConfig.ITEM_COUNT};

private final int[] maxStack = { 1 };

private final int votesRequiredForReward = ExternalConfig.REQUIREDVOTES;

// do not change

private int lastVoteCount = 0;

private static ArrayList<String> _listedIps;

 

private AutoVoteRewardHandler()

{

System.out.println("Vote Reward System Initiated.");

ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);

}

 

private class AutoReward implements Runnable

{

@Override

public void run()

{

int votes = getVotes();

System.out.println("Server Votes: " + votes);

if (votes != 0 && getLastVoteCount() != 0 && votes >= getLastVoteCount() + votesRequiredForReward)

{

Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();

int onlinePlayers = 0;

for (L2PcInstance pl : pls)

{

if (pl.isOnline() && !pl.getClient().isDetached())

{

onlinePlayers++;

}

}

_listedIps = new ArrayList<String>(onlinePlayers);

L2ItemInstance item;

for (L2PcInstance player : pls)

{

if (player != null && player.isOnline() && !player.getClient().isDetached())

{

for (int i = 0; i < itemId.length; i++)

{

item = player.getInventory().getItemByItemId(itemId);

if (item == null || item.getCount() < maxStack)

{

String host = player.getClient().getConnection().getInetAddress().getHostAddress();

if (host != null && !_listedIps.contains(host))

_listedIps.add(host);

else

return;

 

player.addItem("reward", itemId, itemCount, player, true);

}

}

}

}

setLastVoteCount(getLastVoteCount() + votesRequiredForReward);

}

Announcements.getInstance().announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + votesRequiredForReward) + " Votes.");

if (getLastVoteCount() == 0)

{

setLastVoteCount(votes);

}

}

}

 

private int getVotes()

{

URL url = null;

InputStreamReader isr = null;

BufferedReader in = null;

try

{

url = new URL(HOPZONE);

URLConnection con = url.openConnection();

con.addRequestProperty("User-Agent", "Mozilla/4.76");

isr = new InputStreamReader(con.getInputStream());

in = new BufferedReader(isr);

String inputLine;

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

{

if (inputLine.contains("moreinfo_total_rank_text"))

{

return Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));

}

}

}

catch (IOException e)

{

e.printStackTrace();

}

finally

{

try

{

in.close();

}

catch (IOException e)

{

}

try

{

isr.close();

}

catch (IOException e)

{

}

}

return 0;

}

 

private void setLastVoteCount(int voteCount)

{

lastVoteCount = voteCount;

}

 

private int getLastVoteCount()

{

return lastVoteCount;

}

 

public static AutoVoteRewardHandler getInstance()

{

return SingletonHolder._instance;

}

 

@SuppressWarnings("synthetic-access")

private static class SingletonHolder

{

protected static final AutoVoteRewardHandler _instance = new AutoVoteRewardHandler();

}

}

 

Thx everyone!

10 answers to this question

Recommended Posts

  • 0
Posted
Index: /trunk/***/java/com/***/gameserver/handler/AutoVoteRewardHandler.java
===================================================================
--- /trunk/***/java/com/***/gameserver/handler/AutoVoteRewardHandler.java
+++ /trunk/***/java/com/***/gameserver/handler/AutoVoteRewardHandler.java	
@@ -235,7 +235,7 @@
			while ((inputLine = in.readLine()) != null)
			{
-				if (inputLine.contains("moreinfo_total_rank_text"))
+				if (inputLine.contains("rank anonymous tooltip"))
				{
-					votes = Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));
+					votes = Integer.valueOf(inputLine.split(">")[2].replace("</span", ""));
					break;
				}

  • 0
Posted

Change:

while ((inputLine = in.readLine()) != null)
{
if (inputLine.contains("moreinfo_total_rank_text"))
{
	return Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));
}
}

 

For:

while ((inputLine = in.readLine()) != null)
{
if (inputLine.contains("Anonymous User Votes"))
{
	try
	{
		return Integer.parseInt(inputLine.substring(inputLine.indexOf("Votes") + 7, inputLine.indexOf("<", inputLine.indexOf("Votes"))));
	}
	catch (Exception e)
	{
		return -1;
	}
}
}

 

Hope that helps.

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
Answer this question...

×   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

    • 🤣 You were talking about security — I want you to prove that it's actually insecure, try to hack it or something. You're just talking without any evidence, and that's not right. Without the personal key that's generated for each site, you can't do anything. And by the way, boberKurwa isn't even used — it's a joke, and you totally fell for it. You're being very unconstructive. I appreciate criticism based on facts, and here's a fact: Sphere 2 has been running publicly since October, and there haven't been any successful hacking attempts. If you doubt that, go ahead and prove me wrong.  
    • When a conversation loses its direction and turns into pointless justifications, maybe the problem isn't who's right it's who's insecure. The phrase "there is nothing for me to prove" shows confidence or indifference. But let’s look at it in PHP. class Logan22 { public bool $hasSomethingToProve = false; public string $communicationMode = 'normal'; public bool $usesChatGPT = false; public function respond(string $input): string { if (str_contains($input, 'prove')) { return "I have nothing to prove."; } if (str_contains($input, 'defensive')) { $this->communicationMode = 'defensive'; return "You got defensive – did something feel threatening?"; } if (str_contains($input, 'ChatGPT')) { $this->usesChatGPT = true; return "Yes, I use it for speed, accuracy, and because my spelling sucks."; } return "What did you just say again?"; } }  
    • You wrote complete nonsense. Everything you said is utter rubbish from someone who doesn’t understand a thing. As for the ticking time bomb — go ahead and try to prove it. No one has managed so far, and trust me, there’ve been plenty of “smart guys” before you.    
    • Grab a proper launcher for Your server - update files whenever You need
    • ➡ Discount for your purchase: APRIL (10% discount) ➡ Our Online Shop: https://socnet.store  ➡ Our SMM-Boosting Panel: https://socnet.pro  ➡ Telegram Shop Bot: https://socnet.shop  ➡ Telegram Support: https://t.me/solomon_bog  ➡ Telegram Channel: https://t.me/accsforyou_shop  ➡ Discord Support: @AllSocialNetworksShop  ➡ Discord Server: https://discord.gg/y9AStFFsrh  ➡ WhatsApp Support: https://wa.me/79051904467 ➡ WhatsApp Channel: https://whatsapp.com/channel/0029Vau0CMX002TGkD4uHa2n  ➡ Email Support: solomonbog@socnet.store 
  • Topics

×
×
  • Create New...