Removal of vote reward system.
This commit is contained in:
		@@ -1,95 +0,0 @@
 | 
			
		||||
# Vote reward for L2network.eu
 | 
			
		||||
AllowNetworkVoteReward = False
 | 
			
		||||
# Vote reward server link. (IMPORTANT!!!! Always add / at the end of the link)
 | 
			
		||||
NetworkServerLink =
 | 
			
		||||
# Votes for next reward needed.
 | 
			
		||||
NetworkVotesDifference = 4
 | 
			
		||||
# Minutes between rewards.
 | 
			
		||||
# Eg. You put 5 it checks every 5 minutes for reward.
 | 
			
		||||
NetworkRewardCheckTime = 5
 | 
			
		||||
# Reward(s).
 | 
			
		||||
NetworkReward = 3481,5;
 | 
			
		||||
# Network reward max dual boxes reward.
 | 
			
		||||
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
 | 
			
		||||
NetworkDualboxesAllowed = 1
 | 
			
		||||
# Game server console report.
 | 
			
		||||
# If set to true, game server console will get a report of
 | 
			
		||||
# current vote count, votes needed for next reward and votes needed for first page.
 | 
			
		||||
AllowNetworkGameServerReport = False
 | 
			
		||||
 | 
			
		||||
# Vote reward for Topzone.com
 | 
			
		||||
AllowTopzoneVoteReward = False
 | 
			
		||||
# Vote reward server link.
 | 
			
		||||
TopzoneServerLink =
 | 
			
		||||
# Votes for next reward needed.
 | 
			
		||||
TopzoneVotesDifference = 4
 | 
			
		||||
# Minutes between rewards.
 | 
			
		||||
# Eg. You put 5 it checks every 5 minutes for reward.
 | 
			
		||||
TopzoneRewardCheckTime = 5
 | 
			
		||||
# Reward(s).
 | 
			
		||||
TopzoneReward = 3481,5;
 | 
			
		||||
# Topzone reward max dual boxes reward.
 | 
			
		||||
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
 | 
			
		||||
TopzoneDualboxesAllowed = 1
 | 
			
		||||
# Game server console report.
 | 
			
		||||
# If set to true, game server console will get a report of
 | 
			
		||||
# current vote count, votes needed for next reward and votes needed for first page.
 | 
			
		||||
AllowTopzoneGameServerReport = False
 | 
			
		||||
 | 
			
		||||
# Vote reward for Hopzone.net
 | 
			
		||||
AllowHopzoneVoteReward = False
 | 
			
		||||
# Vote reward server link.
 | 
			
		||||
HopzoneServerLink =
 | 
			
		||||
# Votes for next reward needed.
 | 
			
		||||
HopzoneVotesDifference = 4
 | 
			
		||||
# Minutes between rewards.
 | 
			
		||||
# Eg. You put 5 it checks every 5 minutes for reward.
 | 
			
		||||
HopzoneRewardCheckTime = 5
 | 
			
		||||
# Reward(s).
 | 
			
		||||
HopzoneReward = 3481,5;
 | 
			
		||||
# Hopzone reward max dual boxes reward.
 | 
			
		||||
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
 | 
			
		||||
HopzoneDualboxesAllowed = 1
 | 
			
		||||
# Game server console report.
 | 
			
		||||
# If set to true, game server console will get a report of
 | 
			
		||||
# current vote count, votes needed for next reward and votes needed for first page.
 | 
			
		||||
AllowHopzoneGameServerReport = False
 | 
			
		||||
 | 
			
		||||
# Vote reward for L2top.co
 | 
			
		||||
AllowL2topVoteReward = False
 | 
			
		||||
# Vote reward server link.
 | 
			
		||||
L2topServerLink =
 | 
			
		||||
# Votes for next reward needed.
 | 
			
		||||
L2topVotesDifference = 4
 | 
			
		||||
# Minutes between rewards.
 | 
			
		||||
# Eg. You put 5 it checks every 5 minutes for reward.
 | 
			
		||||
L2topRewardCheckTime = 5
 | 
			
		||||
# Reward(s).
 | 
			
		||||
L2topReward = 3481,5;
 | 
			
		||||
# L2top reward max dual boxes reward.
 | 
			
		||||
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
 | 
			
		||||
L2topDualboxesAllowed = 1
 | 
			
		||||
# Game server console report.
 | 
			
		||||
# If set to true, game server console will get a report of
 | 
			
		||||
# current vote count, votes needed for next reward and votes needed for first page.
 | 
			
		||||
AllowL2topGameServerReport = False
 | 
			
		||||
 | 
			
		||||
# Vote reward for L2JBrasil.
 | 
			
		||||
AllowL2JBrasilVoteReward = False
 | 
			
		||||
# Vote reward server link.
 | 
			
		||||
# Example: https://top.l2jbrasil.com/index.php?a=stats&u=l2monkey
 | 
			
		||||
L2JBrasilServerLink = 
 | 
			
		||||
# Votes for next reward needed.
 | 
			
		||||
L2JBrasilVotesDifference = 1
 | 
			
		||||
# Minutes between rewards.
 | 
			
		||||
# Eg. You put 5 it checks every 5 minutes for reward.
 | 
			
		||||
L2JBrasilRewardCheckTime = 1
 | 
			
		||||
# Reward(s).
 | 
			
		||||
L2JBrasilReward = 30002,5;
 | 
			
		||||
# Topzone reward max dual boxes reward.
 | 
			
		||||
# For example if you put 2 and someone has 3 boxes open 2 will be rewarded.
 | 
			
		||||
L2JBrasilDualboxesAllowed = 1
 | 
			
		||||
# Game server console report.
 | 
			
		||||
# If set to true, game server console will get a report of
 | 
			
		||||
# current vote count, votes needed for next reward and votes needed for first page.
 | 
			
		||||
AllowL2JBrasilGameServerReport = True
 | 
			
		||||
@@ -146,7 +146,6 @@ public class Config
 | 
			
		||||
	private static final String CUSTOM_SELL_BUFFS_CONFIG_FILE = "./config/Custom/SellBuffs.ini";
 | 
			
		||||
	private static final String CUSTOM_SERVER_TIME_CONFIG_FILE = "./config/Custom/ServerTime.ini";
 | 
			
		||||
	private static final String CUSTOM_STARTING_LOCATION_CONFIG_FILE = "./config/Custom/StartingLocation.ini";
 | 
			
		||||
	private static final String CUSTOM_VOTE_REWARD_CONFIG_FILE = "./config/Custom/VoteReward.ini";
 | 
			
		||||
	private static final String CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE = "./config/Custom/WalkerBotProtection.ini";
 | 
			
		||||
	
 | 
			
		||||
	// --------------------------------------------------
 | 
			
		||||
@@ -1351,41 +1350,6 @@ public class Config
 | 
			
		||||
	public static long SELLBUFF_MIN_PRICE;
 | 
			
		||||
	public static long SELLBUFF_MAX_PRICE;
 | 
			
		||||
	public static int SELLBUFF_MAX_BUFFS;
 | 
			
		||||
	public static boolean ALLOW_NETWORK_VOTE_REWARD;
 | 
			
		||||
	public static String NETWORK_SERVER_LINK;
 | 
			
		||||
	public static int NETWORK_VOTES_DIFFERENCE;
 | 
			
		||||
	public static int NETWORK_REWARD_CHECK_TIME;
 | 
			
		||||
	public static Map<Integer, Integer> NETWORK_REWARD = new HashMap<>();
 | 
			
		||||
	public static int NETWORK_DUALBOXES_ALLOWED;
 | 
			
		||||
	public static boolean ALLOW_NETWORK_GAME_SERVER_REPORT;
 | 
			
		||||
	public static boolean ALLOW_TOPZONE_VOTE_REWARD;
 | 
			
		||||
	public static String TOPZONE_SERVER_LINK;
 | 
			
		||||
	public static int TOPZONE_VOTES_DIFFERENCE;
 | 
			
		||||
	public static int TOPZONE_REWARD_CHECK_TIME;
 | 
			
		||||
	public static Map<Integer, Integer> TOPZONE_REWARD = new HashMap<>();
 | 
			
		||||
	public static int TOPZONE_DUALBOXES_ALLOWED;
 | 
			
		||||
	public static boolean ALLOW_TOPZONE_GAME_SERVER_REPORT;
 | 
			
		||||
	public static boolean ALLOW_HOPZONE_VOTE_REWARD;
 | 
			
		||||
	public static String HOPZONE_SERVER_LINK;
 | 
			
		||||
	public static int HOPZONE_VOTES_DIFFERENCE;
 | 
			
		||||
	public static int HOPZONE_REWARD_CHECK_TIME;
 | 
			
		||||
	public static Map<Integer, Integer> HOPZONE_REWARD = new HashMap<>();
 | 
			
		||||
	public static int HOPZONE_DUALBOXES_ALLOWED;
 | 
			
		||||
	public static boolean ALLOW_HOPZONE_GAME_SERVER_REPORT;
 | 
			
		||||
	public static boolean ALLOW_L2TOP_VOTE_REWARD;
 | 
			
		||||
	public static String L2TOP_SERVER_LINK;
 | 
			
		||||
	public static int L2TOP_VOTES_DIFFERENCE;
 | 
			
		||||
	public static int L2TOP_REWARD_CHECK_TIME;
 | 
			
		||||
	public static Map<Integer, Integer> L2TOP_REWARD = new HashMap<>();
 | 
			
		||||
	public static int L2TOP_DUALBOXES_ALLOWED;
 | 
			
		||||
	public static boolean ALLOW_L2TOP_GAME_SERVER_REPORT;
 | 
			
		||||
	public static boolean ALLOW_L2JBRASIL_VOTE_REWARD;
 | 
			
		||||
	public static String L2JBRASIL_SERVER_LINK;
 | 
			
		||||
	public static int L2JBRASIL_VOTES_DIFFERENCE;
 | 
			
		||||
	public static int L2JBRASIL_REWARD_CHECK_TIME;
 | 
			
		||||
	public static Map<Integer, Integer> L2JBRASIL_REWARD = new HashMap<>();
 | 
			
		||||
	public static int L2JBRASIL_DUALBOXES_ALLOWED;
 | 
			
		||||
	public static boolean ALLOW_L2JBRASIL_GAME_SERVER_REPORT;
 | 
			
		||||
	
 | 
			
		||||
	public static boolean ENABLE_GUI;
 | 
			
		||||
	public static boolean DARK_THEME;
 | 
			
		||||
@@ -3620,78 +3584,6 @@ public class Config
 | 
			
		||||
			CUSTOM_STARTING_LOC_Y = startingLocationConfig.getInt("CustomStartingLocY", 186527);
 | 
			
		||||
			CUSTOM_STARTING_LOC_Z = startingLocationConfig.getInt("CustomStartingLocZ", -3625);
 | 
			
		||||
			
 | 
			
		||||
			// Load VoteReward config file (if exists)
 | 
			
		||||
			final PropertiesParser voteRewardConfig = new PropertiesParser(CUSTOM_VOTE_REWARD_CONFIG_FILE);
 | 
			
		||||
			// L2network.eu
 | 
			
		||||
			ALLOW_NETWORK_VOTE_REWARD = voteRewardConfig.getBoolean("AllowNetworkVoteReward", false);
 | 
			
		||||
			NETWORK_SERVER_LINK = voteRewardConfig.getString("NetworkServerLink", "");
 | 
			
		||||
			NETWORK_VOTES_DIFFERENCE = voteRewardConfig.getInt("NetworkVotesDifference", 5);
 | 
			
		||||
			NETWORK_REWARD_CHECK_TIME = voteRewardConfig.getInt("NetworkRewardCheckTime", 5);
 | 
			
		||||
			final String networkSmallRewardValue = voteRewardConfig.getString("NetworkReward", "57,100000000;");
 | 
			
		||||
			final String[] networkSmallRewardSplit1 = networkSmallRewardValue.split(";");
 | 
			
		||||
			for (String i : networkSmallRewardSplit1)
 | 
			
		||||
			{
 | 
			
		||||
				final String[] networkSmallRewardSplit2 = i.split(",");
 | 
			
		||||
				NETWORK_REWARD.put(Integer.parseInt(networkSmallRewardSplit2[0]), Integer.parseInt(networkSmallRewardSplit2[1]));
 | 
			
		||||
			}
 | 
			
		||||
			NETWORK_DUALBOXES_ALLOWED = voteRewardConfig.getInt("NetworkDualboxesAllowed", 1);
 | 
			
		||||
			ALLOW_NETWORK_GAME_SERVER_REPORT = voteRewardConfig.getBoolean("AllowNetworkGameServerReport", false);
 | 
			
		||||
			// Topzone.com
 | 
			
		||||
			ALLOW_TOPZONE_VOTE_REWARD = voteRewardConfig.getBoolean("AllowTopzoneVoteReward", false);
 | 
			
		||||
			TOPZONE_SERVER_LINK = voteRewardConfig.getString("TopzoneServerLink", "");
 | 
			
		||||
			TOPZONE_VOTES_DIFFERENCE = voteRewardConfig.getInt("TopzoneVotesDifference", 5);
 | 
			
		||||
			TOPZONE_REWARD_CHECK_TIME = voteRewardConfig.getInt("TopzoneRewardCheckTime", 5);
 | 
			
		||||
			final String topzoneSmallRewardValue = voteRewardConfig.getString("TopzoneReward", "57,100000000;");
 | 
			
		||||
			final String[] topzoneSmallRewardSplit1 = topzoneSmallRewardValue.split(";");
 | 
			
		||||
			for (String i : topzoneSmallRewardSplit1)
 | 
			
		||||
			{
 | 
			
		||||
				final String[] topzoneSmallRewardSplit2 = i.split(",");
 | 
			
		||||
				TOPZONE_REWARD.put(Integer.parseInt(topzoneSmallRewardSplit2[0]), Integer.parseInt(topzoneSmallRewardSplit2[1]));
 | 
			
		||||
			}
 | 
			
		||||
			TOPZONE_DUALBOXES_ALLOWED = voteRewardConfig.getInt("TopzoneDualboxesAllowed", 1);
 | 
			
		||||
			ALLOW_TOPZONE_GAME_SERVER_REPORT = voteRewardConfig.getBoolean("AllowTopzoneGameServerReport", false);
 | 
			
		||||
			// Hopzone.net
 | 
			
		||||
			ALLOW_HOPZONE_VOTE_REWARD = voteRewardConfig.getBoolean("AllowHopzoneVoteReward", false);
 | 
			
		||||
			HOPZONE_SERVER_LINK = voteRewardConfig.getString("HopzoneServerLink", "");
 | 
			
		||||
			HOPZONE_VOTES_DIFFERENCE = voteRewardConfig.getInt("HopzoneVotesDifference", 5);
 | 
			
		||||
			HOPZONE_REWARD_CHECK_TIME = voteRewardConfig.getInt("HopzoneRewardCheckTime", 5);
 | 
			
		||||
			final String hopzoneSmallRewardValue = voteRewardConfig.getString("HopzoneReward", "57,100000000;");
 | 
			
		||||
			final String[] hopzoneSmallRewardSplit1 = hopzoneSmallRewardValue.split(";");
 | 
			
		||||
			for (String i : hopzoneSmallRewardSplit1)
 | 
			
		||||
			{
 | 
			
		||||
				final String[] hopzoneSmallRewardSplit2 = i.split(",");
 | 
			
		||||
				HOPZONE_REWARD.put(Integer.parseInt(hopzoneSmallRewardSplit2[0]), Integer.parseInt(hopzoneSmallRewardSplit2[1]));
 | 
			
		||||
			}
 | 
			
		||||
			HOPZONE_DUALBOXES_ALLOWED = voteRewardConfig.getInt("HopzoneDualboxesAllowed", 1);
 | 
			
		||||
			ALLOW_HOPZONE_GAME_SERVER_REPORT = voteRewardConfig.getBoolean("AllowHopzoneGameServerReport", false);
 | 
			
		||||
			// L2top.co
 | 
			
		||||
			ALLOW_L2TOP_VOTE_REWARD = voteRewardConfig.getBoolean("AllowL2topVoteReward", false);
 | 
			
		||||
			L2TOP_SERVER_LINK = voteRewardConfig.getString("L2topServerLink", "");
 | 
			
		||||
			L2TOP_VOTES_DIFFERENCE = voteRewardConfig.getInt("L2topVotesDifference", 5);
 | 
			
		||||
			L2TOP_REWARD_CHECK_TIME = voteRewardConfig.getInt("L2topRewardCheckTime", 5);
 | 
			
		||||
			final String l2topSmallRewardValue = voteRewardConfig.getString("L2topReward", "57,100000000;");
 | 
			
		||||
			final String[] l2topSmallRewardsplit1 = l2topSmallRewardValue.split(";");
 | 
			
		||||
			for (String i : l2topSmallRewardsplit1)
 | 
			
		||||
			{
 | 
			
		||||
				final String[] l2topSmallRewardSplit2 = i.split(",");
 | 
			
		||||
				L2TOP_REWARD.put(Integer.parseInt(l2topSmallRewardSplit2[0]), Integer.parseInt(l2topSmallRewardSplit2[1]));
 | 
			
		||||
			}
 | 
			
		||||
			L2TOP_DUALBOXES_ALLOWED = voteRewardConfig.getInt("L2topDualboxesAllowed", 1);
 | 
			
		||||
			ALLOW_L2TOP_GAME_SERVER_REPORT = voteRewardConfig.getBoolean("AllowL2topGameServerReport", false);
 | 
			
		||||
			ALLOW_L2JBRASIL_VOTE_REWARD = voteRewardConfig.getBoolean("AllowL2JBrasilVoteReward", false);
 | 
			
		||||
			L2JBRASIL_SERVER_LINK = voteRewardConfig.getString("L2JBrasilServerLink", "");
 | 
			
		||||
			L2JBRASIL_VOTES_DIFFERENCE = voteRewardConfig.getInt("L2JBrasilVotesDifference", 5);
 | 
			
		||||
			L2JBRASIL_REWARD_CHECK_TIME = voteRewardConfig.getInt("L2JBrasilRewardCheckTime", 5);
 | 
			
		||||
			String l2jbrasilSmallRewardValue = voteRewardConfig.getString("L2JBrasilReward", "57,100000000;");
 | 
			
		||||
			String[] l2jbrasilSmallRewardSplit1 = l2jbrasilSmallRewardValue.split(";");
 | 
			
		||||
			for (String i : l2jbrasilSmallRewardSplit1)
 | 
			
		||||
			{
 | 
			
		||||
				String[] l2jbrasilSmallRewardSplit2 = i.split(",");
 | 
			
		||||
				HOPZONE_REWARD.put(Integer.parseInt(l2jbrasilSmallRewardSplit2[0]), Integer.parseInt(l2jbrasilSmallRewardSplit2[1]));
 | 
			
		||||
			}
 | 
			
		||||
			L2JBRASIL_DUALBOXES_ALLOWED = voteRewardConfig.getInt("L2JBrasilDualboxesAllowed", 1);
 | 
			
		||||
			ALLOW_L2JBRASIL_GAME_SERVER_REPORT = voteRewardConfig.getBoolean("AllowL2JBrasilGameServerReport", false);
 | 
			
		||||
			
 | 
			
		||||
			// Load WalkerBotProtection config file (if exists)
 | 
			
		||||
			final PropertiesParser walkerBotProtectionConfig = new PropertiesParser(CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE);
 | 
			
		||||
			L2WALKER_PROTECTION = walkerBotProtectionConfig.getBoolean("L2WalkerProtection", false);
 | 
			
		||||
 
 | 
			
		||||
@@ -156,7 +156,6 @@ import org.l2jmobius.gameserver.model.World;
 | 
			
		||||
import org.l2jmobius.gameserver.model.events.EventDispatcher;
 | 
			
		||||
import org.l2jmobius.gameserver.model.olympiad.Hero;
 | 
			
		||||
import org.l2jmobius.gameserver.model.olympiad.Olympiad;
 | 
			
		||||
import org.l2jmobius.gameserver.model.votereward.VoteSystem;
 | 
			
		||||
import org.l2jmobius.gameserver.network.ClientNetworkManager;
 | 
			
		||||
import org.l2jmobius.gameserver.network.NpcStringId;
 | 
			
		||||
import org.l2jmobius.gameserver.network.SystemMessageId;
 | 
			
		||||
@@ -392,8 +391,6 @@ public class GameServer
 | 
			
		||||
		SpawnData.getInstance().init();
 | 
			
		||||
		DBSpawnManager.getInstance();
 | 
			
		||||
		
 | 
			
		||||
		VoteSystem.initialize();
 | 
			
		||||
		
 | 
			
		||||
		printSection("Siege");
 | 
			
		||||
		SiegeManager.getInstance().getSieges();
 | 
			
		||||
		CastleManager.getInstance().activateInstances();
 | 
			
		||||
 
 | 
			
		||||
@@ -1,81 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the L2J Mobius project.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.model.votereward;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.net.URLConnection;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Anarchy
 | 
			
		||||
 */
 | 
			
		||||
public class Hopzone extends VoteSystem
 | 
			
		||||
{
 | 
			
		||||
	public Hopzone(int votesDiff, boolean allowReport, int boxes, Map<Integer, Integer> rewards, int checkMins)
 | 
			
		||||
	{
 | 
			
		||||
		super(votesDiff, allowReport, boxes, rewards, checkMins);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void run()
 | 
			
		||||
	{
 | 
			
		||||
		reward();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public int getVotes()
 | 
			
		||||
	{
 | 
			
		||||
		InputStreamReader isr = null;
 | 
			
		||||
		BufferedReader br = null;
 | 
			
		||||
		
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			final URLConnection con = new URL(Config.HOPZONE_SERVER_LINK).openConnection();
 | 
			
		||||
			con.addRequestProperty("User-Agent", "Mozilla/5.0");
 | 
			
		||||
			isr = new InputStreamReader(con.getInputStream());
 | 
			
		||||
			br = new BufferedReader(isr);
 | 
			
		||||
			
 | 
			
		||||
			String line;
 | 
			
		||||
			while ((line = br.readLine()) != null)
 | 
			
		||||
			{
 | 
			
		||||
				if (line.contains("<span class=\"rank tooltip\" title"))
 | 
			
		||||
				{
 | 
			
		||||
					return Integer.parseInt(line.split(">")[2].replace("</span", ""));
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			br.close();
 | 
			
		||||
			isr.close();
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getSiteName()
 | 
			
		||||
	{
 | 
			
		||||
		return "Hopzone.net";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,84 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the L2J Mobius project.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.model.votereward;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.net.URLConnection;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Anarchy
 | 
			
		||||
 */
 | 
			
		||||
public class L2jbrasil extends VoteSystem
 | 
			
		||||
{
 | 
			
		||||
	public L2jbrasil(int votesDiff, boolean allowReport, int boxes, Map<Integer, Integer> rewards, int checkMins)
 | 
			
		||||
	{
 | 
			
		||||
		super(votesDiff, allowReport, boxes, rewards, checkMins);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void run()
 | 
			
		||||
	{
 | 
			
		||||
		reward();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public int getVotes()
 | 
			
		||||
	{
 | 
			
		||||
		InputStreamReader isr = null;
 | 
			
		||||
		BufferedReader br = null;
 | 
			
		||||
		
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			URLConnection con = new URL(Config.L2JBRASIL_SERVER_LINK).openConnection();
 | 
			
		||||
			con.addRequestProperty("User-Agent", "Mozilla/5.0");
 | 
			
		||||
			isr = new InputStreamReader(con.getInputStream());
 | 
			
		||||
			br = new BufferedReader(isr);
 | 
			
		||||
			
 | 
			
		||||
			String line;
 | 
			
		||||
			while ((line = br.readLine()) != null)
 | 
			
		||||
			{
 | 
			
		||||
				if (line.contains("<b>Entradas(Total):</b"))
 | 
			
		||||
				{
 | 
			
		||||
					String votesResult = String.valueOf(line.split(">")[2].replace("<br /", ""));
 | 
			
		||||
					int votes = Integer.valueOf(votesResult.replace(" ", ""));
 | 
			
		||||
					return votes;
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			br.close();
 | 
			
		||||
			isr.close();
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
		{
 | 
			
		||||
			e.printStackTrace();
 | 
			
		||||
			LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getSiteName()
 | 
			
		||||
	{
 | 
			
		||||
		return "L2JBrasil";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,81 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the L2J Mobius project.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.model.votereward;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.net.URLConnection;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author andrei
 | 
			
		||||
 */
 | 
			
		||||
public class L2top extends VoteSystem
 | 
			
		||||
{
 | 
			
		||||
	public L2top(int votesDiff, boolean allowReport, int boxes, Map<Integer, Integer> rewards, int checkMins)
 | 
			
		||||
	{
 | 
			
		||||
		super(votesDiff, allowReport, boxes, rewards, checkMins);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void run()
 | 
			
		||||
	{
 | 
			
		||||
		reward();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public int getVotes()
 | 
			
		||||
	{
 | 
			
		||||
		InputStreamReader isr = null;
 | 
			
		||||
		BufferedReader br = null;
 | 
			
		||||
		
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			final URLConnection con = new URL(Config.L2TOP_SERVER_LINK).openConnection();
 | 
			
		||||
			con.addRequestProperty("User-Agent", "Mozilla/5.0");
 | 
			
		||||
			isr = new InputStreamReader(con.getInputStream());
 | 
			
		||||
			br = new BufferedReader(isr);
 | 
			
		||||
			
 | 
			
		||||
			String line;
 | 
			
		||||
			while ((line = br.readLine()) != null)
 | 
			
		||||
			{
 | 
			
		||||
				if (line.matches("\\s+\\d+</li>"))
 | 
			
		||||
				{
 | 
			
		||||
					return Integer.valueOf(line.replace("</li>", "").replaceAll("\t", ""));
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			br.close();
 | 
			
		||||
			isr.close();
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getSiteName()
 | 
			
		||||
	{
 | 
			
		||||
		return "L2top.co";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,81 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the L2J Mobius project.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.model.votereward;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.net.URLConnection;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Anarchy
 | 
			
		||||
 */
 | 
			
		||||
public class Network extends VoteSystem
 | 
			
		||||
{
 | 
			
		||||
	public Network(int votesDiff, boolean allowReport, int boxes, Map<Integer, Integer> rewards, int checkMins)
 | 
			
		||||
	{
 | 
			
		||||
		super(votesDiff, allowReport, boxes, rewards, checkMins);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void run()
 | 
			
		||||
	{
 | 
			
		||||
		reward();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public int getVotes()
 | 
			
		||||
	{
 | 
			
		||||
		InputStreamReader isr = null;
 | 
			
		||||
		BufferedReader br = null;
 | 
			
		||||
		
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			final URLConnection con = new URL(Config.NETWORK_SERVER_LINK).openConnection();
 | 
			
		||||
			con.addRequestProperty("User-Agent", "Mozilla/5.0");
 | 
			
		||||
			isr = new InputStreamReader(con.getInputStream());
 | 
			
		||||
			br = new BufferedReader(isr);
 | 
			
		||||
			
 | 
			
		||||
			String line;
 | 
			
		||||
			while ((line = br.readLine()) != null)
 | 
			
		||||
			{
 | 
			
		||||
				if (line.contains("<div class=\"tls-in-sts\"><b style"))
 | 
			
		||||
				{
 | 
			
		||||
					return Integer.parseInt(line.split(">")[2].replace("</b", ""));
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			br.close();
 | 
			
		||||
			isr.close();
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getSiteName()
 | 
			
		||||
	{
 | 
			
		||||
		return "L2network.eu";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,78 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the L2J Mobius project.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.model.votereward;
 | 
			
		||||
 | 
			
		||||
import java.io.BufferedReader;
 | 
			
		||||
import java.io.InputStreamReader;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.net.URLConnection;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Anarchy
 | 
			
		||||
 */
 | 
			
		||||
public class Topzone extends VoteSystem
 | 
			
		||||
{
 | 
			
		||||
	public Topzone(int votesDiff, boolean allowReport, int boxes, Map<Integer, Integer> rewards, int checkMins)
 | 
			
		||||
	{
 | 
			
		||||
		super(votesDiff, allowReport, boxes, rewards, checkMins);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public void run()
 | 
			
		||||
	{
 | 
			
		||||
		reward();
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public int getVotes()
 | 
			
		||||
	{
 | 
			
		||||
		InputStreamReader isr = null;
 | 
			
		||||
		BufferedReader br = null;
 | 
			
		||||
		
 | 
			
		||||
		try
 | 
			
		||||
		{
 | 
			
		||||
			final URLConnection con = new URL(Config.TOPZONE_SERVER_LINK).openConnection();
 | 
			
		||||
			con.addRequestProperty("User-Agent", "L2TopZone");
 | 
			
		||||
			isr = new InputStreamReader(con.getInputStream());
 | 
			
		||||
			br = new BufferedReader(isr);
 | 
			
		||||
			
 | 
			
		||||
			String line;
 | 
			
		||||
			while ((line = br.readLine()) != null)
 | 
			
		||||
			{
 | 
			
		||||
				return Integer.parseInt(line.split("fa-thumbs-up\"></i>")[1].split("</span>")[0]);
 | 
			
		||||
			}
 | 
			
		||||
			
 | 
			
		||||
			br.close();
 | 
			
		||||
			isr.close();
 | 
			
		||||
		}
 | 
			
		||||
		catch (Exception e)
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		return -1;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	@Override
 | 
			
		||||
	public String getSiteName()
 | 
			
		||||
	{
 | 
			
		||||
		return "Topzone.com";
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
@@ -1,210 +0,0 @@
 | 
			
		||||
/*
 | 
			
		||||
 * This file is part of the L2J Mobius project.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
 * the Free Software Foundation, either version 3 of the License, or
 | 
			
		||||
 * (at your option) any later version.
 | 
			
		||||
 * 
 | 
			
		||||
 * This program is distributed in the hope that it will be useful,
 | 
			
		||||
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
			
		||||
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 | 
			
		||||
 * General Public License for more details.
 | 
			
		||||
 * 
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 */
 | 
			
		||||
package org.l2jmobius.gameserver.model.votereward;
 | 
			
		||||
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.Collection;
 | 
			
		||||
import java.util.HashMap;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
import java.util.logging.Logger;
 | 
			
		||||
 | 
			
		||||
import org.l2jmobius.Config;
 | 
			
		||||
import org.l2jmobius.commons.threads.ThreadPool;
 | 
			
		||||
import org.l2jmobius.gameserver.enums.ChatType;
 | 
			
		||||
import org.l2jmobius.gameserver.model.World;
 | 
			
		||||
import org.l2jmobius.gameserver.model.actor.Player;
 | 
			
		||||
import org.l2jmobius.gameserver.network.serverpackets.CreatureSay;
 | 
			
		||||
import org.l2jmobius.gameserver.util.Broadcast;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @author Anarchy
 | 
			
		||||
 */
 | 
			
		||||
public abstract class VoteSystem implements Runnable
 | 
			
		||||
{
 | 
			
		||||
	protected static final Logger LOGGER = Logger.getLogger(VoteSystem.class.getName());
 | 
			
		||||
	
 | 
			
		||||
	private static List<VoteSystem> voteSystems = new ArrayList<>();
 | 
			
		||||
	
 | 
			
		||||
	private final int votesDiff;
 | 
			
		||||
	private final boolean allowReport;
 | 
			
		||||
	private final int boxes;
 | 
			
		||||
	private final Map<Integer, Integer> rewards;
 | 
			
		||||
	private int lastVotes = 0;
 | 
			
		||||
	private final Map<String, Integer> playerIps = new HashMap<>();
 | 
			
		||||
	
 | 
			
		||||
	public static void initialize()
 | 
			
		||||
	{
 | 
			
		||||
		if (Config.ALLOW_NETWORK_VOTE_REWARD || Config.ALLOW_TOPZONE_VOTE_REWARD || Config.ALLOW_HOPZONE_VOTE_REWARD || Config.ALLOW_L2TOP_VOTE_REWARD || Config.ALLOW_L2JBRASIL_VOTE_REWARD)
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.info("VoteSystem: Initialized.");
 | 
			
		||||
			if (Config.ALLOW_NETWORK_VOTE_REWARD)
 | 
			
		||||
			{
 | 
			
		||||
				voteSystems.add(new Network(Config.NETWORK_VOTES_DIFFERENCE, Config.ALLOW_NETWORK_GAME_SERVER_REPORT, Config.NETWORK_DUALBOXES_ALLOWED, Config.NETWORK_REWARD, Config.NETWORK_REWARD_CHECK_TIME));
 | 
			
		||||
				LOGGER.info("VoteSystem: L2network.eu votes enabled.");
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.info("VoteSystem: L2network.eu votes disabled.");
 | 
			
		||||
			}
 | 
			
		||||
			if (Config.ALLOW_TOPZONE_VOTE_REWARD)
 | 
			
		||||
			{
 | 
			
		||||
				voteSystems.add(new Topzone(Config.TOPZONE_VOTES_DIFFERENCE, Config.ALLOW_TOPZONE_GAME_SERVER_REPORT, Config.TOPZONE_DUALBOXES_ALLOWED, Config.TOPZONE_REWARD, Config.TOPZONE_REWARD_CHECK_TIME));
 | 
			
		||||
				LOGGER.info("VoteSystem: Topzone.com votes enabled.");
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.info("VoteSystem: Topzone.com votes disabled.");
 | 
			
		||||
			}
 | 
			
		||||
			if (Config.ALLOW_HOPZONE_VOTE_REWARD)
 | 
			
		||||
			{
 | 
			
		||||
				voteSystems.add(new Hopzone(Config.HOPZONE_VOTES_DIFFERENCE, Config.ALLOW_HOPZONE_GAME_SERVER_REPORT, Config.HOPZONE_DUALBOXES_ALLOWED, Config.HOPZONE_REWARD, Config.HOPZONE_REWARD_CHECK_TIME));
 | 
			
		||||
				LOGGER.info("VoteSystem: Hopzone.net votes enabled.");
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.info("VoteSystem: Hopzone.net votes disabled.");
 | 
			
		||||
			}
 | 
			
		||||
			if (Config.ALLOW_L2TOP_VOTE_REWARD)
 | 
			
		||||
			{
 | 
			
		||||
				voteSystems.add(new L2top(Config.L2TOP_VOTES_DIFFERENCE, Config.ALLOW_L2TOP_GAME_SERVER_REPORT, Config.L2TOP_DUALBOXES_ALLOWED, Config.L2TOP_REWARD, Config.L2TOP_REWARD_CHECK_TIME));
 | 
			
		||||
				LOGGER.info("VoteSystem: L2top.co votes enabled.");
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.info("VoteSystem: L2top.co votes disabled.");
 | 
			
		||||
			}
 | 
			
		||||
			if (Config.ALLOW_L2JBRASIL_VOTE_REWARD)
 | 
			
		||||
			{
 | 
			
		||||
				voteSystems.add(new L2jbrasil(Config.L2JBRASIL_VOTES_DIFFERENCE, Config.ALLOW_L2JBRASIL_GAME_SERVER_REPORT, Config.L2JBRASIL_DUALBOXES_ALLOWED, Config.L2JBRASIL_REWARD, Config.L2JBRASIL_REWARD_CHECK_TIME));
 | 
			
		||||
				LOGGER.info("VoteSystem: L2JBrasil votes enabled.");
 | 
			
		||||
			}
 | 
			
		||||
			else
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.info("VoteSystem: L2JBrasil votes disabled.");
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.info("VoteSystem: Disabled.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public VoteSystem(int votesDiff, boolean allowReport, int boxes, Map<Integer, Integer> rewards, int checkMins)
 | 
			
		||||
	{
 | 
			
		||||
		this.votesDiff = votesDiff;
 | 
			
		||||
		this.allowReport = allowReport;
 | 
			
		||||
		this.boxes = boxes;
 | 
			
		||||
		this.rewards = rewards;
 | 
			
		||||
		ThreadPool.scheduleAtFixedRate(this, checkMins * 1000 * 60, checkMins * 1000 * 60);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	protected void reward()
 | 
			
		||||
	{
 | 
			
		||||
		final int currentVotes = getVotes();
 | 
			
		||||
		if (currentVotes == -1)
 | 
			
		||||
		{
 | 
			
		||||
			LOGGER.info("VoteSystem: There was a problem on getting server votes.");
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (lastVotes == 0)
 | 
			
		||||
		{
 | 
			
		||||
			lastVotes = currentVotes;
 | 
			
		||||
			announce(getSiteName() + ": Current vote count is " + currentVotes + ".");
 | 
			
		||||
			announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward.");
 | 
			
		||||
			if (allowReport)
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
 | 
			
		||||
				LOGGER.info("VoteSystem: Votes needed for reward: " + ((lastVotes + votesDiff) - currentVotes));
 | 
			
		||||
			}
 | 
			
		||||
			return;
 | 
			
		||||
		}
 | 
			
		||||
		
 | 
			
		||||
		if (currentVotes >= (lastVotes + votesDiff))
 | 
			
		||||
		{
 | 
			
		||||
			final Collection<Player> pls = World.getInstance().getPlayers();
 | 
			
		||||
			if (allowReport)
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
 | 
			
		||||
				LOGGER.info("VoteSystem: Votes needed for next reward: " + ((currentVotes + votesDiff) - currentVotes));
 | 
			
		||||
			}
 | 
			
		||||
			announce(getSiteName() + ": Everyone has been rewarded.");
 | 
			
		||||
			announce(getSiteName() + ": Current vote count is " + currentVotes + ".");
 | 
			
		||||
			announce(getSiteName() + ": We need " + votesDiff + " vote(s) for next reward.");
 | 
			
		||||
			for (Player p : pls)
 | 
			
		||||
			{
 | 
			
		||||
				if ((p.getClient() == null) || p.getClient().isDetached())
 | 
			
		||||
				{
 | 
			
		||||
					continue;
 | 
			
		||||
				}
 | 
			
		||||
				
 | 
			
		||||
				boolean canReward = false;
 | 
			
		||||
				final String pIp = p.getClient().getConnectionAddress().getHostAddress();
 | 
			
		||||
				if (playerIps.containsKey(pIp))
 | 
			
		||||
				{
 | 
			
		||||
					final int count = playerIps.get(pIp);
 | 
			
		||||
					if (count < boxes)
 | 
			
		||||
					{
 | 
			
		||||
						playerIps.remove(pIp);
 | 
			
		||||
						playerIps.put(pIp, count + 1);
 | 
			
		||||
						canReward = true;
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					canReward = true;
 | 
			
		||||
					playerIps.put(pIp, 1);
 | 
			
		||||
				}
 | 
			
		||||
				if (canReward)
 | 
			
		||||
				{
 | 
			
		||||
					for (Entry<Integer, Integer> entry : rewards.entrySet())
 | 
			
		||||
					{
 | 
			
		||||
						p.addItem("Vote reward.", entry.getKey(), entry.getValue(), p, true);
 | 
			
		||||
					}
 | 
			
		||||
				}
 | 
			
		||||
				else
 | 
			
		||||
				{
 | 
			
		||||
					p.sendMessage("Already " + boxes + " character(s) of your ip have been rewarded, so this character won't be rewarded.");
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
			playerIps.clear();
 | 
			
		||||
			
 | 
			
		||||
			lastVotes = currentVotes;
 | 
			
		||||
		}
 | 
			
		||||
		else
 | 
			
		||||
		{
 | 
			
		||||
			if (allowReport)
 | 
			
		||||
			{
 | 
			
		||||
				LOGGER.info("VoteSystem: Server votes on " + getSiteName() + ": " + currentVotes);
 | 
			
		||||
				LOGGER.info("VoteSystem: Votes needed for next reward: " + ((lastVotes + votesDiff) - currentVotes));
 | 
			
		||||
			}
 | 
			
		||||
			announce(getSiteName() + ": Current vote count is " + currentVotes + ".");
 | 
			
		||||
			announce(getSiteName() + ": We need " + ((lastVotes + votesDiff) - currentVotes) + " vote(s) for reward.");
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	private void announce(String msg)
 | 
			
		||||
	{
 | 
			
		||||
		Broadcast.toAllOnlinePlayers(new CreatureSay(null, ChatType.CRITICAL_ANNOUNCE, "", msg));
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	public abstract int getVotes();
 | 
			
		||||
	
 | 
			
		||||
	public abstract String getSiteName();
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user