/**
* 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();
});
}
}
java类org.bukkit.event.player.PlayerToggleSprintEvent的实例源码
PlayerListener.java 文件源码
项目:AddGun
阅读 23
收藏 0
点赞 0
评论 0
EntityActionListener.java 文件源码
项目:FlexMC
阅读 25
收藏 0
点赞 0
评论 0
@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
}
}
feedTask.java 文件源码
项目:COD-Warfare
阅读 23
收藏 0
点赞 0
评论 0
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);
}
}
}
PlayerListener.java 文件源码
项目:SwornRPG
阅读 23
收藏 0
点赞 0
评论 0
@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")));
}
}
PhysicalStrengthEvent.java 文件源码
项目:RealSurvival
阅读 48
收藏 0
点赞 0
评论 0
@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);
}
BackendChecks.java 文件源码
项目:DynamicAC
阅读 23
收藏 0
点赞 0
评论 0
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");
}
}
Backend.java 文件源码
项目:AntiCheat-COMPAT
阅读 21
收藏 0
点赞 0
评论 0
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;
}
}
PlayerListener.java 文件源码
项目:SugCubeCommandPack
阅读 20
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerToggleSprint(PlayerToggleSprintEvent event) {
Player player = (Player) event.getPlayer();
if (sccp.swActionSprint.contains(player)) {
sccp.swPlayers.remove(player);
sccp.swActionSprint.remove(player);
}
}
TalismanListener.java 文件源码
项目:Slimefun4-Chinese-Version
阅读 26
收藏 0
点赞 0
评论 0
@EventHandler
public void onSprint(PlayerToggleSprintEvent e) {
if (e.isSprinting()) Talisman.checkFor(e, SlimefunItem.getByID("TRAVELLER_TALISMAN"));
}
SkillListener.java 文件源码
项目:Minecraft-UAPI
阅读 25
收藏 0
点赞 0
评论 0
@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);
}
Listeners.java 文件源码
项目:COD-Warfare
阅读 24
收藏 0
点赞 0
评论 0
@EventHandler
public void onPlayerSprint(PlayerToggleSprintEvent e) {
if (PerkAPI.getPerk(e.getPlayer()) == Perk.MARATHON) return;
feedTask.startFeedTask(e);
}
TalismanListener.java 文件源码
项目:Slimefun4
阅读 23
收藏 0
点赞 0
评论 0
@EventHandler
public void onSprint(PlayerToggleSprintEvent e) {
if (e.isSprinting()) Talisman.checkFor(e, SlimefunItem.getByID("TRAVELLER_TALISMAN"));
}
PlayerToggleSprintListener.java 文件源码
项目:Equestrian-Dash
阅读 41
收藏 0
点赞 0
评论 0
@EventHandler
public void onSprint(PlayerToggleSprintEvent event)
{
}
ToggleSprint.java 文件源码
项目:MinecraftPlugins
阅读 21
收藏 0
点赞 0
评论 0
@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);
}
}
}
}
}