RequestExCubeGameChangeTeam.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.network.clientpackets;
  16. import java.util.logging.Logger;
  17. import com.l2jserver.gameserver.instancemanager.HandysBlockCheckerManager;
  18. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  19. /**
  20. * Format: chdd
  21. * d: Arena
  22. * d: Team
  23. *
  24. * @author mrTJO
  25. */
  26. public final class RequestExCubeGameChangeTeam extends L2GameClientPacket
  27. {
  28. private static final String _C__D0_5A_REQUESTEXCUBEGAMECHANGETEAM = "[C] D0:5A RequestExCubeGameChangeTeam";
  29. private static Logger _log = Logger.getLogger(RequestExCubeGameChangeTeam.class.getName());
  30. int _arena;
  31. int _team;
  32. @Override
  33. protected void readImpl()
  34. {
  35. // client sends -1,0,1,2 for arena parameter
  36. _arena = readD() + 1;
  37. _team = readD();
  38. }
  39. @Override
  40. public void runImpl()
  41. {
  42. // do not remove players after start
  43. if (HandysBlockCheckerManager.getInstance().arenaIsBeingUsed(_arena))
  44. return;
  45. L2PcInstance player = getClient().getActiveChar();
  46. switch (_team)
  47. {
  48. case 0:
  49. case 1:
  50. // Change Player Team
  51. HandysBlockCheckerManager.getInstance().changePlayerToTeam(player, _arena, _team);
  52. break;
  53. case -1:
  54. // Remove Player (me)
  55. {
  56. int team = HandysBlockCheckerManager.getInstance().getHolder(_arena).getPlayerTeam(player);
  57. // client sends two times this packet if click on exit
  58. // client did not send this packet on restart
  59. if (team > -1)
  60. HandysBlockCheckerManager.getInstance().removePlayer(player, _arena, team);
  61. break;
  62. }
  63. default:
  64. _log.warning("Wrong Cube Game Team ID: "+_team);
  65. break;
  66. }
  67. }
  68. @Override
  69. public String getType()
  70. {
  71. return _C__D0_5A_REQUESTEXCUBEGAMECHANGETEAM;
  72. }
  73. }