Jump to content

[Share]HopZone Vote Reward [Freya]


Recommended Posts

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)
		{

Link to comment
Share on other sites

[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...

Link to comment
Share on other sites

[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...

Link to comment
Share on other sites

  • 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.

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

    • Hello,   I am looking for someone who understands about websites, knows coding etc.   I am dealing with situation where after i bought web hosting my website is loading really slowly or not loading at all at some points. I have tried dealing with the company who provides the web hosting but they could not find issue on their end so i am asking for help, someone who knows their thing about this.   Drop your discord details i will contact you.   Thank you
    • Good afternoon I am selling a list of forums, which contains more than 100 lines of active and current RU forums.   - topics: dark, crypto, SMM, programming, services, cheats, etc.; - sorting from more popular to less popular (by traffic, by the number of new posts per day);   Are you looking for where to advertise your services? This base will definitely suit you! In addition, on the forums you can find a bunch of useful information, software, as well as advertisements about sales and services from other users.   Payment: 12 USTD   After payment you receive a text document with a list of forums (PS. all information is provided for informational purposes only); TELEGRAM - https://t.me/milozare
    • I strongly concur with some opinions shared. As I've previously mentioned on different posts, it's shocking to see how seasonal servers gather this much population. However, being back in the game some months I did start understanding how the current community of L2 plays and thinks.   It's a huge problem, but in my opinion the guilt is shared between server owners and community. To keep a long term project running (more than a year on) you need to have the equivalent community that will support the project, which unfortunately is not that big. The current player community of L2 hops on new servers with such a haste to get full and "dominate" which does indeed give a lot of activity for some weeks but after that it's just downfall, population gets reduced drastically day by day. The reason is, while the community is busy "grinding" to win on their current server, a "new" server is being advertised which most likely is from the same owner. As I've mentioned, the guilt is shared since the server-owners focus on bringing up "new" servers for the cash grab but also since the community doesn't have the patience to support a long-term project. Besides, let's not forget about clans/CPs being invited directly to the server with some benefits. I'll give an example. An admin opens a server, invites 3 groups (either CPs or clans) by promising them some small benefits. Those three groups will invite more players and so on. It's like an investment, they spent 5$ to earn 20$. Therefore, most admins willing to play "fair" do not succeed, except for a few. Most of us "old-timers" play for nostalgia trips and are fine with low populated servers but lets take a step back and think about the owners that really want to provide a good server, no income will slowly dry out the server and eventually die.   Don't get me wrong, there are some great servers out there, but not everything is for everyone. I'll finish by quoting someone I saw few days ago on YouTube, he said something along the lines that we shouldn't expect fair play while we play an "illegal" version of the game.
    • You have to create the "voiced" handler in the core too, or at the very least make sure that the delimiter is underscore and not an empty space. Alternatively, you can try changing all references of the strings below to start with "voiced_", or remove the "voiced_" portion from the button bypass.   private static final String[] VOICED_COMMANDS = { "siege", "siege_gludio", "siege_dion", "siege_giran", "siege_oren", "siege_aden", "siege_innadril", "siege_goddard", "siege_rune", "siege_schuttgart" };
    • Hi maxcheaters, I recently added some code to my l2jacis revision and everything works fine with the .siege commands but when I click on the html options to open the registry I don't succeed!   registerHandler(new Castles());   package net.sf.l2j.gameserver.handler.voicedcommandhandlers;   import net.sf.l2j.Config; import net.sf.l2j.gameserver.handler.IVoicedCommandHandler; import net.sf.l2j.gameserver.data.manager.CastleManager; import net.sf.l2j.gameserver.model.actor.Player; import net.sf.l2j.gameserver.model.entity.Castle; import net.sf.l2j.gameserver.network.SystemMessageId; import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage; import net.sf.l2j.gameserver.network.serverpackets.SiegeInfo;   public class Castles implements IVoicedCommandHandler { private static final String[] VOICED_COMMANDS = { "siege", "siege_gludio", "siege_dion", "siege_giran", "siege_oren", "siege_aden", "siege_innadril", "siege_goddard", "siege_rune", "siege_schuttgart" };   @Override public boolean useVoicedCommand(String command, Player player, String target) { if (command.equals("siege") && Config.ENABLE_MENU) showHtm(player); else if (command.startsWith("siege_")) { if (player.getClan() != null && !player.isClanLeader()) { player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT); return false; }   int castleId = 0; if (command.startsWith("siege_gludio") && Config.SIEGE_GLUDIO) castleId = 1; else if (command.startsWith("siege_dion") && Config.SIEGE_DION) castleId = 2; else if (command.startsWith("siege_giran") && Config.SIEGE_GIRAN) castleId = 3; else if (command.startsWith("siege_oren") && Config.SIEGE_OREN) castleId = 4; else if (command.startsWith("siege_aden") && Config.SIEGE_ADEN) castleId = 5; else if (command.startsWith("siege_innadril") && Config.SIEGE_INNADRIL) castleId = 6; else if (command.startsWith("siege_goddard") && Config.SIEGE_GODDARD) castleId = 7; else if (command.startsWith("siege_rune") && Config.SIEGE_RUNE) castleId = 8; else if (command.startsWith("siege_schuttgart") && Config.SIEGE_SCHUT) castleId = 9; else player.sendMessage("This Castle has been disabled");   Castle castle = CastleManager.getInstance().getCastleById(castleId); if ((castle != null) && (castleId != 0)) player.sendPacket(new SiegeInfo(castle)); } return true; }   private static void showHtm(Player player) { NpcHtmlMessage htm = new NpcHtmlMessage(0); htm.setFile(player.isLang() + "mods/menu/CastleManager.htm"); player.sendPacket(htm); }   @Override public String[] getVoicedCommandList() { return VOICED_COMMANDS; } }     <button value="Giran" action="bypass voiced_siege_giran" width=75 height=22 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal">
  • Topics

×
×
  • Create New...