Loc.java 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /*
  2. * Copyright (C) 2004-2015 L2J DataPack
  3. *
  4. * This file is part of L2J DataPack.
  5. *
  6. * L2J DataPack 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 DataPack 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 handlers.usercommandhandlers;
  20. import com.l2jserver.gameserver.enums.Race;
  21. import com.l2jserver.gameserver.handler.IUserCommandHandler;
  22. import com.l2jserver.gameserver.instancemanager.MapRegionManager;
  23. import com.l2jserver.gameserver.instancemanager.ZoneManager;
  24. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  25. import com.l2jserver.gameserver.model.zone.type.L2RespawnZone;
  26. import com.l2jserver.gameserver.network.SystemMessageId;
  27. import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
  28. /**
  29. * Loc user command.
  30. */
  31. public class Loc implements IUserCommandHandler
  32. {
  33. private static final int[] COMMAND_IDS =
  34. {
  35. 0
  36. };
  37. @Override
  38. public boolean useUserCommand(int id, L2PcInstance activeChar)
  39. {
  40. int region;
  41. L2RespawnZone zone = ZoneManager.getInstance().getZone(activeChar, L2RespawnZone.class);
  42. if (zone != null)
  43. {
  44. region = MapRegionManager.getInstance().getRestartRegion(activeChar, zone.getAllRespawnPoints().get(Race.HUMAN)).getLocId();
  45. }
  46. else
  47. {
  48. region = MapRegionManager.getInstance().getMapRegionLocId(activeChar);
  49. }
  50. SystemMessage sm;
  51. if (region > 0)
  52. {
  53. sm = SystemMessage.getSystemMessage(region);
  54. if (sm.getSystemMessageId().getParamCount() == 3)
  55. {
  56. sm.addInt(activeChar.getX());
  57. sm.addInt(activeChar.getY());
  58. sm.addInt(activeChar.getZ());
  59. }
  60. }
  61. else
  62. {
  63. sm = SystemMessage.getSystemMessage(SystemMessageId.CURRENT_LOCATION_S1);
  64. sm.addString(activeChar.getX() + ", " + activeChar.getY() + ", " + activeChar.getZ());
  65. }
  66. activeChar.sendPacket(sm);
  67. return true;
  68. }
  69. @Override
  70. public int[] getUserCommandList()
  71. {
  72. return COMMAND_IDS;
  73. }
  74. }