Java 类org.bukkit.event.player.PlayerAnimationEvent 实例源码

项目:Crescent    文件:NoSwingA.java   
@Override
public void call(Event event) {
    if (event instanceof PlayerInteractEvent) {
        final PlayerInteractEvent pie = (PlayerInteractEvent) event;

        // Types of interacting where the arm must swing.
        if (pie.getAction() == Action.LEFT_CLICK_AIR || pie.getAction() == Action.LEFT_CLICK_BLOCK) {
            lastInteract = System.currentTimeMillis();
        }
    } else if (event instanceof PlayerAnimationEvent) {
        final PlayerAnimationEvent pae = (PlayerAnimationEvent) event;

        if (pae.getAnimationType() == PlayerAnimationType.ARM_SWING) {
            final long difference = System.currentTimeMillis() - lastInteract;

            Bukkit.broadcastMessage("swing difference: " + difference);
        }
    }
}
项目:ProjectAres    文件:PlayerStaminaState.java   
void onEvent(PlayerAnimationEvent event) {
    if(event.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
    if(event.getPlayer().isDigging()) return;
    if(!isHoldingWeapon()) return;

    swinging = true;
    lastSwingTick = player.getMatch().getClock().now().tick;
}
项目:ProjectAres    文件:PlayerMovementListener.java   
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void detectBlockPunch(PlayerAnimationEvent event) {
    if(event.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
    if(event.getPlayer().getGameMode() != GameMode.ADVENTURE) return;

    // Client will not punch blocks in adventure mode, so we detect it ourselves and fire a BlockPunchEvent.
    // We do this in the kit module only because its the one that is responsible for putting players in adventure mode.
    // A few other modules rely on this, including StaminaModule and BlockDropsModule.
    RayBlockIntersection hit = event.getPlayer().getTargetedBlock(true, false);
    if(hit == null) return;

    eventBus.callEvent(new BlockPunchEvent(event.getPlayer(), hit));
}
项目:Vanguard    文件:VanguardListener.java   
@EventHandler(ignoreCancelled = true, priority = EventPriority.HIGHEST)
    public void move(PlayerAnimationEvent ev) {
        if (Vanguard.isLocked(ev.getPlayer().getUniqueId())) {
//            ev.getPlayer().sendMessage(Configuration.getStringContainer()
//                    .getString("googletokenlogin")
//                    .replace("$timeout$", Long.toString(Configuration.getTimeoutSeconds()))
//                    .split("\n"));
            ev.setCancelled(true);
        }
    }
项目:CraftBukkit    文件:PlayerConnection.java   
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
    if (this.player.dead) return; // CraftBukkit
    this.player.v();
    if (packetplayinarmanimation.d() == 1) {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
        float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
        double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
        double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
        double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
        Vec3D vec3d = Vec3D.a(d0, d1, d2);

        float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 5.0D;
        Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
        MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);

        if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) {
            CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
        }

        // Arm swing animation
        PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
        this.server.getPluginManager().callEvent(event);

        if (event.isCancelled()) return;
        // CraftBukkit end

        this.player.ba();
    }
}
项目:Almura-Server    文件:PlayerConnection.java   
public void a(Packet18ArmAnimation packet18armanimation) {
    if (this.player.dead) return; // CraftBukkit

    this.player.u();
    if (packet18armanimation.b == 1) {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
        float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
        double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
        double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
        double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
        Vec3D vec3d = this.player.world.getVec3DPool().create(d0, d1, d2);

        float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 5.0D;
        Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
        MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, true);

        if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.TILE) {
            CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
        }

        // Arm swing animation
        PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
        this.server.getPluginManager().callEvent(event);

        if (event.isCancelled()) return;
        // CraftBukkit end

        this.player.aV();
    }
}
项目:Tweakkit-Server    文件:PlayerConnection.java   
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
    if (this.player.dead) return; // CraftBukkit
    this.player.v();
    if (packetplayinarmanimation.d() == 1) {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
        float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
        double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
        double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
        double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
        Vec3D vec3d = Vec3D.a(d0, d1, d2);

        float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = player.playerInteractManager.getGameMode() == EnumGamemode.CREATIVE ? 5.0D : 4.5D; // Spigot
        Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
        MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);

        if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.BLOCK) {
            CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
        }

        // Arm swing animation
        PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
        this.server.getPluginManager().callEvent(event);

        if (event.isCancelled()) return;
        // CraftBukkit end

        this.player.ba();
    }
}
项目:SpigotSource    文件:PlayerConnection.java   
public void a(PacketPlayInArmAnimation packetplayinarmanimation) {
    PlayerConnectionUtils.ensureMainThread(packetplayinarmanimation, this, this.player.x());
    if (this.player.dead) return; // CraftBukkit
    this.player.resetIdleTimer();
    // CraftBukkit start - Raytrace to look for 'rogue armswings'
    float f1 = this.player.pitch;
    float f2 = this.player.yaw;
    double d0 = this.player.locX;
    double d1 = this.player.locY + (double) this.player.getHeadHeight();
    double d2 = this.player.locZ;
    Vec3D vec3d = new Vec3D(d0, d1, d2);

    float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
    float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
    float f5 = -MathHelper.cos(-f1 * 0.017453292F);
    float f6 = MathHelper.sin(-f1 * 0.017453292F);
    float f7 = f4 * f5;
    float f8 = f3 * f5;
    double d3 = player.playerInteractManager.getGameMode() == WorldSettings.EnumGamemode.CREATIVE ? 5.0D : 4.5D;
    Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
    MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, false);

    if (movingobjectposition == null || movingobjectposition.type != MovingObjectPosition.EnumMovingObjectType.BLOCK) {
        CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand(), EnumHand.MAIN_HAND);
    }

    // Arm swing animation
    PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
    this.server.getPluginManager().callEvent(event);

    if (event.isCancelled()) return;
    // CraftBukkit end
    this.player.a(packetplayinarmanimation.a());
}
项目:Craft-city    文件:PlayerConnection.java   
public void a(Packet18ArmAnimation packet18armanimation) {
    if (this.player.dead) return; // CraftBukkit

    if (packet18armanimation.b == 1) {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.player.lastPitch + (this.player.pitch - this.player.lastPitch) * f;
        float f2 = this.player.lastYaw + (this.player.yaw - this.player.lastYaw) * f;
        double d0 = this.player.lastX + (this.player.locX - this.player.lastX) * (double) f;
        double d1 = this.player.lastY + (this.player.locY - this.player.lastY) * (double) f + 1.62D - (double) this.player.height;
        double d2 = this.player.lastZ + (this.player.locZ - this.player.lastZ) * (double) f;
        Vec3D vec3d = this.player.world.getVec3DPool().create(d0, d1, d2);

        float f3 = MathHelper.cos(-f2 * 0.017453292F - 3.1415927F);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - 3.1415927F);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 5.0D;
        Vec3D vec3d1 = vec3d.add((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
        MovingObjectPosition movingobjectposition = this.player.world.rayTrace(vec3d, vec3d1, true);

        if (movingobjectposition == null || movingobjectposition.type != EnumMovingObjectType.TILE) {
            CraftEventFactory.callPlayerInteractEvent(this.player, Action.LEFT_CLICK_AIR, this.player.inventory.getItemInHand());
        }

        // Arm swing animation
        PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayer());
        this.server.getPluginManager().callEvent(event);

        if (event.isCancelled()) return;
        // CraftBukkit end

        this.player.bK();
    }
}
项目:RoyalSurvivors    文件:ThirstListener.java   
@EventHandler
public void thirstSwing(PlayerAnimationEvent e) {
    if (e.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
    Player p = e.getPlayer();
    if (!RUtils.isInInfectedWorld(p)) return;
    final ItemStack hand = p.getItemInHand();
    if (hand == null || hand.getType() == Material.AIR) changeThirst(p, -Config.thirstSwing);
    else changeThirst(p, -Config.thirstSwingItem);
}
项目:Crescent    文件:DetectionListener.java   
@EventHandler
public void onPlayerAnimation(PlayerAnimationEvent event) {
    final Player player = event.getPlayer();

    getCheckVersion(player, CheckType.AUTOCLICKER, "A").call(event);
}
项目:ZentrelaRPG    文件:CombatManager.java   
@EventHandler
public void onAnim(PlayerAnimationEvent event) {
    if (event.getAnimationType() == PlayerAnimationType.ARM_SWING) {
        check(event.getPlayer().getInventory().getItemInMainHand(), event.getPlayer());
    }
}
项目:ProjectAres    文件:StaminaMatchModule.java   
@EventHandler(ignoreCancelled = true)
public void onPlayerSwing(PlayerAnimationEvent event) {
    PlayerStaminaState state = states.get(event.getPlayer());
    if(state != null) state.onEvent(event);
}
项目:ProjectAres    文件:DamageDisplayPlayerFacet.java   
@TargetedEventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onSwing(PlayerAnimationEvent event) {
    if(event.getAnimationType() != PlayerAnimationType.ARM_SWING) return;
    if(event.getPlayer().isDigging()) return;
    updateSpeedometer();
}
项目:MiniWynn    文件:SpellListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void on(PlayerAnimationEvent animationEvent){
    Player player = animationEvent.getPlayer();
    on(player, Spell.MouseClick.LEFT);
}
项目:Cauldron    文件:NetHandlerPlayServer.java   
public void processAnimation(C0APacketAnimation p_147350_1_)
{
    if (this.playerEntity.isDead)
    {
        return;    // CraftBukkit
    }

    this.playerEntity.func_143004_u();

    if (p_147350_1_.func_149421_d() == 1)
    {
        // CraftBukkit start - Raytrace to look for 'rogue armswings'
        float f = 1.0F;
        float f1 = this.playerEntity.prevRotationPitch + (this.playerEntity.rotationPitch - this.playerEntity.prevRotationPitch) * f;
        float f2 = this.playerEntity.prevRotationYaw + (this.playerEntity.rotationYaw - this.playerEntity.prevRotationYaw) * f;
        double d0 = this.playerEntity.prevPosX + (this.playerEntity.posX - this.playerEntity.prevPosX) * (double) f;
        double d1 = this.playerEntity.prevPosY + (this.playerEntity.posY - this.playerEntity.prevPosY) * (double) f + 1.62D - (double) this.playerEntity.yOffset;
        double d2 = this.playerEntity.prevPosZ + (this.playerEntity.posZ - this.playerEntity.prevPosZ) * (double) f;
        Vec3 vec3 = Vec3.createVectorHelper(d0, d1, d2);
        float f3 = MathHelper.cos(-f2 * 0.017453292F - (float)Math.PI);
        float f4 = MathHelper.sin(-f2 * 0.017453292F - (float)Math.PI);
        float f5 = -MathHelper.cos(-f1 * 0.017453292F);
        float f6 = MathHelper.sin(-f1 * 0.017453292F);
        float f7 = f4 * f5;
        float f8 = f3 * f5;
        double d3 = 5.0D;
        Vec3 vec31 = vec3.addVector((double) f7 * d3, (double) f6 * d3, (double) f8 * d3);
        MovingObjectPosition movingobjectposition = this.playerEntity.worldObj.rayTraceBlocks(vec3, vec31, true);
        boolean valid = false;

        if (movingobjectposition == null || movingobjectposition.typeOfHit != MovingObjectPosition.MovingObjectType.BLOCK)
        {
            valid = true;
        }
        else
        {
            Block block = this.playerEntity.worldObj.getBlock(movingobjectposition.blockX, movingobjectposition.blockY, movingobjectposition.blockZ);

            if (!block.isOpaqueCube())   // Should be isBreakable?
            {
                valid = true;
            }
        }

        if (valid)
        {
            CraftEventFactory.callPlayerInteractEvent(this.playerEntity, Action.LEFT_CLICK_AIR, this.playerEntity.inventory.getCurrentItem());
        }

        // Arm swing animation
        PlayerAnimationEvent event = new PlayerAnimationEvent(this.getPlayerB());
        this.server.getPluginManager().callEvent(event);

        if (event.isCancelled())
        {
            return;
        }

        // CraftBukkit end
        this.playerEntity.swingItem();
    }
}
项目:ProjectAres    文件:StaminaSymptom.java   
public void onSwing(PlayerAnimationEvent event) {}