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

    • Well, sorry not sorry for resurrecting old topic, but I believe it's ultimately stupid to implement license checks like Vilmis did 🙂   private static String url = "jdbc:mysql://185.80.128.233/" + getData("Zm9ydW1fZGI="); private static String username = getData("bXJjb3B5cmlnaHQ="); private static String password = getData("Y29weXJpZ2h0XzEyMw=="); con = GlobalDB.getInstance().getConnection(); PreparedStatement statement; statement = con.prepareStatement("SELECT field_6 from core_pfields_content WHERE member_id = ?"); statement.setInt(1, Config.FORUM_USER_ID); ResultSet rset = statement.executeQuery();   This awesome way of coding things leaves us with base64-encoded credentials and DB exposed and accessible globally 😉 Btw he checks his licensing data from some plugin generated table his forum uses. Vilmis took action and ensured that mrcopyright user would have only needed accesses and rights for this operation. But he forgot to ensure that his INFORMATION_SCHEMA database would not be exposed and readable... That leads us to fully readable server variables like version used (10.1.26-MariaDB-0+deb9u1 - pretty ancient DB and OS, I'd assume). From here you can go south and do some kinky stuff, if you want and have knowledge for that. But who cares, right?   Ooh, table core_pfields_content field_6 is IP address which is checked by FORUM_USER_ID. Yep, you can query all IP addresses there (124 of them right now) and also do whatever you want with them! 🙂  The most fun part? Files source has been shared what, more than 2 years ago?  Vilmis still uses very same credentials and never changed it after sources exposure - who cares. Although, "sources" may be way too strong word here. If anyone still use paid Orion versions, I'd suggest packing your shit and leaving immediately, or at least fix this incompetent fool caused problems. It's obvious Vilmis don't care or maybe doesn't even know from the first place how to solve this problem (hint hint - tiny PHP Rest API microservice which would do absolutely the same but without exposing sensitive data?). By doing that, he exposes his infrastructure and YOUR data, and he does that for more than 2 years now 🙂 Developer of century!    
    • rename the l2.bin into l2.exe
    • L2LIVE.PRO- Dynamic Mid-rates Essence Seven Signs GRAND OPENING - July 5, 20:00 GMT+3 (EEST) TEST SERVER IS OPEN - COME AND CHECK IT OUT TODAY! Join our community and be part of it at: https://www.l2live.pro https://discord.gg/k3NMgR4Dmu   Server description * EXP/SP: Dynamic (x1- x100 based on your level, *before* Sayha and EXP buffs * Adena: x50 / Item Drop: x10 / Fishing EXP increased / Attribute EXP increased * Simplified gameplay to stay in the loop while not spending hours and hours farming * Starter Pack containing very useful items for beginners * MP replenishing potions with auto-consumption * No overpowered donations L2LIVE shop * All spellbook coupons, pet spellbook coupons and master books are sold via Game Assistant * Additionally you can buy SP pouches, enchanted talismans, pet training guides and various other consumables for Adena and L-Coin * More items such as cloaks, more talismans, agathions, belts, pendants, enchantment scrolls of various grades, evolution stones, etc will be added! Shop server as a shortcut, and all retail-like ways of earning items are still here! L-Coins * Drops with small change and in random amounts from Lv60+ monsters  * All raidbosses drop random amount of L-Coin Pouches generating up to 420 Lcoin per unit. **Grand Olympiad and Events** * Grand Olympiad is held week day * Format is 1v1, unlimited weekly fights  * Heroes are declared weekly at Sunday * There are three automated events - TvT, CTF and Deathmatch, running at evenings * Orc Fortress, Battle with Balok, Keber Hunter, Archievements Box, Daily Gift Calendar provisional events are active too Custom user commands * .offlineplay command, your character will keep playing till death or server restart * .offlineshop command, keeps your shop sitting until all items are purchased * .apon / .apoff - enable/disable HP/MP autoconsume And lots of other small improvements are waiting for you!   Join our community and be part of it at: https://www.l2live.pro https://discord.gg/k3NMgR4Dmu
  • Topics

×
×
  • Create New...