Search in sources :

Example 86 with CraftPlayer

use of org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer in project NoCheatPlus by NoCheatPlus.

the class MCAccessCB3043 method setDead.

@Override
public void setDead(final Player player, final int deathTicks) {
    final EntityPlayer mcPlayer = ((CraftPlayer) player).getHandle();
    mcPlayer.deathTicks = deathTicks;
    mcPlayer.dead = true;
}
Also used : EntityPlayer(net.minecraft.server.v1_7_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_7_R3.entity.CraftPlayer)

Example 87 with CraftPlayer

use of org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer in project NoCheatPlus by NoCheatPlus.

the class MCAccessCB2882 method isIllegalBounds.

@Override
public AlmostBoolean isIllegalBounds(final Player player) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    if (entityPlayer.dead)
        return AlmostBoolean.NO;
    // TODO: Does this need a method call for the "real" box? Might be no problem during moving events, though.
    final AxisAlignedBB box = entityPlayer.boundingBox;
    if (!entityPlayer.isSleeping()) {
        // This can not really test stance but height of bounding box.
        final double dY = Math.abs(box.e - box.b);
        // dY > 1.65D ||
        if (dY > 1.8)
            return AlmostBoolean.YES;
        if (dY < 0.1D && entityPlayer.length >= 0.1)
            return AlmostBoolean.YES;
    }
    return AlmostBoolean.MAYBE;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_6_R3.AxisAlignedBB) EntityPlayer(net.minecraft.server.v1_6_R3.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_6_R3.entity.CraftPlayer)

Example 88 with CraftPlayer

use of org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer in project NoCheatPlus by NoCheatPlus.

the class MCAccessSpigotCB1_9_R1 method isIllegalBounds.

@Override
public AlmostBoolean isIllegalBounds(final Player player) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    if (entityPlayer.dead) {
        return AlmostBoolean.NO;
    }
    // TODO: Does this need a method call for the "real" box? Might be no problem during moving events, though.
    final AxisAlignedBB box = entityPlayer.getBoundingBox();
    if (LocUtil.isBadCoordinate(box.a, box.b, box.c, box.d, box.e, box.f)) {
        return AlmostBoolean.YES;
    }
    if (!entityPlayer.isSleeping()) {
        // This can not really test stance but height of bounding box.
        final double dY = Math.abs(box.e - box.b);
        if (dY > 1.8) {
            // dY > 1.65D ||
            return AlmostBoolean.YES;
        }
        if (dY < 0.1D && entityPlayer.length >= 0.1) {
            return AlmostBoolean.YES;
        }
    }
    return AlmostBoolean.MAYBE;
}
Also used : AxisAlignedBB(net.minecraft.server.v1_9_R1.AxisAlignedBB) EntityPlayer(net.minecraft.server.v1_9_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer)

Example 89 with CraftPlayer

use of org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer in project Denizen-For-Bukkit by DenizenScript.

the class PlayerHelperImpl method sendEntitySpawn.

@Override
public FakeEntity sendEntitySpawn(List<PlayerTag> players, DenizenEntityType entityType, LocationTag location, ArrayList<Mechanism> mechanisms, int customId, UUID customUUID, boolean autoTrack) {
    CraftWorld world = ((CraftWorld) location.getWorld());
    net.minecraft.server.v1_16_R3.Entity nmsEntity;
    if (entityType.isCustom()) {
        if (entityType.customEntityType == CustomEntityType.ITEM_PROJECTILE) {
            org.bukkit.inventory.ItemStack itemStack = new ItemStack(Material.STONE);
            for (Mechanism mechanism : mechanisms) {
                if (mechanism.matches("item") && mechanism.requireObject(ItemTag.class)) {
                    itemStack = mechanism.valueAsType(ItemTag.class).getItemStack();
                }
            }
            nmsEntity = new EntityItemProjectileImpl(world.getHandle(), location, CraftItemStack.asNMSCopy(itemStack));
        } else if (entityType.customEntityType == CustomEntityType.FAKE_PLAYER) {
            String name = null;
            String skin = null;
            for (Mechanism mechanism : new ArrayList<>(mechanisms)) {
                if (mechanism.matches("name")) {
                    name = mechanism.getValue().asString();
                    mechanisms.remove(mechanism);
                } else if (mechanism.matches("skin")) {
                    skin = mechanism.getValue().asString();
                    mechanisms.remove(mechanism);
                }
                if (name != null && skin != null) {
                    break;
                }
            }
            nmsEntity = ((CraftFakePlayerImpl) CustomEntityHelperImpl.spawnFakePlayer(location, name, skin, false)).getHandle();
        } else {
            throw new IllegalArgumentException("entityType");
        }
    } else {
        nmsEntity = world.createEntity(location, entityType.getBukkitEntityType().getEntityClass());
    }
    if (customUUID != null) {
        nmsEntity.e(customId);
        nmsEntity.a_(customUUID);
    }
    EntityTag entity = new EntityTag(nmsEntity.getBukkitEntity());
    for (Mechanism mechanism : mechanisms) {
        entity.safeAdjustDuplicate(mechanism);
    }
    nmsEntity.dead = false;
    FakeEntity fake = new FakeEntity(players, location, entity.getBukkitEntity().getEntityId());
    fake.entity = new EntityTag(entity.getBukkitEntity());
    fake.entity.isFake = true;
    fake.entity.isFakeValid = true;
    List<TrackerData> trackers = new ArrayList<>();
    fake.triggerSpawnPacket = (player) -> {
        EntityPlayer nmsPlayer = ((CraftPlayer) player.getPlayerEntity()).getHandle();
        PlayerConnection conn = nmsPlayer.playerConnection;
        final EntityTrackerEntry tracker = new EntityTrackerEntry(world.getHandle(), nmsEntity, 1, true, conn::sendPacket, Collections.singleton(nmsPlayer));
        tracker.b(nmsPlayer);
        final TrackerData data = new TrackerData();
        data.player = player;
        data.tracker = tracker;
        trackers.add(data);
        if (autoTrack) {
            new BukkitRunnable() {

                boolean wasOnline = true;

                @Override
                public void run() {
                    if (!fake.entity.isFakeValid) {
                        cancel();
                        return;
                    }
                    if (player.isOnline()) {
                        if (!wasOnline) {
                            tracker.b(((CraftPlayer) player.getPlayerEntity()).getHandle());
                            wasOnline = true;
                        }
                        tracker.a();
                    } else if (wasOnline) {
                        wasOnline = false;
                    }
                }
            }.runTaskTimer(Denizen.getInstance(), 1, 1);
        }
    };
    for (PlayerTag player : players) {
        fake.triggerSpawnPacket.accept(player);
    }
    fake.triggerUpdatePacket = () -> {
        for (TrackerData tracker : trackers) {
            if (tracker.player.isOnline()) {
                tracker.tracker.a();
            }
        }
    };
    fake.triggerDestroyPacket = () -> {
        for (TrackerData tracker : trackers) {
            if (tracker.player.isOnline()) {
                tracker.tracker.a(((CraftPlayer) tracker.player.getPlayerEntity()).getHandle());
            }
        }
        trackers.clear();
    };
    return fake;
}
Also used : FakeEntity(com.denizenscript.denizen.utilities.entity.FakeEntity) EntityItemProjectileImpl(com.denizenscript.denizen.nms.v1_16.impl.entities.EntityItemProjectileImpl) CraftFakePlayerImpl(com.denizenscript.denizen.nms.v1_16.impl.entities.CraftFakePlayerImpl) PlayerTag(com.denizenscript.denizen.objects.PlayerTag) Mechanism(com.denizenscript.denizencore.objects.Mechanism) EntityTag(com.denizenscript.denizen.objects.EntityTag) CraftWorld(org.bukkit.craftbukkit.v1_16_R3.CraftWorld) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) ItemStack(org.bukkit.inventory.ItemStack) net.minecraft.server.v1_16_R3(net.minecraft.server.v1_16_R3) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(org.bukkit.inventory.ItemStack) ItemTag(com.denizenscript.denizen.objects.ItemTag)

Example 90 with CraftPlayer

use of org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditorImpl method updatePlayer.

@Override
protected void updatePlayer(Player player, final boolean isSkinChanging) {
    final EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    final UUID uuid = player.getUniqueId();
    PacketPlayOutEntityDestroy destroyPacket = new PacketPlayOutEntityDestroy(entityPlayer.getId());
    for (Player p : Bukkit.getServer().getOnlinePlayers()) {
        if (!p.getUniqueId().equals(uuid)) {
            PacketHelperImpl.sendPacket(p, destroyPacket);
        }
    }
    new BukkitRunnable() {

        @Override
        public void run() {
            PacketPlayOutPlayerInfo playerInfo = new PacketPlayOutPlayerInfo(PacketPlayOutPlayerInfo.EnumPlayerInfoAction.ADD_PLAYER, entityPlayer);
            PacketPlayOutNamedEntitySpawn spawnPacket = new PacketPlayOutNamedEntitySpawn(entityPlayer);
            for (Player player : Bukkit.getServer().getOnlinePlayers()) {
                PacketHelperImpl.sendPacket(player, playerInfo);
                if (!player.getUniqueId().equals(uuid)) {
                    PacketHelperImpl.sendPacket(player, spawnPacket);
                } else {
                    if (isSkinChanging) {
                        ((CraftServer) Bukkit.getServer()).getHandle().moveToWorld(entityPlayer, (WorldServer) entityPlayer.world, true, player.getLocation(), false);
                    }
                    player.updateInventory();
                }
            }
        }
    }.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) UUID(java.util.UUID) CraftServer(org.bukkit.craftbukkit.v1_16_R3.CraftServer)

Aggregations

Player (org.bukkit.entity.Player)83 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)36 CraftPlayer (org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)27 CraftPlayer (org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer)26 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)26 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)24 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)23 Behavior (de.Keyle.MyPet.api.skill.skills.Behavior)21 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)18 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)18 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)18 UUID (java.util.UUID)15 CraftPlayer (org.bukkit.craftbukkit.v1_9_R1.entity.CraftPlayer)15 GameProfile (com.mojang.authlib.GameProfile)14 CraftPlayer (org.bukkit.craftbukkit.v1_8_R1.entity.CraftPlayer)14 CraftPlayer (org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer)14 ServerPlayer (net.minecraft.server.level.ServerPlayer)12 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)11 PacketPlayOutTitle (net.minecraft.server.v1_12_R1.PacketPlayOutTitle)10 MyPetFeedEvent (de.Keyle.MyPet.api.event.MyPetFeedEvent)8