Jump to content

Recommended Posts

Posted (edited)

package net.sf.l2j.gameserver.handler.itemhandlers;

Pvpitem.java

 

package net.sf.l2j.gameserver.handler.itemhandlers;

import net.sf.l2j.gameserver.handler.IItemHandler;
import net.sf.l2j.gameserver.model.actor.Playable;
import net.sf.l2j.gameserver.model.actor.instance.Player;
import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
import net.sf.l2j.gameserver.network.SystemMessageId;


public class Pvpitem implements IItemHandler
{
	
	@Override
	public void useItem(Playable playable, ItemInstance item, boolean forceUse)
	{
		if (!(playable instanceof Player))
			return;
		
		Player player = (Player) playable;
		if (player.isInCombat())
		{
			player.sendMessage("You can't use this item because you are in combat");
			return;
		}
		if (player.getKarma() > 0)
		{
			player.sendMessage("You can't use this item if you have karma.");
			return;
		}
		if (player.isCursedWeaponEquipped())
		{
			player.sendMessage("You can't use this item with a cursed weapon.");
			return;
		}
		if (player.isDead())
		{
			player.sendMessage("You can't use this item while you are dead.");
			return;
		}
		if (player.getActiveTradeList() != null || player.getActiveEnchantItem() != null)
		{
			player.sendMessage("Cannot use while trading/enchanting");
			return;
		}
		else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegisteredInComp(player))
		{
			player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT);
			return;
		}
		
		final int pvps = player.getPvpKills() + 1000;
		player.setPvpKills(pvps);
		player.broadcastUserInfo();
		player.sendMessage("Your PVP count is now " + pvps);
		playable.destroyItem("Consume", item.getObjectId(), 1, null, false);
	}
}

package net.sf.l2j.gameserver.handler;

ItemHandler.java

 

        registerItemHandler(new ClanItem());
		registerItemHandler(new ExpAndSpItem()); 
        registerItemHandler(new CleanKarma());
      + registerItemHandler(new Pvpitem());
		
	}
	
	public void registerItemHandler(IItemHandler handler)
	{
		_datatable.put(handler.getClass().getSimpleName().intern().hashCode(), handler);
	}
	

 

Edited by melron
Cleaned.
Posted
1 minute ago, .Elfocrash said:

Jesus christ clean this mess up.

Create a validator and cleanup your ifelseifelsifelse haduken

Ναι αυτο σε πειραξε εσενα τα bracket που ειναι στο χυμα δεν σε πηραξαν.

Posted
3 hours ago, melron said:

Cleaned...

Come on.. Previous version was better, yet I have no idea what it exactly was... Some crazy math to calculate the addition(?) :D

Posted

mmm nice.. I really miss comments like this since 2010. You guys really help this guy to make it better with your comments. 

This section must be renamed to <Share and humiliate>.

 

Maybe the bullying you get/got from your real life, makes you to act like this on forums. (proven by psychology)

Anyway.. Maybe my words, just gave you reason to continue spam with quotes on this one. So, spend your time to quote this, may make you feel better, if you feel 
I attack your intelligence..

Goodnight!

  • Like 1
  • Sad 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...