Java源码示例:org.bukkit.event.player.PlayerToggleSprintEvent

示例1
@EventHandler(ignoreCancelled = true, priority = EventPriority.MONITOR)
public void onToggleSprint(final PlayerToggleSprintEvent event)
{
    final User user = UserManager.getUser(event.getPlayer().getUniqueId());

    if (user != null) {
        user.getDataMap().setValue(DataKey.SPRINTING, event.isSprinting());
        if (!event.isSprinting()) {
            user.getDataMap().setValue(DataKey.LAST_SPRINT_DURATION, user.getTimestampMap().passedTime(TimestampKey.LAST_SPRINT_TOGGLE));
        }
        user.getTimestampMap().updateTimeStamp(TimestampKey.LAST_SPRINT_TOGGLE);
    }
}
 
示例2
@EventHandler
public void onSprint(PlayerToggleSprintEvent e) {
    if (e.isSprinting()) {
        Talisman.checkFor(e, SlimefunItems.TALISMAN_TRAVELLER);
    }
}