Fixed summoning Cubic NPE.

This commit is contained in:
MobiusDevelopment 2019-10-10 21:59:00 +00:00
parent 3cdb31b034
commit beff746963
14 changed files with 42 additions and 70 deletions

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}

View File

@ -90,14 +90,12 @@ public class SummonCubic extends AbstractEffect
{
// If maximum amount is reached, random cubic is removed.
// Players with no mastery can have only one cubic.
final int allowedCubicCount = (int) effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 1);
final double allowedCubicCount = effected.getActingPlayer().getStat().getValue(Stats.MAX_CUBIC, 0);
final int currentCubicCount = player.getCubics().size();
// Extra cubics are removed, one by one, randomly.
for (int i = 0; i <= ((currentCubicCount + 1) - allowedCubicCount); i++)
if (currentCubicCount >= allowedCubicCount)
{
final int removedCubicId = (int) player.getCubics().keySet().toArray()[Rnd.get(currentCubicCount)];
final CubicInstance removedCubic = player.getCubicById(removedCubicId);
removedCubic.deactivate();
player.getCubics().values().stream().skip((int) (currentCubicCount * Rnd.nextDouble())).findAny().get().deactivate();
}
}