AdminDisconnect.java 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 net.sf.l2j.gameserver.handler.admincommandhandlers;
  16. import net.sf.l2j.gameserver.communitybbs.Manager.RegionBBSManager;
  17. import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
  18. import net.sf.l2j.gameserver.model.L2Object;
  19. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  20. import net.sf.l2j.gameserver.serverpackets.LeaveWorld;
  21. /**
  22. * This class handles following admin commands:
  23. * - character_disconnect = disconnects target player
  24. *
  25. * @version $Revision: 1.2.4.4 $ $Date: 2005/04/11 10:06:00 $
  26. */
  27. public class AdminDisconnect implements IAdminCommandHandler {
  28. private static final String[] ADMIN_COMMANDS =
  29. {
  30. "admin_character_disconnect"
  31. };
  32. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  33. {
  34. if (command.equals("admin_character_disconnect"))
  35. {
  36. disconnectCharacter(activeChar);
  37. }
  38. return true;
  39. }
  40. public String[] getAdminCommandList()
  41. {
  42. return ADMIN_COMMANDS;
  43. }
  44. private void disconnectCharacter(L2PcInstance activeChar)
  45. {
  46. L2Object target = activeChar.getTarget();
  47. L2PcInstance player = null;
  48. if (target instanceof L2PcInstance)
  49. player = (L2PcInstance)target;
  50. else
  51. return;
  52. if (player == activeChar)
  53. {
  54. activeChar.sendMessage("You cannot logout your own character.");
  55. }
  56. else
  57. {
  58. activeChar.sendMessage("Character " + player.getName() + " disconnected from server.");
  59. //Logout Character
  60. LeaveWorld ql = new LeaveWorld();
  61. player.sendPacket(ql);
  62. RegionBBSManager.getInstance().changeCommunityBoard();
  63. player.closeNetConnection();
  64. }
  65. }
  66. }