mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-11-22 18:45:29 +01:00
bugfixes
This commit is contained in:
parent
504d4f94d2
commit
a240b71573
@ -70,11 +70,11 @@ public class Citizens extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String cmdName, String[] args) {
|
||||
if (args[0].equals("test")) {
|
||||
if (args[0].equals("spawn")) {
|
||||
NPC npc = npcManager.createNPC("aPunch");
|
||||
npc.spawn(((Player) sender).getLocation());
|
||||
} else if (args[0].equals("testremove")) {
|
||||
for(NPC npc : npcManager.getNPCs()) {
|
||||
} else if (args[0].equals("despawn")) {
|
||||
for (NPC npc : npcManager.getNPCs()) {
|
||||
npc.despawn();
|
||||
}
|
||||
}
|
||||
@ -82,7 +82,6 @@ public class Citizens extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void setupNPCs() throws NPCLoadException {
|
||||
// TODO needs fixing
|
||||
traitManager.registerTrait(LocationTrait.class);
|
||||
for (DataKey key : saves.getKey("npc").getIntegerSubKeys()) {
|
||||
int id = Integer.parseInt(key.name());
|
||||
|
@ -29,14 +29,17 @@ public class EventListen implements Listener {
|
||||
*/
|
||||
@EventHandler
|
||||
public void onEntityDamage(EntityDamageEvent event) {
|
||||
if (event.isCancelled() || !CitizensAPI.getNPCManager().isNPC(event.getEntity()))
|
||||
if (!CitizensAPI.getNPCManager().isNPC(event.getEntity()))
|
||||
return;
|
||||
|
||||
event.setCancelled(true);
|
||||
if (event instanceof EntityDamageByEntityEvent) {
|
||||
EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
|
||||
if (e.getDamager() instanceof Player) {
|
||||
NPC npc = CitizensAPI.getNPCManager().getNPC(event.getEntity());
|
||||
npc.getCharacter().onLeftClick(npc, (Player) e.getDamager());
|
||||
if (npc.getCharacter() != null) {
|
||||
npc.getCharacter().onLeftClick(npc, (Player) e.getDamager());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +143,11 @@ public class CitizensNPC implements NPC {
|
||||
mcEntity = manager.spawn(this, loc);
|
||||
else
|
||||
manager.spawn(this, loc);
|
||||
|
||||
// Set the location
|
||||
addTrait(LocationTrait.class);
|
||||
getTrait(LocationTrait.class).setLocation(loc);
|
||||
|
||||
spawned = true;
|
||||
}
|
||||
|
||||
@ -156,8 +160,8 @@ public class CitizensNPC implements NPC {
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new NPCDespawnEvent(this));
|
||||
|
||||
mcEntity.die();
|
||||
manager.despawn(this);
|
||||
mcEntity.die();
|
||||
spawned = false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user