Package services

Source Code of services.ManaRegen

package services;

import l2p.extensions.scripts.Functions;
import l2p.extensions.scripts.ScriptFile;
import l2p.gameserver.cache.Msg;
import l2p.gameserver.model.L2Player;
import l2p.gameserver.serverpackets.SystemMessage;

public class ManaRegen extends Functions implements ScriptFile
{
  private static final int ADENA = 57;
  private static final long PRICE = 5; //5 аден за 1 МП

  public void DoManaRegen()
  {
    L2Player player = (L2Player) getSelf();
    long mp = (long) Math.floor(player.getMaxMp() - player.getCurrentMp());
    long fullCost = mp * PRICE;
    if(fullCost <= 0)
    {
      player.sendPacket(Msg.NOTHING_HAPPENED);
      return;
    }
    if(getItemCount(player, ADENA) >= fullCost)
    {
      removeItem(player, ADENA, fullCost);
      player.sendPacket(new SystemMessage(SystemMessage.S1_MPS_HAVE_BEEN_RESTORED).addNumber(mp));
      player.setCurrentMp(player.getMaxMp());
    }
    else
    {
      player.sendPacket(Msg.YOU_DO_NOT_HAVE_ENOUGH_ADENA);
    }
  }

  public void onLoad()
  {
    System.out.println("Loaded Service: Mana Regen");
  }

  public void onReload()
  {
  }

  public void onShutdown()
  {
  }
}
TOP

Related Classes of services.ManaRegen

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.