mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-15 12:41:20 +01:00
Breaking change: add new registry param to CitizensNPC constructor
This commit is contained in:
parent
50a43d6116
commit
815733c2ad
@ -10,6 +10,7 @@ import net.citizensnpcs.api.event.DespawnReason;
|
||||
import net.citizensnpcs.api.event.NPCDespawnEvent;
|
||||
import net.citizensnpcs.api.event.NPCSpawnEvent;
|
||||
import net.citizensnpcs.api.npc.AbstractNPC;
|
||||
import net.citizensnpcs.api.npc.NPCRegistry;
|
||||
import net.citizensnpcs.api.trait.Trait;
|
||||
import net.citizensnpcs.api.trait.trait.Spawned;
|
||||
import net.citizensnpcs.api.util.DataKey;
|
||||
@ -38,8 +39,8 @@ public class CitizensNPC extends AbstractNPC {
|
||||
private EntityController entityController;
|
||||
private final CitizensNavigator navigator = new CitizensNavigator(this);
|
||||
|
||||
public CitizensNPC(int id, String name, EntityController entityController) {
|
||||
super(id, name);
|
||||
public CitizensNPC(int id, String name, EntityController entityController, NPCRegistry registry) {
|
||||
super(id, name, registry);
|
||||
Preconditions.checkNotNull(entityController);
|
||||
this.entityController = entityController;
|
||||
}
|
||||
|
@ -47,8 +47,9 @@ public class CitizensNPCRegistry implements NPCRegistry {
|
||||
@Override
|
||||
public void deregister(NPC npc) {
|
||||
npcs.remove(npc.getId());
|
||||
if (saves != null)
|
||||
if (saves != null) {
|
||||
saves.clearData(npc);
|
||||
}
|
||||
npc.despawn(DespawnReason.REMOVAL);
|
||||
}
|
||||
|
||||
@ -59,10 +60,12 @@ public class CitizensNPCRegistry implements NPCRegistry {
|
||||
NPC npc = itr.next();
|
||||
itr.remove();
|
||||
npc.despawn(DespawnReason.REMOVAL);
|
||||
for (Trait t : npc.getTraits())
|
||||
for (Trait t : npc.getTraits()) {
|
||||
t.onRemove();
|
||||
if (saves != null)
|
||||
}
|
||||
if (saves != null) {
|
||||
saves.clearData(npc);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -78,7 +81,7 @@ public class CitizensNPCRegistry implements NPCRegistry {
|
||||
}
|
||||
|
||||
private CitizensNPC getByType(EntityType type, int id, String name) {
|
||||
return new CitizensNPC(id, name, EntityControllers.createForType(type));
|
||||
return new CitizensNPC(id, name, EntityControllers.createForType(type), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -84,8 +84,9 @@ public class BlazeController extends MobEntityController {
|
||||
// this method is called by both the entities involved - cancelling
|
||||
// it will not stop the NPC from moving.
|
||||
super.collide(entity);
|
||||
if (npc != null)
|
||||
if (npc != null) {
|
||||
Util.callCollisionEvent(npc, entity.getBukkitEntity());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -112,9 +112,9 @@ public class ByIdArray<T> implements Iterable<T> {
|
||||
elementData[index] = null;
|
||||
--size;
|
||||
++modCount;
|
||||
if (index == highest)
|
||||
if (index >= highest)
|
||||
recalcHighest();
|
||||
if (index == lowest)
|
||||
if (index <= lowest)
|
||||
recalcLowest();
|
||||
return prev;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user