Permanently store item owner in ItemInstance.

This commit is contained in:
MobiusDevelopment 2020-10-28 18:14:58 +00:00
parent 60e1de0f75
commit 4f06666dd0
19 changed files with 204 additions and 58 deletions

View File

@ -97,8 +97,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -303,13 +304,13 @@ public class ItemInstance extends WorldObject
/**
* Sets the ownerID of the item
* @param process : String Identifier of process triggering this action
* @param owner_id : int designating the ID of the owner
* @param ownerId : int designating the ID of the owner
* @param creator : PlayerInstance Player requesting the item creation
* @param reference : Object Object referencing current action like NPC selling item or previous item in transformation
*/
public void setOwnerId(String process, int owner_id, PlayerInstance creator, Object reference)
public void setOwnerId(String process, int ownerId, PlayerInstance creator, Object reference)
{
setOwnerId(owner_id);
setOwnerId(ownerId);
if (Config.LOG_ITEMS)
{
@ -358,11 +359,11 @@ public class ItemInstance extends WorldObject
/**
* Sets the ownerID of the item
* @param owner_id : int designating the ID of the owner
* @param ownerId : int designating the ID of the owner
*/
public void setOwnerId(int owner_id)
public void setOwnerId(int ownerId)
{
if (owner_id == _ownerId)
if (ownerId == _ownerId)
{
return;
}
@ -370,7 +371,8 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_ownerId = owner_id;
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
// Give any inventory skills to the new owner only if the item is in inventory
@ -400,11 +402,11 @@ public class ItemInstance extends WorldObject
* Sets the location of the item.<br>
* <u><i>Remark :</i></u> If loc and loc_data different from database, say datas not up-to-date
* @param loc : ItemLocation (enumeration)
* @param loc_data : int designating the slot where the item is stored or the village for freights
* @param locData : int designating the slot where the item is stored or the village for freights
*/
public void setItemLocation(ItemLocation loc, int loc_data)
public void setItemLocation(ItemLocation loc, int locData)
{
if ((loc == _loc) && (loc_data == _locData))
if ((loc == _loc) && (locData == _locData))
{
return;
}
@ -413,7 +415,7 @@ public class ItemInstance extends WorldObject
removeSkillsFromOwner();
_loc = loc;
_locData = loc_data;
_locData = locData;
_storedInDb = false;
// Give any inventory skills to the new owner only if the item is in inventory
@ -1805,9 +1807,9 @@ public class ItemInstance extends WorldObject
return _decrease;
}
public void setInitCount(int InitCount)
public void setInitCount(int initCount)
{
_initCount = InitCount;
_initCount = initCount;
}
public long getInitCount()
@ -1882,7 +1884,7 @@ public class ItemInstance extends WorldObject
{
return;
}
else if (getRemainingTime() <= 0)
if (getRemainingTime() <= 0)
{
endOfLife();
}
@ -2078,7 +2080,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1582,6 +1584,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2085,7 +2089,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1582,6 +1584,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2085,7 +2089,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1582,6 +1584,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2085,7 +2089,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -102,8 +102,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -378,6 +379,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1590,6 +1592,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2093,7 +2097,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -102,8 +102,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -378,6 +379,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1590,6 +1592,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2093,7 +2097,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -102,8 +102,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -378,6 +379,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1590,6 +1592,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2093,7 +2097,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -102,8 +102,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -378,6 +379,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1590,6 +1592,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2093,7 +2097,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -102,8 +102,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -378,6 +379,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1590,6 +1592,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2093,7 +2097,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -87,8 +87,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -284,13 +285,13 @@ public class ItemInstance extends WorldObject
/**
* Sets the ownerID of the item
* @param process : String Identifier of process triggering this action
* @param owner_id : int designating the ID of the owner
* @param ownerId : int designating the ID of the owner
* @param creator : PlayerInstance Player requesting the item creation
* @param reference : Object Object referencing current action like NPC selling item or previous item in transformation
*/
public void setOwnerId(String process, int owner_id, PlayerInstance creator, Object reference)
public void setOwnerId(String process, int ownerId, PlayerInstance creator, Object reference)
{
setOwnerId(owner_id);
setOwnerId(ownerId);
if (Config.LOG_ITEMS)
{
@ -351,6 +352,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -2070,7 +2072,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -87,8 +87,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -284,13 +285,13 @@ public class ItemInstance extends WorldObject
/**
* Sets the ownerID of the item
* @param process : String Identifier of process triggering this action
* @param owner_id : int designating the ID of the owner
* @param ownerId : int designating the ID of the owner
* @param creator : PlayerInstance Player requesting the item creation
* @param reference : Object Object referencing current action like NPC selling item or previous item in transformation
*/
public void setOwnerId(String process, int owner_id, PlayerInstance creator, Object reference)
public void setOwnerId(String process, int ownerId, PlayerInstance creator, Object reference)
{
setOwnerId(owner_id);
setOwnerId(ownerId);
if (Config.LOG_ITEMS)
{
@ -351,6 +352,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -2070,7 +2072,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1580,6 +1582,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2083,7 +2087,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1580,6 +1582,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2083,7 +2087,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1580,6 +1582,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2083,7 +2087,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1580,6 +1582,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2083,7 +2087,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1580,6 +1582,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2083,7 +2087,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1580,6 +1582,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2083,7 +2087,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -97,8 +97,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -370,6 +371,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1572,6 +1574,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2065,7 +2069,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()

View File

@ -99,8 +99,9 @@ public class ItemInstance extends WorldObject
private static final Logger LOGGER = Logger.getLogger(ItemInstance.class.getName());
private static final Logger LOG_ITEMS = Logger.getLogger("item");
/** ID of the owner */
/** Owner */
private int _ownerId;
private PlayerInstance _owner;
/** ID of who dropped the item last, used for knownlist */
private int _dropperObjectId = 0;
@ -375,6 +376,7 @@ public class ItemInstance extends WorldObject
// Remove any inventory skills from the old owner.
removeSkillsFromOwner();
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
@ -1580,6 +1582,8 @@ public class ItemInstance extends WorldObject
ThreadPool.execute(new ItemDropTask(this, dropper, x, y, z));
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
// Notify to scripts
EventDispatcher.getInstance().notifyEventAsync(new OnPlayerItemDrop(dropper.getActingPlayer(), this, new Location(x, y, z)), getItem());
}
@ -2083,7 +2087,11 @@ public class ItemInstance extends WorldObject
@Override
public PlayerInstance getActingPlayer()
{
return World.getInstance().getPlayer(getOwnerId());
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
public int getEquipReuseDelay()