Jump to content

Recommended Posts

Posted

 

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.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);

}

}
ItemHandler.java

package net.sf.l2j.gameserver.handler;

import java.util.HashMap;
import java.util.Map;

import net.sf.l2j.gameserver.handler.itemhandlers.BeastSoulShots;
import net.sf.l2j.gameserver.handler.itemhandlers.BeastSpices;
import net.sf.l2j.gameserver.handler.itemhandlers.BeastSpiritShots;
import net.sf.l2j.gameserver.handler.itemhandlers.BlessedSpiritShots;
import net.sf.l2j.gameserver.handler.itemhandlers.Books;
import net.sf.l2j.gameserver.handler.itemhandlers.Calculators;
import net.sf.l2j.gameserver.handler.itemhandlers.Elixirs;
import net.sf.l2j.gameserver.handler.itemhandlers.EnchantScrolls;
import net.sf.l2j.gameserver.handler.itemhandlers.FishShots;
import net.sf.l2j.gameserver.handler.itemhandlers.Harvesters;
import net.sf.l2j.gameserver.handler.itemhandlers.ItemSkills;
import net.sf.l2j.gameserver.handler.itemhandlers.Keys;
import net.sf.l2j.gameserver.handler.itemhandlers.Maps;
import net.sf.l2j.gameserver.handler.itemhandlers.MercenaryTickets;
import net.sf.l2j.gameserver.handler.itemhandlers.PaganKeys;
import net.sf.l2j.gameserver.handler.itemhandlers.PetFoods;
import net.sf.l2j.gameserver.handler.itemhandlers.Recipes;
import net.sf.l2j.gameserver.handler.itemhandlers.RollingDices;
import net.sf.l2j.gameserver.handler.itemhandlers.ScrollsOfResurrection;
import net.sf.l2j.gameserver.handler.itemhandlers.Seeds;
import net.sf.l2j.gameserver.handler.itemhandlers.SevenSignsRecords;
import net.sf.l2j.gameserver.handler.itemhandlers.SoulCrystals;
import net.sf.l2j.gameserver.handler.itemhandlers.SoulShots;
import net.sf.l2j.gameserver.handler.itemhandlers.SpecialXMas;
import net.sf.l2j.gameserver.handler.itemhandlers.SpiritShots;
import net.sf.l2j.gameserver.handler.itemhandlers.SummonItems;
import net.sf.l2j.gameserver.handler.itemhandlers.Pvpitem;
import net.sf.l2j.gameserver.model.item.kind.EtcItem;

public class ItemHandler
{
	private final Map<Integer, IItemHandler> _entries = new HashMap<>();
	
	protected ItemHandler()
	{
		registerHandler(new BeastSoulShots());
		registerHandler(new BeastSpices());
		registerHandler(new BeastSpiritShots());
		registerHandler(new BlessedSpiritShots());
		registerHandler(new Books());
		registerHandler(new Calculators());
		registerHandler(new Elixirs());
		registerHandler(new EnchantScrolls());
		registerHandler(new FishShots());
		registerHandler(new Harvesters());
		registerHandler(new ItemSkills());
		registerHandler(new Keys());
		registerHandler(new Maps());
		registerHandler(new MercenaryTickets());
		registerHandler(new PaganKeys());
		registerHandler(new PetFoods());
		registerHandler(new Recipes());
		registerHandler(new RollingDices());
		registerHandler(new ScrollsOfResurrection());
		registerHandler(new Seeds());
		registerHandler(new SevenSignsRecords());
		registerHandler(new SoulShots());
		registerHandler(new SpecialXMas());
		registerHandler(new SoulCrystals());
		registerHandler(new SpiritShots());
		registerHandler(new SummonItems());
		registerHandler(new Pvpitem());
	}
	
   
	private void registerHandler(IItemHandler handler)
	{
		_entries.put(handler.getClass().getSimpleName().intern().hashCode(), handler);
	}
	
	public IItemHandler getHandler(EtcItem item)
	{
		if (item == null || item.getHandlerName() == null)
			return null;
		
		return _entries.get(item.getHandlerName().hashCode());
	}
	
	public int size()
	{
		return _entries.size();
	}
	
	public static ItemHandler getInstance()
	{
		return SingletonHolder.INSTANCE;
	}
	
	private static class SingletonHolder
	{
		protected static final ItemHandler INSTANCE = new ItemHandler();
	}
}

Εδω δειχνω σε τελικη μορφη πως ειναι ολο το αρχειο στο pack μεσα, ειναι aCiS 401. και αφορα ενα item που δινει 1000 pvp στον παιχτη. Απλα θα ηθελα να ρωτησω απο καποιον που ξερει καλυτερα αν εγινε σωστα. προσπαθω να περασω διαφορους κωδικες χωρις να ξερω. απλα το παω και λιγο με λογικη... Και εχω μια ερωτηση πολυ βασικη 😄 πως μπορω να βρω αυτο το αντικειμενο μεσα στο παιχνιδι αν ποτε καταφερω να τον φερω προς χρηση 😛 απλα μου βγηκε αυτη η απορια και ειπα να κανω αυτο το post... επισης τον κωδικα τον βρηκα share απλα αλλαξα 2-3 πραγματα στο πως ηταν γραμμενος και εκανα και καποια imports ισως αν ειναι σωστος καποιος να τον αξιοποιησει παραπανω απο εμενα...

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...