l2TopgameserverNet

L2jMobius Interlude vote reward - l2.topgameserver.net

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