Addition of L2top.co vote reward.

Contributed by andrei.
This commit is contained in:
MobiusDevelopment
2020-01-08 12:08:35 +00:00
parent 87a8181f8f
commit 382101d033
119 changed files with 2595 additions and 334 deletions

View File

@@ -1306,7 +1306,14 @@ public class Config
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;
/**
* This class initializes all global variables for configuration.<br>
* If the key doesn't appear in properties file, a default value is set by this class. {@link #SERVER_CONFIG_FILE} (properties file) for configuring your server.
@@ -3494,6 +3501,7 @@ public class Config
// Load VoteReward config file (if exists)
final PropertiesParser VoteReward = new PropertiesParser(CUSTOM_VOTE_REWARD_CONFIG_FILE);
// L2network.eu
ALLOW_NETWORK_VOTE_REWARD = VoteReward.getBoolean("AllowNetworkVoteReward", false);
NETWORK_SERVER_LINK = VoteReward.getString("NetworkServerLink", "");
NETWORK_VOTES_DIFFERENCE = VoteReward.getInt("NetworkVotesDifference", 5);
@@ -3507,6 +3515,7 @@ public class Config
}
NETWORK_DUALBOXES_ALLOWED = VoteReward.getInt("NetworkDualboxesAllowed", 1);
ALLOW_NETWORK_GAME_SERVER_REPORT = VoteReward.getBoolean("AllowNetworkGameServerReport", false);
// Topzone.com
ALLOW_TOPZONE_VOTE_REWARD = VoteReward.getBoolean("AllowTopzoneVoteReward", false);
TOPZONE_SERVER_LINK = VoteReward.getString("TopzoneServerLink", "");
TOPZONE_VOTES_DIFFERENCE = VoteReward.getInt("TopzoneVotesDifference", 5);
@@ -3520,6 +3529,7 @@ public class Config
}
TOPZONE_DUALBOXES_ALLOWED = VoteReward.getInt("TopzoneDualboxesAllowed", 1);
ALLOW_TOPZONE_GAME_SERVER_REPORT = VoteReward.getBoolean("AllowTopzoneGameServerReport", false);
// Hopzone.net
ALLOW_HOPZONE_VOTE_REWARD = VoteReward.getBoolean("AllowHopzoneVoteReward", false);
HOPZONE_SERVER_LINK = VoteReward.getString("HopzoneServerLink", "");
HOPZONE_VOTES_DIFFERENCE = VoteReward.getInt("HopzoneVotesDifference", 5);
@@ -3533,6 +3543,20 @@ public class Config
}
HOPZONE_DUALBOXES_ALLOWED = VoteReward.getInt("HopzoneDualboxesAllowed", 1);
ALLOW_HOPZONE_GAME_SERVER_REPORT = VoteReward.getBoolean("AllowHopzoneGameServerReport", false);
// L2top.co
ALLOW_L2TOP_VOTE_REWARD = VoteReward.getBoolean("AllowL2topVoteReward", false);
L2TOP_SERVER_LINK = VoteReward.getString("L2topServerLink", "");
L2TOP_VOTES_DIFFERENCE = VoteReward.getInt("L2topVotesDifference", 5);
L2TOP_REWARD_CHECK_TIME = VoteReward.getInt("L2topRewardCheckTime", 5);
final String L2TOP_SMALL_REWARD_VALUE = VoteReward.getString("L2topReward", "57,100000000;");
final String[] l2top_small_reward_splitted_1 = L2TOP_SMALL_REWARD_VALUE.split(";");
for (String i : l2top_small_reward_splitted_1)
{
final String[] l2top_small_reward_splitted_2 = i.split(",");
L2TOP_REWARD.put(Integer.parseInt(l2top_small_reward_splitted_2[0]), Integer.parseInt(l2top_small_reward_splitted_2[1]));
}
L2TOP_DUALBOXES_ALLOWED = VoteReward.getInt("L2topDualboxesAllowed", 1);
ALLOW_L2TOP_GAME_SERVER_REPORT = VoteReward.getBoolean("AllowL2topGameServerReport", false);
// Load WalkerBotProtection config file (if exists)
final PropertiesParser WalkerBotProtection = new PropertiesParser(CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE);

View File

@@ -67,7 +67,7 @@ public class Hopzone extends VoteSystem
}
catch (Exception e)
{
LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ". " + e);
LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
}
return -1;
@@ -76,6 +76,6 @@ public class Hopzone extends VoteSystem
@Override
public String getSiteName()
{
return "Hopzone";
return "Hopzone.net";
}
}

View File

@@ -0,0 +1,81 @@
/*
* 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";
}
}

View File

@@ -67,7 +67,7 @@ public class Network extends VoteSystem
}
catch (Exception e)
{
LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ". " + e);
LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
}
return -1;
@@ -76,6 +76,6 @@ public class Network extends VoteSystem
@Override
public String getSiteName()
{
return "Network";
return "L2network.eu";
}
}

View File

@@ -64,7 +64,7 @@ public class Topzone extends VoteSystem
}
catch (Exception e)
{
LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ". " + e);
LOGGER.warning("VoteSystem: Error while getting server vote count from " + getSiteName() + ".");
}
return -1;
@@ -73,6 +73,6 @@ public class Topzone extends VoteSystem
@Override
public String getSiteName()
{
return "Topzone";
return "Topzone.com";
}
}

View File

@@ -50,35 +50,44 @@ public abstract class VoteSystem implements Runnable
public static void initialize()
{
if (Config.ALLOW_NETWORK_VOTE_REWARD || Config.ALLOW_TOPZONE_VOTE_REWARD || Config.ALLOW_HOPZONE_VOTE_REWARD)
if (Config.ALLOW_NETWORK_VOTE_REWARD || Config.ALLOW_TOPZONE_VOTE_REWARD || Config.ALLOW_HOPZONE_VOTE_REWARD || Config.ALLOW_L2TOP_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: Network votes enabled.");
LOGGER.info("VoteSystem: L2network.eu votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Network votes disabled.");
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 votes enabled.");
LOGGER.info("VoteSystem: Topzone.com votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Topzone votes disabled.");
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 votes enabled.");
LOGGER.info("VoteSystem: Hopzone.net votes enabled.");
}
else
{
LOGGER.info("VoteSystem: Hopzone votes disabled.");
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.");
}
}
else