Fix CITIZENS-425

This commit is contained in:
fullwall 2013-02-10 22:34:56 +08:00
parent de8a613170
commit d1279e269c
2 changed files with 13 additions and 1 deletions

View File

@ -1051,8 +1051,19 @@ public class NPCCommands {
// Spawn the NPC if it isn't spawned to prevent NPEs
if (!npc.isSpawned()) {
npc.spawn(args.getSenderLocation());
} else
if (!sender.hasPermission("citizens.npc.tphere.multiworld")
&& npc.getBukkitEntity().getLocation().getWorld() != args.getSenderLocation().getWorld()) {
npc.despawn();
throw new CommandException(Messages.CANNOT_TELEPORT_ACROSS_WORLDS);
}
} else {
if (!sender.hasPermission("citizens.npc.tphere.multiworld")
&& npc.getBukkitEntity().getLocation().getWorld() != args.getSenderLocation().getWorld()) {
npc.despawn();
throw new CommandException(Messages.CANNOT_TELEPORT_ACROSS_WORLDS);
}
npc.getBukkitEntity().teleport(args.getSenderLocation(), TeleportCause.COMMAND);
}
Messaging.sendTr(sender, Messages.NPC_TELEPORTED, npc.getName());
}

View File

@ -210,4 +210,5 @@ public class Messages {
public static final String ZOMBIE_BABY_UNSET = "citizens.commands.npc.zombiemod.baby-unset";
public static final String ZOMBIE_VILLAGER_SET = "citizens.commands.npc.zombiemod.villager-set";
public static final String ZOMBIE_VILLAGER_UNSET = "citizens.commands.npc.zombiemod.villager-unset";
public static final String CANNOT_TELEPORT_ACROSS_WORLDS = "citizens.commands.npc.tphere.multiworld-not-allowed";
}