Added TerminatorLocateTargetEvent
This commit is contained in:
@@ -10,6 +10,7 @@ import net.nuggetmc.tplus.api.agent.legacyagent.ai.NeuralNetwork;
|
|||||||
import net.nuggetmc.tplus.api.event.BotDamageByPlayerEvent;
|
import net.nuggetmc.tplus.api.event.BotDamageByPlayerEvent;
|
||||||
import net.nuggetmc.tplus.api.event.BotDeathEvent;
|
import net.nuggetmc.tplus.api.event.BotDeathEvent;
|
||||||
import net.nuggetmc.tplus.api.event.BotFallDamageEvent;
|
import net.nuggetmc.tplus.api.event.BotFallDamageEvent;
|
||||||
|
import net.nuggetmc.tplus.api.event.TerminatorLocateTargetEvent;
|
||||||
import net.nuggetmc.tplus.api.utils.MathUtils;
|
import net.nuggetmc.tplus.api.utils.MathUtils;
|
||||||
import net.nuggetmc.tplus.api.utils.PlayerUtils;
|
import net.nuggetmc.tplus.api.utils.PlayerUtils;
|
||||||
import org.bukkit.*;
|
import org.bukkit.*;
|
||||||
@@ -1217,8 +1218,10 @@ public class LegacyAgent extends Agent {
|
|||||||
return locateTarget(bot, loc, EnumTargetGoal.NEAREST_VULNERABLE_PLAYER);
|
return locateTarget(bot, loc, EnumTargetGoal.NEAREST_VULNERABLE_PLAYER);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
TerminatorLocateTargetEvent event = new TerminatorLocateTargetEvent(bot, result);
|
||||||
return result;
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
if (event.isCancelled()) return null;
|
||||||
|
return event.getTarget();
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean validateCloserEntity(LivingEntity entity, Location loc, LivingEntity result) {
|
private boolean validateCloserEntity(LivingEntity entity, Location loc, LivingEntity result) {
|
||||||
|
|||||||
@@ -0,0 +1,52 @@
|
|||||||
|
package net.nuggetmc.tplus.api.event;
|
||||||
|
|
||||||
|
import net.nuggetmc.tplus.api.Terminator;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
public class TerminatorLocateTargetEvent extends Event implements Cancellable {
|
||||||
|
|
||||||
|
private static final HandlerList handlerList = new HandlerList();
|
||||||
|
private Terminator terminator;
|
||||||
|
private LivingEntity target;
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
public TerminatorLocateTargetEvent(Terminator terminator, LivingEntity target) {
|
||||||
|
this.terminator = terminator;
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlerList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Terminator getTerminator() {
|
||||||
|
return terminator;
|
||||||
|
}
|
||||||
|
|
||||||
|
public LivingEntity getTarget() {
|
||||||
|
return target;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(LivingEntity target) {
|
||||||
|
this.target = target;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isCancelled() {
|
||||||
|
return cancelled;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setCancelled(boolean cancel) {
|
||||||
|
cancelled = cancel;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user