Removed player reentrant locks.

This commit is contained in:
MobiusDevelopment
2020-03-30 19:03:16 +00:00
parent cdab936ea5
commit dff067c91e
51 changed files with 907 additions and 1121 deletions
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -425,7 +424,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -707,8 +706,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2351,10 +2348,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2435,7 +2433,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9452,10 +9450,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9527,7 +9526,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9542,10 +9541,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9621,7 +9621,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9728,10 +9728,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9875,13 +9876,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -427,7 +426,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -709,8 +708,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2357,10 +2354,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2441,7 +2439,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9459,10 +9457,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9534,7 +9533,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9549,10 +9548,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9628,7 +9628,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9735,10 +9735,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9882,13 +9883,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -429,7 +428,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -711,8 +710,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2359,10 +2356,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2443,7 +2441,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9461,10 +9459,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9536,7 +9535,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9551,10 +9550,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9630,7 +9630,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9737,10 +9737,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9884,13 +9885,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -39,7 +39,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -434,7 +433,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -717,8 +716,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2365,10 +2362,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2449,7 +2447,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9441,10 +9439,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9516,7 +9515,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9531,10 +9530,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9610,7 +9610,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9717,10 +9717,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9864,13 +9865,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -39,7 +39,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -432,7 +431,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -713,8 +712,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2358,10 +2355,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2442,7 +2440,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9428,10 +9426,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9503,7 +9502,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9518,10 +9517,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9597,7 +9597,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9704,10 +9704,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9851,13 +9852,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -39,7 +39,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -432,7 +431,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -713,8 +712,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2358,10 +2355,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2442,7 +2440,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9428,10 +9426,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9503,7 +9502,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9518,10 +9517,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9597,7 +9597,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9704,10 +9704,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9851,13 +9852,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -39,7 +39,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -432,7 +431,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -713,8 +712,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2358,10 +2355,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2442,7 +2440,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9429,10 +9427,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9509,7 +9508,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9524,10 +9523,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9603,7 +9603,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9710,10 +9710,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9857,13 +9858,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -67,38 +67,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -64,38 +64,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -39,7 +39,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -434,7 +433,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -713,8 +712,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2285,10 +2282,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2369,7 +2367,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9397,10 +9395,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9477,7 +9476,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9492,10 +9491,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9571,7 +9571,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9678,10 +9678,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9824,13 +9825,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -87,44 +87,36 @@ public class SoulShots implements IItemHandler
return; return;
} }
player.soulShotLock.lock(); // Check if Soulshot is already active
try if (weaponInst.getChargedSoulshot() != ItemInstance.CHARGED_NONE)
{ {
// Check if Soulshot is already active return;
if (weaponInst.getChargedSoulshot() != ItemInstance.CHARGED_NONE)
{
return;
}
// Consume Soulshots if player has enough of them
final int saSSCount = (int) player.getStat().calcStat(Stat.SOULSHOT_COUNT, 0, null, null);
final int SSCount = saSSCount == 0 ? weaponItem.getSoulShotCount() : saSSCount;
if (!Config.DONT_DESTROY_SS && !player.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
{
if (player.getAutoSoulShot().containsKey(itemId))
{
player.removeAutoSoulShot(itemId);
player.sendPacket(new ExAutoSoulShot(itemId, 0));
final SystemMessage sm = new SystemMessage(SystemMessageId.THE_AUTOMATIC_USE_OF_S1_HAS_BEEN_DEACTIVATED);
sm.addString(item.getItem().getName());
player.sendPacket(sm);
}
else
{
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SOULSHOTS_FOR_THAT);
}
return;
}
// Charge soulshot
weaponInst.setChargedSoulshot(ItemInstance.CHARGED_SOULSHOT);
} }
finally
// Consume Soulshots if player has enough of them
final int saSSCount = (int) player.getStat().calcStat(Stat.SOULSHOT_COUNT, 0, null, null);
final int SSCount = saSSCount == 0 ? weaponItem.getSoulShotCount() : saSSCount;
if (!Config.DONT_DESTROY_SS && !player.destroyItemWithoutTrace("Consume", item.getObjectId(), SSCount, null, false))
{ {
player.soulShotLock.unlock(); if (player.getAutoSoulShot().containsKey(itemId))
{
player.removeAutoSoulShot(itemId);
player.sendPacket(new ExAutoSoulShot(itemId, 0));
final SystemMessage sm = new SystemMessage(SystemMessageId.THE_AUTOMATIC_USE_OF_S1_HAS_BEEN_DEACTIVATED);
sm.addString(item.getItem().getName());
player.sendPacket(sm);
}
else
{
player.sendPacket(SystemMessageId.YOU_DO_NOT_HAVE_ENOUGH_SOULSHOTS_FOR_THAT);
}
return;
} }
// Charge soulshot
weaponInst.setChargedSoulshot(ItemInstance.CHARGED_SOULSHOT);
// Send message to client // Send message to client
player.sendPacket(SystemMessageId.POWER_OF_THE_SPIRITS_ENABLED); player.sendPacket(SystemMessageId.POWER_OF_THE_SPIRITS_ENABLED);
Broadcast.toSelfAndKnownPlayersInRadius(player, new MagicSkillUse(player, player, SKILL_IDS[weaponGrade], 1, 0, 0), 360000/* 600 */); Broadcast.toSelfAndKnownPlayersInRadius(player, new MagicSkillUse(player, player, SKILL_IDS[weaponGrade], 1, 0, 0), 360000/* 600 */);
@@ -34,7 +34,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future; import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import org.l2jmobius.Config; import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool; import org.l2jmobius.commons.concurrent.ThreadPool;
@@ -455,7 +454,6 @@ public class PlayerInstance extends Playable
protected boolean _inventoryDisable = false; protected boolean _inventoryDisable = false;
protected Map<Integer, CubicInstance> _cubics = new ConcurrentHashMap<>(); protected Map<Integer, CubicInstance> _cubics = new ConcurrentHashMap<>();
protected Map<Integer, Integer> _activeSoulShots = new ConcurrentHashMap<>(); protected Map<Integer, Integer> _activeSoulShots = new ConcurrentHashMap<>();
public ReentrantLock soulShotLock = new ReentrantLock();
public Quest dialog = null; public Quest dialog = null;
private final int[] _loto = new int[5]; private final int[] _loto = new int[5];
private final int[] _race = new int[2]; private final int[] _race = new int[2];
@@ -73,38 +73,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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);
} }
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 // Send message to client
player.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED); player.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED);
Broadcast.toSelfAndKnownPlayersInRadius(player, new MagicSkillUse(player, player, skills[0].getSkillId(), skills[0].getSkillLevel(), 0, 0), 600); Broadcast.toSelfAndKnownPlayersInRadius(player, new MagicSkillUse(player, player, skills[0].getSkillId(), skills[0].getSkillLevel(), 0, 0), 600);
@@ -409,7 +409,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -2353,10 +2353,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2433,7 +2434,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -8334,7 +8335,7 @@ public class PlayerInstance extends Playable
public boolean canLogout() public boolean canLogout()
{ {
if (_subclassLock.isLocked()) if (_subclassLock)
{ {
LOGGER.warning("Player " + getName() + " tried to restart/logout during class change."); LOGGER.warning("Player " + getName() + " tried to restart/logout during class change.");
return false; return false;
@@ -10084,10 +10085,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex) public boolean addSubClass(int classId, int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -10150,7 +10152,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -10164,10 +10166,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId) public boolean modifySubClass(int classIndex, int newClassId)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -10223,7 +10226,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex); return addSubClass(newClassId, classIndex);
@@ -10284,10 +10287,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -10436,13 +10440,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isLocked() public boolean isLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -13175,7 +13179,7 @@ public class PlayerInstance extends Playable
public boolean isAllowedToEnchantSkills() public boolean isAllowedToEnchantSkills()
{ {
if (_subclassLock.isLocked()) if (_subclassLock)
{ {
return false; return false;
} }
@@ -73,38 +73,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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);
} }
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 // Send message to client
player.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED); player.sendPacket(SystemMessageId.YOUR_SOULSHOTS_ARE_ENABLED);
Broadcast.toSelfAndKnownPlayersInRadius(player, new MagicSkillUse(player, player, skills[0].getSkillId(), skills[0].getSkillLevel(), 0, 0), 600); 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.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import org.l2jmobius.Config; import org.l2jmobius.Config;
@@ -429,7 +428,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -728,8 +727,6 @@ public class PlayerInstance extends Playable
/** Active shots. */ /** Active shots. */
protected Set<Integer> _activeSoulShots = ConcurrentHashMap.newKeySet(1); protected Set<Integer> _activeSoulShots = ConcurrentHashMap.newKeySet(1);
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2267,10 +2264,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2347,7 +2345,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -8221,7 +8219,7 @@ public class PlayerInstance extends Playable
public boolean canLogout() public boolean canLogout()
{ {
if (_subclassLock.isLocked()) if (_subclassLock)
{ {
LOGGER.warning("Player " + getName() + " tried to restart/logout during class change."); LOGGER.warning("Player " + getName() + " tried to restart/logout during class change.");
return false; return false;
@@ -9970,10 +9968,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex) public boolean addSubClass(int classId, int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -10036,7 +10035,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -10050,10 +10049,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId) public boolean modifySubClass(int classIndex, int newClassId)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -10109,7 +10109,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex); return addSubClass(newClassId, classIndex);
@@ -10170,10 +10170,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -10322,13 +10323,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isLocked() public boolean isLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -13071,7 +13072,7 @@ public class PlayerInstance extends Playable
public boolean isAllowedToEnchantSkills() public boolean isAllowedToEnchantSkills()
{ {
if (_subclassLock.isLocked()) if (_subclassLock)
{ {
return false; return false;
} }
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -426,7 +425,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -705,8 +704,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2332,10 +2329,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2416,7 +2414,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9395,10 +9393,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9470,7 +9469,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9485,10 +9484,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9564,7 +9564,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9671,10 +9671,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9818,13 +9819,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -426,7 +425,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -706,8 +705,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2333,10 +2330,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2417,7 +2415,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9402,10 +9400,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9477,7 +9476,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9492,10 +9491,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9571,7 +9571,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9678,10 +9678,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9825,13 +9826,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -424,7 +423,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -704,8 +703,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2331,10 +2328,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2415,7 +2413,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9388,10 +9386,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9463,7 +9462,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9478,10 +9477,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9557,7 +9557,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9664,10 +9664,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9811,13 +9812,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -431,7 +430,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -711,8 +710,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2341,10 +2338,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2426,7 +2424,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9415,10 +9413,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9490,7 +9489,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9505,10 +9504,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9584,7 +9584,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9691,10 +9691,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9838,13 +9839,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -431,7 +430,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -711,8 +710,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2341,10 +2338,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2426,7 +2424,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9415,10 +9413,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9490,7 +9489,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9505,10 +9504,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9584,7 +9584,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9691,10 +9691,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9838,13 +9839,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -67,38 +67,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -64,38 +64,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -434,7 +433,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -712,8 +711,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2256,10 +2253,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2341,7 +2339,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9327,10 +9325,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9402,7 +9401,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9417,10 +9416,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9496,7 +9496,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9598,10 +9598,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9744,13 +9745,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()
@@ -78,38 +78,31 @@ public class BlessedSoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.BLESSED_SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
if (player.isChargedShot(ShotType.BLESSED_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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
} }
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
player.chargeShot(ShotType.BLESSED_SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -75,38 +75,31 @@ public class SoulShots implements IItemHandler
return false; return false;
} }
player.soulShotLock.lock(); // Check if Soul shot is already active
try if (player.isChargedShot(ShotType.SOULSHOTS))
{ {
// Check if Soul shot is already active return false;
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
player.chargeShot(ShotType.SOULSHOTS);
} }
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
player.chargeShot(ShotType.SOULSHOTS);
// Send message to client // Send message to client
if (!player.getAutoSoulShot().contains(item.getId())) if (!player.getAutoSoulShot().contains(item.getId()))
{ {
@@ -40,7 +40,6 @@ import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture; import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -426,7 +425,7 @@ public class PlayerInstance extends Playable
private long _lastAccess; private long _lastAccess;
private long _uptime; private long _uptime;
private final ReentrantLock _subclassLock = new ReentrantLock(); private boolean _subclassLock = false;
protected int _baseClass; protected int _baseClass;
protected int _activeClass; protected int _activeClass;
protected int _classIndex = 0; protected int _classIndex = 0;
@@ -706,8 +705,6 @@ public class PlayerInstance extends Playable
private BroochJewel _activeRubyJewel = null; private BroochJewel _activeRubyJewel = null;
private BroochJewel _activeShappireJewel = null; private BroochJewel _activeShappireJewel = null;
public ReentrantLock soulShotLock = new ReentrantLock();
/** Event parameters */ /** Event parameters */
private PlayerEventHolder eventStatus = null; private PlayerEventHolder eventStatus = null;
@@ -2335,10 +2332,11 @@ public class PlayerInstance extends Playable
*/ */
public void setClassId(int id) public void setClassId(int id)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -2419,7 +2417,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9414,10 +9412,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean addSubClass(int classId, int classIndex, boolean isDualClass) public boolean addSubClass(int classId, int classIndex, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9489,7 +9488,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
@@ -9504,10 +9503,11 @@ public class PlayerInstance extends Playable
*/ */
public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass) public boolean modifySubClass(int classIndex, int newClassId, boolean isDualClass)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return false; return false;
} }
_subclassLock = true;
try try
{ {
@@ -9583,7 +9583,7 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
return addSubClass(newClassId, classIndex, isDualClass); return addSubClass(newClassId, classIndex, isDualClass);
@@ -9690,10 +9690,11 @@ public class PlayerInstance extends Playable
*/ */
public void setActiveClass(int classIndex) public void setActiveClass(int classIndex)
{ {
if (!_subclassLock.tryLock()) if (_subclassLock)
{ {
return; return;
} }
_subclassLock = true;
try try
{ {
@@ -9837,13 +9838,13 @@ public class PlayerInstance extends Playable
} }
finally finally
{ {
_subclassLock.unlock(); _subclassLock = false;
} }
} }
public boolean isSubclassLocked() public boolean isSubclassLocked()
{ {
return _subclassLock.isLocked(); return _subclassLock;
} }
public void stopWarnUserTakeBreak() public void stopWarnUserTakeBreak()