ExSendUIEvent.java 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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.network.serverpackets;
  20. import java.util.Arrays;
  21. import java.util.List;
  22. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  23. import com.l2jserver.gameserver.network.NpcStringId;
  24. public class ExSendUIEvent extends L2GameServerPacket
  25. {
  26. private final int _objectId;
  27. private final boolean _type;
  28. private final boolean _countUp;
  29. private final int _startTime;
  30. private final int _endTime;
  31. private final int _npcstringId;
  32. private List<String> _params = null;
  33. /**
  34. * @param player
  35. * @param hide
  36. * @param countUp
  37. * @param startTime
  38. * @param endTime
  39. * @param text
  40. */
  41. public ExSendUIEvent(L2PcInstance player, boolean hide, boolean countUp, int startTime, int endTime, String text)
  42. {
  43. this(player, hide, countUp, startTime, endTime, -1, text);
  44. }
  45. /**
  46. * @param player
  47. * @param hide
  48. * @param countUp
  49. * @param startTime
  50. * @param endTime
  51. * @param npcString
  52. * @param params
  53. */
  54. public ExSendUIEvent(L2PcInstance player, boolean hide, boolean countUp, int startTime, int endTime, NpcStringId npcString, String... params)
  55. {
  56. this(player, hide, countUp, startTime, endTime, npcString.getId(), params);
  57. }
  58. /**
  59. * @param player
  60. * @param hide
  61. * @param countUp
  62. * @param startTime
  63. * @param endTime
  64. * @param npcstringId
  65. * @param params
  66. */
  67. public ExSendUIEvent(L2PcInstance player, boolean hide, boolean countUp, int startTime, int endTime, int npcstringId, String... params)
  68. {
  69. _objectId = player.getObjectId();
  70. _type = hide;
  71. _countUp = countUp;
  72. _startTime = startTime;
  73. _endTime = endTime;
  74. _npcstringId = npcstringId;
  75. _params = Arrays.asList(params);
  76. }
  77. @Override
  78. protected void writeImpl()
  79. {
  80. writeC(0xFE);
  81. writeH(0x8E);
  82. writeD(_objectId);
  83. writeD(_type ? 1 : 0); // 0 = show, 1 = hide (there is 2 = pause and 3 = resume also but they don't work well you can only pause count down and you cannot resume it because resume hides the counter).
  84. writeD(0);// unknown
  85. writeD(0);// unknown
  86. writeS(_countUp ? "1" : "0"); // 0 = count down, 1 = count up
  87. // timer always disappears 10 seconds before end
  88. writeS(String.valueOf(_startTime / 60));
  89. writeS(String.valueOf(_startTime % 60));
  90. writeS(String.valueOf(_endTime / 60));
  91. writeS(String.valueOf(_endTime % 60));
  92. writeD(_npcstringId);
  93. if (_params != null)
  94. {
  95. for (String param : _params)
  96. {
  97. writeS(param);
  98. }
  99. }
  100. }
  101. }