Remove possible NPE from trait plotting

This commit is contained in:
fullwall 2018-03-09 22:33:09 +08:00
parent 8054667482
commit dd53b5eefa
3 changed files with 25 additions and 21 deletions

View File

@ -101,7 +101,7 @@ public class CitizensTraitFactory implements TraitFactory {
public void addPlotters(Graph graph) {
for (Map.Entry<String, TraitInfo> entry : registered.entrySet()) {
if (INTERNAL_TRAITS.contains(entry.getKey()))
if (INTERNAL_TRAITS.contains(entry.getKey()) || entry.getKey() == null)
continue;
final Class<? extends Trait> traitClass = entry.getValue().getTraitClass();
graph.addPlotter(new Metrics.Plotter(entry.getKey()) {
@ -109,9 +109,10 @@ public class CitizensTraitFactory implements TraitFactory {
public int getValue() {
int numberUsingTrait = 0;
for (NPC npc : CitizensAPI.getNPCRegistry()) {
if (npc.hasTrait(traitClass))
if (npc.hasTrait(traitClass)) {
++numberUsingTrait;
}
}
return numberUsingTrait;
}
});

View File

@ -89,6 +89,9 @@ public class Skin {
setNPCTexture(entity, localData);
// check if NPC prefers to use cached skin over the latest skin.
if (entity.getNPC().data().has("player-skin-use-latest")) {
entity.getNPC().data().remove("player-skin-use-latest");
}
if (!entity.getNPC().data().get(NPC.PLAYER_SKIN_USE_LATEST, Setting.NPC_SKIN_USE_LATEST.asBoolean())) {
// cache preferred
return true;