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

View File

@@ -87,44 +87,36 @@ public class SoulShots implements IItemHandler
return;
}
player.soulShotLock.lock();
try
// Check if Soulshot is already active
if (weaponInst.getChargedSoulshot() != ItemInstance.CHARGED_NONE)
{
// Check if Soulshot is already active
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);
return;
}
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
player.sendPacket(SystemMessageId.POWER_OF_THE_SPIRITS_ENABLED);
Broadcast.toSelfAndKnownPlayersInRadius(player, new MagicSkillUse(player, player, SKILL_IDS[weaponGrade], 1, 0, 0), 360000/* 600 */);

View File

@@ -34,7 +34,6 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Future;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.ReentrantLock;
import org.l2jmobius.Config;
import org.l2jmobius.commons.concurrent.ThreadPool;
@@ -455,7 +454,6 @@ public class PlayerInstance extends Playable
protected boolean _inventoryDisable = false;
protected Map<Integer, CubicInstance> _cubics = new ConcurrentHashMap<>();
protected Map<Integer, Integer> _activeSoulShots = new ConcurrentHashMap<>();
public ReentrantLock soulShotLock = new ReentrantLock();
public Quest dialog = null;
private final int[] _loto = new int[5];
private final int[] _race = new int[2];