Search in sources :

Example 1 with EntityPlayer

use of net.minecraft.server.v1_4_R1.EntityPlayer in project TotalFreedomMod by TotalFreedom.

the class ServerInterface method purgeWhitelist.

public int purgeWhitelist() {
    String[] whitelisted = getServer().getPlayerList().getWhitelisted();
    int size = whitelisted.length;
    for (EntityPlayer player : getServer().getPlayerList().players) {
        getServer().getPlayerList().getWhitelist().remove(player.getProfile());
    }
    try {
        getServer().getPlayerList().getWhitelist().save();
    } catch (Exception ex) {
        FLog.warning("Could not purge the whitelist!");
        FLog.warning(ex);
    }
    return size;
}
Also used : EntityPlayer(net.minecraft.server.v1_12_R1.EntityPlayer)

Example 2 with EntityPlayer

use of net.minecraft.server.v1_4_R1.EntityPlayer in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditor_v1_9_R2 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)) {
            PacketHelper_v1_9_R2.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()) {
                PacketHelper_v1_9_R2.sendPacket(player, playerInfo);
                if (!player.getUniqueId().equals(uuid)) {
                    PacketHelper_v1_9_R2.sendPacket(player, spawnPacket);
                } else {
                    if (isSkinChanging) {
                        boolean isFlying = player.isFlying();
                        PacketHelper_v1_9_R2.sendPacket(player, new PacketPlayOutRespawn(player.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), entityPlayer.playerInteractManager.getGameMode()));
                        player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
                        player.setFlying(isFlying);
                    }
                    player.updateInventory();
                }
            }
        }
    }.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) PacketPlayOutNamedEntitySpawn(net.minecraft.server.v1_9_R2.PacketPlayOutNamedEntitySpawn) PacketPlayOutEntityDestroy(net.minecraft.server.v1_9_R2.PacketPlayOutEntityDestroy) EntityPlayer(net.minecraft.server.v1_9_R2.EntityPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_9_R2.PacketPlayOutPlayerInfo) PacketPlayOutRespawn(net.minecraft.server.v1_9_R2.PacketPlayOutRespawn) UUID(java.util.UUID)

Example 3 with EntityPlayer

use of net.minecraft.server.v1_4_R1.EntityPlayer in project Denizen-For-Bukkit by DenizenScript.

the class ProfileEditor_v1_11_R1 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)) {
            PacketHelper_v1_11_R1.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()) {
                PacketHelper_v1_11_R1.sendPacket(player, playerInfo);
                if (!player.getUniqueId().equals(uuid)) {
                    PacketHelper_v1_11_R1.sendPacket(player, spawnPacket);
                } else {
                    if (isSkinChanging) {
                        boolean isFlying = player.isFlying();
                        PacketHelper_v1_11_R1.sendPacket(player, new PacketPlayOutRespawn(player.getWorld().getEnvironment().getId(), entityPlayer.getWorld().getDifficulty(), entityPlayer.getWorld().worldData.getType(), entityPlayer.playerInteractManager.getGameMode()));
                        player.teleport(player.getLocation(), PlayerTeleportEvent.TeleportCause.PLUGIN);
                        player.setFlying(isFlying);
                    }
                    player.updateInventory();
                }
            }
        }
    }.runTaskLater(NMSHandler.getJavaPlugin(), 5);
}
Also used : Player(org.bukkit.entity.Player) EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer) PacketPlayOutNamedEntitySpawn(net.minecraft.server.v1_11_R1.PacketPlayOutNamedEntitySpawn) PacketPlayOutEntityDestroy(net.minecraft.server.v1_11_R1.PacketPlayOutEntityDestroy) EntityPlayer(net.minecraft.server.v1_11_R1.EntityPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) CraftPlayer(org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer) PacketPlayOutPlayerInfo(net.minecraft.server.v1_11_R1.PacketPlayOutPlayerInfo) PacketPlayOutRespawn(net.minecraft.server.v1_11_R1.PacketPlayOutRespawn) UUID(java.util.UUID)

Example 4 with EntityPlayer

use of net.minecraft.server.v1_4_R1.EntityPlayer in project MyPet by xXKeyleXx.

the class ControlTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (controlPathfinderGoal == null) {
        if (petEntity.getPathfinder().hasGoal("Control")) {
            controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
        }
    }
    if (controlPathfinderGoal == null) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
        Behavior behaviorSkill = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.boundingBox.grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            if (entityLiving != petEntity) {
                if (entityLiving instanceof EntityPlayer) {
                    Player targetPlayer = (Player) entityLiving.getBukkitEntity();
                    if (myPet.getOwner().equals(targetPlayer)) {
                        continue;
                    } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
                        continue;
                    }
                } else if (entityLiving instanceof EntityTameableAnimal) {
                    EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
                    if (tameable.isTamed() && tameable.getOwner() != null) {
                        Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
                        if (myPet.getOwner().equals(tameableOwner)) {
                            continue;
                        } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
                            continue;
                        }
                    }
                } else if (entityLiving instanceof EntityMyPet) {
                    MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
                    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
                        continue;
                    }
                }
                if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
                    continue;
                }
                if (behaviorSkill != null) {
                    if (behaviorSkill.getBehavior() == BehaviorState.Raid) {
                        if (entityLiving instanceof EntityTameableAnimal) {
                            continue;
                        } else if (entityLiving instanceof EntityMyPet) {
                            continue;
                        } else if (entityLiving instanceof EntityPlayer) {
                            continue;
                        }
                    }
                }
                controlPathfinderGoal.stopControl();
                this.target = entityLiving;
                return true;
            }
        }
    }
    return false;
}
Also used : EntityPlayer(net.minecraft.server.v1_7_R4.EntityPlayer) CraftPlayer(org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer) Player(org.bukkit.entity.Player) EntityMyPet(de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_7_R4.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_7_R4.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_7_R4.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_7_R4.EntityTameableAnimal) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Example 5 with EntityPlayer

use of net.minecraft.server.v1_4_R1.EntityPlayer in project MyPet by xXKeyleXx.

the class ControlTarget method shouldStart.

@Override
public boolean shouldStart() {
    if (controlPathfinderGoal == null) {
        if (petEntity.getPathfinder().hasGoal("Control")) {
            controlPathfinderGoal = (Control) petEntity.getPathfinder().getGoal("Control");
        }
    }
    if (controlPathfinderGoal == null) {
        return false;
    }
    if (myPet.getDamage() <= 0 && myPet.getRangedDamage() <= 0) {
        return false;
    }
    if (controlPathfinderGoal.moveTo != null && petEntity.canMove()) {
        Behavior behaviorSkill = null;
        if (myPet.getSkills().isSkillActive(Behavior.class)) {
            behaviorSkill = myPet.getSkills().getSkill(Behavior.class).get();
            if (behaviorSkill.getBehavior() == Behavior.BehaviorState.Friendly) {
                return false;
            }
        }
        for (Object entityObj : this.petEntity.world.a(EntityLiving.class, this.petEntity.getBoundingBox().grow((double) this.range, 4.0D, (double) this.range))) {
            EntityLiving entityLiving = (EntityLiving) entityObj;
            if (entityLiving != petEntity && !(entityLiving instanceof EntityArmorStand)) {
                if (entityLiving instanceof EntityPlayer) {
                    Player targetPlayer = (Player) entityLiving.getBukkitEntity();
                    if (myPet.getOwner().equals(targetPlayer)) {
                        continue;
                    } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetPlayer, true)) {
                        continue;
                    }
                } else if (entityLiving instanceof EntityTameableAnimal) {
                    EntityTameableAnimal tameable = (EntityTameableAnimal) entityLiving;
                    if (tameable.isTamed() && tameable.getOwner() != null) {
                        Player tameableOwner = (Player) tameable.getOwner().getBukkitEntity();
                        if (myPet.getOwner().equals(tameableOwner)) {
                            continue;
                        } else if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), tameableOwner, true)) {
                            continue;
                        }
                    }
                } else if (entityLiving instanceof EntityMyPet) {
                    MyPet targetMyPet = ((EntityMyPet) entityLiving).getMyPet();
                    if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), targetMyPet.getOwner().getPlayer(), true)) {
                        continue;
                    }
                }
                if (!MyPetApi.getHookHelper().canHurt(myPet.getOwner().getPlayer(), entityLiving.getBukkitEntity())) {
                    continue;
                }
                if (behaviorSkill != null) {
                    if (behaviorSkill.getBehavior() == BehaviorState.Raid) {
                        if (entityLiving instanceof EntityTameableAnimal) {
                            continue;
                        } else if (entityLiving instanceof EntityMyPet) {
                            continue;
                        } else if (entityLiving instanceof EntityPlayer) {
                            continue;
                        }
                    }
                }
                controlPathfinderGoal.stopControl();
                this.target = entityLiving;
                return true;
            }
        }
    }
    return false;
}
Also used : EntityPlayer(net.minecraft.server.v1_8_R2.EntityPlayer) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_8_R2.entity.CraftPlayer) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet) EntityLiving(net.minecraft.server.v1_8_R2.EntityLiving) MyPet(de.Keyle.MyPet.api.entity.MyPet) EntityMyPet(de.Keyle.MyPet.compat.v1_8_R2.entity.EntityMyPet) EntityPlayer(net.minecraft.server.v1_8_R2.EntityPlayer) EntityTameableAnimal(net.minecraft.server.v1_8_R2.EntityTameableAnimal) EntityArmorStand(net.minecraft.server.v1_8_R2.EntityArmorStand) Behavior(de.Keyle.MyPet.skill.skills.Behavior)

Aggregations

Player (org.bukkit.entity.Player)17 EntityPlayer (net.minecraft.server.v1_8_R3.EntityPlayer)14 EntityPlayer (net.minecraft.server.v1_10_R1.EntityPlayer)12 EntityPlayer (net.minecraft.server.v1_11_R1.EntityPlayer)12 EntityPlayer (net.minecraft.server.v1_12_R1.EntityPlayer)12 MyPet (de.Keyle.MyPet.api.entity.MyPet)9 Behavior (de.Keyle.MyPet.skill.skills.Behavior)9 NPC (net.citizensnpcs.api.npc.NPC)8 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)8 SkinnableEntity (net.citizensnpcs.npc.skin.SkinnableEntity)8 CraftPlayer (org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer)8 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)8 CraftPlayer (org.bukkit.craftbukkit.v1_10_R1.entity.CraftPlayer)6 CraftPlayer (org.bukkit.craftbukkit.v1_11_R1.entity.CraftPlayer)6 CraftPlayer (org.bukkit.craftbukkit.v1_12_R1.entity.CraftPlayer)5 UUID (java.util.UUID)4 PacketPlayOutPlayerInfo (net.minecraft.server.v1_10_R1.PacketPlayOutPlayerInfo)4 EntityPlayer (net.minecraft.server.v1_9_R2.EntityPlayer)4 CraftPlayer (org.bukkit.craftbukkit.v1_9_R2.entity.CraftPlayer)4 ArmorStandTrait (net.citizensnpcs.trait.ArmorStandTrait)3