Removed player reentrant locks.
This commit is contained in:
@@ -73,38 +73,31 @@ public class SoulShots implements IItemHandler
|
||||
return false;
|
||||
}
|
||||
|
||||
player.soulShotLock.lock();
|
||||
try
|
||||
// Check if Soul shot is already active
|
||||
if (player.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
// Check if Soul shot is already active
|
||||
if (player.isChargedShot(ShotType.SOULSHOTS))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Consume Soul shots if player has enough of them
|
||||
int SSCount = weaponItem.getSoulShotCount();
|
||||
if ((weaponItem.getReducedSoulShot() > 0) && (Rnd.get(100) < weaponItem.getReducedSoulShotChance()))
|
||||
{
|
||||
SSCount = weaponItem.getReducedSoulShot();
|
||||
}
|
||||
|
||||
if (!player.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
|
||||
{
|
||||
if (!player.disableAutoShot(itemId))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SOULSHOTS_FOR_THAT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Charge soul shot
|
||||
weaponInst.setChargedShot(ShotType.SOULSHOTS, true);
|
||||
return false;
|
||||
}
|
||||
finally
|
||||
|
||||
// Consume Soul shots if player has enough of them
|
||||
int SSCount = weaponItem.getSoulShotCount();
|
||||
if ((weaponItem.getReducedSoulShot() > 0) && (Rnd.get(100) < weaponItem.getReducedSoulShotChance()))
|
||||
{
|
||||
player.soulShotLock.unlock();
|
||||
SSCount = weaponItem.getReducedSoulShot();
|
||||
}
|
||||
|
||||
if (!player.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
|
||||
{
|
||||
if (!player.disableAutoShot(itemId))
|
||||
{
|
||||
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SOULSHOTS_FOR_THAT);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Charge soul shot
|
||||
weaponInst.setChargedShot(ShotType.SOULSHOTS, true);
|
||||
|
||||
// Send message to client
|
||||
player.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED);
|
||||
Broadcast.toSelfAndKnownPlayersInRadius(player, new MagicSkillUse(player, player, skills[0].getSkillId(), skills[0].getSkillLevel(), 0, 0), 600);
|
||||
|
||||
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Level;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
@@ -429,7 +428,7 @@ public class PlayerInstance extends Playable
|
||||
private long _lastAccess;
|
||||
private long _uptime;
|
||||
|
||||
private final ReentrantLock _subclassLock = new ReentrantLock();
|
||||
private boolean _subclassLock = false;
|
||||
protected int _baseClass;
|
||||
protected int _activeClass;
|
||||
protected int _classIndex = 0;
|
||||
@@ -728,8 +727,6 @@ public class PlayerInstance extends Playable
|
||||
/** Active shots. */
|
||||
protected Set<Integer> _activeSoulShots = ConcurrentHashMap.newKeySet(1);
|
||||
|
||||
public ReentrantLock soulShotLock = new ReentrantLock();
|
||||
|
||||
/** Event parameters */
|
||||
private PlayerEventHolder eventStatus = null;
|
||||
|
||||
@@ -2267,10 +2264,11 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public void setClassId(int id)
|
||||
{
|
||||
if (!_subclassLock.tryLock())
|
||||
if (_subclassLock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_subclassLock = true;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -2347,7 +2345,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
finally
|
||||
{
|
||||
_subclassLock.unlock();
|
||||
_subclassLock = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8221,7 +8219,7 @@ public class PlayerInstance extends Playable
|
||||
|
||||
public boolean canLogout()
|
||||
{
|
||||
if (_subclassLock.isLocked())
|
||||
if (_subclassLock)
|
||||
{
|
||||
LOGGER.warning("Player " + getName() + " tried to restart/logout during class change.");
|
||||
return false;
|
||||
@@ -9970,10 +9968,11 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public boolean addSubClass(int classId, int classIndex)
|
||||
{
|
||||
if (!_subclassLock.tryLock())
|
||||
if (_subclassLock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_subclassLock = true;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -10036,7 +10035,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
finally
|
||||
{
|
||||
_subclassLock.unlock();
|
||||
_subclassLock = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10050,10 +10049,11 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public boolean modifySubClass(int classIndex, int newClassId)
|
||||
{
|
||||
if (!_subclassLock.tryLock())
|
||||
if (_subclassLock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
_subclassLock = true;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -10109,7 +10109,7 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
finally
|
||||
{
|
||||
_subclassLock.unlock();
|
||||
_subclassLock = false;
|
||||
}
|
||||
|
||||
return addSubClass(newClassId, classIndex);
|
||||
@@ -10170,10 +10170,11 @@ public class PlayerInstance extends Playable
|
||||
*/
|
||||
public void setActiveClass(int classIndex)
|
||||
{
|
||||
if (!_subclassLock.tryLock())
|
||||
if (_subclassLock)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_subclassLock = true;
|
||||
|
||||
try
|
||||
{
|
||||
@@ -10322,13 +10323,13 @@ public class PlayerInstance extends Playable
|
||||
}
|
||||
finally
|
||||
{
|
||||
_subclassLock.unlock();
|
||||
_subclassLock = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isLocked()
|
||||
{
|
||||
return _subclassLock.isLocked();
|
||||
return _subclassLock;
|
||||
}
|
||||
|
||||
public void stopWarnUserTakeBreak()
|
||||
@@ -13071,7 +13072,7 @@ public class PlayerInstance extends Playable
|
||||
|
||||
public boolean isAllowedToEnchantSkills()
|
||||
{
|
||||
if (_subclassLock.isLocked())
|
||||
if (_subclassLock)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user