Addition of L2jBrasil vote rewards.

Contributed by pecanha.
This commit is contained in:
MobiusDevelopment
2020-04-17 11:56:48 +00:00
parent 95bb4638c4
commit 6702f1fd55
68 changed files with 2278 additions and 17 deletions

View File

@@ -1329,6 +1329,13 @@ public class Config
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;
/**
* This class initializes all global variables for configuration.<br>
@@ -3530,6 +3537,19 @@ public class Config
}
L2TOP_DUALBOXES_ALLOWED = VoteReward.getInt("L2topDualboxesAllowed", 1);
ALLOW_L2TOP_GAME_SERVER_REPORT = VoteReward.getBoolean("AllowL2topGameServerReport", false);
ALLOW_L2JBRASIL_VOTE_REWARD = VoteReward.getBoolean("AllowL2JBrasilVoteReward", false);
L2JBRASIL_SERVER_LINK = VoteReward.getString("L2JBrasilServerLink", "");
L2JBRASIL_VOTES_DIFFERENCE = VoteReward.getInt("L2JBrasilVotesDifference", 5);
L2JBRASIL_REWARD_CHECK_TIME = VoteReward.getInt("L2JBrasilRewardCheckTime", 5);
String L2JBRASIL_SMALL_REWARD_VALUE = VoteReward.getString("L2JBrasilReward", "57,100000000;");
String[] l2jbrasil_small_reward_splitted_1 = L2JBRASIL_SMALL_REWARD_VALUE.split(";");
for (String i : l2jbrasil_small_reward_splitted_1)
{
String[] l2jbrasil_small_reward_splitted_2 = i.split(",");
HOPZONE_REWARD.put(Integer.parseInt(l2jbrasil_small_reward_splitted_2[0]), Integer.parseInt(l2jbrasil_small_reward_splitted_2[1]));
}
L2JBRASIL_DUALBOXES_ALLOWED = VoteReward.getInt("L2JBrasilDualboxesAllowed", 1);
ALLOW_L2JBRASIL_GAME_SERVER_REPORT = VoteReward.getBoolean("AllowL2JBrasilGameServerReport", false);
// Load WalkerBotProtection config file (if exists)
final PropertiesParser WalkerBotProtection = new PropertiesParser(CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE);

View File

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

View File

@@ -50,7 +50,7 @@ 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 || Config.ALLOW_L2TOP_VOTE_REWARD)
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)
@@ -89,6 +89,15 @@ public abstract class VoteSystem implements Runnable
{
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
{