l2TopgameserverNet

L2jMobius-HighFive auto vote reward system - l2.topgameserver.net

Jan 2nd, 2021 (edited)
418
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
  2. index 0fd49e5..302361f 100644
  3. --- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
  4. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/MasterHandler.java
  5. @@ -301,6 +301,7 @@
  6.  import handlers.voicedcommandhandlers.ChatAdmin;
  7.  import handlers.voicedcommandhandlers.Lang;
  8.  import handlers.voicedcommandhandlers.Premium;
  9. +import handlers.voicedcommandhandlers.VoteReward;
  10.  import handlers.voicedcommandhandlers.Wedding;
  11.  
  12.  /**
  13. @@ -565,6 +566,7 @@
  14.             Config.ALLOW_CHANGE_PASSWORD ? ChangePassword.class : null,
  15.             Config.PREMIUM_SYSTEM_ENABLED ? Premium.class : null,
  16.             Config.AUTO_POTIONS_ENABLED ? AutoPotion.class : null,
  17. +           (Config.ENABLE_VOTE_SYSTEM && Config.ENABLE_INDIVIDUAL_VOTE && Config.ENABLE_VOTING_COMMAND ? VoteReward.class : null),
  18.         },
  19.         {
  20.             // Target Handlers
  21. diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/voicedcommandhandlers/VoteReward.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/voicedcommandhandlers/VoteReward.java
  22. new file mode 100644
  23. index 0000000..a74a4c1
  24. --- /dev/null
  25. +++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/voicedcommandhandlers/VoteReward.java
  26. @@ -0,0 +1,87 @@
  27. +/*
  28. + * This file is part of the L2J Mobius project.
  29. + *
  30. + * This program is free software: you can redistribute it and/or modify
  31. + * it under the terms of the GNU General Public License as published by
  32. + * the Free Software Foundation, either version 3 of the License, or
  33. + * (at your option) any later version.
  34. + *
  35. + * This program is distributed in the hope that it will be useful,
  36. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  37. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  38. + * General Public License for more details.
  39. + *
  40. + * You should have received a copy of the GNU General Public License
  41. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  42. + */
  43. +package handlers.voicedcommandhandlers;
  44. +
  45. +import org.l2jmobius.Config;
  46. +import org.l2jmobius.gameserver.handler.IVoicedCommandHandler;
  47. +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  48. +import org.l2jmobius.gameserver.votesystem.Enum.voteSite;
  49. +import org.l2jmobius.gameserver.votesystem.Handler.voteManager;
  50. +import org.l2jmobius.gameserver.votesystem.VoteUtil.VoteSiteXml;
  51. +
  52. +/**
  53. + * @author l2.topgameserver.net
  54. + */
  55. +public class VoteReward implements IVoicedCommandHandler
  56. +{
  57. +  
  58. +   @Override
  59. +   public boolean useVoicedCommand(String command, PlayerInstance player, String params)
  60. +   {
  61. +       if (command.equalsIgnoreCase(Config.VOTING_COMMAND))
  62. +       {
  63. +           if (player.isJailed())
  64. +           {
  65. +               player.sendMessage("You cannot use this function while you are jailed");
  66. +               return false;
  67. +           }
  68. +           if (!Config.ENABLE_VOTE_SYSTEM)
  69. +           {
  70. +               player.sendMessage("The rewards system has been disabled by your administrator");
  71. +               return false;
  72. +           }
  73. +           if (!Config.ENABLE_INDIVIDUAL_VOTE)
  74. +           {
  75. +               player.sendMessage("The individual reward system is disabled");
  76. +               return false;
  77. +           }
  78. +           if (!Config.ENABLE_VOTING_COMMAND)
  79. +           {
  80. +               player.sendMessage("Voting command reward is disabled");
  81. +               return false;
  82. +           }
  83. +          
  84. +           for (voteSite vs : voteSite.values())
  85. +           {
  86. +               new Thread(() ->
  87. +               {
  88. +                   voteManager.getInatance().getReward(player, vs.ordinal());
  89. +               }).start();
  90. +           }
  91. +          
  92. +           return true;
  93. +          
  94. +       }
  95. +       if (command.equalsIgnoreCase("reloadrewards") && player.isGM())
  96. +       {
  97. +           VoteSiteXml.getInstance().load();
  98. +           player.sendMessage("=============All reward has been reloaded=============");
  99. +           return true;
  100. +       }
  101. +       return false;
  102. +   }
  103. +  
  104. +   @Override
  105. +   public String[] getVoicedCommandList()
  106. +   {
  107. +       return new String[]
  108. +       {
  109. +           Config.VOTING_COMMAND,
  110. +       };
  111. +   }
  112. +  
  113. +}
  114. \ No newline at end of file
  115. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  116. index 54df061..e0a8db6 100644
  117. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  118. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/Config.java
  119.  
  120. import java.util.Properties;
  121. +import java.util.concurrent.TimeUnit;
  122. import java.util.logging.Level;
  123.  
  124. @@ -102,6 +102,7 @@
  125.     private static final String CHAT_FILTER_FILE = "./config/chatfilter.txt";
  126.     private static final String HEXID_FILE = "./config/hexid.txt";
  127.     private static final String IPCONFIG_FILE = "./config/ipconfig.xml";
  128. +   private static final String VOTE_SYSTEM_FILE = "./config/votesystem.ini";
  129.    
  130.     // --------------------------------------------------
  131.     // Custom Config File Definitions
  132. @@ -142,6 +143,50 @@
  133.     private static final String CUSTOM_WEDDING_CONFIG_FILE = "./config/Custom/Wedding.ini";
  134.     private static final String CUSTOM_WALKER_BOT_PROTECTION_CONFIG_FILE = "./config/Custom/WalkerBotProtection.ini";
  135.    
  136. +   // ---------------------------------------------------
  137. +   // VOTE SYSTEM
  138. +   // ---------------------------------------------------
  139. +   public static boolean ENABLE_VOTE_SYSTEM;
  140. +   public static boolean ENABLE_INDIVIDUAL_VOTE;
  141. +   public static boolean ENABLE_GLOBAL_VOTE;
  142. +   public static long NEXT_TIME_TO_AUTO_UPDATE_TOTAL_VOTE;
  143. +   public static long NEXT_TIME_TO_AUTO_UPDATE_INDIVIDUAL_VOTES;
  144. +   public static long NEXT_TIME_TO_AUTO_CLEAN_INECESARY_VOTES;
  145. +   public static long NEXT_TIME_TO_CHECK_AUTO_GLOBAL_VOTES_REWARD;
  146. +   public static long INTERVAL_TO_NEXT_VOTE;
  147. +   public static int GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD;
  148. +   public static boolean ENABLE_VOTING_COMMAND;
  149. +   public static String VOTING_COMMAND;
  150. +   public static String VOTE_LINK_TGS;
  151. +   public static String TGS_API_KEY;
  152. +   public static String VOTE_LINK_TOP_CO;
  153. +   public static String TOP_CO_SRV_ID;
  154. +   public static String VOTE_LINK_ITOPZ;
  155. +   public static String ITOPZ_API_KEY;
  156. +   public static String ITOPZ_SRV_ID;
  157. +   public static String VOTE_LINK_VTS;
  158. +   public static String VTS_API_KEY;
  159. +   public static String VTS_SID;
  160. +   public static String VOTE_LINK_HZ;
  161. +   public static String HZ_API_KEY;
  162. +   public static String VOTE_NETWORK_LINK;
  163. +   public static String VOTE_NETWORK_USER_NAME;
  164. +   public static String VOTE_NETWORK_API_KEY;
  165. +   public static String VOTE_LINK_TSS;
  166. +   public static String TSS_API_TOKEN;
  167. +   public static String TS_SRV_ID;
  168. +   public static String TS_DOMAIN_NAME;
  169. +   public static String BRASIL_VOTE_LINK;
  170. +   public static String BRASIL_USER_NAME;
  171. +   public static String VOTE_LINK_MMOTOP;
  172. +   public static String MMOTOP_API_KEY;
  173. +   public static String VOTE_LINK_TZ;
  174. +   public static String TZ_API_KEY;
  175. +   public static String VOTE_LINK_SERVERS;
  176. +   public static String SERVERS_HASH_CODE;
  177. +   public static String SERVERS_SRV_ID;
  178. +   public static String TEST_IP;
  179. +  
  180.     // --------------------------------------------------
  181.     // Variable Definitions
  182.     // --------------------------------------------------
  183. @@ -2944,6 +2989,50 @@
  184.                 }
  185.             }
  186.            
  187. +           // Load VoteSystem config file
  188. +           final PropertiesParser votesystem = new PropertiesParser(VOTE_SYSTEM_FILE);
  189. +          
  190. +           ENABLE_VOTE_SYSTEM = votesystem.getBoolean("EnableVoteSystem", true);
  191. +           ENABLE_INDIVIDUAL_VOTE = votesystem.getBoolean("EnableIndividualVote", true);
  192. +           ENABLE_GLOBAL_VOTE = votesystem.getBoolean("EnableGlobalVote", true);
  193. +           NEXT_TIME_TO_AUTO_UPDATE_TOTAL_VOTE = TimeUnit.MINUTES.toMillis(votesystem.getInt("NextTimeToAutoUpdateTotalVote", 60));// -> minutes
  194. +           NEXT_TIME_TO_AUTO_UPDATE_INDIVIDUAL_VOTES = TimeUnit.MINUTES.toMillis(votesystem.getInt("NextTimeToAutoUpdateIndividualVotes", 60));// -> minutes
  195. +           NEXT_TIME_TO_AUTO_CLEAN_INECESARY_VOTES = TimeUnit.MINUTES.toMillis(votesystem.getInt("NextTimeToAutoCleanInnecesaryVotes", 30));// -> minutes
  196. +           NEXT_TIME_TO_CHECK_AUTO_GLOBAL_VOTES_REWARD = TimeUnit.MINUTES.toMillis(votesystem.getInt("NextTimeToCheckAutoGlobalVotesReward", 5));// -> minutes
  197. +           INTERVAL_TO_NEXT_VOTE = TimeUnit.HOURS.toMillis(votesystem.getInt("IntervalTimeToNextVote", 12)); // -> hours
  198. +           GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD = votesystem.getInt("GlobalVotesAmountToNextReward", 50);
  199. +           ENABLE_VOTING_COMMAND = votesystem.getBoolean("EnableVotingCommand", true);
  200. +           VOTING_COMMAND = votesystem.getString("VotingCommand", "getreward");
  201. +           VOTE_LINK_TGS = votesystem.getString("VoteLinkTgs", "");
  202. +           TGS_API_KEY = votesystem.getString("TgsApiKey", "");
  203. +           VOTE_LINK_TOP_CO = votesystem.getString("VoteLinkTopCo", "");
  204. +           TOP_CO_SRV_ID = votesystem.getString("TopCoSrvId", "");
  205. +           VOTE_LINK_ITOPZ = votesystem.getString("VoteLinkItopz", "");
  206. +           ITOPZ_API_KEY = votesystem.getString("ItopzZpiKey", "");
  207. +           ITOPZ_SRV_ID = votesystem.getString("ItopzSrvId", "");
  208. +           VOTE_LINK_VTS = votesystem.getString("VoteLinkVts", "");
  209. +           VTS_API_KEY = votesystem.getString("VtsApiKey", "");
  210. +           VTS_SID = votesystem.getString("VtsSid", "");
  211. +           VOTE_LINK_HZ = votesystem.getString("VoteLinkHz", "");
  212. +           HZ_API_KEY = votesystem.getString("HzApiKey", "");
  213. +           VOTE_NETWORK_LINK = votesystem.getString("VoteNetworkLink", "");
  214. +           VOTE_NETWORK_USER_NAME = votesystem.getString("VoteNetworkUserName", "");
  215. +           VOTE_NETWORK_API_KEY = votesystem.getString("VoteNetworkApiKey", "");
  216. +           VOTE_LINK_TSS = votesystem.getString("VoteLinkTss", "");
  217. +           TSS_API_TOKEN = votesystem.getString("TssApiToken", "");
  218. +           TS_SRV_ID = votesystem.getString("TsSrvId", "");
  219. +           TS_DOMAIN_NAME = votesystem.getString("TsDomainName", "");
  220. +           BRASIL_VOTE_LINK = votesystem.getString("BrasilVoteLink", "");
  221. +           BRASIL_USER_NAME = votesystem.getString("BrasilUserName", "");
  222. +           VOTE_LINK_MMOTOP = votesystem.getString("VoteLinkMmotop", "");
  223. +           MMOTOP_API_KEY = votesystem.getString("MmotopApiKey", "");
  224. +           VOTE_LINK_TZ = votesystem.getString("VoteLinkTz", "");
  225. +           TZ_API_KEY = votesystem.getString("TzApiKey", "");
  226. +           VOTE_LINK_SERVERS = votesystem.getString("VoteLinkServers", "");
  227. +           SERVERS_HASH_CODE = votesystem.getString("ServersHashCode", "");
  228. +           SERVERS_SRV_ID = votesystem.getString("ServersSrvId", "");
  229. +           TEST_IP = votesystem.getString("TestIp", "");
  230. +          
  231.             // Load PrivateStoreRange config file (if exists)
  232.             final PropertiesParser PrivateStoreRange = new PropertiesParser(CUSTOM_PRIVATE_STORE_RANGE_CONFIG_FILE);
  233.             SHOP_MIN_RANGE_FROM_PLAYER = PrivateStoreRange.getInt("ShopMinRangeFromPlayer", 50);
  234. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/StatsSet.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/StatsSet.java
  235. new file mode 100644
  236. index 0000000..cb54758
  237. --- /dev/null
  238. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/commons/util/StatsSet.java
  239. @@ -0,0 +1,91 @@
  240. +/*
  241. + * This file is part of the L2J Mobius project.
  242. + *
  243. + * This program is free software: you can redistribute it and/or modify
  244. + * it under the terms of the GNU General Public License as published by
  245. + * the Free Software Foundation, either version 3 of the License, or
  246. + * (at your option) any later version.
  247. + *
  248. + * This program is distributed in the hope that it will be useful,
  249. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  250. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  251. + * General Public License for more details.
  252. + *
  253. + * You should have received a copy of the GNU General Public License
  254. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  255. + */
  256. +package org.l2jmobius.commons.util;
  257. +
  258. +import java.util.HashMap;
  259. +
  260. +/**
  261. + * @author escor
  262. + */
  263. +public class StatsSet extends HashMap<String, Object>
  264. +{
  265. +  
  266. +   public StatsSet()
  267. +   {
  268. +       super();
  269. +   }
  270. +  
  271. +   public StatsSet(final StatsSet set)
  272. +   {
  273. +       super(set);
  274. +   }
  275. +  
  276. +   public void set(final String key, final Object value)
  277. +   {
  278. +       put(key, value);
  279. +   }
  280. +  
  281. +   public void set(final String key, final int value)
  282. +   {
  283. +       put(key, value);
  284. +   }
  285. +  
  286. +   public void set(final String key, final int[] value)
  287. +   {
  288. +       put(key, value);
  289. +   }
  290. +  
  291. +   public int getInteger(final String key)
  292. +   {
  293. +       final Object val = get(key);
  294. +      
  295. +       if (val instanceof Number)
  296. +       {
  297. +           return ((Number) val).intValue();
  298. +       }
  299. +       if (val instanceof String)
  300. +       {
  301. +           return Integer.parseInt((String) val);
  302. +       }
  303. +       if (val instanceof Boolean)
  304. +       {
  305. +           return (Boolean) val ? 1 : 0;
  306. +       }
  307. +      
  308. +       throw new IllegalArgumentException("StatsSet : Integer value required, but found: " + val + " for key: " + key + ".");
  309. +   }
  310. +  
  311. +   public int getInteger(final String key, final int defaultValue)
  312. +   {
  313. +       final Object val = get(key);
  314. +      
  315. +       if (val instanceof Number)
  316. +       {
  317. +           return ((Number) val).intValue();
  318. +       }
  319. +       if (val instanceof String)
  320. +       {
  321. +           return Integer.parseInt((String) val);
  322. +       }
  323. +       if (val instanceof Boolean)
  324. +       {
  325. +           return (Boolean) val ? 1 : 0;
  326. +       }
  327. +      
  328. +       return defaultValue;
  329. +   }
  330. +}
  331. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
  332. index fe14f71..e7dc1ee 100644
  333. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
  334. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/GameServer.java
  335. @@ -153,6 +153,8 @@
  336.  import org.l2jmobius.gameserver.taskmanager.TaskManager;
  337.  import org.l2jmobius.gameserver.ui.Gui;
  338.  import org.l2jmobius.gameserver.util.Broadcast;
  339. +import org.l2jmobius.gameserver.votesystem.Handler.voteManager;
  340. +import org.l2jmobius.gameserver.votesystem.VoteUtil.VoteSiteXml;
  341.  
  342.  public class GameServer
  343.  {
  344. @@ -307,6 +309,19 @@
  345.         GrandBossManager.getInstance().initZones();
  346.         EventDroplist.getInstance();
  347.        
  348. +       // load vote reward system
  349. +       printSection("Vote Reward System");
  350. +       if (Config.ENABLE_VOTE_SYSTEM)
  351. +       {
  352. +           voteManager.getInatance();
  353. +           LOGGER.info("======================Vote System Enabled=========================");
  354. +           VoteSiteXml.getInstance();
  355. +       }
  356. +       else
  357. +       {
  358. +           LOGGER.info("======================Vote System Disabled=========================");
  359. +       }
  360. +      
  361.         printSection("Olympiad");
  362.         Olympiad.getInstance();
  363.         Hero.getInstance();
  364. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/Shutdown.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/Shutdown.java
  365. index 9c89c5a..10eb637 100644
  366. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/Shutdown.java
  367. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/Shutdown.java
  368. @@ -49,6 +49,7 @@
  369.  import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
  370.  import org.l2jmobius.gameserver.network.telnet.TelnetServer;
  371.  import org.l2jmobius.gameserver.util.Broadcast;
  372. +import org.l2jmobius.gameserver.votesystem.Handler.voteManager;
  373.  
  374.  /**
  375.   * This class provides the functions for shutting down and restarting the server.<br>
  376. @@ -499,6 +500,19 @@
  377.             LOGGER.info("Items On Ground Manager: Cleaned up(" + tc.getEstimatedTimeAndRestartCounter() + "ms).");
  378.         }
  379.        
  380. +       // sava individual votes data
  381. +       if (Config.ENABLE_VOTE_SYSTEM)
  382. +       {
  383. +           voteManager.getInatance().Shutdown();
  384. +       }
  385. +      
  386. +       // Save bot reports to database
  387. +       if (Config.BOTREPORT_ENABLE)
  388. +       {
  389. +           BotReportTable.getInstance().saveReportedCharData();
  390. +           LOGGER.info("Bot Report Table: Successfully saved reports to database!");
  391. +       }
  392. +      
  393.         // Save bot reports to database
  394.         if (Config.BOTREPORT_ENABLE)
  395.         {
  396. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/NpcVoteRewardInstance.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/NpcVoteRewardInstance.java
  397. new file mode 100644
  398. index 0000000..0f96805
  399. --- /dev/null
  400. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/model/actor/instance/NpcVoteRewardInstance.java
  401. @@ -0,0 +1,119 @@
  402. +/*
  403. + * This file is part of the L2J Mobius project.
  404. + *
  405. + * This program is free software: you can redistribute it and/or modify
  406. + * it under the terms of the GNU General Public License as published by
  407. + * the Free Software Foundation, either version 3 of the License, or
  408. + * (at your option) any later version.
  409. + *
  410. + * This program is distributed in the hope that it will be useful,
  411. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  412. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  413. + * General Public License for more details.
  414. + *
  415. + * You should have received a copy of the GNU General Public License
  416. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  417. + */
  418. +package org.l2jmobius.gameserver.model.actor.instance;
  419. +
  420. +import org.l2jmobius.Config;
  421. +import org.l2jmobius.gameserver.datatables.ItemTable;
  422. +import org.l2jmobius.gameserver.model.actor.templates.NpcTemplate;
  423. +import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
  424. +import org.l2jmobius.gameserver.votesystem.Enum.voteSite;
  425. +import org.l2jmobius.gameserver.votesystem.Handler.voteManager;
  426. +import org.l2jmobius.gameserver.votesystem.Model.Reward;
  427. +import org.l2jmobius.gameserver.votesystem.VoteUtil.VoteSiteXml;
  428. +
  429. +/**
  430. + * @author l2.topgameserver.net
  431. + */
  432. +public class NpcVoteRewardInstance extends NpcInstance
  433. +{
  434. +  
  435. +   /**
  436. +    * @param template
  437. +    */
  438. +   public NpcVoteRewardInstance(NpcTemplate template)
  439. +   {
  440. +       super(template);
  441. +   }
  442. +  
  443. +   @Override
  444. +   public void onBypassFeedback(PlayerInstance player, String command)
  445. +   {
  446. +       if (command == null)
  447. +       {
  448. +           return;
  449. +       }
  450. +       int Ordinalsite = Integer.parseInt(command);
  451. +       voteManager.getInatance().getReward(player, Ordinalsite);
  452. +       showChatWindow(player, 0);
  453. +       super.onBypassFeedback(player, command);
  454. +   }
  455. +  
  456. +   @Override
  457. +   public void showChatWindow(PlayerInstance player, int val)
  458. +   {
  459. +      
  460. +       final NpcHtmlMessage html = new NpcHtmlMessage(0);
  461. +       StringBuilder sb = new StringBuilder();
  462. +       html.setFile(player, getHtmlPath(this.getTemplate().getId(), 0));
  463. +       if (Config.ENABLE_VOTE_SYSTEM && Config.ENABLE_INDIVIDUAL_VOTE)
  464. +       {
  465. +           for (voteSite vs : voteSite.values())
  466. +           {
  467. +               sb.append("<table bgcolor=000000 width=280><tr>");
  468. +               sb.append("<td width=42><img src=\"icon.etc_treasure_box_i08\" width=32 height=32></td>");
  469. +               sb.append("<td width=220><table width=220>");
  470. +               sb.append("<tr><td><table width=220><tr><td width=145>On " + String.format("%s", VoteSiteXml.getInstance().getSiteName(vs.ordinal())) + "</td>");
  471. +               if (voteManager.getInatance().checkIndividualAvailableVote(player, vs.ordinal()))
  472. +               {
  473. +                   sb.append("<td width=75>" + String.format("<button value=\"Get reward\" action=\"bypass -h vote_%s_site %s\" height=17 width=64 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\">", getObjectId(), vs.ordinal()) + "</td>");
  474. +               }
  475. +               else
  476. +               {
  477. +                   sb.append(String.format("<td width=75 align=center><font color=C68E00>%s</font></td>", voteManager.getInatance().getTimeRemainingWithSampleFormat(player, vs.ordinal())));
  478. +               }
  479. +               sb.append("</tr></table></td></tr>");
  480. +               sb.append("<tr><td><table width=220><tr>");
  481. +               int i = 0;
  482. +               for (Reward r : VoteSiteXml.getInstance().getRewards(vs.ordinal()))
  483. +               {
  484. +                   sb.append(String.format("<td width=110 height=32 align=center><font color=BFAF00>%s x%s</font></td>", ItemTable.getInstance().getTemplate(r.getItemId()).getName(), r.getItemCount()));
  485. +                   i++;
  486. +                   if ((i % 2) == 0)
  487. +                   {
  488. +                       sb.append("</tr><tr>");
  489. +                   }
  490. +               }
  491. +               sb.append("</tr></table></td></tr></table></td></tr></table><br>");
  492. +           }
  493. +       }
  494. +       else
  495. +       {
  496. +           sb.append("<table bgcolor=000000 width=280><tr><td><p><font color=#bfb300 >Individual vote system has been disabled for your server owner.</font></p></td></tr></table>");
  497. +       }
  498. +       html.replace("%everyXtime%", Config.INTERVAL_TO_NEXT_VOTE / (3600 * 1000));
  499. +       html.replace("%enablevote%", sb.toString());
  500. +       html.replace("%accountName%", player.getName());
  501. +       player.sendPacket(html);
  502. +   }
  503. +  
  504. +   @Override
  505. +   public String getHtmlPath(int npcId, int val)
  506. +   {
  507. +       String filename = "";
  508. +       if (val == 0)
  509. +       {
  510. +           filename = "" + npcId;
  511. +       }
  512. +       else
  513. +       {
  514. +           filename = npcId + "-" + val;
  515. +       }
  516. +      
  517. +       return "data/html/mods/votesystem/" + filename + ".html";
  518. +   }
  519. +  
  520. +}
  521. \ No newline at end of file
  522. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java
  523. index eeb6178..a842cd3 100644
  524. --- a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java
  525. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/network/clientpackets/RequestBypassToServer.java
  526. @@ -132,6 +132,29 @@
  527.             {
  528.                 comeHere(player);
  529.             }
  530. +           else if (_command.startsWith("vote_"))
  531. +           {
  532. +              
  533. +               int endOfId = _command.indexOf('_', 6);
  534. +               String id;
  535. +               if (endOfId > 0)
  536. +               {
  537. +                   id = _command.substring(5, endOfId);
  538. +               }
  539. +               else
  540. +               {
  541. +                   id = _command.substring(5);
  542. +               }
  543. +              
  544. +               if (_command.split(" ")[1].toString() != null)
  545. +               {
  546. +                   final WorldObject object = World.getInstance().findObject(Integer.parseInt(id));
  547. +                   if ((object != null) && object.isNpc() && (endOfId > 0) && player.isInsideRadius2D(object, Npc.INTERACTION_DISTANCE))
  548. +                   {
  549. +                       ((Npc) object).onBypassFeedback(player, _command.split(" ")[1].toString());
  550. +                   }
  551. +               }
  552. +           }
  553.             else if (_command.startsWith("npc_"))
  554.             {
  555.                 final int endOfId = _command.indexOf('_', 5);
  556. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/DB/globalVoteDB.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/DB/globalVoteDB.java
  557. new file mode 100644
  558. index 0000000..899b19c
  559. --- /dev/null
  560. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/DB/globalVoteDB.java
  561. @@ -0,0 +1,123 @@
  562. +package org.l2jmobius.gameserver.votesystem.DB;
  563. +
  564. +import java.sql.Connection;
  565. +import java.sql.PreparedStatement;
  566. +import java.sql.ResultSet;
  567. +import java.sql.SQLException;
  568. +import java.sql.Statement;
  569. +import java.util.logging.Logger;
  570. +
  571. +import org.l2jmobius.commons.database.DatabaseFactory;
  572. +import org.l2jmobius.gameserver.votesystem.Enum.voteSite;
  573. +import org.l2jmobius.gameserver.votesystem.Model.globalVote;
  574. +
  575. +/**
  576. + * @author l2.topgameserver.net
  577. + */
  578. +public class globalVoteDB
  579. +{
  580. +   public static final Logger LOGGER = Logger.getLogger(globalVoteDB.class.getName());
  581. +   private Statement st;
  582. +   private Connection con;
  583. +   private final globalVote[] _globalVotes;
  584. +  
  585. +   private globalVoteDB()
  586. +   {
  587. +       _globalVotes = new globalVote[voteSite.values().length];
  588. +       loadGlobalVotes();
  589. +   }
  590. +  
  591. +   public void loadGlobalVotes()
  592. +   {
  593. +       con = DatabaseFactory.getConnection();
  594. +       try (PreparedStatement ps = con.prepareStatement("Select voteSite,lastRewardVotes from globalvotes");
  595. +           ResultSet rs = ps.executeQuery();)
  596. +       {
  597. +           if (rs.getRow() == 0)
  598. +           {
  599. +               for (voteSite vs : voteSite.values())
  600. +               {
  601. +                   globalVote gv = new globalVote();
  602. +                   gv.setVoteSite(vs.ordinal());
  603. +                   gv.setVotesLastReward(0);
  604. +                   _globalVotes[gv.getVoyeSite()] = gv;
  605. +               }
  606. +               return;
  607. +           }
  608. +           while (rs.next())
  609. +           {
  610. +               globalVote gv = new globalVote();
  611. +               gv.setVoteSite(rs.getInt("voteSite"));
  612. +               gv.setVotesLastReward(rs.getInt("lastRewardVotes"));
  613. +               _globalVotes[gv.getVoyeSite()] = gv;
  614. +           }
  615. +           ps.close();
  616. +           con.close();
  617. +          
  618. +       }
  619. +       catch (SQLException e)
  620. +       {
  621. +           e.printStackTrace();
  622. +       }
  623. +   }
  624. +  
  625. +   public void saveGlobalVote(globalVote gb)
  626. +   {
  627. +       try (Connection con = DatabaseFactory.getConnection();
  628. +           PreparedStatement ps = con.prepareStatement("INSERT INTO globalvotes(voteSite,lastRewardVotes) VALUES(?,?)" + "ON DUPLICATE KEY UPDATE voteSite = VALUES(voteSite), lastRewardVotes = VALUES(lastRewardVotes)"))
  629. +      
  630. +       {
  631. +           ps.setInt(1, gb.getVoyeSite());
  632. +           ps.setInt(2, gb.getVotesLastReward());
  633. +           ps.executeUpdate();
  634. +          
  635. +           ps.close();
  636. +           con.close();
  637. +          
  638. +       }
  639. +       catch (SQLException e)
  640. +       {
  641. +           e.printStackTrace();
  642. +       }
  643. +   }
  644. +  
  645. +   public void saveGlobalVotes(globalVote[] globalVotes)
  646. +   {
  647. +       try (Connection con = DatabaseFactory.getConnection();
  648. +           PreparedStatement ps = con.prepareStatement("INSERT INTO globalvotes(voteSite,lastRewardVotes) VALUES(?,?)" + "ON DUPLICATE KEY UPDATE voteSite = VALUES(voteSite), lastRewardVotes = VALUES(lastRewardVotes)"))
  649. +      
  650. +       {
  651. +           for (voteSite vs : voteSite.values())
  652. +           {
  653. +               globalVote gb = globalVotes[vs.ordinal()];
  654. +               ps.setInt(1, gb.getVoyeSite());
  655. +               ps.setInt(2, gb.getVotesLastReward());
  656. +               ps.addBatch();
  657. +           }
  658. +           ps.executeBatch();
  659. +          
  660. +           ps.close();
  661. +           con.close();
  662. +          
  663. +       }
  664. +       catch (SQLException e)
  665. +       {
  666. +           e.printStackTrace();
  667. +       }
  668. +   }
  669. +  
  670. +   public globalVote[] getGlobalVotes()
  671. +   {
  672. +       return _globalVotes;
  673. +   }
  674. +  
  675. +   public static final globalVoteDB getInstance()
  676. +   {
  677. +       return SingleHolder.INSTANCE;
  678. +   }
  679. +  
  680. +   private static final class SingleHolder
  681. +   {
  682. +       protected static final globalVoteDB INSTANCE = new globalVoteDB();
  683. +   }
  684. +}
  685. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/DB/individualVoteDB.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/DB/individualVoteDB.java
  686. new file mode 100644
  687. index 0000000..fa9fbe1
  688. --- /dev/null
  689. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/DB/individualVoteDB.java
  690. @@ -0,0 +1,183 @@
  691. +package org.l2jmobius.gameserver.votesystem.DB;
  692. +
  693. +import java.sql.Connection;
  694. +import java.sql.PreparedStatement;
  695. +import java.sql.ResultSet;
  696. +import java.sql.SQLException;
  697. +import java.sql.Statement;
  698. +import java.util.HashMap;
  699. +import java.util.HashSet;
  700. +import java.util.Map;
  701. +import java.util.logging.Logger;
  702. +
  703. +import org.l2jmobius.commons.database.DatabaseFactory;
  704. +import org.l2jmobius.gameserver.votesystem.Enum.voteSite;
  705. +import org.l2jmobius.gameserver.votesystem.Model.individualVote;
  706. +
  707. +/**
  708. + * @author l2.topgameserver.net
  709. + */
  710. +public class individualVoteDB
  711. +{
  712. +   private static final Logger LOGGER = Logger.getLogger(individualVoteDB.class.getName());
  713. +   private final Map<String, individualVote[]> _votes;
  714. +   private Statement st;
  715. +   private Connection con;
  716. +  
  717. +   private individualVoteDB()
  718. +   {
  719. +       _votes = new HashMap<>();
  720. +       loadVotes();
  721. +   }
  722. +  
  723. +   public void loadVotes()
  724. +   {
  725. +      
  726. +       _votes.clear();
  727. +       try (Connection con = DatabaseFactory.getConnection();
  728. +           PreparedStatement ps = con.prepareStatement("SELECT voterIp,voteSite,diffTime,votingTimeSite,alreadyRewarded FROM individualvotes");
  729. +           ResultSet rs = ps.executeQuery();)
  730. +       {
  731. +           individualVote[] ivs = new individualVote[voteSite.values().length];
  732. +           while (rs.next())
  733. +           {
  734. +               individualVote iv = new individualVote();
  735. +               iv.setVoterIp(rs.getString("voterIp"));
  736. +               iv.setVoteSite(rs.getInt("voteSite"));
  737. +               iv.setDiffTime(rs.getLong("diffTime"));
  738. +               iv.setVotingTimeSite(rs.getLong("votingTimeSite"));
  739. +               iv.setAlreadyRewarded(rs.getBoolean("alreadyRewarded"));
  740. +              
  741. +               if (_votes.containsKey(iv.getVoterIp()))
  742. +               {
  743. +                   if (_votes.get(iv.getVoterIp())[iv.getVoteSite()] == null)
  744. +                   {
  745. +                       ivs[iv.getVoteSite()] = iv;
  746. +                       _votes.replace(iv.getVoterIp(), ivs);
  747. +                   }
  748. +               }
  749. +               else
  750. +               {
  751. +                   ivs[iv.getVoteSite()] = iv;
  752. +                   _votes.put(iv.getVoterIp(), ivs);
  753. +                  
  754. +               }
  755. +           }
  756. +          
  757. +       }
  758. +       catch (SQLException e)
  759. +       {
  760. +           e.printStackTrace();
  761. +       }
  762. +      
  763. +   }
  764. +  
  765. +   public void SaveVotes(Map<String, individualVote[]> votes)
  766. +   {
  767. +      
  768. +       if (votes == null)
  769. +       {
  770. +           return;
  771. +       }
  772. +       if (votes.size() == 0)
  773. +       {
  774. +           return;
  775. +       }
  776. +       try (Connection con = DatabaseFactory.getConnection();
  777. +           PreparedStatement ps = con.prepareStatement("INSERT INTO individualvotes(voterIp,voteSite,diffTime,votingTimeSite,alreadyRewarded) VALUES(?,?,?,?,?) ON DUPLICATE KEY UPDATE " + "voterIp = VALUES(voterIp), voteSite = VALUES(voteSite), diffTime = VALUES(diffTime), votingTimeSite = VALUES(votingTimeSite),alreadyRewarded = VALUES(alreadyRewarded)");)
  778. +       {
  779. +          
  780. +           for (Map.Entry<String, individualVote[]> ivm : votes.entrySet())
  781. +           {
  782. +               for (individualVote iv : ivm.getValue())
  783. +               {
  784. +                   if (iv == null)
  785. +                   {
  786. +                       continue;
  787. +                   }
  788. +                   ps.setString(1, iv.getVoterIp());
  789. +                   ps.setInt(2, iv.getVoteSite());
  790. +                   ps.setLong(3, iv.getDiffTime());
  791. +                   ps.setLong(4, iv.getVotingTimeSite());
  792. +                   ps.setBoolean(5, iv.getAlreadyRewarded());
  793. +                   ps.addBatch();
  794. +               }
  795. +           }
  796. +           ps.executeBatch();
  797. +       }
  798. +       catch (SQLException e)
  799. +       {
  800. +           e.printStackTrace();
  801. +       }
  802. +   }
  803. +  
  804. +   public void SaveVote(individualVote vote)
  805. +   {
  806. +      
  807. +       if (vote == null)
  808. +       {
  809. +           return;
  810. +       }
  811. +      
  812. +       try (Connection con = DatabaseFactory.getConnection();
  813. +           PreparedStatement ps = con.prepareStatement("INSERT INTO individualvotes(voterIp,voteSite,diffTime,votingTimeSite,alreadyRewarded) VALUES(?,?,?,?,?) ON DUPLICATE KEY UPDATE" + "voterIp = VALUES(voterIp), voteSite = VALUES(voteSite), diffTime = VALUES(diffTime), votingTimeSite = VALUES(votingTimeSite), alreadyRewarded = VALUES(alreadyRewarded)");)
  814. +       {
  815. +           ps.setString(1, vote.getVoterIp());
  816. +           ps.setInt(2, vote.getVoteSite());
  817. +           ps.setLong(3, vote.getDiffTime());
  818. +           ps.setLong(4, vote.getVotingTimeSite());
  819. +           ps.setBoolean(5, vote.getAlreadyRewarded());
  820. +           ps.executeUpdate();
  821. +       }
  822. +       catch (SQLException e)
  823. +       {
  824. +           e.printStackTrace();
  825. +       }
  826. +   }
  827. +  
  828. +   public void DeleteVotes(HashSet<individualVote> deleteVotes)
  829. +   {
  830. +       if (deleteVotes == null)
  831. +       {
  832. +           return;
  833. +       }
  834. +       if (deleteVotes.size() == 0)
  835. +       {
  836. +           return;
  837. +       }
  838. +       try
  839. +       {
  840. +           con = DatabaseFactory.getConnection();
  841. +           st = con.createStatement();
  842. +           for (individualVote iv : deleteVotes)
  843. +           {
  844. +               String sql = String.format("Delete from individualvotes where voterIp = '%s' AND voteSite = %s", iv.getVoterIp(), iv.getVoteSite());
  845. +               st.addBatch(sql);
  846. +           }
  847. +           int[] result = st.executeBatch();
  848. +           st.close();
  849. +           con.close();
  850. +           LOGGER.info(result.length + " Innecesary votes has been deleted");
  851. +          
  852. +       }
  853. +       catch (SQLException e)
  854. +       {
  855. +           e.printStackTrace();
  856. +       }
  857. +   }
  858. +  
  859. +   public Map<String, individualVote[]> getVotesDB()
  860. +   {
  861. +       return _votes;
  862. +   }
  863. +  
  864. +   public static final individualVoteDB getInstance()
  865. +   {
  866. +       return SingleHolder.INSTANCE;
  867. +   }
  868. +  
  869. +   private static final class SingleHolder
  870. +   {
  871. +       protected static final individualVoteDB INSTANCE = new individualVoteDB();
  872. +   }
  873. +}
  874. \ No newline at end of file
  875. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Enum/voteSite.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Enum/voteSite.java
  876. new file mode 100644
  877. index 0000000..9218452
  878. --- /dev/null
  879. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Enum/voteSite.java
  880. @@ -0,0 +1,19 @@
  881. +package org.l2jmobius.gameserver.votesystem.Enum;
  882. +
  883. +/**
  884. + * @author l2.topgameserver.net
  885. + */
  886. +public enum voteSite
  887. +{
  888. +   L2TOPGAMESERVER, // 0
  889. +   ITOPZ, // 1
  890. +   L2TOPCO, // 2
  891. +   L2VOTES, // 3
  892. +   HOPZONE, // 4
  893. +   L2NETWORK, // 5
  894. +   L2TOPSERVERS, // 6
  895. +   TOPL2JBRASIL, // 7
  896. +   MMOTOP, // 8
  897. +   TOPZONE, // 9
  898. +   L2SERVERS,// 10
  899. +}
  900. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Handler/voteHandler.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Handler/voteHandler.java
  901. new file mode 100644
  902. index 0000000..c1add0a
  903. --- /dev/null
  904. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Handler/voteHandler.java
  905. @@ -0,0 +1,509 @@
  906. +package org.l2jmobius.gameserver.votesystem.Handler;
  907. +
  908. +import java.io.BufferedReader;
  909. +import java.io.DataOutputStream;
  910. +import java.io.InputStreamReader;
  911. +import java.net.HttpURLConnection;
  912. +import java.net.URL;
  913. +import java.nio.charset.Charset;
  914. +import java.text.ParseException;
  915. +import java.text.SimpleDateFormat;
  916. +import java.util.logging.Logger;
  917. +
  918. +import org.l2jmobius.Config;
  919. +import org.l2jmobius.gameserver.votesystem.Enum.voteSite;
  920. +import org.l2jmobius.gameserver.votesystem.Model.individualVoteResponse;
  921. +import org.l2jmobius.gameserver.votesystem.VoteUtil.VoteSiteXml;
  922. +import org.l2jmobius.gameserver.votesystem.VoteUtil.VoteUtil;
  923. +
  924. +/**
  925. + * @author l2.topgameserver.net
  926. + */
  927. +public class voteHandler
  928. +{
  929. +   public static final Logger LOGGER = Logger.getLogger(voteHandler.class.getName());
  930. +  
  931. +   protected static String getNetWorkResponse(String URL, int ordinal)
  932. +   {
  933. +       if ((ordinal == voteSite.L2NETWORK.ordinal()) && ("".equals(Config.VOTE_NETWORK_API_KEY) || "".equals(Config.VOTE_NETWORK_LINK) || "".equals(Config.VOTE_NETWORK_USER_NAME)))
  934. +       {
  935. +           return "";
  936. +       }
  937. +      
  938. +       StringBuffer response = new StringBuffer();
  939. +       try
  940. +       {
  941. +           String API_URL = Config.VOTE_NETWORK_LINK;
  942. +           String detail = URL;
  943. +           String postParameters = "";
  944. +           postParameters += "apiKey=" + VoteUtil.between("apiKey=", detail, "&type=");
  945. +           postParameters += "&type=" + VoteUtil.between("&type=", detail, "&player");
  946. +           String beginIndexPlayer = "&player=";
  947. +           String player = detail.substring(detail.indexOf(beginIndexPlayer) + beginIndexPlayer.length());
  948. +          
  949. +           if ((player != null) && !player.equals(""))
  950. +           {
  951. +               postParameters += "&player=" + player;
  952. +           }
  953. +          
  954. +           byte[] postData = postParameters.getBytes(Charset.forName("UTF-8"));
  955. +           URL url = new URL(API_URL);
  956. +           HttpURLConnection con = (HttpURLConnection) url.openConnection();
  957. +           con.setConnectTimeout(5000);
  958. +           con.setRequestMethod("POST");
  959. +           con.setRequestProperty("Content-Length", Integer.toString(postData.length));
  960. +           con.setRequestProperty("User-Agent", "Mozilla/5.0");
  961. +           con.setDoOutput(true);
  962. +          
  963. +           DataOutputStream os = new DataOutputStream(con.getOutputStream());
  964. +           os.write(postData);
  965. +           os.flush();
  966. +           os.close();
  967. +          
  968. +           BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
  969. +           String inputLine;
  970. +          
  971. +           while ((inputLine = in.readLine()) != null)
  972. +           {
  973. +               response.append(inputLine);
  974. +           }
  975. +           in.close();
  976. +          
  977. +           return response.toString();
  978. +          
  979. +       }
  980. +       catch (Exception e)
  981. +       {
  982. +           LOGGER.warning(VoteUtil.Sites[ordinal] + " Say: An error ocurred " + e.getCause());
  983. +           return "";
  984. +       }
  985. +   }
  986. +  
  987. +   protected static String getResponse(String Url, int ordinal)
  988. +   {
  989. +       if ((ordinal == voteSite.L2NETWORK.ordinal()) && ("".equals(Config.VOTE_NETWORK_API_KEY) || "".equals(Config.VOTE_NETWORK_LINK) || "".equals(Config.VOTE_NETWORK_USER_NAME)))
  990. +       {
  991. +           return "";
  992. +       }
  993. +      
  994. +       try
  995. +       {
  996. +           int responseCode = 0;
  997. +           URL objUrl = new URL(Url);
  998. +           HttpURLConnection con = (HttpURLConnection) objUrl.openConnection();
  999. +           con.setRequestMethod("GET");
  1000. +           con.setRequestProperty("User-Agent", "Mozilla/5.0");
  1001. +           con.setConnectTimeout(5000);
  1002. +           responseCode = con.getResponseCode();
  1003. +           if (responseCode == HttpURLConnection.HTTP_OK)
  1004. +           {
  1005. +               String inputLine;
  1006. +               StringBuffer response = new StringBuffer();
  1007. +               BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
  1008. +               while ((inputLine = in.readLine()) != null)
  1009. +               {
  1010. +                   response.append(inputLine);
  1011. +               }
  1012. +               in.close();
  1013. +               return response.toString();
  1014. +           }
  1015. +          
  1016. +       }
  1017. +       catch (Exception e)
  1018. +       {
  1019. +           LOGGER.warning(VoteSiteXml.getInstance().getSiteName(ordinal) + " Say: An error ocurred " + e.getCause());
  1020. +           return "";
  1021. +       }
  1022. +      
  1023. +       return "";
  1024. +   }
  1025. +  
  1026. +   public static individualVoteResponse getIndividualVoteResponse(int ordinal, String ip, String AccountName)
  1027. +   {
  1028. +       String response = "";
  1029. +       boolean isVoted = false;
  1030. +       long voteSiteTime = 0L, diffTime = 0L;
  1031. +       SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
  1032. +       individualVoteResponse ivr = new individualVoteResponse();
  1033. +      
  1034. +       switch (ordinal)
  1035. +       {
  1036. +           case 0:
  1037. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1038. +               isVoted = (response == "") ? false : Boolean.parseBoolean(VoteUtil.between("\"already_voted\":", response, ",\"vote_time\""));
  1039. +               if (isVoted)
  1040. +               {
  1041. +                   try
  1042. +                   {
  1043. +                       voteSiteTime = format.parse(VoteUtil.between("\"vote_time\":\"", response, "\",\"server_time\"")).getTime();
  1044. +                       diffTime = System.currentTimeMillis() - format.parse(VoteUtil.between("\"server_time\":\"", response, "\"}")).getTime();
  1045. +                   }
  1046. +                   catch (ParseException e)
  1047. +                   {
  1048. +                       e.printStackTrace();
  1049. +                   }
  1050. +               }
  1051. +               break;
  1052. +          
  1053. +           case 1:
  1054. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1055. +               isVoted = (response == "") ? false : Boolean.parseBoolean(VoteUtil.between("\"isvoted\":", response.toString().toLowerCase().replaceAll("\n", "").replaceAll(" ", ""), ",\"votetime").replaceAll("\"", ""));
  1056. +               if (isVoted)
  1057. +               {
  1058. +                   try
  1059. +                   {
  1060. +                       voteSiteTime = (Long.parseLong(VoteUtil.between("\"votetime\":", response.toString().toLowerCase().replaceAll("\n", "").replaceAll(" ", ""), ",\"servertime"))) * 1000;
  1061. +                       diffTime = System.currentTimeMillis() - ((Long.parseLong(VoteUtil.between("\"servertime\":", response.toLowerCase().replaceAll("\n", "").replaceAll(" ", ""), "}"))) * 1000);
  1062. +                   }
  1063. +                   catch (Exception e)
  1064. +                   {
  1065. +                       e.printStackTrace();
  1066. +                   }
  1067. +               }
  1068. +               break;
  1069. +          
  1070. +           case 2:
  1071. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1072. +               isVoted = (response == "") ? false : Boolean.parseBoolean(response);
  1073. +               if (isVoted)
  1074. +               {
  1075. +                   voteSiteTime = System.currentTimeMillis();
  1076. +                   diffTime = 0;
  1077. +               }
  1078. +               break;
  1079. +          
  1080. +           case 3:
  1081. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1082. +               isVoted = ((VoteUtil.between("\"status\":\"", response, "\",\"date\"") != "") && (Integer.parseInt(VoteUtil.between("\"status\":\"", response, "\",\"date\"")) == 1)) ? true : false;
  1083. +               if (isVoted)
  1084. +               {
  1085. +                   String dateString = VoteUtil.between("\"date\":\"", response, "\"}]");
  1086. +                   try
  1087. +                   {
  1088. +                       voteSiteTime = System.currentTimeMillis();
  1089. +                       diffTime = 0;
  1090. +                   }
  1091. +                   catch (Exception e)
  1092. +                   {
  1093. +                       e.printStackTrace();
  1094. +                   }
  1095. +                  
  1096. +               }
  1097. +               break;
  1098. +          
  1099. +           case 4:
  1100. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1101. +               isVoted = (response == "") ? false : Boolean.parseBoolean(VoteUtil.between("\"voted\":", response, ",\"voteTime\""));
  1102. +               if (isVoted)
  1103. +               {
  1104. +                   try
  1105. +                   {
  1106. +                       voteSiteTime = format.parse(VoteUtil.between("\"voteTime\":\"", response, "\",\"hopzoneServerTime\"")).getTime();
  1107. +                       diffTime = System.currentTimeMillis() - format.parse(VoteUtil.between("\"hopzoneServerTime\":\"", response, "\",\"status_code\":")).getTime();
  1108. +                   }
  1109. +                   catch (ParseException e)
  1110. +                   {
  1111. +                       e.printStackTrace();
  1112. +                   }
  1113. +               }
  1114. +               break;
  1115. +          
  1116. +           case 5:
  1117. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1118. +               isVoted = (!"".equals(response) && (Integer.parseInt(response) == 1)) ? true : false;
  1119. +               if (isVoted)
  1120. +               {
  1121. +                   voteSiteTime = System.currentTimeMillis();
  1122. +                   diffTime = 0;
  1123. +               }
  1124. +               break;
  1125. +          
  1126. +           case 6:
  1127. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1128. +               isVoted = ("".equals(response)) ? false : Boolean.parseBoolean(VoteUtil.between("\"voted\":", response, ",\"voteTime\""));
  1129. +               if (isVoted)
  1130. +               {
  1131. +                   try
  1132. +                   {
  1133. +                       voteSiteTime = System.currentTimeMillis();
  1134. +                       diffTime = 0;
  1135. +                   }
  1136. +                   catch (Exception e)
  1137. +                   {
  1138. +                       e.printStackTrace();
  1139. +                   }
  1140. +                  
  1141. +               }
  1142. +               break;
  1143. +          
  1144. +           case 7:
  1145. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1146. +               isVoted = ((VoteUtil.between("\"status\":\"", response, "\",\"server_time\"") != "") && (Integer.parseInt(VoteUtil.between("\"status\":\"", response, "\",\"server_time\"")) == 1)) ? true : false;
  1147. +               if (isVoted)
  1148. +               {
  1149. +                   try
  1150. +                   {
  1151. +                       voteSiteTime = System.currentTimeMillis();
  1152. +                       diffTime = 0;
  1153. +                   }
  1154. +                   catch (Exception e)
  1155. +                   {
  1156. +                       e.printStackTrace();
  1157. +                   }
  1158. +               }
  1159. +               break;
  1160. +          
  1161. +           case 8:
  1162. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1163. +               isVoted = (response == "") ? false : Boolean.parseBoolean(VoteUtil.between("\"is_voted\":", response, ",\"vote_time\""));
  1164. +               if (isVoted)
  1165. +               {
  1166. +                   try
  1167. +                   {
  1168. +                       voteSiteTime = (Long.parseLong(VoteUtil.between("\"vote_time\":", response, ",\"server_time\""))) * 1000;
  1169. +                       diffTime = System.currentTimeMillis() - (Long.parseLong(VoteUtil.between("\"server_time\":", response, "}}")) * 1000);
  1170. +                   }
  1171. +                   catch (Exception e)
  1172. +                   {
  1173. +                       e.printStackTrace();
  1174. +                   }
  1175. +               }
  1176. +               break;
  1177. +          
  1178. +           case 9:
  1179. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1180. +               isVoted = (response == "") ? false : Boolean.parseBoolean(VoteUtil.between("\"isVoted\": ", response, ",\"voteTime\""));
  1181. +               if (isVoted)
  1182. +               {
  1183. +                   voteSiteTime = Long.parseLong(VoteUtil.between("\"voteTime\": \"", response, "\",\"serverTime\"")) * 1000;
  1184. +                   diffTime = System.currentTimeMillis() - (Long.parseLong(VoteUtil.between("\"serverTime\": ", response, "}}")) * 1000);
  1185. +               }
  1186. +               break;
  1187. +          
  1188. +           case 10:
  1189. +               response = getResponse(getIndividualUrl(ordinal, ip, null), ordinal);
  1190. +               isVoted = (response == "") ? false : Boolean.parseBoolean(response);
  1191. +               if (isVoted)
  1192. +               {
  1193. +                   voteSiteTime = System.currentTimeMillis();
  1194. +                   diffTime = 0;
  1195. +               }
  1196. +               break;
  1197. +          
  1198. +       }
  1199. +       if (!response.equals(""))
  1200. +       {
  1201. +           ivr.setIsVoted(isVoted);
  1202. +           ivr.setDiffTime(diffTime);
  1203. +           ivr.setVoteSiteTime(voteSiteTime);
  1204. +           return ivr;
  1205. +       }
  1206. +       return null;
  1207. +   }
  1208. +  
  1209. +   public int getGlobalVotesResponse(int ordinal)
  1210. +   {
  1211. +      
  1212. +       String response = "";
  1213. +       int totalVotes = 0;
  1214. +      
  1215. +       switch (ordinal)
  1216. +       {
  1217. +           case 0:
  1218. +               response = getResponse(getGlobalUrl(ordinal), ordinal);
  1219. +               response = VoteUtil.between("\"getVotes\":", response, "}");
  1220. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1221. +               break;
  1222. +          
  1223. +           case 1:
  1224. +               response = getResponse(getGlobalUrl(ordinal), ordinal);
  1225. +               response = VoteUtil.between("server_votes\":", response.replace(" ", ""), ",\"server_rank");
  1226. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1227. +               break;
  1228. +          
  1229. +           case 2:
  1230. +               response = getResponse(getGlobalUrl(ordinal), ordinal);
  1231. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1232. +               break;
  1233. +          
  1234. +           case 3:
  1235. +               response = VoteUtil.getResponse(getGlobalUrl(ordinal), ordinal);
  1236. +               response = VoteUtil.between("Votes:</th><th><a class='votes'>", response, "</a></th></tr><tr><th>Clicks:");
  1237. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1238. +               break;
  1239. +          
  1240. +           case 4:
  1241. +               response = getResponse(getGlobalUrl(ordinal), ordinal);
  1242. +               response = VoteUtil.between("\"totalvotes\":", response, ",\"status_code\"");
  1243. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1244. +               break;
  1245. +          
  1246. +           case 5:
  1247. +               String responseNetwork = getNetWorkResponse(getGlobalUrl(ordinal), ordinal);
  1248. +               totalVotes = (!"".equals(responseNetwork)) ? Integer.parseInt(responseNetwork) : -1;
  1249. +               break;
  1250. +          
  1251. +           case 6:
  1252. +               response = VoteUtil.getResponse(getGlobalUrl(ordinal), ordinal);
  1253. +               response = VoteUtil.between("VOTE <span>", response.toString().replaceAll("\n", ""), "</span>");
  1254. +              
  1255. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1256. +               break;
  1257. +          
  1258. +           case 7:
  1259. +               response = VoteUtil.getResponse(getGlobalUrl(ordinal), ordinal);
  1260. +               response = VoteUtil.between("nicas:</b> ", response, "<br /><br />");
  1261. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1262. +               break;
  1263. +          
  1264. +           case 8:
  1265. +               response = getResponse(getGlobalUrl(ordinal), ordinal);
  1266. +               response = VoteUtil.between("\"monthly_votes\":", response, "}}");
  1267. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1268. +               break;
  1269. +          
  1270. +           case 9:
  1271. +               response = getResponse(getGlobalUrl(ordinal), ordinal);
  1272. +               response = VoteUtil.between("\"totalVotes\":\"", response, "\",\"serverRank\"");
  1273. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1274. +               break;
  1275. +          
  1276. +           case 10:
  1277. +               response = getResponse(getGlobalUrl(ordinal), ordinal);
  1278. +               totalVotes = (!"".equals(response)) ? Integer.parseInt(response) : -1;
  1279. +               break;
  1280. +       }
  1281. +      
  1282. +       return totalVotes;
  1283. +   }
  1284. +  
  1285. +   public static String getIndividualUrl(int ordinal, String ip, String AccountName)
  1286. +   {
  1287. +       String url = "";
  1288. +       ip = (Config.TEST_IP.equalsIgnoreCase("off") || Config.TEST_IP.equalsIgnoreCase("")) ? ip : Config.TEST_IP;
  1289. +       switch (ordinal)
  1290. +       {
  1291. +           case 0:
  1292. +               // l2.topgameserver.net
  1293. +               url = String.format("%sAPI_KEY=%s/getData/%s", Config.VOTE_LINK_TGS, Config.TGS_API_KEY, ip);
  1294. +               break;
  1295. +          
  1296. +           case 1:
  1297. +               // itopz.com
  1298. +               url = String.format("%s%s/%s/%s", Config.VOTE_LINK_ITOPZ, Config.ITOPZ_API_KEY, Config.ITOPZ_SRV_ID, ip);
  1299. +               break;
  1300. +          
  1301. +           case 2:
  1302. +               // l2top.co
  1303. +               url = String.format("%sVoteCheck.php?id=%s&ip=%s", Config.VOTE_LINK_TOP_CO, Config.TOP_CO_SRV_ID, ip);
  1304. +               break;
  1305. +          
  1306. +           case 3:
  1307. +               // l2votes.com
  1308. +               url = String.format("%sapi.php?apiKey=%s&ip=%s", Config.VOTE_LINK_VTS, Config.VTS_API_KEY, ip);
  1309. +               break;
  1310. +          
  1311. +           case 4:
  1312. +               // hopzone.net
  1313. +               url = String.format("%svote?token=%s&ip_address=%s", Config.VOTE_LINK_HZ, Config.HZ_API_KEY, ip);
  1314. +               break;
  1315. +          
  1316. +           case 5:
  1317. +               // l2network.eu
  1318. +               url = String.format("https://l2network.eu/index.php?a=in&u=%s&ipc=%s", Config.VOTE_NETWORK_USER_NAME, ip);
  1319. +               break;
  1320. +          
  1321. +           case 6:
  1322. +               // l2topservers.com
  1323. +               url = String.format("%stoken=%s&ip=%s", Config.VOTE_LINK_TSS, Config.TSS_API_TOKEN, ip);
  1324. +               break;
  1325. +          
  1326. +           case 7:
  1327. +               // top.l2jbrasil.com
  1328. +               url = String.format("%susername=%s&ip=%s&type=json", Config.BRASIL_VOTE_LINK, Config.BRASIL_USER_NAME, ip);
  1329. +               break;
  1330. +          
  1331. +           case 8:
  1332. +               // mmotop
  1333. +               url = String.format("%s%s/ip/%s", Config.VOTE_LINK_MMOTOP, Config.MMOTOP_API_KEY, ip);
  1334. +               break;
  1335. +          
  1336. +           case 9:
  1337. +               // topzone.com
  1338. +               url = String.format("%svote?token=%s&ip=%s", Config.VOTE_LINK_TZ, Config.TZ_API_KEY, ip);
  1339. +               break;
  1340. +          
  1341. +           case 10:
  1342. +               // l2servers.com
  1343. +               url = String.format("%scheckip.php?hash=%s&server_id=%s&ip=%s", Config.VOTE_LINK_SERVERS, Config.SERVERS_HASH_CODE, Config.SERVERS_SRV_ID, ip);
  1344. +               break;
  1345. +       }
  1346. +      
  1347. +       return url;
  1348. +   }
  1349. +  
  1350. +   public String getGlobalUrl(int ordinal)
  1351. +   {
  1352. +       String url = "";
  1353. +      
  1354. +       switch (ordinal)
  1355. +       {
  1356. +           case 0:
  1357. +               // l2.topgameserver.net
  1358. +               url = String.format("%sAPI_KEY=%s/getData", Config.VOTE_LINK_TGS, Config.TGS_API_KEY);
  1359. +               break;
  1360. +          
  1361. +           case 1:
  1362. +               // itopz.com
  1363. +               url = String.format("%s%s/%s", Config.VOTE_LINK_ITOPZ, Config.ITOPZ_API_KEY, Config.ITOPZ_SRV_ID);
  1364. +               break;
  1365. +          
  1366. +           case 2:
  1367. +               // l2top.co
  1368. +               url = String.format("%sVoteCheck_Total.php?id=%s", Config.VOTE_LINK_TOP_CO, Config.TOP_CO_SRV_ID);
  1369. +               break;
  1370. +          
  1371. +           case 3:
  1372. +               // l2votes.com
  1373. +               url = String.format("%sserverPage.php?sid=%s", Config.VOTE_LINK_VTS, Config.VTS_SID);
  1374. +               break;
  1375. +          
  1376. +           case 4:
  1377. +               // hopzone.net
  1378. +               url = String.format("%svotes?token=%s", Config.VOTE_LINK_HZ, Config.HZ_API_KEY);
  1379. +               break;
  1380. +          
  1381. +           case 5:
  1382. +               // l2network.eu
  1383. +               url = String.format("apiKey=%s&type=%s&player=", Config.VOTE_NETWORK_API_KEY, 1);
  1384. +               break;
  1385. +          
  1386. +           case 6:
  1387. +               // l2topservers
  1388. +               url = String.format("https://l2topservers.com/l2top/%s/%s", Config.TS_SRV_ID, Config.TS_DOMAIN_NAME);
  1389. +               break;
  1390. +          
  1391. +           case 7:
  1392. +               // top.l2jbrasil.com
  1393. +               url = String.format("https://top.l2jbrasil.com/index.php?a=stats&u=%s", Config.BRASIL_USER_NAME);
  1394. +               break;
  1395. +          
  1396. +           case 8:
  1397. +               // mmotop.eu/l2/
  1398. +               url = String.format("%s%s/info/", Config.VOTE_LINK_MMOTOP, Config.MMOTOP_API_KEY);
  1399. +               break;
  1400. +          
  1401. +           case 9:
  1402. +               // l2topzone.com
  1403. +               url = String.format("%sserver_%s/getServerData", Config.VOTE_LINK_TZ, Config.TZ_API_KEY);
  1404. +               break;
  1405. +          
  1406. +           case 10:
  1407. +               // l2servers.com
  1408. +               url = String.format("%syearlyvotes.php?server_id=%s", Config.VOTE_LINK_SERVERS, Config.SERVERS_SRV_ID);
  1409. +               break;
  1410. +       }
  1411. +      
  1412. +       return url;
  1413. +   }
  1414. +}
  1415. \ No newline at end of file
  1416. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Handler/voteManager.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Handler/voteManager.java
  1417. new file mode 100644
  1418. index 0000000..7f5afc4
  1419. --- /dev/null
  1420. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Handler/voteManager.java
  1421. @@ -0,0 +1,393 @@
  1422. +package org.l2jmobius.gameserver.votesystem.Handler;
  1423. +
  1424. +import java.util.HashSet;
  1425. +import java.util.Map;
  1426. +import java.util.concurrent.ConcurrentHashMap;
  1427. +import java.util.concurrent.ScheduledFuture;
  1428. +
  1429. +import org.l2jmobius.Config;
  1430. +import org.l2jmobius.commons.concurrent.ThreadPool;
  1431. +import org.l2jmobius.gameserver.model.World;
  1432. +import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
  1433. +import org.l2jmobius.gameserver.network.GameClient;
  1434. +import org.l2jmobius.gameserver.network.SystemMessageId;
  1435. +import org.l2jmobius.gameserver.network.serverpackets.ItemList;
  1436. +import org.l2jmobius.gameserver.network.serverpackets.SystemMessage;
  1437. +import org.l2jmobius.gameserver.util.Broadcast;
  1438. +import org.l2jmobius.gameserver.votesystem.DB.globalVoteDB;
  1439. +import org.l2jmobius.gameserver.votesystem.DB.individualVoteDB;
  1440. +import org.l2jmobius.gameserver.votesystem.Enum.voteSite;
  1441. +import org.l2jmobius.gameserver.votesystem.Model.Reward;
  1442. +import org.l2jmobius.gameserver.votesystem.Model.globalVote;
  1443. +import org.l2jmobius.gameserver.votesystem.Model.individualVote;
  1444. +import org.l2jmobius.gameserver.votesystem.Model.individualVoteResponse;
  1445. +import org.l2jmobius.gameserver.votesystem.VoteUtil.VoteSiteXml;
  1446. +import org.l2jmobius.gameserver.votesystem.VoteUtil.VoteUtil;
  1447. +
  1448. +/**
  1449. + * @author l2.topgameserver.net
  1450. + */
  1451. +public final class voteManager extends voteHandler
  1452. +{
  1453. +   private ScheduledFuture<?> _saveGlobalVotes;
  1454. +   private ScheduledFuture<?> _updateIndividualVotes;
  1455. +   private ScheduledFuture<?> _autoGlobalVotesReward;
  1456. +  
  1457. +   private HashSet<individualVote> _votes;
  1458. +   private Map<String, individualVote[]> _foundVoters;
  1459. +   private globalVote[] _globalVotes = new globalVote[voteSite.values().length];
  1460. +  
  1461. +   public voteManager()
  1462. +   {
  1463. +       _foundVoters = new ConcurrentHashMap<>();
  1464. +       loadVotes();
  1465. +       loadGlobalVotes();
  1466. +       checkAllResponseGlobalVotes();
  1467. +       stopAutoTasks();
  1468. +      
  1469. +       if (Config.ENABLE_INDIVIDUAL_VOTE && Config.ENABLE_VOTE_SYSTEM)
  1470. +       {
  1471. +           _updateIndividualVotes = ThreadPool.scheduleAtFixedRate(new AutoUpdateIndividualVotesTask(), 30000, Config.NEXT_TIME_TO_AUTO_UPDATE_INDIVIDUAL_VOTES);
  1472. +       }
  1473. +       if (Config.ENABLE_GLOBAL_VOTE && Config.ENABLE_VOTE_SYSTEM)
  1474. +       {
  1475. +           _autoGlobalVotesReward = ThreadPool.scheduleAtFixedRate(new AutoGlobalVoteRewardTask(), 10000, Config.NEXT_TIME_TO_CHECK_AUTO_GLOBAL_VOTES_REWARD);
  1476. +           _saveGlobalVotes = ThreadPool.scheduleAtFixedRate(new AutoSaveGlobalVotesTask(), 30000, Config.NEXT_TIME_TO_AUTO_UPDATE_TOTAL_VOTE);
  1477. +       }
  1478. +   }
  1479. +  
  1480. +   private void stopAutoTasks()
  1481. +   {
  1482. +       if (_saveGlobalVotes != null)
  1483. +       {
  1484. +           _saveGlobalVotes.cancel(true);
  1485. +           _saveGlobalVotes = null;
  1486. +       }
  1487. +       if (_updateIndividualVotes != null)
  1488. +       {
  1489. +           _updateIndividualVotes.cancel(true);
  1490. +           _updateIndividualVotes = null;
  1491. +       }
  1492. +       if (_autoGlobalVotesReward != null)
  1493. +       {
  1494. +           _autoGlobalVotesReward.cancel(true);
  1495. +           _autoGlobalVotesReward = null;
  1496. +       }
  1497. +   }
  1498. +  
  1499. +   public void getReward(PlayerInstance player, int ordinalSite)
  1500. +   {
  1501. +       String ip = existIp(player);
  1502. +       if (ip == null)
  1503. +       {
  1504. +           return;
  1505. +       }
  1506. +       individualVoteResponse ivr = getIndividualVoteResponse(ordinalSite, ip, player.getAccountName());
  1507. +       if (ivr == null)
  1508. +       {
  1509. +           player.sendMessage("We were unable to verify your vote with: " + VoteSiteXml.getInstance().getSiteName(ordinalSite) + ", please try again");
  1510. +           return;
  1511. +       }
  1512. +
  1513. +       if (getTimeRemaining(new individualVote(ip, ivr.getVoteSiteTime(), ordinalSite, false)) < 0)
  1514. +       {
  1515. +           player.sendMessage("We were unable to verify your vote with: " + VoteSiteXml.getInstance().getSiteName(ordinalSite) + ", please try again");
  1516. +           return;
  1517. +       }
  1518. +       if (!ivr.getIsVoted())
  1519. +       {
  1520. +           player.sendMessage(String.format("You haven't vote on %s yet!", VoteSiteXml.getInstance().getSiteName(ordinalSite)));
  1521. +           return;
  1522. +       }
  1523. +       if (!checkIndividualAvailableVote(player, ordinalSite))
  1524. +       {
  1525. +           player.sendMessage(String.format("You can get the reward again on %s at %s", VoteSiteXml.getInstance().getSiteName(ordinalSite), getTimeRemainingWithSampleFormat(player, ordinalSite)));
  1526. +           return;
  1527. +       }
  1528. +       individualVote iv = new individualVote(ip, ivr.getDiffTime(), ivr.getVoteSiteTime(), ordinalSite, false);
  1529. +      
  1530. +       individualVote[] aiv;
  1531. +       if (!_foundVoters.containsKey(ip))
  1532. +       {
  1533. +           aiv = new individualVote[voteSite.values().length];
  1534. +           iv.setAlreadyRewarded(true);
  1535. +           aiv[ordinalSite] = iv;
  1536. +           _foundVoters.put(ip, aiv);
  1537. +       }
  1538. +       else
  1539. +       {
  1540. +           aiv = _foundVoters.get(ip);
  1541. +           iv.setAlreadyRewarded(true);
  1542. +           aiv[ordinalSite] = iv;
  1543. +           _foundVoters.replace(ip, aiv);
  1544. +          
  1545. +       }
  1546. +       for (Reward reward : VoteSiteXml.getInstance().getRewards(ordinalSite))
  1547. +       {
  1548. +           player.getInventory().addItem("VoteSystem", reward.getItemId(), reward.getItemCount(), player, null);
  1549. +           player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S).addItemName(reward.getItemId()).addInt(reward.getItemCount()));
  1550. +       }
  1551. +       player.sendMessage(String.format("%s: Thank you for voting for our server, your reward has been delivered.", VoteSiteXml.getInstance().getSiteName(ordinalSite)));
  1552. +       player.sendPacket(new ItemList(player, true));
  1553. +   }
  1554. +  
  1555. +   public boolean checkIndividualAvailableVote(PlayerInstance player, int ordinalSite)
  1556. +   {
  1557. +       String ip = existIp(player);
  1558. +       if (_foundVoters.containsKey(ip))
  1559. +       {
  1560. +           individualVote[] ivs = _foundVoters.get(ip);
  1561. +           if (ivs[ordinalSite] == null)
  1562. +           {
  1563. +               return true;
  1564. +           }
  1565. +           if (ivs[ordinalSite] != null)
  1566. +           {
  1567. +               individualVote iv = ivs[ordinalSite];
  1568. +               if (getTimeRemaining(iv) < 0)
  1569. +               {
  1570. +                   return true;
  1571. +               }
  1572. +           }
  1573. +       }
  1574. +       else
  1575. +       {
  1576. +           return true;
  1577. +       }
  1578. +      
  1579. +       return false;
  1580. +   }
  1581. +  
  1582. +   public long getTimeRemaining(individualVote iv)
  1583. +   {
  1584. +       long timeRemaining = 0L;
  1585. +       timeRemaining = ((iv.getVotingTimeSite() + Config.INTERVAL_TO_NEXT_VOTE) - ((iv.getDiffTime() > 0) ? (System.currentTimeMillis() + iv.getDiffTime()) : (System.currentTimeMillis() - iv.getDiffTime())));
  1586. +       return timeRemaining;
  1587. +   }
  1588. +  
  1589. +   public String getTimeRemainingWithSampleFormat(PlayerInstance player, int ordinalSite)
  1590. +   {
  1591. +       String ip = existIp(player);
  1592. +       String timeRemainingWithSampleFormat = "";
  1593. +       if (_foundVoters.containsKey(ip))
  1594. +       {
  1595. +           individualVote[] ivs = _foundVoters.get(ip);
  1596. +           if (ivs[ordinalSite] != null)
  1597. +           {
  1598. +               individualVote iv = ivs[ordinalSite];
  1599. +               long timeRemaining = getTimeRemaining(iv);
  1600. +               if (timeRemaining > 0)
  1601. +               {
  1602. +                   timeRemainingWithSampleFormat = CalculateTimeRemainingWithSampleDateFormat(timeRemaining);
  1603. +                   return timeRemainingWithSampleFormat;
  1604. +               }
  1605. +           }
  1606. +       }
  1607. +       return timeRemainingWithSampleFormat;
  1608. +   }
  1609. +  
  1610. +   public String CalculateTimeRemainingWithSampleDateFormat(long timeRemaining)
  1611. +   {
  1612. +       long t = timeRemaining / 1000;
  1613. +       int hours = Math.round(((t / 3600) % 24));
  1614. +       int minutes = Math.round((t / 60) % 60);
  1615. +       int seconds = Math.round(t % 60);
  1616. +       return String.format("%sH:%sm:%ss", hours, minutes, seconds);
  1617. +   }
  1618. +  
  1619. +   public String existIp(PlayerInstance p)
  1620. +   {
  1621. +      
  1622. +       GameClient client = p.getClient();
  1623. +       if ((client.getConnectionAddress() != null) && (client.getPlayer() != null) && !client.isDetached())
  1624. +       {
  1625. +           try
  1626. +           {
  1627. +               return client.getConnectionAddress().getHostAddress();
  1628. +           }
  1629. +           catch (Exception e)
  1630. +           {
  1631. +               e.printStackTrace();
  1632. +           }
  1633. +       }
  1634. +       return null;
  1635. +      
  1636. +   }
  1637. +  
  1638. +   public final void loadVotes()
  1639. +   {
  1640. +       _foundVoters = individualVoteDB.getInstance().getVotesDB();
  1641. +   }
  1642. +  
  1643. +   protected void loadGlobalVotes()
  1644. +   {
  1645. +       _globalVotes = globalVoteDB.getInstance().getGlobalVotes();
  1646. +   }
  1647. +  
  1648. +   public void saveVotes()
  1649. +   {
  1650. +       individualVoteDB.getInstance().SaveVotes(_foundVoters);
  1651. +   }
  1652. +  
  1653. +   protected void AutoGlobalVoteReward()
  1654. +   {
  1655. +       HashSet<String> ipList = new HashSet<>();
  1656. +       for (voteSite vs : voteSite.values())
  1657. +       {
  1658. +          
  1659. +           new Thread(() ->
  1660. +           {
  1661. +               checkNewUpdate(vs.ordinal());
  1662. +               if (_globalVotes[vs.ordinal()].getCurrentVotes() >= (_globalVotes[vs.ordinal()].getVotesLastReward() + (vs.ordinal() == voteSite.L2SERVERS.ordinal() ? 25 * Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD : Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD)))
  1663. +               {
  1664. +                   _globalVotes[vs.ordinal()].setVotesLastReward(_globalVotes[vs.ordinal()].getVotesLastReward() + (vs.ordinal() == voteSite.L2SERVERS.ordinal() ? 25 * Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD : Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD));
  1665. +                   for (PlayerInstance player : World.getInstance().getPlayers())
  1666. +                   {
  1667. +                       String ip = existIp(player);
  1668. +                       if (ip == null)
  1669. +                       {
  1670. +                           continue;
  1671. +                       }
  1672. +                       if (ipList.contains(ip))
  1673. +                       {
  1674. +                           continue;
  1675. +                       }
  1676. +                       for (Reward reward : VoteSiteXml.getInstance().getRewards(11))
  1677. +                       {
  1678. +                           player.getInventory().addItem("VoteSystem: ", reward.getItemId(), reward.getItemCount(), player, null);
  1679. +                           player.sendPacket(new SystemMessage(SystemMessageId.YOU_HAVE_EARNED_S2_S1_S).addItemName(reward.getItemId()).addInt(reward.getItemCount()));
  1680. +                       }
  1681. +                       ipList.add(ip);
  1682. +                       player.sendPacket(new ItemList(player, true));
  1683. +                   }
  1684. +                   Broadcast.toAllOnlinePlayers(VoteUtil.Sites[vs.ordinal()] + ": All players has been rewarded, please check your inventory", true);
  1685. +               }
  1686. +               else
  1687. +               {
  1688. +                   String encourage = "";
  1689. +                   int nextReward = _globalVotes[vs.ordinal()].getVotesLastReward() + (vs.ordinal() == voteSite.L2SERVERS.ordinal() ? 25 * Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD : Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD);
  1690. +                   encourage = String.format("Vote for %s current Votes: %s, next quantity of votes to reward : %s, need votes to next reward: %s", VoteUtil.Sites[vs.ordinal()], _globalVotes[vs.ordinal()].getCurrentVotes(), nextReward, nextReward - _globalVotes[vs.ordinal()].getCurrentVotes());
  1691. +                   Broadcast.toAllOnlinePlayers(encourage, true);
  1692. +               }
  1693. +           }).start();
  1694. +          
  1695. +       }
  1696. +   }
  1697. +  
  1698. +   protected void AutoSaveGlobalVotes()
  1699. +   {
  1700. +       globalVoteDB.getInstance().saveGlobalVotes(_globalVotes);
  1701. +   }
  1702. +  
  1703. +   protected synchronized void AutoUpdateIndividualVotes()
  1704. +   {
  1705. +       AutoCleanInnecesaryIndividualVotes();
  1706. +       individualVoteDB.getInstance().SaveVotes(_foundVoters);
  1707. +   }
  1708. +  
  1709. +   protected synchronized void AutoCleanInnecesaryIndividualVotes()
  1710. +   {
  1711. +       HashSet<individualVote> removeVotes = new HashSet<>();
  1712. +       for (Map.Entry<String, individualVote[]> ivs : _foundVoters.entrySet())
  1713. +       {
  1714. +           for (individualVote individualvote : ivs.getValue())
  1715. +           {
  1716. +               if (individualvote == null)
  1717. +               {
  1718. +                   continue;
  1719. +               }
  1720. +               if (getTimeRemaining(individualvote) < 0)
  1721. +               {
  1722. +                   removeVotes.add(individualvote);
  1723. +                   if (_foundVoters.containsKey(individualvote.getVoterIp()))
  1724. +                   {
  1725. +                       if (_foundVoters.get(individualvote.getVoterIp())[individualvote.getVoteSite()] != null)
  1726. +                       {
  1727. +                           _foundVoters.get(individualvote.getVoterIp())[individualvote.getVoteSite()] = null;
  1728. +                       }
  1729. +                   }
  1730. +               }
  1731. +           }
  1732. +       }
  1733. +       individualVoteDB.getInstance().DeleteVotes(removeVotes);
  1734. +   }
  1735. +  
  1736. +   public void checkAllResponseGlobalVotes()
  1737. +   {
  1738. +       for (voteSite vs : voteSite.values())
  1739. +       {
  1740. +           new Thread(() ->
  1741. +           {
  1742. +               checkNewUpdate(vs.ordinal());
  1743. +           });
  1744. +       }
  1745. +   }
  1746. +  
  1747. +   public void checkNewUpdate(int ordinalSite)
  1748. +   {
  1749. +       int globalVotesResponse = getGlobalVotesResponse(ordinalSite);
  1750. +       if (globalVotesResponse == -1)
  1751. +       {
  1752. +           return;
  1753. +       }
  1754. +       _globalVotes[ordinalSite].setCurrentVotes(globalVotesResponse);
  1755. +       int last = globalVotesResponse - (ordinalSite == voteSite.L2SERVERS.ordinal() ? 25 * Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD : Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD);
  1756. +       if (last < 0)
  1757. +       {
  1758. +           _globalVotes[ordinalSite].setVotesLastReward(0);
  1759. +           return;
  1760. +       }
  1761. +       if ((_globalVotes[ordinalSite].getVotesLastReward() + (ordinalSite == voteSite.L2SERVERS.ordinal() ? 25 * Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD : Config.GLOBAL_VOTES_AMOUNT_TO_NEXT_REWARD)) < globalVotesResponse)
  1762. +       {
  1763. +           _globalVotes[ordinalSite].setVotesLastReward(globalVotesResponse);
  1764. +           return;
  1765. +       }
  1766. +   }
  1767. +  
  1768. +   public void Shutdown()
  1769. +   {
  1770. +       AutoSaveGlobalVotes();
  1771. +       AutoCleanInnecesaryIndividualVotes();
  1772. +       AutoUpdateIndividualVotes();
  1773. +   }
  1774. +  
  1775. +   protected class AutoGlobalVoteRewardTask implements Runnable
  1776. +   {
  1777. +      
  1778. +       @Override
  1779. +       public void run()
  1780. +       {
  1781. +           AutoGlobalVoteReward();
  1782. +          
  1783. +       }
  1784. +      
  1785. +   }
  1786. +  
  1787. +   protected class AutoSaveGlobalVotesTask implements Runnable
  1788. +   {
  1789. +      
  1790. +       @Override
  1791. +       public void run()
  1792. +       {
  1793. +           AutoSaveGlobalVotes();
  1794. +          
  1795. +       }
  1796. +      
  1797. +   }
  1798. +  
  1799. +   protected class AutoUpdateIndividualVotesTask implements Runnable
  1800. +   {
  1801. +      
  1802. +       @Override
  1803. +       public void run()
  1804. +       {
  1805. +           AutoUpdateIndividualVotes();
  1806. +          
  1807. +       }
  1808. +      
  1809. +   }
  1810. +  
  1811. +   public static voteManager getInatance()
  1812. +   {
  1813. +       return SingleHolder.INSTANCE;
  1814. +   }
  1815. +  
  1816. +   private static class SingleHolder
  1817. +   {
  1818. +       protected static final voteManager INSTANCE = new voteManager();
  1819. +   }
  1820. +}
  1821. \ No newline at end of file
  1822. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/Reward.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/Reward.java
  1823. new file mode 100644
  1824. index 0000000..92068aa
  1825. --- /dev/null
  1826. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/Reward.java
  1827. @@ -0,0 +1,38 @@
  1828. +package org.l2jmobius.gameserver.votesystem.Model;
  1829. +
  1830. +import org.l2jmobius.commons.util.StatsSet;
  1831. +
  1832. +/**
  1833. + * @author l2.topgameserver.net
  1834. + */
  1835. +public class Reward
  1836. +{
  1837. +   private int _itemId;
  1838. +   private int _itemCount;
  1839. +  
  1840. +   public Reward(StatsSet set)
  1841. +   {
  1842. +       _itemId = set.getInteger("itemId");
  1843. +       _itemCount = set.getInteger("itemCount");
  1844. +   }
  1845. +  
  1846. +   public void setItemId(int itemId)
  1847. +   {
  1848. +       _itemId = itemId;
  1849. +   }
  1850. +  
  1851. +   public void setItemCount(int itemCount)
  1852. +   {
  1853. +       _itemCount = itemCount;
  1854. +   }
  1855. +  
  1856. +   public int getItemId()
  1857. +   {
  1858. +       return _itemId;
  1859. +   }
  1860. +  
  1861. +   public int getItemCount()
  1862. +   {
  1863. +       return _itemCount;
  1864. +   }
  1865. +}
  1866. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/VoteSite.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/VoteSite.java
  1867. new file mode 100644
  1868. index 0000000..0b26c01
  1869. --- /dev/null
  1870. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/VoteSite.java
  1871. @@ -0,0 +1,53 @@
  1872. +package org.l2jmobius.gameserver.votesystem.Model;
  1873. +
  1874. +import java.util.ArrayList;
  1875. +import java.util.List;
  1876. +
  1877. +/**
  1878. + * @author l2.topgameserver.net
  1879. + */
  1880. +public class VoteSite
  1881. +{
  1882. +   private int _siteOrdinal;
  1883. +   private String _siteName;
  1884. +   private final List<Reward> _rewards = new ArrayList<>();
  1885. +  
  1886. +   public VoteSite()
  1887. +   {
  1888. +      
  1889. +   }
  1890. +  
  1891. +   public void setSiteOrdinal(int siteOrdinal)
  1892. +   {
  1893. +       _siteOrdinal = siteOrdinal;
  1894. +   }
  1895. +  
  1896. +   public void setSiteName(String siteName)
  1897. +   {
  1898. +       _siteName = siteName;
  1899. +   }
  1900. +  
  1901. +   public void setRewardList(List<Reward> rewards)
  1902. +   {
  1903. +       for (Reward r : rewards)
  1904. +       {
  1905. +           _rewards.add(r);
  1906. +       }
  1907. +   }
  1908. +  
  1909. +   public int getSiteOrdinal()
  1910. +   {
  1911. +       return _siteOrdinal;
  1912. +   }
  1913. +  
  1914. +   public String getSiteName()
  1915. +   {
  1916. +       return _siteName;
  1917. +   }
  1918. +  
  1919. +   public List<Reward> getRewardList()
  1920. +   {
  1921. +       return _rewards;
  1922. +   }
  1923. +  
  1924. +}
  1925. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/globalVote.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/globalVote.java
  1926. new file mode 100644
  1927. index 0000000..6ed7b6b
  1928. --- /dev/null
  1929. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/globalVote.java
  1930. @@ -0,0 +1,53 @@
  1931. +package org.l2jmobius.gameserver.votesystem.Model;
  1932. +
  1933. +/**
  1934. + * @author l2.topgameserver.net
  1935. + */
  1936. +public class globalVote
  1937. +{
  1938. +   private int _voteSite;
  1939. +   private int _votesLastReward;
  1940. +   private int _currentVotes;
  1941. +  
  1942. +   public globalVote()
  1943. +   {
  1944. +      
  1945. +   }
  1946. +  
  1947. +   public globalVote(int voteSite, int votesLastReward)
  1948. +   {
  1949. +       _voteSite = voteSite;
  1950. +       _votesLastReward = votesLastReward;
  1951. +   }
  1952. +  
  1953. +   public void setVoteSite(int voteSite)
  1954. +   {
  1955. +       _voteSite = voteSite;
  1956. +   }
  1957. +  
  1958. +   public void setVotesLastReward(int votesLastReward)
  1959. +   {
  1960. +       _votesLastReward = votesLastReward;
  1961. +   }
  1962. +  
  1963. +   public void setCurrentVotes(int currentVotes)
  1964. +   {
  1965. +       _currentVotes = currentVotes;
  1966. +   }
  1967. +  
  1968. +   public int getVoyeSite()
  1969. +   {
  1970. +       return _voteSite;
  1971. +   }
  1972. +  
  1973. +   public int getVotesLastReward()
  1974. +   {
  1975. +       return _votesLastReward;
  1976. +   }
  1977. +  
  1978. +   public int getCurrentVotes()
  1979. +   {
  1980. +       return _currentVotes;
  1981. +   }
  1982. +  
  1983. +}
  1984. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/individualVote.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/individualVote.java
  1985. new file mode 100644
  1986. index 0000000..2b22289
  1987. --- /dev/null
  1988. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/individualVote.java
  1989. @@ -0,0 +1,78 @@
  1990. +package org.l2jmobius.gameserver.votesystem.Model;
  1991. +
  1992. +/**
  1993. + * @author l2.topgameserver.net
  1994. + */
  1995. +public class individualVote
  1996. +{
  1997. +   private String _voterIp;
  1998. +   private long _diffTime;
  1999. +   private long _votingTimeSite;
  2000. +   private int _voteSite;
  2001. +   private boolean _alreadyRewarded;
  2002. +  
  2003. +   public individualVote(String voterIp, long diffTime, long votingTimeSite, int voteSite, boolean alreadyRewarded)
  2004. +   {
  2005. +       _voterIp = voterIp;
  2006. +       _diffTime = diffTime;
  2007. +       _votingTimeSite = votingTimeSite;
  2008. +       _voteSite = voteSite;
  2009. +       _alreadyRewarded = alreadyRewarded;
  2010. +   }
  2011. +  
  2012. +   public individualVote()
  2013. +   {
  2014. +      
  2015. +   }
  2016. +  
  2017. +   public void setVoterIp(String voterIp)
  2018. +   {
  2019. +       _voterIp = voterIp;
  2020. +   }
  2021. +  
  2022. +   public void setDiffTime(long diffTime)
  2023. +   {
  2024. +       _diffTime = diffTime;
  2025. +   }
  2026. +  
  2027. +   public void setVotingTimeSite(long votingTimeSite)
  2028. +   {
  2029. +       _votingTimeSite = votingTimeSite;
  2030. +   }
  2031. +  
  2032. +   public void setVoteSite(int voteSite)
  2033. +   {
  2034. +       _voteSite = voteSite;
  2035. +   }
  2036. +  
  2037. +   public void setAlreadyRewarded(boolean alreadyRewarded)
  2038. +   {
  2039. +       _alreadyRewarded = alreadyRewarded;
  2040. +   }
  2041. +  
  2042. +   public String getVoterIp()
  2043. +   {
  2044. +       return _voterIp;
  2045. +   }
  2046. +  
  2047. +   public long getDiffTime()
  2048. +   {
  2049. +       return _diffTime;
  2050. +   }
  2051. +  
  2052. +   public long getVotingTimeSite()
  2053. +   {
  2054. +       return _votingTimeSite;
  2055. +   }
  2056. +  
  2057. +   public int getVoteSite()
  2058. +   {
  2059. +       return _voteSite;
  2060. +   }
  2061. +  
  2062. +   public boolean getAlreadyRewarded()
  2063. +   {
  2064. +       return _alreadyRewarded;
  2065. +   }
  2066. +  
  2067. +}
  2068. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/individualVoteResponse.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/individualVoteResponse.java
  2069. new file mode 100644
  2070. index 0000000..6707e1b
  2071. --- /dev/null
  2072. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/Model/individualVoteResponse.java
  2073. @@ -0,0 +1,46 @@
  2074. +package org.l2jmobius.gameserver.votesystem.Model;
  2075. +
  2076. +/**
  2077. + * @author l2.topgameserver.net
  2078. + */
  2079. +public class individualVoteResponse
  2080. +{
  2081. +   private boolean _isVoted;
  2082. +   private long _diffTime;
  2083. +   private long _voteSiteTime;
  2084. +  
  2085. +   public individualVoteResponse()
  2086. +   {
  2087. +      
  2088. +   }
  2089. +  
  2090. +   public void setIsVoted(boolean isVoted)
  2091. +   {
  2092. +       _isVoted = isVoted;
  2093. +   }
  2094. +  
  2095. +   public void setDiffTime(long diffTime)
  2096. +   {
  2097. +       _diffTime = diffTime;
  2098. +   }
  2099. +  
  2100. +   public void setVoteSiteTime(long voteSiteTime)
  2101. +   {
  2102. +       _voteSiteTime = voteSiteTime;
  2103. +   }
  2104. +  
  2105. +   public boolean getIsVoted()
  2106. +   {
  2107. +       return _isVoted;
  2108. +   }
  2109. +  
  2110. +   public long getDiffTime()
  2111. +   {
  2112. +       return _diffTime;
  2113. +   }
  2114. +  
  2115. +   public long getVoteSiteTime()
  2116. +   {
  2117. +       return _voteSiteTime;
  2118. +   }
  2119. +}
  2120. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/VoteUtil/VoteSiteXml.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/VoteUtil/VoteSiteXml.java
  2121. new file mode 100644
  2122. index 0000000..618de10
  2123. --- /dev/null
  2124. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/VoteUtil/VoteSiteXml.java
  2125. @@ -0,0 +1,92 @@
  2126. +package org.l2jmobius.gameserver.votesystem.VoteUtil;
  2127. +
  2128. +import java.io.File;
  2129. +import java.util.Collection;
  2130. +import java.util.HashMap;
  2131. +import java.util.Map;
  2132. +import java.util.logging.Level;
  2133. +
  2134. +import org.w3c.dom.Document;
  2135. +import org.w3c.dom.NamedNodeMap;
  2136. +import org.w3c.dom.Node;
  2137. +
  2138. +import org.l2jmobius.commons.util.IXmlReader;
  2139. +import org.l2jmobius.commons.util.StatsSet;
  2140. +import org.l2jmobius.gameserver.votesystem.Model.Reward;
  2141. +import org.l2jmobius.gameserver.votesystem.Model.VoteSite;
  2142. +
  2143. +/**
  2144. + * @author l2.topgameserver.net
  2145. + */
  2146. +public class VoteSiteXml implements IXmlReader
  2147. +{
  2148. +  
  2149. +   private final Map<Integer, VoteSite> _voteSites = new HashMap<>();
  2150. +  
  2151. +   protected VoteSiteXml()
  2152. +   {
  2153. +       load();
  2154. +   }
  2155. +  
  2156. +   @Override
  2157. +   public synchronized void load()
  2158. +   {
  2159. +       parseDatapackFile("data/votesystem.xml");
  2160. +       LOGGER.log(Level.INFO, "Loaded {} reward sites", _voteSites.size());
  2161. +   }
  2162. +  
  2163. +   @Override
  2164. +   public void parseDocument(Document doc, File f)
  2165. +   {
  2166. +       forEach(doc, "list", listNode ->
  2167. +       {
  2168. +           forEach(listNode, "votesite", votesiteNode ->
  2169. +           {
  2170. +               final VoteSite votesite = new VoteSite();
  2171. +               final NamedNodeMap attrs = votesiteNode.getAttributes();
  2172. +               votesite.setSiteOrdinal(parseInteger(attrs, "ordinal"));
  2173. +               votesite.setSiteName(parseString(attrs, "name"));
  2174. +               forEach(votesiteNode, "items", itemsNode -> forEach(itemsNode, "item", itemNode -> votesite.getRewardList().add(new Reward(parseAttributes(itemNode)))));
  2175. +               _voteSites.put(votesite.getSiteOrdinal(), votesite);
  2176. +           });
  2177. +       });
  2178. +   }
  2179. +  
  2180. +   /**
  2181. +    * @param itemNode
  2182. +    * @return
  2183. +    */
  2184. +   @Override
  2185. +   public StatsSet parseAttributes(Node node)
  2186. +   {
  2187. +       final NamedNodeMap attrs = node.getAttributes();
  2188. +       final StatsSet map = new StatsSet();
  2189. +       for (int i = 0; i < attrs.getLength(); i++)
  2190. +       {
  2191. +           final Node att = attrs.item(i);
  2192. +           map.put(att.getNodeName(), att.getNodeValue());
  2193. +       }
  2194. +       return map;
  2195. +   }
  2196. +  
  2197. +   public String getSiteName(int ordinal)
  2198. +   {
  2199. +       return _voteSites.get(ordinal).getSiteName();
  2200. +   }
  2201. +  
  2202. +   public Collection<Reward> getRewards(int ordinal)
  2203. +   {
  2204. +       return _voteSites.get(ordinal).getRewardList();
  2205. +   }
  2206. +  
  2207. +   public static final VoteSiteXml getInstance()
  2208. +   {
  2209. +       return SingletonHolder.INSTANCE;
  2210. +   }
  2211. +  
  2212. +   private static final class SingletonHolder
  2213. +   {
  2214. +       protected static final VoteSiteXml INSTANCE = new VoteSiteXml();
  2215. +   }
  2216. +  
  2217. +}
  2218. diff --git a/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/VoteUtil/VoteUtil.java b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/VoteUtil/VoteUtil.java
  2219. new file mode 100644
  2220. index 0000000..1a904c1
  2221. --- /dev/null
  2222. +++ b/L2J_Mobius_CT_2.6_HighFive/java/org/l2jmobius/gameserver/votesystem/VoteUtil/VoteUtil.java
  2223. @@ -0,0 +1,123 @@
  2224. +package org.l2jmobius.gameserver.votesystem.VoteUtil;
  2225. +
  2226. +import java.io.BufferedReader;
  2227. +import java.io.InputStreamReader;
  2228. +import java.net.HttpURLConnection;
  2229. +import java.net.URL;
  2230. +import java.time.LocalDateTime;
  2231. +import java.time.ZoneId;
  2232. +import java.time.ZonedDateTime;
  2233. +import java.util.logging.Logger;
  2234. +
  2235. +import org.l2jmobius.gameserver.votesystem.Handler.voteHandler;
  2236. +
  2237. +/**
  2238. + * @author l2.topgameserver.net
  2239. + */
  2240. +public final class VoteUtil
  2241. +{
  2242. +   public static final Logger LOGGER = Logger.getLogger(voteHandler.class.getName());
  2243. +  
  2244. +   private static String voteTimeZones[] =
  2245. +   {
  2246. +       "topgameserver.net=Europe/Berlin",
  2247. +       "itopz.com=America/New_York",
  2248. +       "l2top.co=Europe/London",
  2249. +       "l2votes.com=GMT",
  2250. +       "hopzone.net=Europe/Athens",
  2251. +       "l2network.eu=America/Chicago",
  2252. +       "l2topservers.com=Europe/Athens",
  2253. +       "top.l2jbrasil.com=America/Sao_Paulo",
  2254. +       "mmotop.eu=America/Chicago",
  2255. +       "l2topzone.com=America/Chicago",
  2256. +       "l2servers.com=America/Chicago",
  2257. +   };
  2258. +  
  2259. +   public static final long getTimeVotingSite(int ordinalSite)
  2260. +   {
  2261. +       LocalDateTime ldt = LocalDateTime.now(ZoneId.of(voteTimeZones[ordinalSite].split("=")[1]));
  2262. +       ZonedDateTime zdt = ldt.atZone(ZoneId.systemDefault());
  2263. +       long millis = zdt.toInstant().toEpochMilli();
  2264. +       return millis;
  2265. +   }
  2266. +  
  2267. +   public static final String Sites[] =
  2268. +   {
  2269. +       "L2.TopGameServer.net",
  2270. +       "ITopZ.com",
  2271. +       "L2Top.co",
  2272. +       "L2Votes.com",
  2273. +       "L2.Hopzone.net",
  2274. +       "L2Network.eu",
  2275. +       "L2TopServers.com",
  2276. +       "top.l2jbrasil.com",
  2277. +       "MMOTOP.eu",
  2278. +       "L2Topzone.com",
  2279. +       "L2Servers.com"
  2280. +   };
  2281. +  
  2282. +   public static final String getResponse(String Url, int ordinal)
  2283. +   {
  2284. +      
  2285. +       try
  2286. +       {
  2287. +           int responseCode = 0;
  2288. +           URL objUrl = new URL(Url);
  2289. +           HttpURLConnection con = (HttpURLConnection) objUrl.openConnection();
  2290. +           con.setRequestMethod("GET");
  2291. +           con.setRequestProperty("User-Agent", "Mozilla/5.0");
  2292. +           con.setConnectTimeout(5000);
  2293. +           responseCode = con.getResponseCode();
  2294. +           if (responseCode == HttpURLConnection.HTTP_OK)
  2295. +           {
  2296. +              
  2297. +               String inputLine;
  2298. +               StringBuffer response = new StringBuffer();
  2299. +               BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream()));
  2300. +               while ((inputLine = in.readLine()) != null)
  2301. +               {
  2302. +                   if (ordinal == 3)
  2303. +                   {
  2304. +                       if (inputLine.contains("Votes:"))
  2305. +                       {
  2306. +                           response.append(inputLine);
  2307. +                           break;
  2308. +                       }
  2309. +                   }
  2310. +                   if (ordinal == 7)
  2311. +                   {
  2312. +                       if (inputLine.contains("<b>Entradas "))
  2313. +                       {
  2314. +                           response.append(inputLine);
  2315. +                           break;
  2316. +                       }
  2317. +                   }
  2318. +               }
  2319. +               in.close();
  2320. +               return response.toString();
  2321. +           }
  2322. +          
  2323. +       }
  2324. +       catch (Exception e)
  2325. +       {
  2326. +           LOGGER.warning(VoteUtil.Sites[ordinal] + " Say: An error ocurred " + e.getStackTrace());
  2327. +           return "";
  2328. +       }
  2329. +      
  2330. +       return "";
  2331. +   }
  2332. +  
  2333. +   public static final String between(String p1, String str, String p2)
  2334. +   {
  2335. +       String returnValue = "";
  2336. +       int i1 = str.indexOf(p1);
  2337. +       int i2 = str.indexOf(p2);
  2338. +       if ((i1 != -1) && (i2 != -1))
  2339. +       {
  2340. +           i1 = i1 + p1.length();
  2341. +           returnValue = str.substring(i1, i2);
  2342. +       }
  2343. +       return returnValue;
  2344. +   }
  2345. +  
  2346. +}
  2347.  
  2348. \ No newline at end of file
  2349. diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/stats/npcs/custom/custom.xml b/L2J_Mobius_Classic_Interlude/dist/game/data/stats/npcs/custom/custom.xml
  2350. index 2e508bf..7cc4037 100644
  2351. --- a/L2J_Mobius_Classic_Interlude/dist/game/data/stats/npcs/custom/custom.xml
  2352. +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/stats/npcs/custom/custom.xml
  2353. @@ -90,4 +90,22 @@
  2354.             <height normal="12.5" />
  2355.         </collision>
  2356.     </npc>
  2357. +   <npc id="900105" displayId="32365" name="Kaaya" usingServerSideName="true" title="Vote Reward System" type="NpcVoteReward">
  2358. +       <race>HUMAN</race>
  2359. +       <sex>FEMALE</sex>
  2360. +       <stats>
  2361. +           <vitals hp="2444.46819" hpRegen="7.5" mp="1345.8" mpRegen="2.7" />
  2362. +           <attack physical="688.86373" magical="470.40463" random="30" critical="4" accuracy="95" attackSpeed="253" type="SWORD" range="40" distance="80" width="120" />
  2363. +           <defence physical="295.91597" magical="216.53847" />
  2364. +           <speed>
  2365. +               <walk ground="50" />
  2366. +               <run ground="120" />
  2367. +           </speed>
  2368. +       </stats>
  2369. +       <status attackable="false" />
  2370. +       <collision>
  2371. +           <radius normal="11" />
  2372. +           <height normal="22.25" />
  2373. +       </collision>
  2374. +   </npc>
  2375.  </list>
  2376. \ No newline at end of file
  2377. diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/votesystem.xml b/L2J_Mobius_Classic_Interlude/dist/game/data/votesystem.xml
  2378. new file mode 100644
  2379. index 0000000..c125243
  2380. --- /dev/null
  2381. +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/votesystem.xml
  2382. @@ -0,0 +1,71 @@
  2383. +<?xml version="1.0" encoding="UTF-8"?>
  2384. +<list xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="xsd/votesystem.xsd">
  2385. +
  2386. +   <votesite name="l2.topgameserver.net" ordinal="0">
  2387. +       <items>
  2388. +       <item itemId="57" itemCount="100000" />
  2389. +       </items>
  2390. +   </votesite>
  2391. +   <votesite name="ItopZ.com" ordinal="1">
  2392. +       <items>
  2393. +       <item itemId="57" itemCount="100000" />
  2394. +       </items>
  2395. +   </votesite>
  2396. +   <votesite name="L2Top.co" ordinal="2">
  2397. +       <items>
  2398. +       <item itemId="57" itemCount="100000" />
  2399. +       <item itemId="6673" itemCount="1"/>
  2400. +       </items>
  2401. +   </votesite>
  2402. +   <votesite name="L2Votes.com" ordinal="3">
  2403. +       <items>
  2404. +       <item itemId="57" itemCount="100000" />
  2405. +       </items>
  2406. +   </votesite>
  2407. +   <votesite name="Hopzone.net" ordinal="4">
  2408. +       <items>
  2409. +       <item itemId="57" itemCount="100000" />
  2410. +       </items>
  2411. +   </votesite>
  2412. +   <votesite name="L2Network.eu" ordinal="5">
  2413. +       <items>
  2414. +       <item itemId="57" itemCount="100000" />
  2415. +       <item itemId="6673" itemCount="1"/>
  2416. +       </items>
  2417. +   </votesite>
  2418. +   <votesite name="L2Topservers.com" ordinal="6">
  2419. +       <items>
  2420. +       <item itemId="57" itemCount="100000" />
  2421. +       <item itemId="6673" itemCount="1"/>
  2422. +       </items>
  2423. +   </votesite>
  2424. +   <votesite name="top.l2jbrasil.com" ordinal="7">
  2425. +       <items>
  2426. +       <item itemId="57" itemCount="100000" />
  2427. +       <item itemId="6673" itemCount="1"/>
  2428. +       </items>
  2429. +   </votesite>
  2430. +   <votesite name="MMOTOP.eu" ordinal="8">
  2431. +       <items>
  2432. +       <item itemId="57" itemCount="100000" />
  2433. +       <item itemId="6673" itemCount="1"/>
  2434. +       </items>
  2435. +   </votesite>
  2436. +   <votesite name="L2Topzone.com" ordinal="9">
  2437. +       <items>
  2438. +       <item itemId="57" itemCount="100000" />
  2439. +   </items>
  2440. +   </votesite>
  2441. +   <votesite name="L2Servers.com" ordinal="10">
  2442. +       <items>
  2443. +       <item itemId="57" itemCount="100000" />
  2444. +       <item itemId="6673" itemCount="1"/>
  2445. +       </items>
  2446. +   </votesite>
  2447. +   <votesite name="globalVotes" ordinal="11">
  2448. +       <items>
  2449. +       <item itemId="57" itemCount="100000" />
  2450. +       <item itemId="6673" itemCount="1"/>
  2451. +   </items>
  2452. +   </votesite>
  2453. +</list>
  2454. \ No newline at end of file
  2455. diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/xsd/votesystem.xsd b/L2J_Mobius_Classic_Interlude/dist/game/data/xsd/votesystem.xsd
  2456. new file mode 100644
  2457. index 0000000..f5c1e52
  2458. --- /dev/null
  2459. +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/xsd/votesystem.xsd
  2460. @@ -0,0 +1,32 @@
  2461. +<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  2462. +  <xs:element name="list">
  2463. +    <xs:complexType>
  2464. +      <xs:sequence>
  2465. +        <xs:element name="votesite" maxOccurs="unbounded" minOccurs="0">
  2466. +          <xs:complexType>
  2467. +            <xs:sequence>
  2468. +              <xs:element name="items">
  2469. +                <xs:complexType>
  2470. +                  <xs:sequence>
  2471. +                    <xs:element name="item" maxOccurs="unbounded" minOccurs="0">
  2472. +                      <xs:complexType>
  2473. +                        <xs:simpleContent>
  2474. +                          <xs:extension base="xs:string">
  2475. +                            <xs:attribute type="xs:short" name="itemId" use="optional"/>
  2476. +                            <xs:attribute type="xs:int" name="itemCount" use="optional"/>
  2477. +                          </xs:extension>
  2478. +                        </xs:simpleContent>
  2479. +                      </xs:complexType>
  2480. +                    </xs:element>
  2481. +                  </xs:sequence>
  2482. +                </xs:complexType>
  2483. +              </xs:element>
  2484. +            </xs:sequence>
  2485. +            <xs:attribute type="xs:string" name="name" use="optional"/>
  2486. +            <xs:attribute type="xs:byte" name="ordinal" use="optional"/>
  2487. +          </xs:complexType>
  2488. +        </xs:element>
  2489. +      </xs:sequence>
  2490. +    </xs:complexType>
  2491. +  </xs:element>
  2492. +</xs:schema>
  2493. \ No newline at end of file
  2494.  
  2495. diff --git a/L2J_Mobius_Classic_Interlude/dist/game/data/html/mods/votesystem/900105.html b/L2J_Mobius_Classic_Interlude/dist/game/data/html/mods/votesystem/900105.html
  2496. new file mode 100644
  2497. index 0000000..b2a5624
  2498. --- /dev/null
  2499. +++ b/L2J_Mobius_Classic_Interlude/dist/game/data/html/mods/votesystem/900105.html
  2500. @@ -0,0 +1,19 @@
  2501. +<html>
  2502. +<title>Voting panel</title>
  2503. +<body><center>
  2504. +   <br><img src="L2UI_CH3.herotower_deco" width=256 height=32><br>
  2505. +   <table cellpadding=2 width=280>
  2506. +       <tr><td width="280">Hello <font color="C6AF00">%accountName%</font>, welcome to the voting rewards dashboard, please help us by voting by server every <font color="C6AF00">%everyXtime% hours</font> in all voting sites.</td></tr>
  2507. +   </table>
  2508. +   <table width="290"><tr><td width="290" align="center">You can vote: </td></tr></table>
  2509. +   <br><img src="l2ui.SquareWhite" width=290 height=1><br>
  2510. +
  2511. +   %enablevote%
  2512. +
  2513. +   <br>
  2514. +   <img src="l2ui.SquareWhite" width=290 height=1><br>
  2515. +
  2516. +
  2517. +
  2518. +</center></body>
  2519. +</html>
  2520. \ No newline at end of file
  2521.  
  2522. // votesystem.ini
  2523.  
  2524.  
  2525. EnableVoteSystem = True
  2526.  
  2527. EnableGlobalVote = True
  2528.  
  2529. EnableIndividualVote = True
  2530.  
  2531. ## Time to Update table totalVotes from DB
  2532. NextTimeToAutoUpdateTotalVote = 2
  2533.  
  2534. ## Time to update table individualVotes
  2535. NextTimeToAutoUpdateIndividualVotes = 2
  2536.  
  2537. NextTimeToAutoCleanInnecesaryVotes = 30
  2538.  
  2539. NextTimeToCheckAutoGlobalVotesReward = 1
  2540.  
  2541. IntervalTimeToNextVote = 12
  2542.  
  2543. GlobalVotesAmountToNextReward = 1
  2544.  
  2545. EnableVotingCommand = True
  2546.  
  2547. VotingCommand = getreward
  2548.  
  2549. ## l2.topgameserver.net
  2550. VoteLinkTgs = http://l2.topgameserver.net/lineage/VoteApi/
  2551.  
  2552. TgsApiKey = M0wyIENodWtpYWl1bTVjZmVmM2I0ODkyMDM=
  2553.  
  2554. ## l2top.co
  2555. VoteLinkTopCo = https://l2top.co/reward/
  2556.  
  2557. TopCoSrvId =
  2558.  
  2559. ## ITopz.com
  2560. VoteLinkItopz = https://itopz.com/check/
  2561.  
  2562. ItopzZpiKey = h7TfjAcWra-HE0tMMMBgbeRm5DMhcYK
  2563.  
  2564. ItopzSrvId = 325316
  2565.  
  2566. ## l2votes.com
  2567. VoteLinkVts = https://l2votes.com/
  2568.  
  2569. VtsApiKey =
  2570.  
  2571. VtsSid =
  2572.  
  2573. ## Hopzone.net
  2574. VoteLinkHz = https://api.hopzone.net/lineage2/
  2575.  
  2576. HzApiKey = 1fvTOehqGka8NYRc
  2577.  
  2578. ## l2network.eu
  2579. VoteNetworkLink = https://l2network.eu/api.php
  2580.  
  2581. VoteNetworkUserName =
  2582.  
  2583. VoteNetworkApiKey =
  2584.  
  2585. ## L2TopServer.com
  2586. VoteLinkTss = https://l2topservers.com/votes?
  2587.  
  2588. TssApiToken =
  2589.  
  2590. TsSrvId = 453
  2591.  
  2592. TsDomainName= l2catgang
  2593.  
  2594. ## top.l2jbrasil.com
  2595. BrasilVoteLink = https://top.l2jbrasil.com/votesystem/index.php?
  2596.  
  2597. BrasilUserName = julioguzman
  2598.  
  2599. ## Mmotop.eu
  2600. VoteLinkMmotop = https://l2jtop.com/api/
  2601.  
  2602. MmotopApiKey =
  2603.  
  2604. ## L2TopZone.com
  2605. VoteLinkTz = https://api.l2topzone.com/v1/
  2606.  
  2607. TzApiKey =
  2608.  
  2609. ## L2Servers.com
  2610. VoteLinkServers = https://www.l2servers.com/api/
  2611.  
  2612. ServersHashCode =
  2613.  
  2614. ServersSrvId =
  2615.  
  2616.  
  2617. ## for localhost test if your project is live, put the word off or leave it blank
  2618. TestIp =
  2619.  
  2620. ==========================================SQL================================
  2621. -- ----------------------------
  2622. -- Table structure for globalvotes
  2623. -- ----------------------------
  2624. DROP TABLE IF EXISTS `globalvotes`;
  2625. CREATE TABLE `globalvotes`  (
  2626.   `voteSite` tinyint(2) NOT NULL,
  2627.   `lastRewardVotes` int(11) NULL DEFAULT NULL,
  2628.   PRIMARY KEY (`voteSite`) USING BTREE
  2629. ) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
  2630.  
  2631. -- ----------------------------
  2632. -- Records of globalvotes
  2633. -- ----------------------------
  2634. INSERT INTO `globalvotes` VALUES (0, 13);
  2635. INSERT INTO `globalvotes` VALUES (1, 68);
  2636. INSERT INTO `globalvotes` VALUES (2, 0);
  2637. INSERT INTO `globalvotes` VALUES (3, 3);
  2638. INSERT INTO `globalvotes` VALUES (4, 2);
  2639. INSERT INTO `globalvotes` VALUES (5, 0);
  2640. INSERT INTO `globalvotes` VALUES (6, 0);
  2641. INSERT INTO `globalvotes` VALUES (7, 2);
  2642. INSERT INTO `globalvotes` VALUES (8, 3);
  2643. INSERT INTO `globalvotes` VALUES (9, 0);
  2644. INSERT INTO `globalvotes` VALUES (10, 75);
  2645.  
  2646. -- ----------------------------
  2647. -- Table structure for individualvotes
  2648. -- ----------------------------
  2649. DROP TABLE IF EXISTS `individualvotes`;
  2650. CREATE TABLE `individualvotes`  (
  2651.   `voterIp` varchar(40) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL,
  2652.   `voteSite` tinyint(3) NOT NULL,
  2653.   `diffTime` bigint(20) NULL DEFAULT NULL,
  2654.   `votingTimeSite` bigint(20) NULL DEFAULT NULL,
  2655.   `alreadyRewarded` tinyint(3) NULL DEFAULT NULL,
  2656.   PRIMARY KEY (`voterIp`, `voteSite`) USING BTREE
  2657. ) ENGINE = InnoDB CHARACTER SET = latin1 COLLATE = latin1_swedish_ci ROW_FORMAT = Dynamic;
RAW Paste Data Copied