Search in sources :

Example 1 with EntityPlayer

use of net.minecraft.server.EntityPlayer in project Arcade2 by ShootGame.

the class GamePlayer method getAttribute.

@Override
public Attribute getAttribute(AttributeKey key) {
    EntityPlayer mojang = this.getMojang();
    if (this.attributeMap == null) {
        try {
            Field mojangMap = EntityLiving.class.getDeclaredField("attributeMap");
            mojangMap.setAccessible(true);
            this.attributeMap = new TrackingAttributeMap((AttributeMapBase) mojangMap.get(mojang));
        } catch (ReflectiveOperationException ex) {
            this.game.getPlugin().getLogger().log(Level.SEVERE, "Could not inject attribute map", ex);
            return null;
        }
    }
    return this.attributeMap.getAttribute(key);
}
Also used : Field(java.lang.reflect.Field) AttributeMapBase(net.minecraft.server.AttributeMapBase) TrackingAttributeMap(pl.themolka.arcade.attribute.TrackingAttributeMap) EntityPlayer(net.minecraft.server.EntityPlayer)

Example 2 with EntityPlayer

use of net.minecraft.server.EntityPlayer in project Arcade2 by ShootGame.

the class ArcadePlayer method respawn.

/**
 * @deprecated Will not fire {@link pl.themolka.arcade.respawn.PlayerRespawnEvent}
 * and {@link org.bukkit.event.player.PlayerRespawnEvent}!
 */
@Deprecated
public void respawn(Location at) {
    // 'worldId' is not used if 'at' is null
    int worldId = -1;
    if (at != null) {
        worldId = ((CraftWorld) at.getWorld()).getHandle().dimension;
    }
    GamePlayer gamePlayer = this.getGamePlayer();
    if (gamePlayer != null) {
        gamePlayer.resetHealth();
    }
    EntityPlayer mojang = this.getMojang();
    if (mojang != null) {
        mojang.server.getPlayerList().moveToWorld(mojang, worldId, false, at, false);
    }
}
Also used : GamePlayer(pl.themolka.arcade.game.GamePlayer) EntityPlayer(net.minecraft.server.EntityPlayer) CraftWorld(org.bukkit.craftbukkit.CraftWorld)

Aggregations

EntityPlayer (net.minecraft.server.EntityPlayer)2 Field (java.lang.reflect.Field)1 AttributeMapBase (net.minecraft.server.AttributeMapBase)1 CraftWorld (org.bukkit.craftbukkit.CraftWorld)1 TrackingAttributeMap (pl.themolka.arcade.attribute.TrackingAttributeMap)1 GamePlayer (pl.themolka.arcade.game.GamePlayer)1