Jump to content

Recommended Posts

Posted

Hello this code was taken from extreme i made it for interlude and putted some configs it has been tested on a live server everything works fine!

 

Index: java/com/l2jmoxos12/gameserver/instancemanager/AutoVoteRewardHandler.java
===================================================================
--- java/com/l2jmoxos12/gameserver/instancemanager/AutoVoteRewardHandler.java	(revision 0)
+++ java/com/l2jmoxos12/gameserver/instancemanager/AutoVoteRewardHandler.java	(revision 0)
@@ -0,0 +1,162 @@
+package com.l2jmoxos12.gameserver.instancemanager;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+import com.l2jmoxos12.Config;
+import com.l2jmoxos12.L2DatabaseFactory;
+import com.l2jmoxos12.gameserver.Announcements;
+import com.l2jmoxos12.gameserver.ThreadPoolManager;
+import com.l2jmoxos12.gameserver.model.L2ItemInstance;
+import com.l2jmoxos12.gameserver.model.L2World;
+import com.l2jmoxos12.gameserver.model.actor.instance.L2PcInstance;
+
+public class AutoVoteRewardHandler
+{
+	private final String HOPZONE = "Config.HopZone_ID";
+	// 60 * 1000(1000milliseconds = 1 second) = 60seconds
+	private final int initialCheck = 60 * 1000;
+	// 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes
+	private final int delayForCheck = Config.Delay_for_check * 1000;
+	private final int[] itemId = {Config.Item_ID};
+	private final int[] itemCount = {Config.Item_Count};
+	private final int[] maxStack = {Config.Max_Stack};
+	private final int votesRequiredForReward = Config.Votes_Required;
+	// do not change
+	private int lastVoteCount = 0;
+	
+	private AutoVoteRewardHandler()
+	{
+		System.out.println("Vote Reward System Initiated.");
+		ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
+	}
+	
+	private class AutoReward implements Runnable
+	{
+		public void run()
+		{
+			int votes = getVotes();
+			System.out.println("Server Votes: " + votes);
+			if (votes != 0 && getLastVoteCount() != 0 && votes >= getLastVoteCount() + votesRequiredForReward)
+			{
+				Connection con = null;
+				try
+				{
+					con = L2DatabaseFactory.getInstance().getConnection();
+					PreparedStatement statement = con.prepareStatement("" +
+							"SELECT" +
+							"	c.charId," +
+							"	c.char_name" +
+							"FROM" +
+							"	characters AS c" +
+							"LEFT JOIN" +
+							"	accounts AS a" +
+							"ON" +
+							"	c.account_name = a.login" +
+							"WHERE" +
+							"	c.online > 0" +
+							"GROUP BY" +
+							"	a.lastIP" +
+							"ORDER BY" +
+							"	c.level" +
+							"DESC");
+					ResultSet rset = statement.executeQuery();
+					L2PcInstance player = null;
+					L2ItemInstance item = null;
+					while (rset.next())
+					{
+						player = L2World.getInstance().getPlayer("charId");
+						if (player != null && !player.getClient().isDetached())
+						{
+							for (int i = 0; i < itemId.length; i++)
+							{
+								item = player.getInventory().getItemByItemId(itemId[i]);
+								if (item == null || item.getCount() < maxStack[i])
+									player.addItem("reward", itemId[i], itemCount[i], player, true);
+							}
+						}
+					}
+					statement.close();
+				}
+				catch (SQLException e)
+				{
+					e.printStackTrace();
+				}
+				finally
+				{
+                           try { if (con != null) con.close(); } catch (SQLException e) { e.printStackTrace(); }
+				}
+				
+				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();
+	}
+}
Index: java/com/l2jmoxos12/gameserver/GameServer.java
===================================================================
--- java/com/l2jmoxos12/gameserver/GameServer.java	(revision 4407)
+++ java/com/l2jmoxos12/gameserver/GameServer.java	(working copy)
@@ -83,6 +83,7 @@
import com.l2jmoxos12.gameserver.idfactory.IdFactory;
import com.l2jmoxos12.gameserver.instancemanager.AirShipManager;
import com.l2jmoxos12.gameserver.instancemanager.AuctionManager;
+import com.l2jmoxos12.gameserver.instancemanager.AutoVoteRewardHandler;
import com.l2jmoxos12.gameserver.instancemanager.BoatManager;
import com.l2jmoxos12.gameserver.instancemanager.CastleManager;
import com.l2jmoxos12.gameserver.instancemanager.CastleManorManager;
@@ -406,6 +407,8 @@
		if ((Config.OFFLINE_TRADE_ENABLE || Config.OFFLINE_CRAFT_ENABLE) && Config.RESTORE_OFFLINERS)
			OfflineTradersTable.restoreOfflineTraders(); 

+		AutoVoteRewardHandler.getInstance();
+		
		if (Config.DEADLOCK_DETECTOR)
		{
			_deadDetectThread = new DeadLockDetector();

Index: java/com/l2jmoxos12/gameserver/Config.java
===================================================================
--- java/com/l2jmoxos12/gameserver/Config.java	(revision 0)
+++ java/com/l2jmoxos12/gameserver/Config.java	(revision 0)
@@ -0,0 +1,162 @@
public static int Random_Of_Sailren_Spawn;

	//Vote Reward by Boorinio
+	public static int HopZone_ID;  
+	public static int  Delay_for_check; 
+	public static int  Item_ID; 
+	public static int  Item_Count; 
+	public static int  Max_Stack;
+	public static int Votes_Required;
@@ -32,4 +4,153 @@
CLAN_LEADER_COLOR_CLAN_LEVEL = Integer.parseInt(L2jMoxos12Settings.getProperty("ClanLeaderColorAtClanLevel", "1"));
+
+HopZone_ID =  Integer.parseInt(L2jMoxos12Settings.getProperty("HopZoneID", "www.google.com"));
+Delay_for_check =  Integer.parseInt(L2jMoxos12Settings.getProperty("Delayforcheck", "600"));
+Item_ID =  Integer.parseInt(L2jMoxos12Settings.getProperty("ItemID", "3470"));
+Item_Count =  Integer.parseInt(L2jMoxos12Settings.getProperty("ItemCount", "1"));
+Max_Stack =  Integer.parseInt(L2jMoxos12Settings.getProperty("MaxStack", "1"));
+Votes_Required =  Integer.parseInt(L2jMoxos12Settings.getProperty("VotesRequired", "10"));

Index: L2jMoxos12/config/l2jmoxos12.properties
===================================================================
--- L2jMoxos12/config/l2jmoxos12.properties	(revision 0)
+++ L2jMoxos12/config/l2jmoxos12.properties	(revision 0)
@@ -39,6 +39,9 @@
+# ============================= #             
+#L2jMoxos12 HopZone Java Vote Reward 
+# ============================= #
+# Hopzone Url
+#For example http://l2.hopzone.net/lineage2/moreinfo/L2Gang/82066.html
+HopZoneID = www.google.com
+
+# Dealy Check
+#This means in every x seconds the Handler will check for vote count
+Delayforcheck = 600
+
+# Item id
+# The reward of your choice 
+ItemID = 3470
+
+# Item Count
+# The Count of your choice
+ItemCount = 1
+
+# MaxStack
+# Recommended 1
+MaxStack = 1
+
+# Votes Required
+# Votes required between rewards
+VotesRequired = 10

Posted

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:179: illegal start of expression

    [javac] private void setLastVoteCount(int voteCount)

    [javac] ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:179: illegal start of expression

    [javac] private void setLastVoteCount(int voteCount)

    [javac]         ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:179: ';' expected

    [javac] private void setLastVoteCount(int voteCount)

    [javac]                             ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:179: ';' expected

    [javac] private void setLastVoteCount(int voteCount)

    [javac]                                           ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:184: illegal start of expression

    [javac] private int getLastVoteCount()

    [javac] ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:184: ';' expected

    [javac] private int getLastVoteCount()

    [javac]                             ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:189: illegal start of expression

    [javac] public static AutoVoteRewardHandler getInstance()

    [javac] ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:189: illegal start of expression

    [javac] public static AutoVoteRewardHandler getInstance()

    [javac]       ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:189: ';' expected

    [javac] public static AutoVoteRewardHandler getInstance()

    [javac]                                   ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:189: ';' expected

    [javac] public static AutoVoteRewardHandler getInstance()

    [javac]                                                 ^

    [javac] C:\Users\Florin\Desktop\java\Promisance\L2_GameServer_It\java\net\sf\l2j\gameserver\instancemanager\AutoVoteRewardHandler.java:200: reached end of file while parsing

    [javac] }

    [javac]  ^

    [javac] 11 errors

Posted

0 to me and my friend too....are there any errors when you are putting  the code? do it manually not by applying the patch

I did it manually and same..

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

    • hello everyone! I am wanting to save the files (Ini. - Data - ) of the EP5 Client: Salvation... But they generate the error "corrupt files"... I tried several versions of L2FileEditor without good results. I need help! Thank you!
    • Opening December 6th at 19:00 (GMT +3)! Open Beta Test from November 30th!   https://l2soe.com/   🌟 Introducing L2 Saga of Eternia: A Revolution in Lineage 2 High Five! 🌟   Dear Lineage 2 enthusiasts, Prepare to witness the future of private servers! L2 Saga of Eternia is not just another High Five project—it’s a game-changing experience designed to compete with the giants of the Lineage 2 private server scene. Built for the community, by the community, we’re here to raise the bar in quality, innovation, and longevity. What Sets Us Apart? 💎 No Wipes, Ever Say goodbye to the fear of losing your progress. Our server is built to last and will never close. Stability and consistency are our promises to you. ⚔️ Weekly New Content Our dedicated development team ensures fresh challenges, events, and updates every week. From custom quests to exclusive features, there will always be something exciting to explore. 💰 No Pay-to-Win Skill and strategy matter most here. Enjoy a balanced gameplay environment where your achievements come from effort, not your wallet. 🌍 A Massive Community With 2000+ players expected, join a vibrant and active community of like-minded adventurers ready to conquer the world of Aden. 🏆 Fair and Competitive Gameplay Our systems are designed to promote healthy competition while avoiding abusive mechanics and exploits. 🔧 Professional Development From advanced bug fixes to carefully curated content, we pride ourselves on smooth performance, no lag, and unparalleled server quality. Key Features Chronicle: High Five with unique interface Rate: Dynamic x10 rates Class Balance: Carefully fine-tuned for a fair experience PvP Focused: PvP Ranking & aura display effect for 3 Top PvPers every week Custom Events: Seasonal and permanent events to keep you engaged Additional Features:   Custom Endgame Content: Introduce unique dungeons, raids, or zones unavailable in other servers. Player-Driven Economy: Implement a strong market system and avoid overinflated drops or rewards. Epic Siege Battles: Announce special large-scale sieges and PvP events. Incentives for Streamers and Clans: Attract influencers and big clans to boost server publicity. Roadmap Transparency: Share a public roadmap of planned updates to build trust and excitemen   Here you can read all the features: https://l2soe.com/features   Video preview: Join the Revolution! This is your chance to be part of something legendary. L2 Saga of Eternia is not just a server; it’s a movement to redefine what Lineage 2 can be. Whether you’re a seasoned veteran or a newcomer to the world of Aden, we invite you to experience Lineage 2 at its finest.   Official Launch Date: December 6th 2024 Website: https://l2soe.com/ Facebook: https://www.facebook.com/l2soe Discord: https://discord.com/invite/l2eternia   Let’s build the ultimate Lineage 2 experience together. See you in-game! 🎮
    • That's like a tutorial on how to run l2 on MacOS Xd but good job for the investigation. 
    • small update: dc robe set sold   wts adena 1kk = 1.5$ 
    • DISCORD : utchiha_market telegram : https://t.me/utchiha_market SELLIX STORE : https://utchihamkt.mysellix.io/ Join our server for more products : https://discord.gg/hood-services https://campsite.bio/utchihaamkt
  • Topics

×
×
  • Create New...