mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2024-09-28 23:27:40 +02:00
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)
|
@EventHandler(ignoreCancelled = true)
|
||||||
public void onNPCSpawn(NPCSpawnEvent event) {
|
public void onNPCSpawn(NPCSpawnEvent event) {
|
||||||
|
toRespawn.remove(new ChunkCoord(event.getNPC().getStoredLocation()), event.getNPC());
|
||||||
skinUpdateTracker.onNPCSpawn(event.getNPC());
|
skinUpdateTracker.onNPCSpawn(event.getNPC());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2032,19 +2032,13 @@ public class NPCCommands {
|
|||||||
public void tphere(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
public void tphere(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
|
||||||
if (args.getSenderLocation() == null)
|
if (args.getSenderLocation() == null)
|
||||||
throw new ServerCommandException();
|
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()) {
|
if (!npc.isSpawned()) {
|
||||||
npc.spawn(args.getSenderLocation(), SpawnReason.COMMAND);
|
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 {
|
} 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);
|
npc.teleport(args.getSenderLocation(), TeleportCause.COMMAND);
|
||||||
}
|
}
|
||||||
Messaging.sendTr(sender, Messages.NPC_TELEPORTED, npc.getName());
|
Messaging.sendTr(sender, Messages.NPC_TELEPORTED, npc.getName());
|
||||||
|
@ -252,9 +252,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
if (skinnable != null) {
|
if (skinnable != null) {
|
||||||
skinnable.getSkinTracker().onSpawnNPC();
|
skinnable.getSkinTracker().onSpawnNPC();
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
if (!couldSpawn) {
|
|
||||||
Messaging.debug("Retrying spawn of", getId(), "later due to chunk being unloaded.",
|
Messaging.debug("Retrying spawn of", getId(), "later due to chunk being unloaded.",
|
||||||
Util.isLoaded(at) ? "Util.isLoaded true" : "Util.isLoaded false");
|
Util.isLoaded(at) ? "Util.isLoaded true" : "Util.isLoaded false");
|
||||||
// we need to wait for a chunk load before trying to spawn
|
// we need to wait for a chunk load before trying to spawn
|
||||||
@ -313,6 +311,7 @@ public class CitizensNPC extends AbstractNPC {
|
|||||||
|
|
||||||
updateFlyableState();
|
updateFlyableState();
|
||||||
|
|
||||||
|
Messaging.debug("Spawned", getId(), "SpawnReason." + reason);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user