Skip to content
Permalink
Browse files

Sentinel 1.0 - also, an API event

  • Loading branch information...
mcmonkey4eva committed Dec 7, 2016
1 parent 7f50a95 commit 3d87ff7f5b6b4d6d44e49aa4913fb351040af0f2
@@ -7,7 +7,7 @@
<groupId>org.mcmonkey</groupId>
<artifactId>sentinel</artifactId>
<packaging>jar</packaging>
<version>0.9</version>
<version>1.0</version>
<name>Sentinel</name>
<description>Combat NPCs for Spigot</description>

@@ -35,6 +35,7 @@
import org.bukkit.projectiles.ProjectileSource;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
import org.mcmonkey.sentinel.events.SentinelAttackEvent;

import java.util.*;
import java.util.regex.Pattern;
@@ -963,6 +964,11 @@ public void tryAttack(LivingEntity entity) {
else if (autoswitch && dist < 3 * 3) {
swapToMelee();
}
SentinelAttackEvent sat = new SentinelAttackEvent(npc);
Bukkit.getPluginManager().callEvent(sat);
if (sat.isCancelled()) {
return;
}
if (usesBow()) {
if (canSee(entity)) {
if (timeSinceAttack < attackRateRanged) {
@@ -0,0 +1,35 @@
package org.mcmonkey.sentinel.events;

import net.citizensnpcs.api.event.NPCEvent;
import net.citizensnpcs.api.npc.NPC;
import org.bukkit.event.Cancellable;
import org.bukkit.event.HandlerList;

public class SentinelAttackEvent extends NPCEvent implements Cancellable {

private static final HandlerList handlers = new HandlerList();

private boolean cancelled = false;

public SentinelAttackEvent(NPC npc) {
super(npc);
}

public HandlerList getHandlers() {
return handlers;
}

public static HandlerList getHandlerList() {
return handlers;
}

@Override
public boolean isCancelled() {
return cancelled;
}

@Override
public void setCancelled(boolean cancelled) {
this.cancelled = cancelled;
}
}

0 comments on commit 3d87ff7

Please sign in to comment.
You can’t perform that action at this time.