AdminTest.java 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. /*
  2. * $Header: AdminTest.java, 25/07/2005 17:15:21 luisantonioa Exp $
  3. *
  4. * $Author: luisantonioa $
  5. * $Date: 25/07/2005 17:15:21 $
  6. * $Revision: 1 $
  7. * $Log: AdminTest.java,v $
  8. * Revision 1 25/07/2005 17:15:21 luisantonioa
  9. * Added copyright notice
  10. *
  11. *
  12. * This program is free software: you can redistribute it and/or modify it under
  13. * the terms of the GNU General Public License as published by the Free Software
  14. * Foundation, either version 3 of the License, or (at your option) any later
  15. * version.
  16. *
  17. * This program is distributed in the hope that it will be useful, but WITHOUT
  18. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  19. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  20. * details.
  21. *
  22. * You should have received a copy of the GNU General Public License along with
  23. * this program. If not, see <http://www.gnu.org/licenses/>.
  24. */
  25. package handlers.admincommandhandlers;
  26. import java.util.NoSuchElementException;
  27. import java.util.StringTokenizer;
  28. import com.l2jserver.Config;
  29. import com.l2jserver.gameserver.ThreadPoolManager;
  30. import com.l2jserver.gameserver.datatables.SkillTable;
  31. import com.l2jserver.gameserver.handler.IAdminCommandHandler;
  32. import com.l2jserver.gameserver.model.L2Object;
  33. import com.l2jserver.gameserver.model.L2Skill;
  34. import com.l2jserver.gameserver.model.actor.L2Character;
  35. import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
  36. import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
  37. /**
  38. * This class ...
  39. *
  40. * @version $Revision: 1.2 $ $Date: 2004/06/27 08:12:59 $
  41. */
  42. public class AdminTest implements IAdminCommandHandler
  43. {
  44. private static final String[] ADMIN_COMMANDS =
  45. {
  46. "admin_stats",
  47. "admin_skill_test",
  48. "admin_known"
  49. };
  50. /* (non-Javadoc)
  51. * @see com.l2jserver.gameserver.handler.IAdminCommandHandler#useAdminCommand(java.lang.String, com.l2jserver.gameserver.model.L2PcInstance)
  52. */
  53. public boolean useAdminCommand(String command, L2PcInstance activeChar)
  54. {
  55. if (command.equals("admin_stats"))
  56. {
  57. for (String line : ThreadPoolManager.getInstance().getStats())
  58. {
  59. activeChar.sendMessage(line);
  60. }
  61. }
  62. else if (command.startsWith("admin_skill_test") || command.startsWith("admin_st"))
  63. {
  64. try
  65. {
  66. StringTokenizer st = new StringTokenizer(command);
  67. st.nextToken();
  68. int id = Integer.parseInt(st.nextToken());
  69. if(command.startsWith("admin_skill_test"))
  70. adminTestSkill(activeChar, id, true);
  71. else
  72. adminTestSkill(activeChar, id, false);
  73. }
  74. catch (NumberFormatException e)
  75. {
  76. activeChar.sendMessage("Command format is //skill_test <ID>");
  77. }
  78. catch (NoSuchElementException nsee)
  79. {
  80. activeChar.sendMessage("Command format is //skill_test <ID>");
  81. }
  82. }
  83. else if (command.equals("admin_known on"))
  84. {
  85. Config.CHECK_KNOWN = true;
  86. }
  87. else if (command.equals("admin_known off"))
  88. {
  89. Config.CHECK_KNOWN = false;
  90. }
  91. return true;
  92. }
  93. /**
  94. * @param activeChar
  95. * @param id
  96. */
  97. private void adminTestSkill(L2PcInstance activeChar, int id, boolean msu)
  98. {
  99. L2Character caster;
  100. L2Object target = activeChar.getTarget();
  101. if (!(target instanceof L2Character))
  102. caster = activeChar;
  103. else
  104. caster = (L2Character) target;
  105. L2Skill _skill = SkillTable.getInstance().getInfo(id, 1);
  106. if(_skill != null)
  107. {
  108. caster.setTarget(activeChar);
  109. if(msu)
  110. caster.broadcastPacket(new MagicSkillUse(caster, activeChar, id, 1, _skill.getHitTime(), _skill.getReuseDelay()));
  111. else
  112. caster.doCast(_skill);
  113. }
  114. }
  115. /* (non-Javadoc)
  116. * @see com.l2jserver.gameserver.handler.IAdminCommandHandler#getAdminCommandList()
  117. */
  118. public String[] getAdminCommandList()
  119. {
  120. return ADMIN_COMMANDS;
  121. }
  122. }