OlympiadAnnouncer.java 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * Copyright (C) 2004-2015 L2J Server
  3. *
  4. * This file is part of L2J Server.
  5. *
  6. * L2J Server is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * L2J Server is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. package com.l2jserver.gameserver.model.olympiad;
  20. import java.util.Set;
  21. import com.l2jserver.gameserver.datatables.SpawnTable;
  22. import com.l2jserver.gameserver.model.L2Spawn;
  23. import com.l2jserver.gameserver.model.actor.L2Npc;
  24. import com.l2jserver.gameserver.network.NpcStringId;
  25. import com.l2jserver.gameserver.network.clientpackets.Say2;
  26. import com.l2jserver.gameserver.network.serverpackets.NpcSay;
  27. /**
  28. * @author DS
  29. */
  30. public final class OlympiadAnnouncer implements Runnable
  31. {
  32. private static final int OLY_MANAGER = 31688;
  33. private final Set<L2Spawn> _managers;
  34. private int _currentStadium = 0;
  35. public OlympiadAnnouncer()
  36. {
  37. _managers = SpawnTable.getInstance().getSpawns(OLY_MANAGER);
  38. }
  39. @Override
  40. public void run()
  41. {
  42. OlympiadGameTask task;
  43. for (int i = OlympiadGameManager.getInstance().getNumberOfStadiums(); --i >= 0; _currentStadium++)
  44. {
  45. if (_currentStadium >= OlympiadGameManager.getInstance().getNumberOfStadiums())
  46. {
  47. _currentStadium = 0;
  48. }
  49. task = OlympiadGameManager.getInstance().getOlympiadTask(_currentStadium);
  50. if ((task != null) && (task.getGame() != null) && task.needAnnounce())
  51. {
  52. NpcStringId npcString;
  53. final String arenaId = String.valueOf(task.getGame().getStadiumId() + 1);
  54. switch (task.getGame().getType())
  55. {
  56. case NON_CLASSED:
  57. npcString = NpcStringId.OLYMPIAD_CLASS_FREE_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
  58. break;
  59. case CLASSED:
  60. npcString = NpcStringId.OLYMPIAD_CLASS_INDIVIDUAL_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
  61. break;
  62. case TEAMS:
  63. npcString = NpcStringId.OLYMPIAD_CLASS_FREE_TEAM_MATCH_IS_GOING_TO_BEGIN_IN_ARENA_S1_IN_A_MOMENT;
  64. break;
  65. default:
  66. continue;
  67. }
  68. L2Npc manager;
  69. NpcSay packet;
  70. for (L2Spawn spawn : _managers)
  71. {
  72. manager = spawn.getLastSpawn();
  73. if (manager != null)
  74. {
  75. packet = new NpcSay(manager.getObjectId(), Say2.NPC_SHOUT, manager.getId(), npcString);
  76. packet.addStringParameter(arenaId);
  77. manager.broadcastPacket(packet);
  78. }
  79. }
  80. break;
  81. }
  82. }
  83. }
  84. }