Minor PlayerInstanceAction cleanup.

This commit is contained in:
MobiusDevelopment 2019-12-12 02:36:34 +00:00
parent 88084387a3
commit 6abcec1ce6
17 changed files with 157 additions and 108 deletions

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -51,70 +51,72 @@ public class PlayerInstanceAction implements IActionHandler
* <BR> * <BR>
* <li>Client packet : Action, AttackRequest</li><BR> * <li>Client packet : Action, AttackRequest</li><BR>
* <BR> * <BR>
* @param activeChar The player that start an action on target PlayerInstance * @param player The player that start an action on target PlayerInstance
*/ */
@Override @Override
public boolean action(PlayerInstance activeChar, WorldObject target, boolean interact) public boolean action(PlayerInstance player, WorldObject target, boolean interact)
{ {
// See description in TvTEvent.java // See description in TvTEvent.java
if (!TvTEvent.onAction(activeChar, target.getObjectId())) if (!TvTEvent.onAction(player, target.getObjectId()))
{ {
return false; return false;
} }
// Check if the PlayerInstance is confused // Check if the PlayerInstance is confused
if (activeChar.isOutOfControl()) if (player.isOutOfControl())
{ {
return false; return false;
} }
// Aggression target lock effect // Aggression target lock effect
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target)) if (player.isLockedTarget() && (player.getLockedTarget() != target))
{ {
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ATTACK_TARGET); player.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ATTACK_TARGET);
return false; return false;
} }
// Check if the activeChar already target this PlayerInstance // Check if the player already target this PlayerInstance
if (activeChar.getTarget() != target) if (player.getTarget() != target)
{ {
// Set the target of the activeChar // Set the target of the player
activeChar.setTarget(target); player.setTarget(target);
} }
else if (interact) else if (interact)
{ {
final PlayerInstance player = target.getActingPlayer();
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (player.getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, player); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
else else
{ {
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (player.isAutoAttackable(activeChar)) if (target.isAutoAttackable(player))
{ {
if ((player.isCursedWeaponEquipped() && (activeChar.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) // // Player with lvl < 21 can't attack a cursed weapon holder
|| (activeChar.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL))) // And a cursed weapon holder can't attack players with lvl < 21
if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
activeChar.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }
else else
{ {
if (GeoEngine.getInstance().canSeeTarget(activeChar, player)) if (GeoEngine.getInstance().canSeeTarget(player, target))
{ {
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
activeChar.onActionRequest(); player.onActionRequest();
} }
} }
} }
else else
{ {
// This Action Failed packet avoids activeChar getting stuck when clicking three or more times // This Action Failed packet avoids player getting stuck when clicking three or more times
activeChar.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
if (GeoEngine.getInstance().canSeeTarget(activeChar, player)) if (GeoEngine.getInstance().canSeeTarget(player, target))
{ {
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player); player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
} }
} }
} }

View File

@ -51,70 +51,72 @@ public class PlayerInstanceAction implements IActionHandler
* <BR> * <BR>
* <li>Client packet : Action, AttackRequest</li><BR> * <li>Client packet : Action, AttackRequest</li><BR>
* <BR> * <BR>
* @param activeChar The player that start an action on target PlayerInstance * @param player The player that start an action on target PlayerInstance
*/ */
@Override @Override
public boolean action(PlayerInstance activeChar, WorldObject target, boolean interact) public boolean action(PlayerInstance player, WorldObject target, boolean interact)
{ {
// See description in TvTEvent.java // See description in TvTEvent.java
if (!TvTEvent.onAction(activeChar, target.getObjectId())) if (!TvTEvent.onAction(player, target.getObjectId()))
{ {
return false; return false;
} }
// Check if the PlayerInstance is confused // Check if the PlayerInstance is confused
if (activeChar.isOutOfControl()) if (player.isOutOfControl())
{ {
return false; return false;
} }
// Aggression target lock effect // Aggression target lock effect
if (activeChar.isLockedTarget() && (activeChar.getLockedTarget() != target)) if (player.isLockedTarget() && (player.getLockedTarget() != target))
{ {
activeChar.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ATTACK_TARGET); player.sendPacket(SystemMessageId.FAILED_TO_CHANGE_ATTACK_TARGET);
return false; return false;
} }
// Check if the activeChar already target this PlayerInstance // Check if the player already target this PlayerInstance
if (activeChar.getTarget() != target) if (player.getTarget() != target)
{ {
// Set the target of the activeChar // Set the target of the player
activeChar.setTarget(target); player.setTarget(target);
} }
else if (interact) else if (interact)
{ {
final PlayerInstance player = target.getActingPlayer();
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (player.getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, player); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
else else
{ {
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (player.isAutoAttackable(activeChar)) if (target.isAutoAttackable(player))
{ {
if ((player.isCursedWeaponEquipped() && (activeChar.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) // // Player with lvl < 21 can't attack a cursed weapon holder
|| (activeChar.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL))) // And a cursed weapon holder can't attack players with lvl < 21
if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
activeChar.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }
else else
{ {
if (GeoEngine.getInstance().canSeeTarget(activeChar, player)) if (GeoEngine.getInstance().canSeeTarget(player, target))
{ {
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, player); player.getAI().setIntention(CtrlIntention.AI_INTENTION_ATTACK, target);
activeChar.onActionRequest(); player.onActionRequest();
} }
} }
} }
else else
{ {
// This Action Failed packet avoids activeChar getting stuck when clicking three or more times // This Action Failed packet avoids player getting stuck when clicking three or more times
activeChar.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
if (GeoEngine.getInstance().canSeeTarget(activeChar, player)) if (GeoEngine.getInstance().canSeeTarget(player, target))
{ {
activeChar.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, player); player.getAI().setIntention(CtrlIntention.AI_INTENTION_FOLLOW, target);
} }
} }
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }

View File

@ -22,13 +22,14 @@ import org.l2jmobius.gameserver.enums.PrivateStoreType;
import org.l2jmobius.gameserver.geoengine.GeoEngine; import org.l2jmobius.gameserver.geoengine.GeoEngine;
import org.l2jmobius.gameserver.handler.IActionHandler; import org.l2jmobius.gameserver.handler.IActionHandler;
import org.l2jmobius.gameserver.model.WorldObject; import org.l2jmobius.gameserver.model.WorldObject;
import org.l2jmobius.gameserver.model.actor.Creature;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance; import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
import org.l2jmobius.gameserver.network.SystemMessageId; import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ActionFailed; import org.l2jmobius.gameserver.network.serverpackets.ActionFailed;
public class PlayerInstanceAction implements IActionHandler public class PlayerInstanceAction implements IActionHandler
{ {
private static final int CURSED_WEAPON_VICTIM_MIN_LEVEL = 21;
/** /**
* Manage actions when a player click on this PlayerInstance.<BR> * Manage actions when a player click on this PlayerInstance.<BR>
* <BR> * <BR>
@ -76,7 +77,8 @@ public class PlayerInstanceAction implements IActionHandler
else if (interact) else if (interact)
{ {
// Check if this PlayerInstance has a Private Store // Check if this PlayerInstance has a Private Store
if (((PlayerInstance) target).getPrivateStoreType() != PrivateStoreType.NONE) final PlayerInstance targetPlayer = target.getActingPlayer();
if (targetPlayer.getPrivateStoreType() != PrivateStoreType.NONE)
{ {
player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target); player.getAI().setIntention(CtrlIntention.AI_INTENTION_INTERACT, target);
} }
@ -85,9 +87,10 @@ public class PlayerInstanceAction implements IActionHandler
// Check if this PlayerInstance is autoAttackable // Check if this PlayerInstance is autoAttackable
if (target.isAutoAttackable(player)) if (target.isAutoAttackable(player))
{ {
// player with lvl < 21 can't attack a cursed weapon holder // Player with lvl < 21 can't attack a cursed weapon holder
// And a cursed weapon holder can't attack players with lvl < 21 // And a cursed weapon holder can't attack players with lvl < 21
if ((((PlayerInstance) target).isCursedWeaponEquipped() && (player.getLevel() < 21)) || (player.isCursedWeaponEquipped() && (((Creature) target).getLevel() < 21))) if ((targetPlayer.isCursedWeaponEquipped() && (player.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)) //
|| (player.isCursedWeaponEquipped() && (targetPlayer.getLevel() < CURSED_WEAPON_VICTIM_MIN_LEVEL)))
{ {
player.sendPacket(ActionFailed.STATIC_PACKET); player.sendPacket(ActionFailed.STATIC_PACKET);
} }