Search in sources :

Example 86 with CraftPlayer

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer in project MyPet by xXKeyleXx.

the class CustomInventory method open.

@Override
public void open(Player player) {
    EntityPlayer entityPlayer = ((CraftPlayer) player).getHandle();
    Container container = new CraftContainer(getBukkitInventory(), entityPlayer, entityPlayer.nextContainerCounter());
    container = CraftEventFactory.callInventoryOpenEvent(entityPlayer, container);
    if (container != null) {
        Containers customSize = Containers.GENERIC_9X1;
        switch(this.getSize()) {
            case 18:
                customSize = Containers.GENERIC_9X2;
                break;
            case 27:
                customSize = Containers.GENERIC_9X3;
                break;
            case 36:
                customSize = Containers.GENERIC_9X4;
                break;
            case 45:
                customSize = Containers.GENERIC_9X5;
                break;
            case 54:
                customSize = Containers.GENERIC_9X6;
                break;
        }
        entityPlayer.playerConnection.sendPacket(new PacketPlayOutOpenWindow(container.windowId, customSize, new ChatComponentText(this.getName())));
        entityPlayer.activeContainer = container;
        entityPlayer.activeContainer.addSlotListener(entityPlayer);
    }
}
Also used : CraftContainer(org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer) CraftPlayer(org.bukkit.craftbukkit.v1_16_R1.entity.CraftPlayer) CraftContainer(org.bukkit.craftbukkit.v1_16_R1.inventory.CraftContainer)

Example 87 with CraftPlayer

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer in project MyPet by xXKeyleXx.

the class BehaviorDuelTarget method shouldFinish.

@Override
public boolean shouldFinish() {
    if (!petEntity.canMove()) {
        return true;
    } else if (!petEntity.hasTarget()) {
        return true;
    }
    EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill.getBehavior() != BehaviorMode.Duel) {
        return true;
    } else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return true;
    } else if (target.world != petEntity.world) {
        return true;
    } else if (petEntity.h(target) > 400) {
        return true;
    } else
        return petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600;
}
Also used : EntityLiving(net.minecraft.server.v1_16_R3.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftLivingEntity) CraftPlayer(org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 88 with CraftPlayer

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer in project MyPet by xXKeyleXx.

the class BehaviorFarmTarget method shouldFinish.

@Override
public boolean shouldFinish() {
    if (!petEntity.canMove()) {
        return true;
    }
    if (!this.petEntity.hasTarget()) {
        return true;
    }
    net.minecraft.world.entity.LivingEntity target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
    if (!target.isAlive()) {
        return true;
    }
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill.getBehavior() != BehaviorMode.Farm) {
        return true;
    } else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return true;
    } else if (target.level != petEntity.level) {
        return true;
    } else if (petEntity.distanceToSqr(target) > 400) {
        return true;
    } else
        return petEntity.distanceToSqr(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600;
}
Also used : CraftLivingEntity(org.bukkit.craftbukkit.v1_17_R1.entity.CraftLivingEntity) CraftPlayer(org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Example 89 with CraftPlayer

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer in project MyPet by xXKeyleXx.

the class PlatformHelper method playParticleEffect.

/**
 * @param location   the {@link Location} around which players must be to see the effect
 * @param effectName list of effects: https://gist.github.com/riking/5759002
 * @param offsetX    the amount to be randomly offset by in the X axis
 * @param offsetY    the amount to be randomly offset by in the Y axis
 * @param offsetZ    the amount to be randomly offset by in the Z axis
 * @param speed      the speed of the particles
 * @param count      the number of particles
 * @param radius     the radius around the location
 */
public void playParticleEffect(Location location, String effectName, float offsetX, float offsetY, float offsetZ, float speed, int count, int radius, de.Keyle.MyPet.api.compat.Compat<Object> data) {
    EnumParticle effect;
    try {
        effect = EnumParticle.valueOf(effectName);
    } catch (IllegalArgumentException e) {
        effect = EnumParticle.a(effectName);
    }
    Validate.notNull(location, "Location cannot be null");
    Validate.notNull(effect, "Effect cannot be null");
    Validate.notNull(location.getWorld(), "World cannot be null");
    int[] intData = data != null ? (int[]) data.get() : new int[0];
    PacketPlayOutWorldParticles packet = new PacketPlayOutWorldParticles(effect, false, (float) location.getX(), (float) location.getY(), (float) location.getZ(), offsetX, offsetY, offsetZ, speed, count, intData);
    radius = radius * radius;
    for (Player player : location.getWorld().getPlayers()) {
        if ((int) MyPetApi.getPlatformHelper().distanceSquared(player.getLocation(), location) <= radius) {
            ((CraftPlayer) player).getHandle().playerConnection.sendPacket(packet);
        }
    }
}
Also used : Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) MyPetPlayer(de.Keyle.MyPet.api.player.MyPetPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)

Example 90 with CraftPlayer

use of org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer in project MyPet by xXKeyleXx.

the class BehaviorDuelTarget method shouldFinish.

@Override
public boolean shouldFinish() {
    if (!petEntity.canMove()) {
        return true;
    } else if (!petEntity.hasTarget()) {
        return true;
    }
    EntityLiving target = ((CraftLivingEntity) this.petEntity.getMyPetTarget()).getHandle();
    Behavior behaviorSkill = myPet.getSkills().get(Behavior.class);
    if (behaviorSkill.getBehavior() != BehaviorMode.Duel) {
        return true;
    } else if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return true;
    } else if (target.world != petEntity.world) {
        return true;
    } else if (petEntity.h(target) > 400) {
        return true;
    } else if (petEntity.h(((CraftPlayer) petEntity.getOwner().getPlayer()).getHandle()) > 600) {
        return true;
    }
    return false;
}
Also used : EntityLiving(net.minecraft.server.v1_9_R2.EntityLiving) CraftLivingEntity(org.bukkit.craftbukkit.v1_9_R2.entity.CraftLivingEntity) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) Behavior(de.Keyle.MyPet.api.skill.skills.Behavior)

Aggregations

Player (org.bukkit.entity.Player)250 ServerPlayer (net.minecraft.server.level.ServerPlayer)140 CraftPlayer (org.bukkit.craftbukkit.v1_17_R1.entity.CraftPlayer)113 CraftPlayer (org.bukkit.craftbukkit.v1_18_R1.entity.CraftPlayer)90 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)81 CraftPlayer (org.bukkit.craftbukkit.v1_16_R3.entity.CraftPlayer)81 ItemStack (org.bukkit.inventory.ItemStack)80 Location (org.bukkit.Location)75 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)70 CraftPlayer (org.bukkit.craftbukkit.v1_18_R2.entity.CraftPlayer)66 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)57 CraftPlayer (org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer)52 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)51 GameProfile (com.mojang.authlib.GameProfile)48 EntityPlayer (net.minecraft.server.level.EntityPlayer)47 CraftPlayer (org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer)45 CraftPlayer (org.bukkit.craftbukkit.v1_13_R2.entity.CraftPlayer)45 Property (com.mojang.authlib.properties.Property)44 CraftPlayer (org.bukkit.craftbukkit.v1_14_R1.entity.CraftPlayer)42 CraftPlayer (org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)41