Skip to content

Commit

Permalink
fix mistake
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Nov 29, 2023
1 parent 64df9d1 commit cca6c6b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 66 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityTargetEvent;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -105,36 +104,4 @@ private void onPathfind(EntityPathfindEvent event) {
}
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onTargetAcquire(EntityTargetEvent event) {
if (event.getTarget() == null) return;
final double targetDistance = event.getEntity().getLocation().distance(event.getTarget().getLocation());

if (globalDistanceEnabled) {
if (targetDistance > globalMaxDistance) {
event.setCancelled(true);
event.setTarget(null);
if (logIsEnabled) LogUtils.moduleLog(Level.INFO, name(),
"Cancelled entity "+event.getEntityType()+" from targeting entity at "
+event.getTarget().getLocation().toBlockLocation()
+" because target is further than the global limit. Distance: "+targetDistance
);
return;
}
}

if (perTypeDistanceEnabled) {
final EntityType pathfindingType = event.getEntityType();
if (limitedTypes.containsKey(pathfindingType) && targetDistance > limitedTypes.get(pathfindingType)) {
event.setCancelled(true);
event.setTarget(null);
if (logIsEnabled) LogUtils.moduleLog(Level.INFO, name(),
"Cancelled entity "+event.getEntityType()+" from targeting entity at "
+event.getTarget().getLocation().toBlockLocation()
+" because target is further than the global limit. Distance: "+targetDistance
);
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityTargetEvent;

import java.util.HashMap;
import java.util.Map;
Expand Down Expand Up @@ -99,36 +98,4 @@ private void onPathfind(EntityPathfindEvent event) {
}
}
}

@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
private void onTargetAcquire(EntityTargetEvent event) {
if (event.getTarget() == null) return;
final double targetDistance = event.getEntity().getLocation().distance(event.getTarget().getLocation());

if (globalDistanceEnabled) {
if (targetDistance > globalMaxDistance) {
event.setCancelled(true);
event.setTarget(null);
if (logIsEnabled) LogUtils.moduleLog(Level.INFO, name(),
"Cancelled entity "+event.getEntityType()+" from targeting entity at "
+event.getTarget().getLocation().toBlockLocation()
+" because target is further than the global limit. Distance: "+targetDistance
);
return;
}
}

if (perTypeDistanceEnabled) {
final EntityType pathfindingType = event.getEntityType();
if (limitedTypes.containsKey(pathfindingType) && targetDistance > limitedTypes.get(pathfindingType)) {
event.setCancelled(true);
event.setTarget(null);
if (logIsEnabled) LogUtils.moduleLog(Level.INFO, name(),
"Cancelled entity "+event.getEntityType()+" from targeting entity at "
+event.getTarget().getLocation().toBlockLocation()
+" because target is further than the global limit. Distance: "+targetDistance
);
}
}
}
}

0 comments on commit cca6c6b

Please sign in to comment.