Add new API to avoid default skin fetching

This commit is contained in:
fullwall 2020-04-18 12:24:29 +08:00
parent c63b6efdf7
commit aaa6397a69
3 changed files with 30 additions and 0 deletions

View File

@ -41,6 +41,7 @@ import net.citizensnpcs.trait.ScoreboardTrait;
import net.citizensnpcs.trait.ScriptTrait;
import net.citizensnpcs.trait.SheepTrait;
import net.citizensnpcs.trait.SkinLayers;
import net.citizensnpcs.trait.SkinTrait;
import net.citizensnpcs.trait.SlimeSize;
import net.citizensnpcs.trait.VillagerProfession;
import net.citizensnpcs.trait.WitherTrait;
@ -77,6 +78,7 @@ public class CitizensTraitFactory implements TraitFactory {
registerTrait(TraitInfo.create(ScriptTrait.class));
registerTrait(TraitInfo.create(SheepTrait.class));
registerTrait(TraitInfo.create(SkinLayers.class));
registerTrait(TraitInfo.create(SkinTrait.class));
registerTrait(TraitInfo.create(MountTrait.class));
registerTrait(TraitInfo.create(SlimeSize.class));
registerTrait(TraitInfo.create(Spawned.class));

View File

@ -26,6 +26,7 @@ import net.citizensnpcs.api.util.Messaging;
import net.citizensnpcs.npc.profile.ProfileFetchHandler;
import net.citizensnpcs.npc.profile.ProfileFetcher;
import net.citizensnpcs.npc.profile.ProfileRequest;
import net.citizensnpcs.trait.SkinTrait;
/**
* Stores data for a single skin.
@ -100,6 +101,10 @@ public class Skin {
}
if (!hasSkinData()) {
if (npc.hasTrait(SkinTrait.class) && !this.skinName.equals(cachedName)
&& !npc.getTrait(SkinTrait.class).fetchDefaultSkin()) {
return false;
}
if (hasFetched) {
return true;
} else {

View File

@ -0,0 +1,23 @@
package net.citizensnpcs.trait;
import net.citizensnpcs.api.persistence.Persist;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.TraitName;
@TraitName("skintrait")
public class SkinTrait extends Trait {
@Persist
private boolean fetchDefaultSkin = true;
public SkinTrait() {
super("skintrait");
}
public boolean fetchDefaultSkin() {
return fetchDefaultSkin;
}
public void setFetchDefaultSkin(boolean fetch) {
this.fetchDefaultSkin = fetch;
}
}