Jump to content

Recommended Posts

Posted

Hopzone Vote Reward For Freya. Test 100%

 

### Eclipse Workspace Patch 1.0
#P L2J_Server
Index: java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardHandler.java
===================================================================
--- java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardHandler.java	(revision 0)
+++ java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardHandler.java	(revision 0)
@@ -0,0 +1,151 @@
+package com.l2jserver.gameserver.instancemanager;
+
+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 com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.model.L2ItemInstance;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+
+public class AutoVoteRewardHandler
+{
+	private final String HOPZONE = "http://l2.hopzone.net/lineage2/moreinfo/L2Worldx20x1000PvP/74078.html";
+	// 60 * 1000(1000milliseconds = 1 second) = 60seconds
+	private final int initialCheck = 60 * 1000;
+	// 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes
+	private final int delayForCheck = 600 * 1000;
+	private final int[] itemId = {3500, 5000, 6500 };
+	private final int[] itemCount = { 1, 5, 4};
+	private final int[] maxStack = { 1, 1, 1 };
+	private final int votesRequiredForReward = 1;
+	// 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[i]);
+							if (item == null || item.getCount() < maxStack[i])
+							{
+								String host = player.getClient().getConnection().getInetAddress().getHostAddress();
+								if (host != null && !_listedIps.contains(host))
+									_listedIps.add(host);
+								else
+									return;
+								
+								player.addItem("reward", itemId[i], itemCount[i], 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);
+			isr = new InputStreamReader(url.openStream());
+			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();
+	}
+}
\ No newline at end of file

 

 


### Eclipse Workspace Patch 1.0
#P L2J_Server
Index: java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java	(revision 4569)
+++ java/com/l2jserver/gameserver/GameServer.java	(working copy)

@@ -135,6 +136,8 @@
import com.l2jserver.status.Status;
import com.l2jserver.util.DeadLockDetector;
import com.l2jserver.util.IPv4Filter;
+import com.l2jserver.gameserver.instancemanager.AutoVoteRewardHandler;
+


@@ -406,6 +410,11 @@

		if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
			OfflineTradersTable.restoreOfflineTraders();
+			
+
+       
+		AutoVoteRewardHandler.getInstance();
+		

		if (Config.DEADLOCK_DETECTOR)
		{

Posted

[GR] evala ton code ola ok xoris error alla exw ena problima twra, otan beno eki pou dialego server ph (Bartz) m vgazi You have been disconnected from the server. gt?? :P

Posted

[GR] evala ton code ola ok xoris error alla exw ena problima twra, otan beno eki pou dialego server ph (Bartz) m vgazi You have been disconnected from the server. gt?? :P

 

[GR]Ayto den einai apo to java code File mou ayto einai apo alla thema...

Posted

[GR] ayto to thema mporei na einai apo client mporei na einai apo polla.. den 3erw ti mporei na exeis kanei sto pack sou... ama theleis perisoterh boi8ia kane edw to  provlima sou post

 

[Request] Dev Help [L2J] Gr giati edw  den mporeis na  kaneis post gia help...

  • 2 weeks 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

    • https://prnt.sc/Bkkc0ShGXv9m https://prnt.sc/-JFLvZXsn27A
    • Hello guys want to sell adena in L2 Reborn Signature x1  Stock =14kk good price 
    • Hi guys, I have the following problem, I want to set up two servers on the same dedicated server and I can't.   L2jacis 409 Linux Server. The first gameserver has the following configuration: # ================================================================ # Gameserver setting # ================================================================ # This is transmitted to the clients, so it has to be an IP or resolvable hostname. If this ip is resolvable by Login just leave * Hostname = 190.25.103.103 # Bind ip of the gameserver, use * to bind on all available IPs. GameserverHostname = * GameserverPort = 7777 # The Loginserver host and port. LoginHost = 127.0.0.1 LoginPort = 9014 # This is the server id that the gameserver will request. RequestServerID = 1 # If set to true, the login will give an other id to the server (if the requested id is already reserved). AcceptAlternateID = True UseBlowfishCipher = True # ================================================================ # Database informations # ================================================================ URL = jdbc:mariadb://localhost/server1 Login = server1 Password = server1 I configured the second gameserver like this:   # ================================================================ # Gameserver setting # ================================================================ # This is transmitted to the clients, so it has to be an IP or resolvable hostname. If this ip is resolvable by Login just leave * Hostname = 0.0.0.0 # Bind ip of the gameserver, use * to bind on all available IPs. GameserverHostname = * GameserverPort = 7788 # The Loginserver host and port. LoginHost = 127.0.0.1 LoginPort = 9014 # This is the server id that the gameserver will request. RequestServerID = 2 # If set to true, the login will give an other id to the server (if the requested id is already reserved). AcceptAlternateID = True UseBlowfishCipher = True # ================================================================ # Database informations # ================================================================ URL = jdbc:mariadb://localhost/server2 Login = server2 Password = server2 apart from having tested 0.0.0.0 on the second gameserver I also tried 127.0.0.1 In both cases I see the two servers in the login when I log in, but I try to enter the one with the lowest ping and it kicks me out. The other server always appears with ping 9999 and I try to enter but it doesn't do anything and it freezes the login so I have to log in again. The hexids are in their respective folders. For server 1, it has its hexid inside the gameserver config folder, and I checked that the hexid id is the same id, for example id 1 in the gameserver is also id1 for server 1, and hexid 2 has its hexid 2 for server 2. The server ports are open and listening when I turn on both gameservers. I really don't know what could be wrong. If you could give me some help I would appreciate it. Excuse my English.
    • We have both old channels from 2006-2009 with the 3rd verification function enabled, and new ones.   For availability, please contact us below: Link - Telegram Link - Facebook WhatsApp - Click here to go to WhatsApp chat
    • You can contact me on skype: niedziolek50
  • Topics

×
×
  • Create New...