Jump to content
  • 0

[HELP] Autovote system error in Eclipse...


Question

Posted

I have this auto vote system:

Index: dist/game/config/l2jmods.properties
===================================================================
--- dist/game/config/l2jmods.properties	(revision 5038)
+++ dist/game/config/l2jmods.properties	(working copy)

@@ -456,7 +459,67 @@
# Default: 127.0.0.1,0 (no limits from localhost)
DualboxCheckWhitelist = 127.0.0.1,0

+
# ---------------------------------------------------------------------------
+# Vote System
+# ---------------------------------------------------------------------------
+
+# Enable vote system?
+EnableVoteSystem = true
+
+#Hopzone = true / Topzone = false
+VoteSystemHopzone = true
+
+# Save Votes in Database?
+# Recomendable true if you Shutdown/Restart the server.
+SaveVotesIntoDataBase = true
+
+# Vote Page URL.
+# Working/Tested in HopZone.
+VoteSystemPage = http://l2.hopzone.net/lineage2/details/74078/L2World-Servers
+
+# Reward players every xxx votes.
+VoteSystemVotes = 10
+
+# Frist Check delay.
+# In Seconds.
+VoteSystemStartCheckTime = 60
+
+# Continue Check delay.
+# In Seconds.
+VoteSystemRunCheckTime = 120
+
+# Items Rewards ID.
+# Separated whit a ",".
+VoteSystemItemID = 57,20034
+
+# Items Rewards Count.
+# Separated whit a ",".
+VoteSystemItemCount = 1000,2
\ No newline at end of file
Index: java/com/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java	(revision 5038)
+++ java/com/l2jserver/gameserver/GameServer.java	(working copy)
@@ -79,6 +79,7 @@
import com.l2jserver.gameserver.instancemanager.AirShipManager;
import com.l2jserver.gameserver.instancemanager.AntiFeedManager;
import com.l2jserver.gameserver.instancemanager.AuctionManager;
+import com.l2jserver.gameserver.instancemanager.AutoVoteRewardManager;
import com.l2jserver.gameserver.instancemanager.BoatManager;
import com.l2jserver.gameserver.instancemanager.CHSiegeManager;
import com.l2jserver.gameserver.instancemanager.CastleManager;

@@ -311,6 +314,11 @@
		BoatManager.getInstance();
		AirShipManager.getInstance();
		GraciaSeedsManager.getInstance();
+                if(Config.VOTE_SYSTEM_ENABLE == true){
+		AutoVoteRewardManager.getInstance();
+		}

		try
		{
Index: java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardManager.java
===================================================================
--- java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardManager.java	(revision 0)
+++ java/com/l2jserver/gameserver/instancemanager/AutoVoteRewardManager.java	(revision 0)
@@ -0,0 +1,222 @@
+package com.l2jserver.gameserver.instancemanager;
+    
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.net.URLConnection;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+    
+import com.l2jserver.Config;
+import com.l2jserver.L2DatabaseFactory;
+import com.l2jserver.gameserver.Announcements;
+import com.l2jserver.gameserver.ThreadPoolManager;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+    
+public class AutoVoteRewardManager
+{
+   private static Logger _log = Logger.getLogger(AutoVoteRewardManager.class.getName());
+       
+   private static final int initialCheck  = Config.VOTE_SYSTEM_START_TIME * 1000;
+   private static final int delayForCheck = Config.VOTE_SYSTEM_CHECK_TIME * 1000;
+   private int votesneed;
+   
+   private static List<String> _ips = new ArrayList<String>();
+   private static int lastVoteCount = 0;
+      
+   private AutoVoteRewardManager()
+   {
+       _log.info("AutoVoteRewardManager: Vote reward system initiated.");
+       if (Config.VOTE_SYSTEM_DATABASE_SAVE)
+           load();
+       ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
+   }
+      
+   private class AutoReward implements Runnable
+   {
+       @Override
+	public void run()
+       {
+           int votes = getVotes();
+           _log.info("AutoVoteRewardManager: Current Votes: " + getVotes());
+           _log.info("AutoVoteRewardManager: Votes needed: "+(getLastVoteCount()+Config.VOTE_SYSTEM_COUNT));
+           _log.info("AutoVoteRewardManager: Next Check in: "+(delayForCheck/1000)+" sec.");
+           Announcements.getInstance().announceToAll("Vote for us in HopZone!");
+           
+           if (votes >= getLastVoteCount() + Config.VOTE_SYSTEM_COUNT)
+           {
+        	   Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().valueCollection();
+               {
+                   for (L2PcInstance onlinePlayer : pls)
+                   {
+                       if (onlinePlayer.isOnline() && !onlinePlayer.getClient().isDetached() && !_ips.contains(onlinePlayer.getClient().getConnection().getInetAddress().getHostAddress()))
+                       {
+                    	   String[] parase = Config.VOTE_SYSTEM_ITEM_ID.split(",");
+                    	   String[] parase3 = Config.VOTE_SYSTEM_ITEM_COUNT.split(",");
+                    	   for(int o = 0; o <parase.length; o++){
+                    		   int parase2 = Integer.parseInt(parase[o]);
+                    		   int parase4 = Integer.parseInt(parase3[o]);
+                           for (int i = 0; i < parase.length; i++)
+                           {
+                               onlinePlayer.addItem("vote_reward", parase2, parase4, onlinePlayer, true);
+                           }
+                    	   }
+                           _ips.add(onlinePlayer.getClient().getConnection().getInetAddress().getHostAddress());
+                       }
+                   }
+               }
+               _log.info("AutoVoteRewardManager: All players has been rewared!");
+               Announcements.getInstance().announceToAll("Thanks for vote, you has been rewarded!");
+               setLastVoteCount(getLastVoteCount() + Config.VOTE_SYSTEM_COUNT);
+           }
+                
+           if (getLastVoteCount() == 0)
+           {
+               setLastVoteCount(votes);
+           }
+           else if ((getLastVoteCount() + Config.VOTE_SYSTEM_COUNT) - votes > Config.VOTE_SYSTEM_COUNT || votes > (getLastVoteCount() + Config.VOTE_SYSTEM_COUNT))
+           {
+               setLastVoteCount(votes);
+           }
+           votesneed = (getLastVoteCount()+Config.VOTE_SYSTEM_COUNT) - votes;
+           if(votesneed == 0){
+        	   votesneed = Config.VOTE_SYSTEM_COUNT;
+           }
+           Announcements.getInstance().announceToAll("Need " + votesneed + " votes more to reward all players.");
+           _ips.clear();
+       }
+   }
+      
+   private int getVotes()
+   {
+       URL url = null;
+       InputStreamReader isr = null;
+       BufferedReader in = null;
+       try
+       {
+           url = new URL(Config.VOTE_SYSTEM_PAGE);
+           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(Config.VOTE_SYSTEM_HOPZONE == false){
+        	   //TopZone
+        	   if(inputLine.contains("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\">")){
+        	   String i = inputLine.replace("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\">", "");
+        	   i = i.replace("</font></b></div></td></tr>", "");
+        	   i = i.trim();
+        	   int o = Integer.parseInt(i);
+        	   return Integer.valueOf(o);
+        	   }
+        	   } else {
+        	                 //for hopzone
+               if (inputLine.contains("Anonymous User Votes"))
+                   return Integer.valueOf(inputLine.split(">")[2].replace("</span", ""));
+
+               }
+           }
+       }
+       catch (IOException e)
+       {
+           _log.warning("AutoVoteRewardHandler: "+e);
+       }
+       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;
+   }
+   
+   private void load()
+   {
+       int votes = 0;
+       Connection con = null;
+       try
+       {
+           con = L2DatabaseFactory.getInstance().getConnection();
+           PreparedStatement statement = con.prepareStatement("SELECT vote FROM votes LIMIT 1");
+           ResultSet rset = statement.executeQuery();
+
+           while (rset.next())
+           {
+               votes = rset.getInt("vote");
+           }
+           rset.close();
+           statement.close();
+       }
+       catch (Exception e)
+       {
+           _log.log(Level.WARNING, "data error on vote: ", e);
+       }
+       finally
+       {
+           L2DatabaseFactory.close(con);
+       }
+      
+       setLastVoteCount(votes);
+   }
+   
+   public void save()
+   {
+       Connection con = null;
+       try
+       {
+           con = L2DatabaseFactory.getInstance().getConnection();
+           PreparedStatement statement = con.prepareStatement("UPDATE votes SET vote = ? WHERE id=1");
+           statement.setInt(1, getLastVoteCount());
+           statement.execute();
+           statement.close();
+       }
+       catch (Exception e)
+       {
+           _log.log(Level.WARNING, "data error on vote: ", e);
+       }
+       finally
+       {
+           L2DatabaseFactory.close(con);
+       }
+   }
+  
+   public static AutoVoteRewardManager getInstance()
+   {
+       return SingletonHolder._instance;
+   }
+      
+   @SuppressWarnings("synthetic-access")
+   private static class SingletonHolder
+   {
+       protected static final AutoVoteRewardManager _instance = new AutoVoteRewardManager();
+   }
+}
\ No newline at end of file
Index: java/com/l2jserver/Config.java
===================================================================
--- java/com/l2jserver/Config.java	(revision 5038)
+++ java/com/l2jserver/Config.java	(working copy)

@@ -763,6 +764,26 @@
	public static int L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP;
	public static int L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP;
	public static TIntIntHashMap L2JMOD_DUALBOX_CHECK_WHITELIST;
+        public static boolean VOTE_SYSTEM_ENABLE;
+	public static boolean VOTE_SYSTEM_HOPZONE;
+	public static boolean VOTE_SYSTEM_DATABASE_SAVE;
+	public static String VOTE_SYSTEM_PAGE;
+	public static int VOTE_SYSTEM_COUNT;
+	public static int VOTE_SYSTEM_START_TIME;
+	public static int VOTE_SYSTEM_CHECK_TIME;
+	public static String VOTE_SYSTEM_ITEM_ID;
+	public static String VOTE_SYSTEM_ITEM_COUNT;



	//--------------------------------------------------

@@ -2628,7 +2649,17 @@

					L2WALKER_PROTECTION = Boolean.parseBoolean(L2JModSettings.getProperty("L2WalkerProtection", "False"));
					L2JMOD_DEBUG_VOICE_COMMAND = Boolean.parseBoolean(L2JModSettings.getProperty("DebugVoiceCommand", "False"));
-
+					
+					VOTE_SYSTEM_ENABLE = Boolean.parseBoolean(L2JModSettings.getProperty("EnableVoteSystem", "False"));
+					VOTE_SYSTEM_HOPZONE = Boolean.parseBoolean(L2JModSettings.getProperty("VoteSystemHopzone", "true"));
+					VOTE_SYSTEM_DATABASE_SAVE = Boolean.parseBoolean(L2JModSettings.getProperty("SaveVotesIntoDataBase", "true"));
+					VOTE_SYSTEM_PAGE = L2JModSettings.getProperty("VoteSystemPage", "");
+					VOTE_SYSTEM_COUNT = Integer.parseInt(L2JModSettings.getProperty("VoteSystemVotes", "10"));
+					VOTE_SYSTEM_START_TIME = Integer.parseInt(L2JModSettings.getProperty("VoteSystemStartCheckTime", "60"));
+					VOTE_SYSTEM_CHECK_TIME = Integer.parseInt(L2JModSettings.getProperty("VoteSystemRunCheckTime", "120"));
+					VOTE_SYSTEM_ITEM_ID = L2JModSettings.getProperty("VoteSystemItemID", "57, 1000");
+					VOTE_SYSTEM_ITEM_COUNT = L2JModSettings.getProperty("VoteSystemItemCount", "1000, 1");
+	
					L2JMOD_DUALBOX_CHECK_MAX_PLAYERS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxPlayersPerIP", "0"));
					L2JMOD_DUALBOX_CHECK_MAX_OLYMPIAD_PARTICIPANTS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxOlympiadParticipantsPerIP", "0"));
					L2JMOD_DUALBOX_CHECK_MAX_L2EVENT_PARTICIPANTS_PER_IP = Integer.parseInt(L2JModSettings.getProperty("DualboxCheckMaxL2EventParticipantsPerIP", "0"));

Index: java/com/l2jserver/gameserver/Shutdown.java
===================================================================
--- java/com/l2jserver/gameserver/Shutdown.java	(revision 5038)
+++ java/com/l2jserver/gameserver/Shutdown.java	(working copy)
@@ -44,6 +44,7 @@
import com.l2jserver.gameserver.network.serverpackets.ServerClose;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.util.Broadcast;
+import com.l2jserver.gameserver.instancemanager.AutoVoteRewardManager;


/**
@@ -543,6 +544,12 @@
		SevenSigns.getInstance().saveSevenSignsStatus();
		_log.info("SevenSigns: Seven Signs status saved("+tc.getEstimatedTimeAndRestartCounter()+"ms).");

+		//Save Votes if save votes enable
+		if(Config.VOTE_SYSTEM_DATABASE_SAVE){
+			AutoVoteRewardManager.getInstance().save();
+			_log.info("Vote System: Votes has been saved!!");
+		}
+		
		// Save all raidboss and GrandBoss status ^_^
		RaidBossSpawnManager.getInstance().cleanUp();
		_log.info("RaidBossSpawnManager: All raidboss info saved("+tc.getEstimatedTimeAndRestartCounter()+"ms).");

 

But it gives me some errors in Eclipse: http://imageshack.us/photo/my-images/14/autovoterewardmanager.jpg/

                                                            http://imageshack.us/photo/my-images/197/gameserver.JPG/

 

Anyone can help???

0 answers to this question

Recommended Posts

There have been no answers to this question yet

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

    • GoldRush launches tomorrow! July 18 16:00 GMT+3 Europe / International Register your account in the website, connect wallet and be ready to dominate!
    • 🏰 L2EXALTA LEGACY — Interlude x45 📅 Grand Opening: 31/07/2026 — 21:30 (GMT+3) 🌐 Website: https://l2exalta.org/ 💬 Discord: https://discord.gg/zNTCZD4AcT 📌 Wiki: https://l2exalta.org/en/wiki.html#progression   ⚙️ MAIN INFO Chronicle : Interlude Rates : x45 Adena : x50 Spoil : x1 Drop : x5 Safe Enchant : +3 Files : L2OFF   💰 ECONOMY EX Coin : dynamic market currency, mined from monsters, Raid Bosses and Grand Bosses value fluctuates over time Exalta Vouchers : premium currency used for store, donations and EX Coin exchange Exchange : convert EX Coin into Exalta Vouchers Investment options : choose safer or riskier market strategies with EX Coin   ⚔️ PROGRESSION & GEAR Exalta Armors : signature top-tier gear line Forge System : upgrade weapons, armor and jewels with risk/reward mechanics Raid Boss progression tied to materials and prestige   🤖 AUTOFARM Access : Auto Hunting button, bottom-right UI Duration : controlled via tickets or in-game currency Route Mode : record custom farm routes Support Mode : healer/support builds auto-follow, heal and assist party Smart targeting logic with class-specific behavior (mage/archer/melee/support) Captcha designed not to interrupt legitimate AutoFarm sessions   🧪 BUFFER Exalta Buffer NPC/interface Scheme Buffer : save multiple buff loadouts Class presets for mage, fighter, support, PvP   🛠️ SMART GADGETS / QOL Autoloot filter Drop value tracker Boss timer tools Farm stats tracker Auto-consume system In-game server assistant   🗺️ DUNGEON FINDER / PVE Party matching with roles (Tank / Healer / DPS) Ready-check before teleport Monastery of Silence custom PvE zone Party-based reward structure   🎟️ DAILY PROGRESS / EXALTA PASS Daily and weekly tasks (farm, PvP, boss, check-in) Premium Pass track with extra rewards Monastery Daily Quest Reward boards for claiming progress   🏠 HOUSING & EXPEDITIONS Player residences with service NPCs Exalta Spirit Expeditions to themed territories Rewards vary by territory Owner-only access   🏆 PVP / TOURNAMENT Scheduled Tournament system Ranking points from wins/participation Spectator Mode for watching live matches PvP Statues for top-ranked players Anti-feed protections   🛡️ CLAN CONTENT Clan Civil War battlefield event Clan Dungeon Raid content DPS Meter for contribution tracking Support Credit system Classic siege/clan politics preserved   🏪 AUCTION / SHOPS Auction House with seller fee Black Market Dealer (limited-time special offers) Custom shops and multisells Confirmation prompts on purchases/sales   💳 DONATIONS / VIP Donation rewards linked to Exalta Vouchers VIP tiers with comfort/cosmetic bonuses Premium store Gift/promo codes for events   🎥 STREAMER / COMMUNITY Streamer Panel with visible stream links Viewer rewards system Streamer Points for cosmetics/vouchers In-game voice chat (global/party/clan/alliance/command)   🔒 FAIR PLAY Strong Anti-Bot protection Reward protection tied to valid client state Captcha on suspicious activity Staff investigation tools No bots, packet tools or modified clients allowed   👑 GRANDBOSS SPAWNS Orfen : 1 day + 1h random Core : 1 day + 1h random Queen Ant : 1 day 6h + 1h random Zaken : 2 days 12h + 1h random Baium : 5 days + 1h random Antharas : 8 days + 1h random Valakas : 11 days + 1h random   🏅 OLYMPIAD Runs Thursday, Friday, Saturday Heroes change monthly Balanced and fair matchmaking
    • yup basically another one just in case https://drive.google.com/file/d/1UtccbD9e50x3WEnQBab2PTZnBHwpcGYM/view?usp=sharing LineageWarrior.FMagic (CollideActors = True; > False) LineageWarrior.FOrc (CollideActors = True; > False) LineageWarrior.FShaman (CollideActors = True; > False) LineageWarrior.MDarkElf (CollideActors = True; > False) LineageWarrior.MDwarf (CollideActors = True; > False) LineageWarrior.MElf (CollideActors = True; > False) LineageWarrior.MFighter (CollideActors = True; > False) LineageWarrior.MMagic (CollideActors = True; > False) LineageWarrior.MOrc (CollideActors = True; > False) LineageWarrior.MShaman (CollideActors = True; > False) LineageWarrior.FDwarf (CollideActors = True; > False) LineageWarrior.FElf (CollideActors = True; > False) LineageWarrior.FFighter (CollideActors = True; > False)
    • @l2naylondev Requiring a player to log in just for the sake of logging  seems exploitable. Someone could log in only to claim the reward and immediately leave, or repeatedly change their ip. So i guess  are there are additional protections in place ? such as locking the reward by account, character , and ip. It would also be useful to add a playtime requirement. For example, after logging in, the player would need to remain active for at least x playtime  before getting the reward or other parameters configurable by the xml.  I suggest improving the system before selling it. 
  • Topics

×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..