Optimizes the plugin by executing the code inside PlayerMoveEvent only when the event is called because the player changes blocks, not when he moves his head.

This commit is contained in:
vSKAH 2022-02-23 19:16:17 +01:00
parent c504909668
commit a80fd2e110
1 changed files with 5 additions and 4 deletions

View File

@ -118,13 +118,14 @@ public class Listeners implements Listener {
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
public void onMoveEvent(PlayerMoveEvent event) {
// will check if the player is in the portal or not.
if (!Portal.portalsActive || event.isCancelled()) {
return;
}
if (!Portal.portalsActive || event.isCancelled()) return;
//Optimizes the plugin by executing the code only when the event is called because the player changes blocks, not when he moves his head. - vSKAH
if (event.getFrom().getBlockX() == event.getTo().getBlockX() && event.getFrom().getBlockZ() == event.getTo().getBlockZ()) return;
Player player = event.getPlayer();
checkTriggerLocations(player, false, event.getTo(), player.getEyeLocation());
}