Search in sources :

Example 1 with NPC

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);
}
Also used : CloudNPC(eu.cloudnetservice.cloudnet.ext.npcs.CloudNPC) NPC(com.github.juliarn.npc.NPC) java.util(java.util) ItemMeta(org.bukkit.inventory.meta.ItemMeta) EnumWrappers(com.comphenix.protocol.wrappers.EnumWrappers) NPCConfiguration(eu.cloudnetservice.cloudnet.ext.npcs.configuration.NPCConfiguration) AbstractNPCManagement(eu.cloudnetservice.cloudnet.ext.npcs.AbstractNPCManagement) WorldPosition(de.dytanic.cloudnet.ext.bridge.WorldPosition) Profile(com.github.juliarn.npc.profile.Profile) Location(org.bukkit.Location) NPCConfigurationEntry(eu.cloudnetservice.cloudnet.ext.npcs.configuration.NPCConfigurationEntry) NPCPool(com.github.juliarn.npc.NPCPool) Material(org.bukkit.Material) Bukkit(org.bukkit.Bukkit) CloudNPC(eu.cloudnetservice.cloudnet.ext.npcs.CloudNPC) ServiceInfoSnapshot(de.dytanic.cloudnet.driver.service.ServiceInfoSnapshot) Entity(org.bukkit.entity.Entity) NPC(com.github.juliarn.npc.NPC) Pair(de.dytanic.cloudnet.common.collection.Pair) EntityType(org.bukkit.entity.EntityType) Collectors(java.util.stream.Collectors) MetadataModifier(com.github.juliarn.npc.modifier.MetadataModifier) ItemStack(org.bukkit.inventory.ItemStack) JavaPlugin(org.bukkit.plugin.java.JavaPlugin) BridgeServiceProperty(de.dytanic.cloudnet.ext.bridge.BridgeServiceProperty) ArmorStand(org.bukkit.entity.ArmorStand) NotNull(org.jetbrains.annotations.NotNull) ServiceLifeCycle(de.dytanic.cloudnet.driver.service.ServiceLifeCycle) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack) Profile(com.github.juliarn.npc.profile.Profile) Location(org.bukkit.Location)

Aggregations

EnumWrappers (com.comphenix.protocol.wrappers.EnumWrappers)1 NPC (com.github.juliarn.npc.NPC)1 NPCPool (com.github.juliarn.npc.NPCPool)1 MetadataModifier (com.github.juliarn.npc.modifier.MetadataModifier)1 Profile (com.github.juliarn.npc.profile.Profile)1 Pair (de.dytanic.cloudnet.common.collection.Pair)1 ServiceInfoSnapshot (de.dytanic.cloudnet.driver.service.ServiceInfoSnapshot)1 ServiceLifeCycle (de.dytanic.cloudnet.driver.service.ServiceLifeCycle)1 BridgeServiceProperty (de.dytanic.cloudnet.ext.bridge.BridgeServiceProperty)1 WorldPosition (de.dytanic.cloudnet.ext.bridge.WorldPosition)1 AbstractNPCManagement (eu.cloudnetservice.cloudnet.ext.npcs.AbstractNPCManagement)1 CloudNPC (eu.cloudnetservice.cloudnet.ext.npcs.CloudNPC)1 NPCConfiguration (eu.cloudnetservice.cloudnet.ext.npcs.configuration.NPCConfiguration)1 NPCConfigurationEntry (eu.cloudnetservice.cloudnet.ext.npcs.configuration.NPCConfigurationEntry)1 java.util (java.util)1 Collectors (java.util.stream.Collectors)1 Bukkit (org.bukkit.Bukkit)1 Location (org.bukkit.Location)1 Material (org.bukkit.Material)1 ArmorStand (org.bukkit.entity.ArmorStand)1