I cant seem to make it stop players from sprinting... Heres my code. Code: @EventHandler public void onPlayerToggleSprint(final PlayerToggleSprintEvent event) { Player player = event.getPlayer(); event.setCancelled(true); }
You have a final modifier before the event, meaning that the variable is final; in other words, it can't be changed. Remove that modifier and it should work.
AngryNerd Yeah, that's not correct. The final keyword prevents it from being reassigned. MineCrypt Are you registering your EventHandler?
MineCrypt A variable that can't be reassigned has nothing to do with the mutability of the object the variable is pointing to.
Code:java @EventHandlerpublic void onPlayerMove(PlayerMoveEvent event) { Player p = event.getPlayer(); if (p.isSprinting()) { event.setCancelled(true); }} This will stop the player's movement when they attempt to sprint.
You sure you're registering the event? Try boradcast something when it's called (outside the ifs) and if you see the broadcast then use Lone's method, the other would be considered broken.