Advertisement
Guest User

vote

a guest
Feb 7th, 2017
1,500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.53 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P aCis_gameserver
  3. Index: java/net/sf/l2j/gameserver/autovotereward/AutoVoteMain.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/autovotereward/AutoVoteMain.java (revision 0)
  6. +++ java/net/sf/l2j/gameserver/autovotereward/AutoVoteMain.java (working copy)
  7. @@ -0,0 +1,180 @@
  8. +/*
  9. + * This program is free software: you can redistribute it and/or modify it under
  10. + * the terms of the GNU General Public License as published by the Free Software
  11. + * Foundation, either version 3 of the License, or (at your option) any later
  12. + * version.
  13. + *
  14. + * This program is distributed in the hope that it will be useful, but WITHOUT
  15. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  16. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  17. + * details.
  18. + *
  19. + * You should have received a copy of the GNU General Public License along with
  20. + * this program. If not, see <http://www.gnu.org/licenses/>.
  21. + */
  22. +package net.sf.l2j.gameserver.autovotereward;
  23. +
  24. +import java.util.Collection;
  25. +import java.util.HashMap;
  26. +import java.util.Map;
  27. +import java.util.logging.Logger;
  28. +
  29. +import net.sf.l2j.commons.concurrent.ThreadPool;
  30. +
  31. +import net.sf.l2j.Config;
  32. +import net.sf.l2j.gameserver.model.World;
  33. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  34. +import net.sf.l2j.gameserver.autovotereward.HopZoneAuto.CheckForRewardHop;
  35. +import net.sf.l2j.gameserver.autovotereward.NetWorkAuto.CheckForRewardNet;
  36. +import net.sf.l2j.gameserver.autovotereward.TopZoneAuto.CheckForRewardTop;
  37. +
  38. +/**
  39. + * @author Reborn12
  40. + *
  41. + */
  42. +public class AutoVoteMain
  43. +{
  44. + static final Logger LOGGER = Logger.getLogger(AutoVoteMain.class.getName());
  45. + static Map<String, Integer> playerIps = new HashMap<>();
  46. + private static int _topzoneVotesCount = 0;
  47. + private static int _l2networkVotesCount = 0;
  48. + private static int _hopzoneVotesCount = 0;
  49. + static boolean _topzone = false;
  50. + static boolean _l2network = false;
  51. + static boolean _hopzone = false;
  52. +
  53. + AutoVoteMain()
  54. + {
  55. + LOGGER.info("VoteSystem Loaded.");
  56. + if (_topzone)
  57. + {
  58. + int topzone_votes = TopZoneAuto.getTopZoneVotes();
  59. +
  60. + if (topzone_votes == -1)
  61. + topzone_votes = 0;
  62. +
  63. + setTopZoneVoteCount(topzone_votes);
  64. + }
  65. +
  66. + if (_l2network)
  67. + {
  68. + int l2network_votes = NetWorkAuto.getL2NetworkVotes();
  69. +
  70. + if (l2network_votes == -1)
  71. + l2network_votes = 0;
  72. +
  73. + setL2NetworkVoteCount(l2network_votes);
  74. + }
  75. +
  76. + if (_hopzone)
  77. + {
  78. + int hopzone_votes = HopZoneAuto.getHopZoneVotes();
  79. +
  80. + if (hopzone_votes == -1)
  81. + hopzone_votes = 0;
  82. +
  83. + setHopZoneVoteCount(hopzone_votes);
  84. + }
  85. + startTimer();
  86. + }
  87. +
  88. + private static void startTimer()
  89. + {
  90. + ThreadPool.scheduleAtFixedRate(new CheckForRewardNet(), Config.VOTES_SYSTEM_INITIAL_DELAY_NET * 60 * 1000, Config.VOTES_SYSTEM_STEP_DELAY_NET * 60 * 1000);
  91. + ThreadPool.scheduleAtFixedRate(new CheckForRewardTop(), Config.VOTES_SYSTEM_INITIAL_DELAY_TOP * 60 * 1000, Config.VOTES_SYSTEM_STEP_DELAY_TOP * 60 * 1000);
  92. + ThreadPool.scheduleAtFixedRate(new CheckForRewardHop(), Config.VOTES_SYSTEM_INITIAL_DELAY_HOP * 60 * 1000, Config.VOTES_SYSTEM_STEP_DELAY_HOP * 60 * 1000);
  93. + }
  94. +
  95. + protected static void rewardPlayer()
  96. + {
  97. + Collection<L2PcInstance> pls = World.getInstance().getPlayers();
  98. +
  99. + for (L2PcInstance p : pls)
  100. + {
  101. + if (p.getClient() == null || p.getClient().isDetached()) // offline shops protection
  102. + continue;
  103. +
  104. + boolean canReward = false;
  105. + String pIp = p.getClient().getConnection().getInetAddress().getHostAddress();
  106. + if (playerIps.containsKey(pIp))
  107. + {
  108. + int count = playerIps.get(pIp);
  109. + if (count < Config.VOTE_BOXES_ALLOWED)
  110. + {
  111. + playerIps.remove(pIp);
  112. + playerIps.put(pIp, count + 1);
  113. + canReward = true;
  114. + }
  115. + }
  116. + else
  117. + {
  118. + canReward = true;
  119. + playerIps.put(pIp, 1);
  120. + }
  121. + if (canReward)
  122. + for (int i : Config.VOTES_REWARDS_LIST_AUTOVOTE.keySet())
  123. + p.addItem("Vote reward.", i, Config.VOTES_REWARDS_LIST_AUTOVOTE.get(i), p, true);
  124. + else
  125. + p.sendMessage("Already " + Config.VOTE_BOXES_ALLOWED + " character(s) of your ip have been rewarded, so this character won't be rewarded.");
  126. + }
  127. + playerIps.clear();
  128. + }
  129. +
  130. + protected static void setTopZoneVoteCount(int voteCount)
  131. + {
  132. + _topzoneVotesCount = voteCount;
  133. + }
  134. +
  135. + protected static int getTopZoneVoteCount()
  136. + {
  137. + return _topzoneVotesCount;
  138. +
  139. + }
  140. +
  141. + protected static void setL2NetworkVoteCount(int voteCount)
  142. + {
  143. + _l2networkVotesCount = voteCount;
  144. + }
  145. +
  146. + protected static int getL2NetworkVoteCount()
  147. + {
  148. + return _l2networkVotesCount;
  149. + }
  150. +
  151. + protected static void setHopZoneVoteCount(int voteCount)
  152. + {
  153. + _hopzoneVotesCount = voteCount;
  154. + }
  155. +
  156. + protected static int getHopZoneVoteCount()
  157. + {
  158. + return _hopzoneVotesCount;
  159. + }
  160. +
  161. + public static AutoVoteMain getInstance()
  162. + {
  163. +
  164. + if (Config.VOTES_SITE_TOPZONE_LINK_TOP != null && !Config.VOTES_SITE_TOPZONE_LINK_TOP.equals(""))
  165. + {
  166. + _topzone = true;
  167. + }
  168. + if (Config.VOTES_SITE_L2NETWORK_LINK_NET != null && !Config.VOTES_SITE_L2NETWORK_LINK_NET.equals(""))
  169. + {
  170. + _l2network = true;
  171. + }
  172. + if (Config.VOTES_SITE_HOPZONE_LINK_HOP != null && !Config.VOTES_SITE_HOPZONE_LINK_HOP.equals(""))
  173. + {
  174. + _hopzone = true;
  175. + }
  176. + if (_topzone && _l2network && _hopzone)
  177. + {
  178. + return SingletonHolder._instance;
  179. + }
  180. + return null;
  181. + }
  182. +
  183. + private static class SingletonHolder
  184. + {
  185. + protected static final AutoVoteMain _instance = new AutoVoteMain();
  186. + }
  187. +}
  188. Index: java/net/sf/l2j/gameserver/autovotereward/HopZoneAuto.java
  189. ===================================================================
  190. --- java/net/sf/l2j/gameserver/autovotereward/HopZoneAuto.java (revision 0)
  191. +++ java/net/sf/l2j/gameserver/autovotereward/HopZoneAuto.java (working copy)
  192. @@ -0,0 +1,95 @@
  193. +/*
  194. + * This program is free software: you can redistribute it and/or modify it under
  195. + * the terms of the GNU General Public License as published by the Free Software
  196. + * Foundation, either version 3 of the License, or (at your option) any later
  197. + * version.
  198. + *
  199. + * This program is distributed in the hope that it will be useful, but WITHOUT
  200. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  201. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  202. + * details.
  203. + *
  204. + * You should have received a copy of the GNU General Public License along with
  205. + * this program. If not, see <http://www.gnu.org/licenses/>.
  206. + */
  207. +package net.sf.l2j.gameserver.autovotereward;
  208. +
  209. +import java.io.BufferedReader;
  210. +import java.io.InputStreamReader;
  211. +import java.net.HttpURLConnection;
  212. +import java.net.URL;
  213. +import net.sf.l2j.Config;
  214. +import net.sf.l2j.gameserver.model.Announcement;
  215. +
  216. +/**
  217. + * @author Reborn12
  218. + */
  219. +public class HopZoneAuto extends AutoVoteMain
  220. +{
  221. +
  222. + protected static int getHopZoneVotes()
  223. + {
  224. + int votes = -1;
  225. +
  226. + try
  227. + {
  228. + final URL obj = new URL(Config.VOTES_SITE_HOPZONE_LINK_HOP);
  229. + final HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  230. + con.addRequestProperty("User-Agent", "L2Hopzone");
  231. + con.setConnectTimeout(5000);
  232. +
  233. + final int responseCode = con.getResponseCode();
  234. + if (responseCode == 200)
  235. + {
  236. + try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())))
  237. + {
  238. + String line;
  239. + while ((line = in.readLine()) != null)
  240. + {
  241. + if (line.contains("Total Votes") || line.contains("rank tooltip") || line.contains("no steal make love") || line.contains("no votes here") || line.contains("bang, you don't have votes") || line.contains("la vita e bella") || line.contains("rank anonymous tooltip"))
  242. + {
  243. + String inputLine = line.split(">")[2].replace("</span", "");
  244. + votes = Integer.parseInt(inputLine);
  245. + break;
  246. + }
  247. + }
  248. + }
  249. + }
  250. + }
  251. + catch (Exception e)
  252. + {
  253. + System.out.println("Server HOPZONE is offline Trying to Reconnect");
  254. + Announcement.VoteAnnouncements("HOPZONE is offline...Trying to Reconnect");
  255. + }
  256. + return votes;
  257. + }
  258. +
  259. + public static class CheckForRewardHop implements Runnable
  260. + {
  261. +
  262. + @Override
  263. + public void run()
  264. + {
  265. +
  266. + if (_hopzone)
  267. + {
  268. + int hopzone_votes = getHopZoneVotes();
  269. + if (hopzone_votes != -1)
  270. + {
  271. + LOGGER.info("[HOPZONE] Votes: " + hopzone_votes);
  272. +
  273. + Announcement.VoteAnnouncements("[HOPZONE] Votes are " + hopzone_votes + "...");
  274. +
  275. + if (hopzone_votes != 0 && hopzone_votes >= getHopZoneVoteCount() + Config.VOTES_FOR_REWARD_HOP)
  276. + {
  277. + rewardPlayer();
  278. + Announcement.VoteAnnouncements("[HOPZONE] Thanks For Voting..Players Rewarded!");
  279. + }
  280. + setHopZoneVoteCount(hopzone_votes);
  281. + }
  282. + Announcement.VoteAnnouncements("[HOPZONE]Next Reward at " + (getHopZoneVoteCount() + Config.VOTES_FOR_REWARD_HOP) + " Votes!!");
  283. + Announcement.VoteAnnouncements("[WEBSITE] " + Config.SERVER_WEB_SITE);
  284. + }
  285. + }
  286. + }
  287. +}
  288. \ No newline at end of file
  289. Index: java/net/sf/l2j/Config.java
  290. ===================================================================
  291. --- java/net/sf/l2j/Config.java (revision 10)
  292. +++ java/net/sf/l2j/Config.java (working copy)
  293. @@ -53,6 +53,7 @@
  294. public static final String SIEGE_FILE = "./config/siege.properties";
  295. public static final String EVENTS_FILE_CUSTOM = "./config/customevents.properties";
  296. public static final String CLANMANAGER_FILE = "./config/clanmanager.properties";
  297. + public static final String VOTE_FILE = "./config/vote.properties";
  298.  
  299. @@ -547,6 +548,26 @@
  300. public static int BUFFS_MAX_AMOUNT;
  301.  
  302. // --------------------------------------------------
  303. + // Vote settings
  304. + // --------------------------------------------------
  305. + public static boolean VOTE_SYSTEM_ENABLED;
  306. + public static int VOTES_FOR_REWARD_TOP;
  307. + public static int VOTES_FOR_REWARD_NET;
  308. + public static int VOTES_FOR_REWARD_HOP;
  309. + public static int VOTES_SYSTEM_INITIAL_DELAY_TOP;
  310. + public static int VOTES_SYSTEM_STEP_DELAY_TOP;
  311. + public static int VOTES_SYSTEM_INITIAL_DELAY_HOP;
  312. + public static int VOTES_SYSTEM_STEP_DELAY_HOP;
  313. + public static int VOTES_SYSTEM_INITIAL_DELAY_NET;
  314. + public static int VOTES_SYSTEM_STEP_DELAY_NET;
  315. + public static Map<Integer, Integer> VOTES_REWARDS_LIST_AUTOVOTE = new HashMap<>();
  316. + public static int VOTE_BOXES_ALLOWED;
  317. + public static String VOTES_SITE_TOPZONE_LINK_TOP;
  318. + public static String VOTES_SITE_HOPZONE_LINK_HOP;
  319. + public static String VOTES_SITE_L2NETWORK_LINK_NET;
  320. + public static String SERVER_WEB_SITE;
  321. +
  322. + // --------------------------------------------------
  323. // Server
  324. // --------------------------------------------------
  325.  
  326. @@ -1315,6 +1340,38 @@
  327. }
  328.  
  329. /**
  330. + * Loads VoteSystem settings.
  331. + */
  332. + private static final void LoadVoteSystem()
  333. + {
  334. + final ExProperties vote = initProperties(VOTE_FILE);
  335. + VOTE_SYSTEM_ENABLED = vote.getProperty("EnableVoteRewardSystem", true);
  336. + VOTES_FOR_REWARD_TOP = vote.getProperty("VotesRequiredForRewardTop", 100);
  337. + VOTES_SYSTEM_INITIAL_DELAY_TOP = vote.getProperty("VotesSystemInitialDelayTop", 18);
  338. + VOTES_SYSTEM_STEP_DELAY_TOP = vote.getProperty("VotesSystemStepDelayTop", 18);
  339. + VOTES_FOR_REWARD_HOP = vote.getProperty("VotesRequiredForRewardHop", 100);
  340. + VOTES_SYSTEM_INITIAL_DELAY_HOP = vote.getProperty("VotesSystemInitialDelayHop", 18);
  341. + VOTES_SYSTEM_STEP_DELAY_HOP = vote.getProperty("VotesSystemStepDelayHop", 18);
  342. + VOTES_FOR_REWARD_NET = vote.getProperty("VotesRequiredForRewardNet", 100);
  343. + VOTES_SYSTEM_INITIAL_DELAY_NET = vote.getProperty("VotesSystemInitialDelayNet", 18);
  344. + VOTES_SYSTEM_STEP_DELAY_NET = vote.getProperty("VotesSystemStepDelayNet", 18);
  345. + VOTE_BOXES_ALLOWED = vote.getProperty("AutoVoteBoxesAllowed", 18);
  346. + String REWARD_AUTO = vote.getProperty("AutoVoteSystemReward", "57,100000000;");
  347. + String[] reward_splitted_1 = REWARD_AUTO.split(";");
  348. + for (String i : reward_splitted_1)
  349. + {
  350. + String[] reward_splitted_2 = i.split(",");
  351. + VOTES_REWARDS_LIST_AUTOVOTE.put(Integer.parseInt(reward_splitted_2[0]), Integer.parseInt(reward_splitted_2[1]));
  352. + }
  353. + VOTE_BOXES_ALLOWED = vote.getProperty("AutoVoteBoxesAllowed", 1);
  354. + VOTES_SITE_TOPZONE_LINK_TOP = vote.getProperty("VotesSiteTopZoneLinkTop", "");
  355. + VOTES_SITE_HOPZONE_LINK_HOP = vote.getProperty("VotesSiteHopZoneLinkHop", "");
  356. + VOTES_SITE_L2NETWORK_LINK_NET = vote.getProperty("VotesSiteNetWorkLinkNet", "");
  357. + SERVER_WEB_SITE = vote.getProperty("ServerWebSite", "");
  358. +
  359. + }
  360. +
  361. + /**
  362. * Loads gameserver settings.<br>
  363. * IP addresses, database, rates, feature enabled/disabled, misc.
  364. */
  365. @@ -1538,6 +1595,9 @@
  366. // players settings
  367. loadPlayers();
  368.  
  369. + // vote setting
  370. + LoadVoteSystem();
  371. +
  372. // server settings
  373. loadServer();
  374. }
  375. Index: java/net/sf/l2j/gameserver/model/Announcement.java
  376. ===================================================================
  377. --- java/net/sf/l2j/gameserver/model/Announcement.java (revision 3)
  378. +++ java/net/sf/l2j/gameserver/model/Announcement.java (working copy)
  379. @@ -18,6 +18,9 @@
  380.  
  381. import net.sf.l2j.commons.concurrent.ThreadPool;
  382.  
  383. +import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  384. +import net.sf.l2j.gameserver.network.clientpackets.Say2;
  385. +import net.sf.l2j.gameserver.network.serverpackets.CreatureSay;
  386. import net.sf.l2j.gameserver.util.Broadcast;
  387.  
  388. /**
  389. @@ -125,6 +128,19 @@
  390. }
  391. }
  392.  
  393. + public static void VoteAnnouncements(String text)
  394. + {
  395. + CreatureSay cs = new CreatureSay(0, Say2.HERO_VOICE, "", "" + text);
  396. + for (L2PcInstance player : World.getInstance().getPlayers())
  397. + {
  398. + if (player != null)
  399. + if (player.isOnlineInt() != 0)
  400. + player.sendPacket(cs);
  401. + }
  402. +
  403. + cs = null;
  404. + }
  405. +
  406. public void reloadTask()
  407. {
  408. stopTask();
  409. Index: java/net/sf/l2j/gameserver/autovotereward/NetWorkAuto.java
  410. ===================================================================
  411. --- java/net/sf/l2j/gameserver/autovotereward/NetWorkAuto.java (revision 0)
  412. +++ java/net/sf/l2j/gameserver/autovotereward/NetWorkAuto.java (working copy)
  413. @@ -0,0 +1,93 @@
  414. +/*
  415. + * This program is free software: you can redistribute it and/or modify it under
  416. + * the terms of the GNU General Public License as published by the Free Software
  417. + * Foundation, either version 3 of the License, or (at your option) any later
  418. + * version.
  419. + *
  420. + * This program is distributed in the hope that it will be useful, but WITHOUT
  421. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  422. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  423. + * details.
  424. + *
  425. + * You should have received a copy of the GNU General Public License along with
  426. + * this program. If not, see <http://www.gnu.org/licenses/>.
  427. + */
  428. +package net.sf.l2j.gameserver.autovotereward;
  429. +
  430. +import java.io.BufferedReader;
  431. +import java.io.InputStreamReader;
  432. +import java.net.HttpURLConnection;
  433. +import java.net.URL;
  434. +import net.sf.l2j.Config;
  435. +import net.sf.l2j.gameserver.model.Announcement;
  436. +
  437. +/**
  438. + * @author Reborn12
  439. + */
  440. +public class NetWorkAuto extends AutoVoteMain
  441. +{
  442. +
  443. + protected static int getL2NetworkVotes()
  444. + {
  445. + int votes = -1;
  446. +
  447. + try
  448. + {
  449. + final URL obj = new URL(Config.VOTES_SITE_L2NETWORK_LINK_NET);
  450. + final HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  451. +
  452. + con.addRequestProperty("User-Agent", "L2Network");
  453. + con.setConnectTimeout(5000);
  454. +
  455. + final int responseCode = con.getResponseCode();
  456. + if (responseCode == 200)
  457. + {
  458. + try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())))
  459. + {
  460. + String inputLine;
  461. + while ((inputLine = in.readLine()) != null)
  462. + {
  463. + if (inputLine.contains("color:#e7ebf2"))
  464. + {
  465. + votes = Integer.valueOf(inputLine.split(">")[2].replace("</b", ""));
  466. + break;
  467. + }
  468. + }
  469. + }
  470. + }
  471. + }
  472. + catch (Exception e)
  473. + {
  474. + System.out.println("Server L2Network is offline Trying to Reconnect");
  475. + Announcement.VoteAnnouncements("L2Network is offline...Trying to Reconnect");
  476. + }
  477. + return votes;
  478. + }
  479. +
  480. + public static class CheckForRewardNet implements Runnable
  481. + {
  482. +
  483. + @Override
  484. + public void run()
  485. + {
  486. + if (_l2network)
  487. + {
  488. + int l2network_votes = getL2NetworkVotes();
  489. + if (l2network_votes != -1)
  490. + {
  491. + LOGGER.info("[NETWORK] Votes: " + l2network_votes);
  492. + Announcement.VoteAnnouncements("[NETWORK] Votes are " + l2network_votes + "...");
  493. + if ((l2network_votes != 0) && (l2network_votes >= getL2NetworkVoteCount() + Config.VOTES_FOR_REWARD_NET))
  494. + {
  495. + rewardPlayer();
  496. + Announcement.VoteAnnouncements("[NETWORK] Thanks For Voting..Players Rewarded!");
  497. + }
  498. + setL2NetworkVoteCount(l2network_votes);
  499. + }
  500. + Announcement.VoteAnnouncements("[NETWORK]Next Reward at " + (getL2NetworkVoteCount() + Config.VOTES_FOR_REWARD_NET) + " Votes!!");
  501. +
  502. + Announcement.VoteAnnouncements("[WEBSITE] " + Config.SERVER_WEB_SITE);
  503. + }
  504. + }
  505. + }
  506. +}
  507. \ No newline at end of file
  508. Index: java/net/sf/l2j/gameserver/autovotereward/TopZoneAuto.java
  509. ===================================================================
  510. --- java/net/sf/l2j/gameserver/autovotereward/TopZoneAuto.java (revision 0)
  511. +++ java/net/sf/l2j/gameserver/autovotereward/TopZoneAuto.java (working copy)
  512. @@ -0,0 +1,90 @@
  513. +/*
  514. + * This program is free software: you can redistribute it and/or modify it under
  515. + * the terms of the GNU General Public License as published by the Free Software
  516. + * Foundation, either version 3 of the License, or (at your option) any later
  517. + * version.
  518. + *
  519. + * This program is distributed in the hope that it will be useful, but WITHOUT
  520. + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  521. + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  522. + * details.
  523. + *
  524. + * You should have received a copy of the GNU General Public License along with
  525. + * this program. If not, see <http://www.gnu.org/licenses/>.
  526. + */
  527. +package net.sf.l2j.gameserver.autovotereward;
  528. +
  529. +import java.io.BufferedReader;
  530. +import java.io.InputStreamReader;
  531. +import java.net.HttpURLConnection;
  532. +import java.net.URL;
  533. +import net.sf.l2j.Config;
  534. +import net.sf.l2j.gameserver.model.Announcement;
  535. +
  536. +/**
  537. + * @author Reborn12
  538. + */
  539. +public class TopZoneAuto extends AutoVoteMain
  540. +{
  541. +
  542. + public static int getTopZoneVotes()
  543. + {
  544. + int votes = -1;
  545. +
  546. + try
  547. + {
  548. + final URL obj = new URL(Config.VOTES_SITE_TOPZONE_LINK_TOP);
  549. + final HttpURLConnection con = (HttpURLConnection) obj.openConnection();
  550. + con.addRequestProperty("User-Agent", "L2TopZone");
  551. + con.setConnectTimeout(5000);
  552. +
  553. + final int responseCode = con.getResponseCode();
  554. + if (responseCode == 200)
  555. + {
  556. + try (BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())))
  557. + {
  558. + String inputLine;
  559. + while ((inputLine = in.readLine()) != null)
  560. + {
  561. + votes = Integer.valueOf(inputLine);
  562. + break;
  563. + }
  564. + }
  565. + }
  566. + }
  567. + catch (Exception e)
  568. + {
  569. + System.out.println("Server TOPZONE is offline Trying to Reconnect");
  570. + Announcement.VoteAnnouncements("TOPZONE is offline...Trying to Reconnect");
  571. + }
  572. + return votes;
  573. + }
  574. +
  575. + public static class CheckForRewardTop implements Runnable
  576. + {
  577. + @Override
  578. + public void run()
  579. + {
  580. + if (_topzone)
  581. + {
  582. + int topzone_votes = getTopZoneVotes();
  583. + if (topzone_votes != -1)
  584. + {
  585. + LOGGER.info("[TOPZONE] Votes: " + topzone_votes);
  586. + Announcement.VoteAnnouncements("[TOPZONE] Votes are " + topzone_votes + "...");
  587. +
  588. + if (topzone_votes != 0 && topzone_votes >= getTopZoneVoteCount() + Config.VOTES_FOR_REWARD_TOP)
  589. + {
  590. + rewardPlayer();
  591. + Announcement.VoteAnnouncements("[TOPZONE] Thanks For Voting..Players Rewarded!");
  592. + }
  593. + setTopZoneVoteCount(topzone_votes);
  594. + }
  595. + Announcement.VoteAnnouncements("[TOPZONE]Next Reward at " + (getTopZoneVoteCount() + Config.VOTES_FOR_REWARD_TOP) + " Votes!!");
  596. +
  597. + Announcement.VoteAnnouncements("[WEBSITE] " + Config.SERVER_WEB_SITE);
  598. + }
  599. + }
  600. + }
  601. +
  602. +}
  603. Index: java/net/sf/l2j/gameserver/GameServer.java
  604. ===================================================================
  605. --- java/net/sf/l2j/gameserver/GameServer.java (revision 6)
  606. +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
  607. @@ -31,6 +31,7 @@
  608.  
  609. import net.sf.l2j.Config;
  610. import net.sf.l2j.L2DatabaseFactory;
  611. +import net.sf.l2j.gameserver.autovotereward.AutoVoteMain;
  612. import net.sf.l2j.gameserver.cache.CrestCache;
  613. import net.sf.l2j.gameserver.cache.HtmCache;
  614. import net.sf.l2j.gameserver.communitybbs.Manager.ForumsBBSManager;
  615. @@ -267,6 +268,10 @@
  616. StringUtil.printSection("Quests & Scripts");
  617. ScriptManager.getInstance();
  618.  
  619. + StringUtil.printSection("Vote System");
  620. + if (Config.VOTE_SYSTEM_ENABLED)
  621. + AutoVoteMain.getInstance();
  622. +
  623. if (Config.ALLOW_BOAT)
  624. {
  625. BoatManager.getInstance();
  626. Index: config/vote.properties
  627. ===================================================================
  628. --- config/vote.properties (revision 0)
  629. +++ config/vote.properties (working copy)
  630. @@ -0,0 +1,51 @@
  631. +# =================================================================
  632. +# AutoVote Settings
  633. +# =================================================================
  634. +# Automatic Vote Reward System
  635. +EnableVoteRewardSystem = True
  636. +# =================================================================
  637. +# TopZone Settings
  638. +# =================================================================
  639. +# Automatic Vote Reward System
  640. +VotesRequiredForRewardTop = 1
  641. +#Delay To Announce The Site:in Minutes
  642. +VotesSystemInitialDelayTop = 15
  643. +#StepDelay To Announce Again The Site:in Minutes
  644. +VotesSystemStepDelayTop = 30
  645. +# =================================================================
  646. +# HopZone Settings
  647. +# =================================================================
  648. +# Automatic Vote Reward System
  649. +VotesRequiredForRewardHop = 1
  650. +#Delay To Announce The Site:in Minutes
  651. +VotesSystemInitialDelayHop = 20
  652. +#StepDelay To Announce Again The Site:in Minutes
  653. +VotesSystemStepDelayHop = 35
  654. +# =================================================================
  655. +# Network Settings
  656. +# =================================================================
  657. +# Automatic Vote Reward System
  658. +VotesRequiredForRewardNet = 1
  659. +#Delay To Announce The Site:in Minutes
  660. +VotesSystemInitialDelayNet = 25
  661. +#StepDelay To Announce Again The Site:in Minutes
  662. +VotesSystemStepDelayNet = 40
  663. +# =================================================================
  664. +# Reward Settings
  665. +# =================================================================
  666. +#AutoVote Reward ID,Count
  667. +AutoVoteSystemReward = 57,5
  668. +# =================================================================
  669. +# Links Settings & Protection Dual Box
  670. +# =================================================================
  671. +#Boxes Allowed To Take Reward from same ip
  672. +#Ofc Offline Shops Is Protected They dont Take Reward in Offline Mode
  673. +AutoVoteBoxesAllowed = 1
  674. +
  675. +#If You Want To Dissable Any Site Just Delete The Link After =
  676. +VotesSiteTopZoneLinkTop = https://l2topzone.com/tv.php?id=12609
  677. +VotesSiteHopZoneLinkHop = http://l2.hopzone.net/gr/lineage2/details/101262/L2Centos-X9000
  678. +VotesSiteNetWorkLinkNet = http://l2network.eu/details/L2Centos/
  679. +
  680. +#Announce Your Server WebSite
  681. +ServerWebSite = L2centos.com
  682. \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement