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