Skip to content

Commit

Permalink
Set MobType immediately
Browse files Browse the repository at this point in the history
  • Loading branch information
fullwall committed Oct 1, 2023
1 parent 28916be commit e98cfd5
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions main/src/main/java/net/citizensnpcs/npc/CitizensNPCRegistry.java
Expand Up @@ -27,6 +27,7 @@
import net.citizensnpcs.api.npc.NPCDataStore;
import net.citizensnpcs.api.npc.NPCRegistry;
import net.citizensnpcs.api.trait.Trait;
import net.citizensnpcs.api.trait.trait.MobType;
import net.citizensnpcs.api.util.RemoveReason;
import net.citizensnpcs.npc.ai.NPCHolder;
import net.citizensnpcs.trait.ArmorStandTrait;
Expand All @@ -49,10 +50,6 @@ public CitizensNPCRegistry(NPCDataStore store, String registryName) {
name = registryName;
}

private CitizensNPC create(EntityType type, UUID uuid, int id, String name) {
return new CitizensNPC(uuid, id, name, EntityControllers.createForType(type), this);
}

@Override
public NPC createNPC(EntityType type, String name) {
return createNPC(type, UUID.randomUUID(), generateIntegerId(), name);
Expand All @@ -69,10 +66,8 @@ public NPC createNPC(EntityType type, String name, Location loc) {
public NPC createNPC(EntityType type, UUID uuid, int id, String name) {
Preconditions.checkNotNull(name, "name cannot be null");
Preconditions.checkNotNull(type, "type cannot be null");
CitizensNPC npc = create(type, uuid, id, name);

if (npc == null)
throw new IllegalStateException("Could not create NPC.");
CitizensNPC npc = new CitizensNPC(uuid, id, name, EntityControllers.createForType(type), this);
npc.getOrAddTrait(MobType.class).setType(type);
npcs.put(id, npc);
uniqueNPCs.put(npc.getUniqueId(), npc);
Bukkit.getPluginManager().callEvent(new NPCCreateEvent(npc));
Expand Down

0 comments on commit e98cfd5

Please sign in to comment.