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