l2TopgameserverNet

Mobius Interlude classic vote reward - l2.topgameserver.net

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