Advertisement
warc222

Auto Announce Online Players.

Oct 3rd, 2015
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.98 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P Coding Time!
  3. Index: java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java
  4. ===================================================================
  5. --- java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java (revision 0)
  6. +++ java/net/sf/l2j/gameserver/model/entity/AnnounceOnlinePlayers.java (working copy)
  7. @@ -0,0 +1,52 @@
  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.model.entity;
  23. +
  24. +import net.sf.l2j.Config;
  25. +import net.sf.l2j.gameserver.Announcements;
  26. +import net.sf.l2j.gameserver.ThreadPoolManager;
  27. +import net.sf.l2j.gameserver.model.L2World;
  28. +
  29. +/**
  30. + *
  31. + * @author Debian
  32. + *
  33. + */
  34. +
  35. +public class AnnounceOnlinePlayers
  36. +{
  37. + public static void getInstance()
  38. + {
  39. + ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new Runnable()
  40. + {
  41. + @Override
  42. + @SuppressWarnings("synthetic-access")
  43. + public void run()
  44. + {
  45. + Announce();
  46. + }
  47. + }, 0,Config.ANNOUNCE_ONLINE_PLAYERS_DELAY * 1000);
  48. + }
  49. + @SuppressWarnings("static-access")
  50. + private static void Announce()
  51. + {
  52. + int NumberofPlayers = L2World.getInstance().getAllPlayersCount();
  53. +
  54. + if (NumberofPlayers == 1)
  55. + Announcements.getInstance().announceToAll(NumberofPlayers + " player is online.");
  56. + else
  57. + Announcements.getInstance().announceToAll(NumberofPlayers + " players are online.");
  58. + }
  59. +}
  60. \ No newline at end of file
  61. Index: java/net/sf/l2j/gameserver/GameServer.java
  62. ===================================================================
  63. --- java/net/sf/l2j/gameserver/GameServer.java (revision 270)
  64. +++ java/net/sf/l2j/gameserver/GameServer.java (working copy)
  65. @@ -89,6 +89,7 @@
  66. import net.sf.l2j.gameserver.model.L2World;
  67. import net.sf.l2j.gameserver.model.PartyMatchRoomList;
  68. import net.sf.l2j.gameserver.model.PartyMatchWaitingList;
  69. +import net.sf.l2j.gameserver.model.entity.AnnounceOnlinePlayers;
  70. import net.sf.l2j.gameserver.model.entity.Castle;
  71. import net.sf.l2j.gameserver.model.entity.Hero;
  72. import net.sf.l2j.gameserver.model.olympiad.Olympiad;
  73. @@ -273,6 +274,9 @@
  74. if (Config.ALLOW_WEDDING)
  75. CoupleManager.getInstance();
  76.  
  77. + if (Config.ALLOW_ANNOUNCE_ONLINE_PLAYERS)
  78. + AnnounceOnlinePlayers.getInstance();
  79. +
  80. Util.printSection("System");
  81. TaskManager.getInstance();
  82.  
  83. Index: config/events.properties
  84. ===================================================================
  85. --- config/events.properties (revision 270)
  86. +++ config/events.properties (working copy)
  87. @@ -229,4 +229,13 @@
  88. AltLottery3NumberRate = 0.2
  89.  
  90. # How much adena receive characters who pick two or less of the winning number
  91. -AltLottery2and1NumberPrize = 200
  92. \ No newline at end of file
  93. +AltLottery2and1NumberPrize = 200
  94. +
  95. +#=============================================================
  96. +# Announce Online Players
  97. +#=============================================================
  98. +# Enable this feature.
  99. +AllowAnnounceOnlinePlayers = True
  100. +
  101. +# Announcement Delay (in seconds)
  102. +AnnounceOnlinePlayersDelay = 300
  103. \ No newline at end of file
  104. Index: java/net/sf/l2j/Config.java
  105. ===================================================================
  106. --- java/net/sf/l2j/Config.java (revision 270)
  107. +++ java/net/sf/l2j/Config.java (working copy)
  108. @@ -262,6 +262,10 @@
  109. public static float ALT_LOTTERY_3_NUMBER_RATE;
  110. public static int ALT_LOTTERY_2_AND_1_NUMBER_PRIZE;
  111.  
  112. + /** Announce Online Players */
  113. + public static boolean ALLOW_ANNOUNCE_ONLINE_PLAYERS;
  114. + public static int ANNOUNCE_ONLINE_PLAYERS_DELAY;
  115. +
  116. // --------------------------------------------------
  117. // HexID
  118. // --------------------------------------------------
  119. @@ -994,6 +998,8 @@
  120. ALT_LOTTERY_4_NUMBER_RATE = Float.parseFloat(events.getProperty("AltLottery4NumberRate", "0.2"));
  121. ALT_LOTTERY_3_NUMBER_RATE = Float.parseFloat(events.getProperty("AltLottery3NumberRate", "0.2"));
  122. ALT_LOTTERY_2_AND_1_NUMBER_PRIZE = Integer.parseInt(events.getProperty("AltLottery2and1NumberPrize", "200"));
  123. + ALLOW_ANNOUNCE_ONLINE_PLAYERS = Boolean.parseBoolean(events.getProperty("AllowAnnounceOnlinePlayers", "True"));
  124. + ANNOUNCE_ONLINE_PLAYERS_DELAY = Integer.parseInt(events.getProperty("AnnounceOnlinePlayersDelay", "300"));
  125. }
  126. catch (Exception e)
  127. {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement