Package commands.user

Source Code of commands.user.Escape

package commands.user;

import l2p.extensions.multilang.CustomMessage;
import l2p.extensions.scripts.ScriptFile;
import l2p.gameserver.cache.Msg;
import l2p.gameserver.handler.IUserCommandHandler;
import l2p.gameserver.handler.UserCommandHandler;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.model.L2Skill;
import l2p.gameserver.tables.SkillTable;

/**
* Support for /unstuck command
*/
public class Escape implements IUserCommandHandler, ScriptFile
{
  private static final int[] COMMAND_IDS = {52};

  public boolean useUserCommand(int id, L2Player activeChar)
  {
    if(id != COMMAND_IDS[0])
    {
      return false;
    }
    if(activeChar.isMovementDisabled() || activeChar.isInOlympiadMode())
    {
      return false;
    }
    if(activeChar.getTeleMode() != 0)
    {
      activeChar.sendMessage(new CustomMessage("common.TryLater", activeChar));
      return false;
    }
    if(activeChar.isTerritoryFlagEquipped())
    {
      activeChar.sendPacket(Msg.YOU_CANNOT_TELEPORT_WHILE_IN_POSSESSION_OF_A_WARD);
      return false;
    }
    if(activeChar.getDuel() != null || activeChar.getTeam() != 0)
    {
      activeChar.sendMessage(new CustomMessage("common.RecallInDuel", activeChar));
      return false;
    }
    activeChar.abortAttack(true, true);
    activeChar.abortCast(true);
    activeChar.stopMove();
    L2Skill skill;
    if(activeChar.getPlayerAccess().FastUnstuck)
    {
      skill = SkillTable.getInstance().getInfo(1050, 2);
    }
    else
    {
      skill = SkillTable.getInstance().getInfo(2099, 1);
    }
    if(skill != null && skill.checkCondition(activeChar, activeChar, false, false, true))
    {
      activeChar.getAI().Cast(skill, activeChar, false, true);
    }
    return true;
  }

  public final int[] getUserCommandList()
  {
    return COMMAND_IDS;
  }

  public void onLoad()
  {
    UserCommandHandler.getInstance().registerUserCommandHandler(this);
  }

  public void onReload()
  {
  }

  public void onShutdown()
  {
  }
}
TOP

Related Classes of commands.user.Escape

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.