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

    • You think you have good “l2j” files until you try running a low-rate server.   Saying “there’s not a single L2 server out there worth mentioning” just shows you probably only know the first 10 servers on voting sites, the same voting sites that owned by them. You call the forum dead, yet you’re here discussing your next projects… From my perspective, you don’t seem ready to run any L2 server in 2025. Around 70% of players are here for RMT or ask for payment just to bring their clan, and you really think the community cares about Premium or donations or files quality? The other 20% spend their time downloading and deleting servers all day, playing for one day, then quitting for whatever random reason. And finally, the last 10% are the only ones who actually play because they genuinely like your features, your server files, and your overall project. Good luck 🙂
    • I genuinely admire your bravery - in an age where AI can whip up something better in under a minute, you still stubbornly try to sell these "projects" of yours on a forum that’s been clinically dead for years. That’s no longer determination, that’s digital archaeology. I just can’t tell whether you’re actually trying to make money, or simply testing how much we can endure before we ask an AI to generate you some actual talent.   And ofc AI will make it for free, $220 saved.
    • I’m glad I’m not the only one who appreciates Maxthor’s involvement in group gay orgies, he can’t be bothered to reply to messages, but covering the entire forum in gay lights is absolutely no issue for him. As for the project - the forum is packed with feedback from the testers, the lads are spending every spare moment fixing even the tiniest typo in an NPC’s text. I’ll share the links as soon as I get the green light. Edit: I forgot to add that the GM recruitment will begin once the links are released. Three people will be accepted, and they’ll work in a three-shift rotation so that there’s always a GM available online.
    • Added: a brand-new default dashboard template. You can now add multiple game/login server builds. Full support for running both PTS & L2J servers simultaneously, with switching between them. Payment systems: added OmegaPay and Pally (new PayPal-style API). Account history now stores everything: donations, items delivered to characters, referrals, transfers between game accounts, and coin transfers to another master account. Personal Promo Code System: you can create a promo code and assign it to a user or promoter. When donating, a player can enter this promo code to receive bonus coins, and the promo code owner also receives a bonus — all fully configurable in the admin panel.     Look demo site: demo
    • One of best project i play last few years
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock