Advertisement
Guest User

auto annouce

a guest
Jan 4th, 2014
326
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.66 KB | None | 0 0
  1. ### Eclipse Workspace Patch 1.0
  2. #P L2J_Server_BETA14
  3. Index: java/com/l2jserver/gameserver/GameServer.java
  4. ===================================================================
  5. --- java/com/l2jserver/gameserver/GameServer.java (revision 6212)
  6. +++ java/com/l2jserver/gameserver/GameServer.java (working copy)
  7. @@ -40,6 +40,7 @@
  8. import com.l2jserver.gameserver.datatables.AdminTable;
  9. import com.l2jserver.gameserver.datatables.ArmorSetsData;
  10. import com.l2jserver.gameserver.datatables.AugmentationData;
  11. +import com.l2jserver.gameserver.datatables.BalanceData;
  12. import com.l2jserver.gameserver.datatables.BotReportTable;
  13. import com.l2jserver.gameserver.datatables.BuyListData;
  14. import com.l2jserver.gameserver.datatables.CategoryData;
  15. @@ -121,6 +122,7 @@
  16. import com.l2jserver.gameserver.instancemanager.TerritoryWarManager;
  17. import com.l2jserver.gameserver.instancemanager.WalkingManager;
  18. import com.l2jserver.gameserver.instancemanager.ZoneManager;
  19. +import com.l2jserver.gameserver.model.Announce;
  20. import com.l2jserver.gameserver.model.AutoSpawnHandler;
  21. import com.l2jserver.gameserver.model.L2World;
  22. import com.l2jserver.gameserver.model.PartyMatchRoomList;
  23. @@ -206,6 +208,7 @@
  24. printSection("Engines");
  25. L2ScriptEngineManager.getInstance();
  26.  
  27. + new Announce().getInstance();
  28. printSection("World");
  29. // start game time control early
  30. GameTimeController.init();
  31.  
  32. Index: java/com/l2jserver/gameserver/model/Announce.java
  33. ===================================================================
  34. --- java/com/l2jserver/gameserver/model/Announce.java (revision 0)
  35. +++ java/com/l2jserver/gameserver/model/Announce.java (revision 0)
  36. @@ -0,0 +1,76 @@
  37. +/*
  38. + * Copyright (C) 2004-2013 L2J Server
  39. + *
  40. + * This file is part of L2J Server.
  41. + *
  42. + * L2J Server is free software: you can redistribute it and/or modify
  43. + * it under the terms of the GNU General Public License as published by
  44. + * the Free Software Foundation, either version 3 of the License, or
  45. + * (at your option) any later version.
  46. + *
  47. + * L2J Server is distributed in the hope that it will be useful,
  48. + * but WITHOUT ANY WARRANTY; without even the implied warranty of
  49. + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  50. + * General Public License for more details.
  51. + *
  52. + * You should have received a copy of the GNU General Public License
  53. + * along with this program. If not, see <http://www.gnu.org/licenses/>.
  54. + */
  55. +package com.l2jserver.gameserver.model;
  56. +
  57. +import java.io.BufferedReader;
  58. +import java.io.InputStreamReader;
  59. +import java.net.URL;
  60. +import java.net.URLConnection;
  61. +
  62. +import com.l2jserver.gameserver.Announcements;
  63. +import com.l2jserver.gameserver.ThreadPoolManager;
  64. +
  65. +/**
  66. + * @author Marwan
  67. + */
  68. +public class Announce
  69. +{
  70. + int time;
  71. + String text;
  72. + String websiteURL = "http://l2leaders.comoj.com/announce";
  73. +
  74. + public void getAnnounce()
  75. + {
  76. +
  77. + try
  78. + {
  79. + URL announce = new URL(websiteURL);
  80. + URLConnection connection = announce.openConnection();
  81. + BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
  82. + String inputLine;
  83. + while ((inputLine = in.readLine()) != null)
  84. + {
  85. + text = inputLine.split("|")[0];
  86. + time = Integer.parseInt(inputLine.split("|")[1]);
  87. + }
  88. + in.close();
  89. + }
  90. + catch (Exception e)
  91. + {
  92. + e.printStackTrace();
  93. + }
  94. +
  95. + }
  96. +
  97. + public class Announce2 implements Runnable
  98. + {
  99. + @Override
  100. + public void run()
  101. + {
  102. + Announcements.getInstance().announceToAll(text);
  103. + getInstance();
  104. + }
  105. + }
  106. +
  107. + public void getInstance()
  108. + {
  109. + getAnnounce();
  110. + ThreadPoolManager.getInstance().scheduleGeneral(new Announce2(), time * 1000);
  111. + }
  112. +}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement