Clean up multiworld permission check for /npc tphere and don't respawn NPCs who were spawned for another reason
This commit is contained in:
parent
a9ddebd8f8
commit
e6cf9b8b08
|
@ -420,6 +420,7 @@ public class EventListen implements Listener {
|
|||
|
||||
@EventHandler(ignoreCancelled = true)
|
||||
public void onNPCSpawn(NPCSpawnEvent event) {
|
||||
toRespawn.remove(new ChunkCoord(event.getNPC().getStoredLocation()), event.getNPC());
|
||||
skinUpdateTracker.onNPCSpawn(event.getNPC());
|
||||
}
|
||||
|
||||
|
|
|
@ -2032,19 +2032,13 @@ public class NPCCommands {
|
|||
public void tphere(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||
if (args.getSenderLocation() == null)
|
||||
throw new ServerCommandException();
|
||||
if (!sender.hasPermission("citizens.npc.tphere.multiworld")
|
||||
&& npc.getStoredLocation().getWorld() != args.getSenderLocation().getWorld()) {
|
||||
throw new CommandException(Messages.CANNOT_TELEPORT_ACROSS_WORLDS);
|
||||
}
|
||||
if (!npc.isSpawned()) {
|
||||
npc.spawn(args.getSenderLocation(), SpawnReason.COMMAND);
|
||||
if (!sender.hasPermission("citizens.npc.tphere.multiworld")
|
||||
&& npc.getEntity().getLocation().getWorld() != args.getSenderLocation().getWorld()) {
|
||||
npc.despawn(DespawnReason.REMOVAL);
|
||||
throw new CommandException(Messages.CANNOT_TELEPORT_ACROSS_WORLDS);
|
||||
}
|
||||
} else {
|
||||
if (!sender.hasPermission("citizens.npc.tphere.multiworld")
|
||||
&& npc.getEntity().getLocation().getWorld() != args.getSenderLocation().getWorld()) {
|
||||
npc.despawn(DespawnReason.REMOVAL);
|
||||
throw new CommandException(Messages.CANNOT_TELEPORT_ACROSS_WORLDS);
|
||||
}
|
||||
npc.teleport(args.getSenderLocation(), TeleportCause.COMMAND);
|
||||
}
|
||||
Messaging.sendTr(sender, Messages.NPC_TELEPORTED, npc.getName());
|
||||
|
|
|
@ -252,9 +252,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||
if (skinnable != null) {
|
||||
skinnable.getSkinTracker().onSpawnNPC();
|
||||
}
|
||||
}
|
||||
|
||||
if (!couldSpawn) {
|
||||
} else {
|
||||
Messaging.debug("Retrying spawn of", getId(), "later due to chunk being unloaded.",
|
||||
Util.isLoaded(at) ? "Util.isLoaded true" : "Util.isLoaded false");
|
||||
// we need to wait for a chunk load before trying to spawn
|
||||
|
@ -313,6 +311,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||
|
||||
updateFlyableState();
|
||||
|
||||
Messaging.debug("Spawned", getId(), "SpawnReason." + reason);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue