Guest User

Untitled

a guest
Nov 25th, 2018
216
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.63 KB | None | 0 0
  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.skillhandlers;
  16.  
  17. import net.sf.l2j.gameserver.ThreadPoolManager;
  18. import net.sf.l2j.gameserver.handler.ISkillHandler;
  19. import net.sf.l2j.gameserver.model.L2Object;
  20. import net.sf.l2j.gameserver.model.L2Skill;
  21. import net.sf.l2j.gameserver.model.actor.L2Character;
  22. import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
  23. import net.sf.l2j.gameserver.model.itemcontainer.Inventory;
  24. import net.sf.l2j.gameserver.model.zone.ZoneId;
  25. import net.sf.l2j.gameserver.templates.skills.L2SkillType;
  26.  
  27. public class TankUlti implements ISkillHandler
  28. {
  29.     private static final L2SkillType[] SKILL_IDS = { L2SkillType.TANK };
  30.    
  31.     @Override
  32.     public void useSkill(L2Character activeChar, L2Skill skill, L2Object[] targets)
  33.     {
  34.         if (!(activeChar instanceof L2PcInstance))
  35.         {
  36.             return;
  37.         }
  38.        
  39.         L2PcInstance p = (L2PcInstance)activeChar;
  40.        
  41.         if (p.isInOlympiadMode())
  42.         {
  43.             p.sendMessage("You can't use this skill while you are in olympiad.");
  44.             return;
  45.         }
  46.        
  47.         if (p.isInsideZone(ZoneId.TOWN))
  48.         {
  49.             p.sendMessage("You can't use this skill while you are in town.");
  50.             return;
  51.         }
  52.        
  53.         L2Object trg = p.getTarget();
  54.        
  55.         if (!(trg instanceof L2PcInstance))
  56.         {
  57.             p.enableSkill(skill);
  58.             p.sendSkillList();
  59.             p.sendMessage("Invalid target.");
  60.             return;
  61.         }
  62.        
  63.         final L2PcInstance t = (L2PcInstance)trg;
  64.        
  65.         if (t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND) == null)
  66.         {
  67.             p.enableSkill(skill);
  68.             p.sendSkillList();
  69.             p.sendMessage("That player does not have a weapon.");
  70.             return;
  71.         }
  72.        
  73.         t.useEquippableItem(t.getInventory().getPaperdollItem(Inventory.PAPERDOLL_RHAND), true);
  74.         t.setWeaponRestricted(true);
  75.         ThreadPoolManager.getInstance().scheduleGeneral(new Runnable()
  76.         {
  77.             @Override
  78.             public void run()
  79.             {
  80.                 t.setWeaponRestricted(false);
  81.                 t.sendMessage("You can now equip your weapon again.");
  82.             }
  83.         }, 5000);
  84.     }
  85.  
  86.     @Override
  87.     public L2SkillType[] getSkillIds()
  88.     {
  89.         return SKILL_IDS;
  90.     }
  91. }
Add Comment
Please, Sign In to add comment