Search in sources :

Example 76 with EntityPlayer

use of net.minecraft.server.v1_16_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class NMSImpl method sendTabListRemove.

@Override
public void sendTabListRemove(Player recipient, Collection<? extends SkinnableEntity> skinnableNPCs) {
    Preconditions.checkNotNull(recipient);
    Preconditions.checkNotNull(skinnableNPCs);
    EntityPlayer[] entities = new EntityPlayer[skinnableNPCs.size()];
    int i = 0;
    for (SkinnableEntity skinnable : skinnableNPCs) {
        entities[i] = (EntityPlayer) skinnable;
        i++;
    }
    NMSImpl.sendPacket(recipient, new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entities));
}
Also used : SkinnableEntity(net.citizensnpcs.npc.skin.SkinnableEntity) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_15_R1.PacketPlayOutPlayerInfo) PathPoint(net.minecraft.server.v1_15_R1.PathPoint)

Example 77 with EntityPlayer

use of net.minecraft.server.v1_16_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class NMSImpl method sendTabListRemove.

@Override
public void sendTabListRemove(Player recipient, Player listPlayer) {
    Preconditions.checkNotNull(recipient);
    Preconditions.checkNotNull(listPlayer);
    EntityPlayer entity = ((CraftPlayer) listPlayer).getHandle();
    NMSImpl.sendPacket(recipient, new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.REMOVE_PLAYER, entity));
}
Also used : EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_15_R1.PacketPlayOutPlayerInfo)

Example 78 with EntityPlayer

use of net.minecraft.server.v1_16_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class PlayerAnimationImpl method play.

public static void play(PlayerAnimation animation, Player bplayer, int radius) {
    final EntityPlayer player = (EntityPlayer) NMSImpl.getHandle(bplayer);
    if (DEFAULTS.containsKey(animation)) {
        playDefaultAnimation(player, radius, DEFAULTS.get(animation));
        return;
    }
    switch(animation) {
        case SIT:
            player.getBukkitEntity().setMetadata("citizens.sitting", new FixedMetadataValue(CitizensAPI.getPlugin(), true));
            NPCRegistry registry = CitizensAPI.getNamedNPCRegistry("PlayerAnimationImpl");
            if (registry == null) {
                registry = CitizensAPI.createNamedNPCRegistry("PlayerAnimationImpl", new MemoryNPCDataStore());
            }
            final NPC holder = registry.createNPC(EntityType.ARMOR_STAND, "");
            holder.spawn(player.getBukkitEntity().getLocation());
            ArmorStandTrait trait = holder.getOrAddTrait(ArmorStandTrait.class);
            trait.setGravity(false);
            trait.setHasArms(false);
            trait.setHasBaseplate(false);
            trait.setSmall(true);
            trait.setMarker(true);
            trait.setVisible(false);
            holder.data().set(NPC.NAMEPLATE_VISIBLE_METADATA, false);
            holder.data().set(NPC.DEFAULT_PROTECTED_METADATA, true);
            new BukkitRunnable() {

                @Override
                public void cancel() {
                    super.cancel();
                    holder.destroy();
                }

                @Override
                public void run() {
                    if (player.dead || !player.valid || !player.getBukkitEntity().hasMetadata("citizens.sitting") || !player.getBukkitEntity().getMetadata("citizens.sitting").get(0).asBoolean()) {
                        cancel();
                        return;
                    }
                    if (player instanceof NPCHolder && !((NPCHolder) player).getNPC().isSpawned()) {
                        cancel();
                        return;
                    }
                    if (!NMS.getPassengers(holder.getEntity()).contains(player.getBukkitEntity())) {
                        NMS.mount(holder.getEntity(), player.getBukkitEntity());
                    }
                }
            }.runTaskTimer(CitizensAPI.getPlugin(), 0, 1);
            break;
        case SLEEP:
            try {
                ENTITY_SETPOSE_METHOD.invoke(player, EntityPose.SLEEPING);
            } catch (Throwable e) {
                e.printStackTrace();
            }
            break;
        case SNEAK:
            player.getBukkitEntity().setSneaking(true);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case START_ELYTRA:
            player.startGliding();
            break;
        case START_USE_MAINHAND_ITEM:
            player.c(EnumHand.MAIN_HAND);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case START_USE_OFFHAND_ITEM:
            player.c(EnumHand.OFF_HAND);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case STOP_SITTING:
            player.getBukkitEntity().setMetadata("citizens.sitting", new FixedMetadataValue(CitizensAPI.getPlugin(), false));
            NMS.mount(player.getBukkitEntity(), null);
            break;
        case STOP_SLEEPING:
            try {
                ENTITY_SETPOSE_METHOD.invoke(player, EntityPose.STANDING);
            } catch (Throwable e) {
                e.printStackTrace();
            }
            break;
        case STOP_SNEAKING:
            player.getBukkitEntity().setSneaking(false);
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        case STOP_USE_ITEM:
            player.clearActiveItem();
            sendPacketNearby(new PacketPlayOutEntityMetadata(player.getId(), player.getDataWatcher(), true), player, radius);
            break;
        default:
            throw new UnsupportedOperationException();
    }
}
Also used : MemoryNPCDataStore(net.citizensnpcs.api.npc.MemoryNPCDataStore) NPC(net.citizensnpcs.api.npc.NPC) NPCHolder(net.citizensnpcs.npc.ai.NPCHolder) PacketPlayOutEntityMetadata(net.minecraft.server.v1_15_R1.PacketPlayOutEntityMetadata) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) FixedMetadataValue(org.bukkit.metadata.FixedMetadataValue) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) ArmorStandTrait(net.citizensnpcs.trait.ArmorStandTrait) NPCRegistry(net.citizensnpcs.api.npc.NPCRegistry)

Example 79 with EntityPlayer

use of net.minecraft.server.v1_16_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class PlayerlistTracker method updateLastPlayer.

public void updateLastPlayer() {
    if (tracker.dead)
        return;
    final EntityPlayer entityplayer = lastUpdatedPlayer;
    NMS.sendTabListAdd(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
    if (!Setting.DISABLE_TABLIST.asBoolean())
        return;
    Bukkit.getScheduler().scheduleSyncDelayedTask(CitizensAPI.getPlugin(), new Runnable() {

        @Override
        public void run() {
            NMS.sendTabListRemove(entityplayer.getBukkitEntity(), (Player) tracker.getBukkitEntity());
        }
    }, Setting.TABLIST_REMOVE_PACKET_DELAY.asInt());
}
Also used : EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer) Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_15_R1.EntityPlayer)

Example 80 with EntityPlayer

use of net.minecraft.server.v1_16_R2.EntityPlayer in project Citizens2 by CitizensDev.

the class NMSImpl method removeFromServerPlayerList.

@Override
public void removeFromServerPlayerList(Player player) {
    EntityPlayer handle = (EntityPlayer) NMSImpl.getHandle(player);
    ((CraftServer) Bukkit.getServer()).getHandle().players.remove(handle);
}
Also used : EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) CraftServer(org.bukkit.craftbukkit.v1_11_R1.CraftServer)

Aggregations

Player (org.bukkit.entity.Player)70 ItemStack (org.bukkit.inventory.ItemStack)46 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)36 EntityPlayer (net.minecraft.server.v1_16_R3.EntityPlayer)31 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)31 EntityPlayer (net.minecraft.server.v1_15_R1.EntityPlayer)26 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)25 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)25 EntityPlayer (net.minecraft.server.v1_13_R2.EntityPlayer)25 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)23 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)22 EntityPlayer (net.minecraft.server.v1_14_R1.EntityPlayer)21 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)19 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)19 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)19 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)18 GameProfile (com.mojang.authlib.GameProfile)16 MyPet (de.Keyle.MyPet.api.entity.MyPet)16 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)16 EntityPlayer (net.minecraft.server.v1_16_R1.EntityPlayer)15