Jump to content

[share] maxvotes Java vote code reward


Recommended Posts

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,162 @@
+package com.l2jserver.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.l2jserver.L2DatabaseFactory;
+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 MAXVOTES = "http://maxvotes.com/sinfo/XXX.html";
+	// 60 * 1000(1000milliseconds = 1 second) = 60seconds
+	private final int initialCheck = 60 * 1000;
+	// 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes
+	private final int delayForCheck = 1800 * 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 = 10;
+	// 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(rset.getInt("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
+				{
+					L2DatabaseFactory.close(con);
+				}
+				
+				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(MAXVOTE);
+			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/l2jserver/gameserver/GameServer.java
===================================================================
--- java/com/l2jserver/gameserver/GameServer.java	(revision 4407)
+++ java/com/l2jserver/gameserver/GameServer.java	(working copy)
@@ -83,6 +83,7 @@
import com.l2jserver.gameserver.idfactory.IdFactory;
import com.l2jserver.gameserver.instancemanager.AirShipManager;
import com.l2jserver.gameserver.instancemanager.AuctionManager;
+import com.l2jserver.gameserver.instancemanager.AutoVoteRewardHandler;
import com.l2jserver.gameserver.instancemanager.BoatManager;
import com.l2jserver.gameserver.instancemanager.CastleManager;
import com.l2jserver.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();

 

work with sites like MaxVotes

 

credits: Death, Codex

code source: l2jserver forum

Link to comment
Share on other sites

Isnt huge deal to change some arrays from the based(hopzone)

Anyway,

thanks for share

 

newbies cant change that bro

i just recode the main code,i know its easy not a rocket build lol

 

The same code posted XX times with some simple changes.

 

its true

 

but as i said before

we code that vote system code for newbies in java

 

i saw like that share before

 

whats the different? :O

 

there are no difference uncle son

 

u saw codes like that because its already shared before

but for other sites like hopzone or gamesites200 etc..

 

 

Xmmm

Nothing.

But i think its a way to advertise hi's topsite :<

 

really?

so show me if someone share the code with changes before me

 

 

 

Who add server where?

This site is dead.

 

i dont want your opinion bro

but after all i respect your opinion

 

you are sleep when we make hugh changes in maxvotes

 

 

i dont mean this.

i mean all system dead

 

:D

Link to comment
Share on other sites

What you did?

You re-code?

Do you even know what does it means?

You just take the shared one and you change some arrays,anyway

i dont mean this.

i mean all system dead

ah lol
Link to comment
Share on other sites

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,   LF Developer.   Project: Sunrise, High Five Client.   Reply here discord name or send me message thanks
    • 🚨🇦🇷🇧🇷🇪🇸🇸🇰🇺🇳🇨🇱🚨 Devianne - Lineage 2 Interlude  Client - Classic. INTERLUDE MID RATE CRAFT  🔷Dynamic Rates 🔸Experience (EXP) - 10x 🔸Skill Points (SP) - 10x 🔸Adena - 6x 🔸Drop Items - 3x 🔸Spoil - 3x 🔸Quest Experience (EXP) - 1x 🔸Quest Skill Points (SP) - 1x 🔸Quest Adena - 1x 🔸Quest Items Drop - 1x 🔸Seal stone Drop - 1x 🔸Epic raid - 1x 🔸Raid Drop - 2.0x 🔸Manor - 5x 🔸Daily quest ⚠️Extra Settings⚠️ 🔸Server time, site - GMT -3 🔸Buffs, Dances, and Songs duration - 1 hour 🔸Max Buffs Slots - 24+ 4 divine 🔸Maximum Slots Dances and Songs - 12 🔸GmShop Grade - C 🔸Global teleport 🔸Grade B-A-S - Craft 🔸Mana potion recharge 🔸1000 (9 seconds delay) 🔸Raid HP - x1.4 🔸Raid epic HP - x1 🔸Blacksmith Mammon - 24/7 🔸Champions System - Yes chance respawn 0.5% 🔸Offline mode Shop - Yes 🔸Auto Learn Skills - Yes 🔸Auto Learn Loot - Yes 🔸Auto Learn Raid & Grand 🔸Boss Loot - No 🔸Buffer offline - Yes 🔸Wedding System - Yes 🔸Max level diff distribution drop in party - 14 🔸Limit the number of active gaming clients on one PC - 2 🔸Limit the number of active gaming clients on one PC for Premium - 3 🔸The clan leader will be replaced after server restart ⚠️Class and Subclass Change⚠️ 🔸1st profession Quest - No 🔸2nd profession Quest - No 🔸3rd profession Quest - Yes 🔸Sub Class Quest- Yes 🔸Sub Class Raid - 8 hours +-30m random 🔸Nobility and Olympiads Nobility Quest - Yes 🔸Olympiads (duration) - 14 days 🔸Max enchant - +6 🔸Respawn Barakiel 6 hours - +-15 min random 🔸Olympiad schedule - 13:00  ⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️⚠️ WEB: https://devianne-l2.com/   DISCORD: https://discord.gg/Q3HAMzasUk   🔥🔥SERVER TEST OPEN !!🔥🔥  
    • With so many tools in your arsenal, I’d suggest taking a look at how internal linking is handled on each site you design—keeping everything connected really helps with SEO.
    • mpa pali to idio pragma  mallon apo oti katalava fteei to back up   katevasa to pack tou l2 finest alla enw ola trexoun kanonika den me vazei sto game.   telos panton mhpws mporoume na vroume kanena interlude pack  gia na asxolithw?
  • Topics

×
×
  • Create New...