Addition of ItemManaTaskManager item owner check.
This commit is contained in:
@@ -200,7 +200,6 @@ public class OfflineTraderTable
|
||||
client.setPlayer(player);
|
||||
client.setAccountName(player.getAccountName());
|
||||
player.setClient(client);
|
||||
player.setOfflineMode(true);
|
||||
player.setOnlineStatus(false);
|
||||
player.setOfflineStartTime(time);
|
||||
if (Config.OFFLINE_SLEEP_EFFECT)
|
||||
|
@@ -441,7 +441,6 @@ public class Player extends Playable
|
||||
private double _mpUpdateDecCheck = .0;
|
||||
private double _mpUpdateInterval = .0;
|
||||
private long _timerToAttack;
|
||||
private boolean _isInOfflineMode = false;
|
||||
private boolean _isTradeOff = false;
|
||||
private long _offlineShopStart = 0;
|
||||
public int _originalNameColorOffline = 0xFFFFFF;
|
||||
@@ -7993,15 +7992,7 @@ public class Player extends Playable
|
||||
statement.setLong(33, getDeleteTimer());
|
||||
statement.setString(34, getTitle());
|
||||
statement.setInt(35, getAccessLevel().getLevel());
|
||||
if (_isInOfflineMode || isOnline()) // in offline mode or online
|
||||
{
|
||||
statement.setInt(36, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
statement.setInt(36, isOnline() ? 1 : 0);
|
||||
}
|
||||
|
||||
statement.setInt(36, isOnlineInt());
|
||||
statement.setInt(37, isIn7sDungeon() ? 1 : 0);
|
||||
statement.setInt(38, getClanPrivileges());
|
||||
statement.setInt(39, getWantsPeace());
|
||||
@@ -8163,14 +8154,34 @@ public class Player extends Playable
|
||||
}
|
||||
|
||||
/**
|
||||
* Return True if the Player is online.
|
||||
* @return if player is online
|
||||
* @return True if the Player is online.
|
||||
*/
|
||||
public boolean isOnline()
|
||||
{
|
||||
return _isOnline;
|
||||
}
|
||||
|
||||
public int isOnlineInt()
|
||||
{
|
||||
if (_isOnline && (_client != null))
|
||||
{
|
||||
return _client.isDetached() ? 2 : 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies if the player is in offline mode.<br>
|
||||
* The offline mode may happen for different reasons:<br>
|
||||
* Abnormally: Player gets abruptly disconnected from server.<br>
|
||||
* Normally: The player gets into offline shop mode, only available by enabling the offline shop mod.
|
||||
* @return {@code true} if the player is in offline mode, {@code false} otherwise
|
||||
*/
|
||||
public boolean isInOfflineMode()
|
||||
{
|
||||
return (_client == null) || _client.isDetached();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is in7s dungeon.
|
||||
* @return true, if is in7s dungeon
|
||||
@@ -14278,24 +14289,6 @@ public class Player extends Playable
|
||||
return color;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is offline.
|
||||
* @return true, if is offline
|
||||
*/
|
||||
public boolean isInOfflineMode()
|
||||
{
|
||||
return _isInOfflineMode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the offline.
|
||||
* @param set the new offline
|
||||
*/
|
||||
public void setOfflineMode(boolean set)
|
||||
{
|
||||
_isInOfflineMode = set;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if is trade disabled.
|
||||
* @return true, if is trade disabled
|
||||
|
@@ -79,7 +79,10 @@ public class Item extends WorldObject
|
||||
FREIGHT
|
||||
}
|
||||
|
||||
/** Owner */
|
||||
private int _ownerId;
|
||||
private Player _owner;
|
||||
|
||||
private int _count;
|
||||
private int _initCount;
|
||||
private int _time;
|
||||
@@ -171,6 +174,7 @@ public class Item extends WorldObject
|
||||
return;
|
||||
}
|
||||
|
||||
_owner = null;
|
||||
_ownerId = ownerId;
|
||||
_storedInDb = false;
|
||||
}
|
||||
@@ -1072,6 +1076,11 @@ public class Item extends WorldObject
|
||||
{
|
||||
ItemsOnGroundManager.getInstance().save(this);
|
||||
}
|
||||
|
||||
if ((dropper != null) && dropper.isPlayer())
|
||||
{
|
||||
_owner = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1369,4 +1378,14 @@ public class Item extends WorldObject
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Player getActingPlayer()
|
||||
{
|
||||
if ((_owner == null) && (_ownerId != 0))
|
||||
{
|
||||
_owner = World.getInstance().getPlayer(_ownerId);
|
||||
}
|
||||
return _owner;
|
||||
}
|
||||
}
|
||||
|
@@ -664,7 +664,6 @@ public class GameClient extends ChannelInboundHandler<GameClient>
|
||||
{
|
||||
if (!Config.OFFLINE_MODE_IN_PEACE_ZONE || (Config.OFFLINE_MODE_IN_PEACE_ZONE && player.isInsideZone(ZoneId.PEACE)))
|
||||
{
|
||||
player.setOfflineMode(true);
|
||||
player.setOnlineStatus(false);
|
||||
player.leaveParty();
|
||||
player.store();
|
||||
|
@@ -22,6 +22,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import org.l2jmobius.commons.threads.ThreadPool;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.gameserver.model.actor.Player;
|
||||
import org.l2jmobius.gameserver.model.item.instance.Item;
|
||||
|
||||
/**
|
||||
@@ -54,7 +55,14 @@ public class ItemManaTaskManager implements Runnable
|
||||
{
|
||||
final Item item = entry.getKey();
|
||||
ITEMS.remove(item);
|
||||
item.decreaseMana(true);
|
||||
|
||||
final Player player = item.getActingPlayer();
|
||||
if ((player == null) || player.isInOfflineMode())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
item.decreaseMana(item.isEquipped());
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user