2
0

AdminDisconnect.java 2.3 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.network.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. {
  29. private static final String[] ADMIN_COMMANDS =
  30. {
  31. "admin_character_disconnect"
  32. };
  33. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  34. {
  35. if (command.equals("admin_character_disconnect"))
  36. {
  37. disconnectCharacter(activeChar);
  38. }
  39. return true;
  40. }
  41. public String[] getAdminCommandList()
  42. {
  43. return ADMIN_COMMANDS;
  44. }
  45. private void disconnectCharacter(L2PcInstance activeChar)
  46. {
  47. L2Object target = activeChar.getTarget();
  48. L2PcInstance player = null;
  49. if (target instanceof L2PcInstance)
  50. player = (L2PcInstance) target;
  51. else
  52. return;
  53. if (player == activeChar)
  54. {
  55. activeChar.sendMessage("You cannot logout your own character.");
  56. }
  57. else
  58. {
  59. activeChar.sendMessage("Character " + player.getName() + " disconnected from server.");
  60. //Logout Character
  61. LeaveWorld ql = new LeaveWorld();
  62. player.sendPacket(ql);
  63. RegionBBSManager.getInstance().changeCommunityBoard();
  64. player.closeNetConnection();
  65. }
  66. }
  67. }