Search in sources :

Example 11 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project solinia3-core by mixxit.

the class Solinia3CorePlayerListener method onPlayerJoin.

@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
    if (event.getPlayer() != null)
        event.getPlayer().setCollidable(false);
    for (PotionEffect effect : event.getPlayer().getActivePotionEffects()) event.getPlayer().removePotionEffect(effect.getType());
    // disable knockback effects, try to remove mounted arrows
    try {
        if (event.getPlayer().getVehicle() != null) {
            event.getPlayer().eject();
            event.getPlayer().getVehicle().eject();
        }
        EntityHuman entityHuman = ((CraftPlayer) event.getPlayer()).getHandle();
        entityHuman.getAttributeInstance(GenericAttributes.KNOCKBACK_RESISTANCE).setValue(1.0D);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    SoliniaPlayerJoinEvent soliniaevent;
    try {
        ISoliniaPlayer solplayer = SoliniaPlayerAdapter.Adapt(event.getPlayer());
        soliniaevent = new SoliniaPlayerJoinEvent(event, solplayer);
        solplayer.resetPlayerStatus(plugin);
        Bukkit.getPluginManager().callEvent(soliniaevent);
        // Reset users mod version
        StateManager.getInstance().getPlayerManager().resetPlayerVersion(event.getPlayer().getUniqueId());
        // Reset users Zone Packet
        StateManager.getInstance().getPlayerManager().setPlayerLastZone(event.getPlayer(), -1);
        if (solplayer.isForceNewAlt() || (!solplayer.isPlayable() && !event.getPlayer().isOp() && !event.getPlayer().hasPermission("solinia.characterdonochangelocation"))) {
            event.getPlayer().sendMessage("You have been forced to create a new character");
            EntityUtils.teleportSafely(event.getPlayer(), Bukkit.getWorld("world").getSpawnLocation());
            StateManager.getInstance().getPlayerManager().createNewPlayerAlt(plugin, event.getPlayer(), false);
        }
        // patch
        if (solplayer.getClassObj() != null)
            solplayer.setChosenClass(true);
        else
            solplayer.setChosenClass(false);
        // patch
        if (solplayer.getRace() != null)
            solplayer.setChosenRace(true);
        else
            solplayer.setChosenRace(false);
        if (solplayer.getWorld().getPlayerIpNameMappings().get(event.getPlayer().getAddress().getAddress().toString()) == null) {
            solplayer.getWorld().getPlayerIpNameMappings().put(event.getPlayer().getAddress().getAddress().toString(), new ArrayList<String>());
        }
        String players = "";
        try {
            if (!solplayer.getWorld().getPlayerIpNameMappings().get(event.getPlayer().getAddress().getAddress().toString()).contains(event.getPlayer().getUniqueId().toString()))
                solplayer.getWorld().getPlayerIpNameMappings().get(event.getPlayer().getAddress().getAddress().toString()).add(event.getPlayer().getUniqueId().toString());
            ArrayList<String> playerUuids = solplayer.getWorld().getPlayerIpNameMappings().get(event.getPlayer().getAddress().getAddress().toString());
            for (String playerUuid : playerUuids) {
                try {
                    players += Bukkit.getOfflinePlayer(UUID.fromString(playerUuid)).getName() + " ";
                } catch (Exception e) {
                }
            }
            ChatUtils.SendHintToServer(HINT.PLAYER_JOIN, event.getPlayer().getName() + " (" + solplayer.getFullName() + ") has joined the game aka: " + players);
        } catch (Exception e) {
        // not vital if this fails
        }
        try {
            LivingEntity pet = StateManager.getInstance().getEntityManager().getPet(event.getPlayer().getUniqueId());
            if (pet != null) {
                ISoliniaLivingEntity petsolEntity = SoliniaLivingEntityAdapter.Adapt(pet);
                StateManager.getInstance().getEntityManager().removePet(event.getPlayer().getUniqueId(), !petsolEntity.isCharmed());
            }
        } catch (CoreStateInitException e) {
        }
        solplayer.sendSlotsAsPacket();
        solplayer.sendMemorisedSpellSlots();
    } catch (CoreStateInitException e) {
        event.getPlayer().kickPlayer("Server initialising");
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) EntityHuman(net.minecraft.server.v1_15_R1.EntityHuman) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) PotionEffect(org.bukkit.potion.PotionEffect) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) SoliniaPlayerJoinEvent(com.solinia.solinia.Events.SoliniaPlayerJoinEvent) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) EventHandler(org.bukkit.event.EventHandler)

Example 12 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project solinia3-core by mixxit.

the class Solinia3CorePlayerListener method onPlayerQuit.

@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
    try {
        LivingEntity pet = StateManager.getInstance().getEntityManager().getPet(event.getPlayer().getUniqueId());
        if (pet != null) {
            ISoliniaLivingEntity petsolEntity = SoliniaLivingEntityAdapter.Adapt(pet);
            StateManager.getInstance().getEntityManager().removePet(event.getPlayer().getUniqueId(), !petsolEntity.isCharmed());
        }
        ISoliniaPlayer solPlayer = SoliniaPlayerAdapter.Adapt(event.getPlayer());
        if (solPlayer != null) {
            solPlayer.resetPlayerStatus(plugin);
        }
        if (event.getPlayer() != null) {
            if (solPlayer != null && solPlayer.isMentoring())
                solPlayer.setMentor(null);
        }
    } catch (CoreStateInitException e) {
    }
    // enable knockback effects
    try {
        Player player = event.getPlayer();
        EntityHuman entityHuman = ((CraftPlayer) player).getHandle();
        entityHuman.getAttributeInstance(GenericAttributes.KNOCKBACK_RESISTANCE).setValue(0.0D);
    } catch (Exception ex) {
        ex.printStackTrace();
    }
    ISoliniaGroup group = StateManager.getInstance().getGroupByMember(event.getPlayer().getUniqueId());
    if (group != null) {
        StateManager.getInstance().removePlayerFromGroup(event.getPlayer());
    }
}
Also used : ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) LivingEntity(org.bukkit.entity.LivingEntity) EntityHuman(net.minecraft.server.v1_15_R1.EntityHuman) Player(org.bukkit.entity.Player) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) ISoliniaLivingEntity(com.solinia.solinia.Interfaces.ISoliniaLivingEntity) ISoliniaGroup(com.solinia.solinia.Interfaces.ISoliniaGroup) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) CraftPlayer(org.bukkit.craftbukkit.v1_15_R1.entity.CraftPlayer) ISoliniaPlayer(com.solinia.solinia.Interfaces.ISoliniaPlayer) SoliniaItemException(com.solinia.solinia.Exceptions.SoliniaItemException) CoreStateInitException(com.solinia.solinia.Exceptions.CoreStateInitException) EventHandler(org.bukkit.event.EventHandler)

Example 13 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project Village_Defense by Plajer.

the class RidableIronGolem method g.

@Override
public void g(float f, float f1) {
    EntityLiving entityliving = (EntityLiving) bw();
    if (entityliving == null) {
        // search first human passenger
        for (final Entity e : passengers) {
            if (e instanceof EntityHuman) {
                entityliving = (EntityLiving) e;
                break;
            }
        }
        if (entityliving == null) {
            this.l((float) 0.12);
            super.g(f, f1);
            return;
        }
    }
    this.lastYaw = this.yaw = entityliving.yaw;
    this.pitch = entityliving.pitch * 0.5F;
    this.setYawPitch(this.yaw, this.pitch);
    this.aQ = this.aO = this.yaw;
    f = entityliving.be * 0.75F;
    f1 = entityliving.bf;
    if (f1 <= 0.0f) {
        f1 *= 0.25F;
    }
    this.l((float) 0.12);
    super.g(f, f1);
    P = (float) 1.0;
}
Also used : Entity(net.minecraft.server.v1_11_R1.Entity) EntityHuman(net.minecraft.server.v1_11_R1.EntityHuman) EntityLiving(net.minecraft.server.v1_11_R1.EntityLiving)

Example 14 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project Village_Defense by Plajer.

the class RidableIronGolem method a.

public void a(float f, float f1, float f2) {
    EntityLiving entityliving = null;
    for (final Entity e : passengers) {
        if (e instanceof EntityHuman) {
            entityliving = (EntityLiving) e;
            break;
        }
    }
    if (entityliving == null) {
        this.P = 0.5F;
        this.aR = 0.02F;
        this.k((float) 0.12);
        super.a(f, f1, f2);
        return;
    }
    this.lastYaw = this.yaw = entityliving.yaw;
    this.pitch = entityliving.pitch * 0.5F;
    this.setYawPitch(this.yaw, this.pitch);
    this.aO = this.aM = this.yaw;
    f = entityliving.be * 0.5F * 0.75F;
    f2 = entityliving.bg;
    if (f2 <= 0.0f) {
        f2 *= 0.25F;
    }
    k(0.12f);
    super.a(f, f1, f2);
    P = (float) 1.0;
}
Also used : Entity(net.minecraft.server.v1_12_R1.Entity) EntityHuman(net.minecraft.server.v1_12_R1.EntityHuman) EntityLiving(net.minecraft.server.v1_12_R1.EntityLiving)

Example 15 with EntityHuman

use of net.minecraft.server.v1_16_R3.EntityHuman in project WildChests by BG-Software-LLC.

the class NMSAdapter_v1_16_R3 method dropItemAsPlayer.

@Override
public void dropItemAsPlayer(HumanEntity humanEntity, org.bukkit.inventory.ItemStack bukkitItem) {
    EntityHuman entityHuman = ((CraftHumanEntity) humanEntity).getHandle();
    ItemStack itemStack = CraftItemStack.asNMSCopy(bukkitItem);
    entityHuman.drop(itemStack, false);
}
Also used : EntityHuman(net.minecraft.server.v1_16_R3.EntityHuman) CraftHumanEntity(org.bukkit.craftbukkit.v1_16_R3.entity.CraftHumanEntity) CraftItemStack(org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack) ItemStack(net.minecraft.server.v1_16_R3.ItemStack)

Aggregations

net.minecraft.server.v1_16_R3 (net.minecraft.server.v1_16_R3)20 CraftItemStack (org.bukkit.craftbukkit.v1_16_R3.inventory.CraftItemStack)19 MyPetApi (de.Keyle.MyPet.MyPetApi)18 EntitySize (de.Keyle.MyPet.api.entity.EntitySize)18 MyPet (de.Keyle.MyPet.api.entity.MyPet)18 EntityMyPet (de.Keyle.MyPet.compat.v1_16_R3.entity.EntityMyPet)18 InvocationTargetException (java.lang.reflect.InvocationTargetException)18 Pair (com.mojang.datafixers.util.Pair)17 Util (de.Keyle.MyPet.api.Util)17 EquipmentSlot (de.Keyle.MyPet.api.entity.EquipmentSlot)17 Arrays (java.util.Arrays)17 Bukkit (org.bukkit.Bukkit)17 ENTITY_LIVING_broadcastItemBreak (de.Keyle.MyPet.compat.v1_16_R3.CompatManager.ENTITY_LIVING_broadcastItemBreak)15 LivingEntity (org.bukkit.entity.LivingEntity)15 Configuration (de.Keyle.MyPet.api.Configuration)10 EntityHuman (net.minecraft.server.v1_11_R1.EntityHuman)7 PetState (de.Keyle.MyPet.api.entity.MyPet.PetState)6 EntityHuman (net.minecraft.server.v1_12_R1.EntityHuman)6 EntityHuman (net.minecraft.server.v1_8_R3.EntityHuman)6 NPCHolder (net.citizensnpcs.npc.ai.NPCHolder)5