Addition of ItemManaTaskManager item owner check.

This commit is contained in:
MobiusDevelopment
2022-01-11 04:18:22 +00:00
parent aabe24f088
commit 4fc9d70c1e
56 changed files with 332 additions and 112 deletions

View File

@@ -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)

View File

@@ -455,7 +455,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;
@@ -8140,15 +8139,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());
@@ -8310,14 +8301,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
@@ -14640,24 +14651,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

View File

@@ -80,7 +80,10 @@ public class Item extends WorldObject
FREIGHT
}
/** Owner */
private int _ownerId;
private Player _owner;
private int _count;
private int _initCount;
private int _time;
@@ -173,6 +176,7 @@ public class Item extends WorldObject
return;
}
_owner = null;
_ownerId = ownerId;
_storedInDb = false;
}
@@ -1133,6 +1137,11 @@ public class Item extends WorldObject
{
ItemsOnGroundManager.getInstance().save(this);
}
if ((dropper != null) && dropper.isPlayer())
{
_owner = null;
}
}
/**
@@ -1436,4 +1445,14 @@ public class Item extends WorldObject
{
return true;
}
@Override
public Player getActingPlayer()
{
if ((_owner == null) && (_ownerId != 0))
{
_owner = World.getInstance().getPlayer(_ownerId);
}
return _owner;
}
}

View File

@@ -658,7 +658,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();

View File

@@ -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());
}
}