use of com.github.juliarn.npc.NPC in project CloudNet-v3 by CloudNetService.
the class BukkitNPCManagement method createNPC.
private void createNPC(CloudNPC cloudNPC) {
if (!this.isWorldLoaded(cloudNPC)) {
return;
}
Location location = this.toLocation(cloudNPC.getPosition());
NPC npc = new NPC.Builder(new Profile(cloudNPC.getUUID(), cloudNPC.getDisplayName(), cloudNPC.getProfileProperties().stream().map(npcProfileProperty -> new Profile.Property(npcProfileProperty.getName(), npcProfileProperty.getValue(), npcProfileProperty.getSignature())).collect(Collectors.toSet()))).location(location).lookAtPlayer(cloudNPC.isLookAtPlayer()).imitatePlayer(cloudNPC.isImitatePlayer()).spawnCustomizer((spawnedNPC, player) -> {
spawnedNPC.rotation().queueRotate(location.getYaw(), location.getPitch()).send(player);
spawnedNPC.metadata().queue(MetadataModifier.EntityMetadata.SKIN_LAYERS, true).queue(MetadataModifier.EntityMetadata.SNEAKING, false).send(player);
Material material = Material.getMaterial(cloudNPC.getItemInHand());
if (material != null) {
spawnedNPC.equipment().queue(EnumWrappers.ItemSlot.MAINHAND, new ItemStack(material)).send(player);
}
}).build(this.npcPool);
this.npcProperties.put(cloudNPC.getUUID(), new BukkitNPCProperties(cloudNPC, npc.getEntityId(), Bukkit.createInventory(null, this.defaultItems.length, cloudNPC.getDisplayName()), new HashMap<>()));
this.updateNPC(cloudNPC);
}
Aggregations