npc mixin: add null checks for composition
This commit is contained in:
@@ -27,6 +27,7 @@ package net.runelite.mixins;
|
|||||||
import net.runelite.api.mixins.Inject;
|
import net.runelite.api.mixins.Inject;
|
||||||
import net.runelite.api.mixins.Mixin;
|
import net.runelite.api.mixins.Mixin;
|
||||||
import net.runelite.rs.api.RSNPC;
|
import net.runelite.rs.api.RSNPC;
|
||||||
|
import net.runelite.rs.api.RSNPCComposition;
|
||||||
|
|
||||||
@Mixin(RSNPC.class)
|
@Mixin(RSNPC.class)
|
||||||
public abstract class RSNPCMixin implements RSNPC
|
public abstract class RSNPCMixin implements RSNPC
|
||||||
@@ -35,20 +36,23 @@ public abstract class RSNPCMixin implements RSNPC
|
|||||||
@Override
|
@Override
|
||||||
public int getId()
|
public int getId()
|
||||||
{
|
{
|
||||||
return getComposition().getId();
|
RSNPCComposition composition = getComposition();
|
||||||
|
return composition == null ? -1 : composition.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Override
|
@Override
|
||||||
public String getName()
|
public String getName()
|
||||||
{
|
{
|
||||||
return getComposition().getName().replace('\u00A0', ' ');
|
RSNPCComposition composition = getComposition();
|
||||||
|
return composition == null ? null : composition.getName().replace('\u00A0', ' ');
|
||||||
}
|
}
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@Override
|
@Override
|
||||||
public int getCombatLevel()
|
public int getCombatLevel()
|
||||||
{
|
{
|
||||||
return getComposition().getCombatLevel();
|
RSNPCComposition composition = getComposition();
|
||||||
|
return composition == null ? -1 : composition.getCombatLevel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user