Skip to content
Snippets Groups Projects
Commit 2efffdf8 authored by Zoey76's avatar Zoey76
Browse files

BETA: Datapack part for [L6447]:

	* Do not perform null checks on `params`.
	* To verify if parameters has been loaded use `StatsSet#isEmpty()`.
	* Minor cleanup.

'''Note:''' Do not hide or mask exceptions, they lead to harder debugging in most cases.
parent 8f51bdd6
No related branches found
No related tags found
No related merge requests found
Showing
with 26 additions and 28 deletions
......@@ -47,7 +47,7 @@ public final class Reeling extends AbstractEffect
{
super(attachCond, applyCond, set, params);
if ((params == null) || (params.getString("power", null) == null))
if (params.getString("power", null) == null)
{
throw new IllegalArgumentException(getClass().getSimpleName() + ": effect without power!");
}
......
......@@ -37,7 +37,7 @@ public final class RefuelAirship extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_value = params != null ? params.getInt("value", 0) : 0;
_value = params.getInt("value", 0);
}
@Override
......
......@@ -41,19 +41,17 @@ public final class ResistSkill extends AbstractEffect
{
super(attachCond, applyCond, set, params);
if (params != null)
for (int i = 1;; i++)
{
for (int i = 1;; i++)
int skillId = params.getInt("skillId" + i, 0);
int skillLvl = params.getInt("skillLvl" + i, 0);
if (skillId == 0)
{
int skillId = params.getInt("skillId" + i, 0);
int skillLvl = params.getInt("skillLvl" + i, 0);
if (skillId == 0)
{
break;
}
_skills.add(new SkillHolder(skillId, skillLvl));
break;
}
_skills.add(new SkillHolder(skillId, skillLvl));
}
if (_skills.isEmpty())
{
throw new IllegalArgumentException(getClass().getSimpleName() + ": Without parameters!");
......
......@@ -39,7 +39,7 @@ public final class Resurrection extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_power = params != null ? params.getInt("power", 0) : 0;
_power = params.getInt("power", 0);
}
@Override
......
......@@ -35,7 +35,7 @@ public final class SkillTurning extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_chance = params != null ? params.getInt("chance", 100) : 100;
_chance = params.getInt("chance", 100);
}
@Override
......
......@@ -36,7 +36,7 @@ public final class StaticDamage extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_power = params != null ? params.getInt("power", 0) : 0;
_power = params.getInt("power", 0);
}
@Override
......
......@@ -47,7 +47,7 @@ public final class Summon extends AbstractEffect
{
super(attachCond, applyCond, set, params);
if (params == null)
if (params.isEmpty())
{
throw new IllegalArgumentException("Summon effect without parameters!");
}
......
......@@ -37,15 +37,12 @@ public final class SummonAgathion extends AbstractEffect
{
super(attachCond, applyCond, set, params);
if (params != null)
if (params.isEmpty())
{
_npcId = params.getInt("npcId", 0);
}
else
{
_npcId = 0;
_log.warning(getClass().getSimpleName() + ": must have parameters.");
}
_npcId = params.getInt("npcId", 0);
}
@Override
......
......@@ -49,6 +49,7 @@ public final class SummonCubic extends AbstractEffect
public SummonCubic(Condition attachCond, Condition applyCond, StatsSet set, StatsSet params)
{
super(attachCond, applyCond, set, params);
_cubicId = params.getInt("cubicId", -1);
// Custom AI data.
_cubicPower = params.getInt("cubicPower", 0);
......
......@@ -37,7 +37,7 @@ public final class TargetCancel extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_chance = params != null ? params.getInt("chance", 100) : 100;
_chance = params.getInt("chance", 100);
}
@Override
......
......@@ -37,7 +37,7 @@ public final class TargetMeProbability extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_chance = params != null ? params.getInt("chance", 100) : 100;
_chance = params.getInt("chance", 100);
}
@Override
......
......@@ -39,7 +39,7 @@ public final class TransferHate extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_chance = params != null ? params.getInt("chance", 100) : 100;
_chance = params.getInt("chance", 100);
}
@Override
......
......@@ -36,10 +36,11 @@ public final class TrapDetect extends AbstractEffect
{
super(attachCond, applyCond, set, params);
if (params == null)
if (params.isEmpty())
{
throw new IllegalArgumentException(getClass().getSimpleName() + ": effect without power!");
}
_power = params.getInt("power");
}
......
......@@ -41,10 +41,11 @@ public final class TrapRemove extends AbstractEffect
{
super(attachCond, applyCond, set, params);
if (params == null)
if (params.isEmpty())
{
throw new IllegalArgumentException(getClass().getSimpleName() + ": effect without power!");
}
_power = params.getInt("power");
}
......
......@@ -41,7 +41,7 @@ public final class Unsummon extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_chance = params != null ? params.getInt("chance", 100) : 100;
_chance = params.getInt("chance", 100);
}
@Override
......
......@@ -36,7 +36,7 @@ public final class VitalityPointUp extends AbstractEffect
{
super(attachCond, applyCond, set, params);
_value = params != null ? params.getFloat("value", 0) : 0;
_value = params.getFloat("value", 0);
}
@Override
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment