use of net.citizensnpcs.api.event.NPCSelectEvent in project Citizens2 by CitizensDev.
the class NPCSelector method select.
public void select(CommandSender sender, NPC npc) {
// Remove existing selection if any
List<String> selectors = npc.data().get("selectors");
if (selectors == null) {
selectors = Lists.newArrayList();
npc.data().set("selectors", selectors);
}
if (sender instanceof Player) {
Player player = (Player) sender;
setMetadata(npc, player);
selectors.add(sender.getName());
// Remove editor if the player has one
Editor.leave(player);
} else if (sender instanceof BlockCommandSender) {
Block block = ((BlockCommandSender) sender).getBlock();
setMetadata(npc, block);
selectors.add(toName(block));
} else if (sender instanceof ConsoleCommandSender) {
consoleSelectedNPC = npc.getUniqueId();
selectors.add("console");
}
Bukkit.getPluginManager().callEvent(new NPCSelectEvent(npc, sender));
}
Aggregations