l2TopgameserverNet

L2jFrozen 1132 Interlude vote reward - l2.topgameserver.net

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