mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-12 13:44:07 +01:00
Add new API to avoid default skin fetching
This commit is contained in:
parent
c63b6efdf7
commit
aaa6397a69
@ -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));
|
||||
|
@ -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 {
|
||||
|
23
main/src/main/java/net/citizensnpcs/trait/SkinTrait.java
Normal file
23
main/src/main/java/net/citizensnpcs/trait/SkinTrait.java
Normal 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;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user