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

项目:AddGun    文件:PlayerListener.java   
/**
 * Keeps track of player sprint; if they are sprinting we track when they sprinted, or, clear if no longer sprinting.
 * 
 * @param event
 *            the sprint toggle event
 */
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void toggleSprintEvent(PlayerToggleSprintEvent event) {
    if (event.isSprinting()) {
        sprintingSince.computeIfAbsent(event.getPlayer().getUniqueId(), u -> {
            //if (event.getPlayer().hasPermission("addgun.data")) { event.getPlayer().sendMessage(ChatColor.GOLD + " sprint started"); }
            return System.currentTimeMillis();
        });
        sprintingEnd.remove(event.getPlayer().getUniqueId());
    } else {
        /*if (sprintingSince.containsKey(event.getPlayer().getUniqueId()) && event.getPlayer().hasPermission("addgun.data")) { 
            event.getPlayer().sendMessage(ChatColor.GOLD + " sprint cleared");
        }*/
        sprintingSince.remove(event.getPlayer().getUniqueId());
        sprintingEnd.computeIfAbsent(event.getPlayer().getUniqueId(), u -> {
            return System.currentTimeMillis();
        });
    }
}
项目:FlexMC    文件:EntityActionListener.java   
@Override
public void handle( ConnectionHandler connectionHandler, MessageC15EntityAction message ) {
    FlexPlayer player = connectionHandler.getPlayer();
    switch ( message.getActionId() ) {
        case 0:
            player.setSneaking( true );
            EventFactory.call( new PlayerToggleSneakEvent( player, true ) );
            break;
        case 1:
            player.setSneaking( false );
            EventFactory.call( new PlayerToggleSneakEvent( player, false ) );
            break;
        case 2:
            player.setSprinting( true );
            EventFactory.call( new PlayerToggleSprintEvent( player, true ) );
            break;
        case 3:
            player.setSprinting( false );
            EventFactory.call( new PlayerToggleSprintEvent( player, false ) );
            break;

        // todo handle other cases
    }
}
项目:COD-Warfare    文件:feedTask.java   
public static void startFeedTask(PlayerToggleSprintEvent e) {
    if (Main.WaitingPlayers.contains(e.getPlayer()) || Main.PlayingPlayers.contains(e.getPlayer())) {
        final Player p = e.getPlayer();
        if (Main.noHungerLoss.contains(p)) return;

        if (e.isSprinting()) {
            if (fillTask.get(p) != null) {
                fillTask.get(p).cancel();
                fillTask.put(p, null);
            }

            emptyFoodBar(p);
        }

        if (!(e.isSprinting())) {
            if (emptyTask.get(p) != null) {
                emptyTask.get(p).cancel();
                emptyTask.put(p, null);
            }

            fillFoodBar(p);
        }
    }
}
项目:SwornRPG    文件:PlayerListener.java   
@EventHandler(priority = EventPriority.MONITOR)
public void onPlayerToggleSprint(PlayerToggleSprintEvent event)
{
    if (! speedBoostEnabled || event.isCancelled())
        return;

    Player player = event.getPlayer();
    if (plugin.isDisabledWorld(player))
        return;

    if (! player.isSprinting() || player.getGameMode() != GameMode.SURVIVAL)
        return;

    if (plugin.isSwornNationsEnabled() && plugin.getSwornNationsHandler().isApplicable(player, false))
        return;

    if (Util.random(speedBoostOdds) == 0)
    {
        player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, speedBoostDuration, speedBoostStrength));
        player.sendMessage(plugin.getPrefix() + FormatUtil.format(plugin.getMessage("speed_boost")));
    }
}
项目:RealSurvival    文件:PhysicalStrengthEvent.java   
@EventHandler
public void sprint(PlayerToggleSprintEvent e){
    if(rs.getPlayerData(e.getPlayer())==null)return;
    if(rs.getPlayerData(e.getPlayer()).getPhysical_strength()>=rs.getSprinting()||
            rs.getPlayerData(e.getPlayer()).getWeight()<=rs.getWeight())return;
        e.setCancelled(true);
        e.getPlayer().setSprinting(false);
}
项目:DynamicAC    文件:BackendChecks.java   
public void checkSprintHungry(PlayerToggleSprintEvent e) {
    Player player = e.getPlayer();
    if(e.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= 6) {
        for(Player pla : DynamicAC.instance.onlinestaff) {
            pla.sendMessage(DynamicAC.prefix + player.getName() + " sprinted while under 3 food thingies!");
        }
        DACManager.getUserManager().incrementUser(DACManager.getUserManager().getUser(player.getName()), "Sprinted while hungry");
    }
}
项目:AntiCheat-COMPAT    文件:Backend.java   
public CheckResult checkSprintHungry(PlayerToggleSprintEvent event) {
    Player player = event.getPlayer();
    if (event.isSprinting() && player.getGameMode() != GameMode.CREATIVE && player.getFoodLevel() <= magic.SPRINT_FOOD_MIN()) {
        return new CheckResult(CheckResult.Result.FAILED, player.getName() + " sprinted while hungry (food=" + player.getFoodLevel() + ", min=" + magic.SPRINT_FOOD_MIN() + ")");
    } else {
        return PASS;
    }
}
项目:SugCubeCommandPack    文件:PlayerListener.java   
@EventHandler
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
    Player player = (Player) event.getPlayer();
    if (sccp.swActionSprint.contains(player)) {
        sccp.swPlayers.remove(player);
        sccp.swActionSprint.remove(player);
       }
}
项目:Slimefun4-Chinese-Version    文件:TalismanListener.java   
@EventHandler
public void onSprint(PlayerToggleSprintEvent e) {
    if (e.isSprinting()) Talisman.checkFor(e, SlimefunItem.getByID("TRAVELLER_TALISMAN"));
}
项目:Minecraft-UAPI    文件:SkillListener.java   
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerToggleSprintEvent(PlayerToggleSprintEvent event) {
    User user = API.to(event.getPlayer());
    if (user == null) return;
    if (this.call(new SkillEventSprint(user, event.isSprinting())).isCancelled()) event.setCancelled(true);
}
项目:COD-Warfare    文件:Listeners.java   
@EventHandler
public void onPlayerSprint(PlayerToggleSprintEvent e) {
    if (PerkAPI.getPerk(e.getPlayer()) == Perk.MARATHON) return;
    feedTask.startFeedTask(e);
}
项目:Slimefun4    文件:TalismanListener.java   
@EventHandler
public void onSprint(PlayerToggleSprintEvent e) {
    if (e.isSprinting()) Talisman.checkFor(e, SlimefunItem.getByID("TRAVELLER_TALISMAN"));
}
项目:Equestrian-Dash    文件:PlayerToggleSprintListener.java   
@EventHandler
public void onSprint(PlayerToggleSprintEvent event)
{

}
项目:MinecraftPlugins    文件:ToggleSprint.java   
@EventHandler
public void toggleRocketSprint(PlayerToggleSprintEvent event) {

    RocketFunctions rocketFunctions = new RocketFunctions();
    CommonString commonString = new CommonString();

    if (event.isSprinting()) {

        final Player player = event.getPlayer();
        UUID playerUUID = player.getUniqueId();

        if (RocketInit.rocketPower.containsKey(playerUUID)) {

            if (!RocketInit.rocketSprint.containsKey(playerUUID)) {

                if (player.isFlying() && RocketInit.rocketVariant.get(playerUUID) != RocketVariant.Variant.RUNNER) {

                    RocketInit.rocketSprint.put(playerUUID, "AIR");

                    commonString.messageSend(RocketInit.getPlugin(), player, true, new String[]{
                            RocketLanguage.RB_COOLDOWN_HEAT, RocketLanguage.RB_COOLDOWN_LAND
                    });

                    player.getWorld().playSound(player.getLocation(), Sound.ENTITY_FIREWORK_BLAST, 0.5f, 0.75f);

                } else if (RocketInit.rocketVariant.get(playerUUID) == RocketVariant.Variant.RUNNER) {

                    ItemStack boots = player.getInventory().getBoots();
                    int bootPower = rocketFunctions.getBootPowerLevel(boots);

                    if (!player.hasPotionEffect(PotionEffectType.SPEED))
                        rocketFunctions.changeBootDurability(player, boots);

                    player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, bootPower * 120, bootPower * 3, true, false), true);
                    player.getWorld().playSound(player.getEyeLocation(), Sound.BLOCK_PISTON_EXTEND, 1.25f, 0.75f);

                } else {

                    RocketInit.rocketSprint.put(playerUUID, "LAND");
                    commonString.messageSend(RocketInit.getPlugin(), player, true, RocketLanguage.RB_SPRINT);

                }

            }

        }

    }

}