Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions core/src/main/java/com/nisovin/magicspells/MagicSpells.java
Original file line number Diff line number Diff line change
Expand Up @@ -1972,7 +1972,7 @@ public static void registerEvents(final Listener listener, EventPriority customP
if (handler == null) continue;
EventPriority priority = handler.priority();

if (hasAnnotation(method, OverridePriority.class)) priority = customPriority;
if (method.getAnnotation(OverridePriority.class) != null) priority = customPriority;

final Class<?>[] paramTypes = method.getParameterTypes();
if (paramTypes.length != 1 || !Event.class.isAssignableFrom(paramTypes[0])) {
Expand Down Expand Up @@ -2020,10 +2020,6 @@ public void execute(@NotNull Listener listener, @NotNull Event event) {
}
}

private static boolean hasAnnotation(Method m, Class<? extends Annotation> clazz) {
return m.getAnnotation(clazz) != null;
}

public static int scheduleDelayedTask(final Runnable task, long delay) {
return Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, !plugin.enableErrorLogging ? task : () -> {
try {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
package com.nisovin.magicspells.util;

import org.bukkit.event.EventHandler;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
* Used on {@link EventHandler} annotated methods implemented by
* PassiveSpell triggers to allow for configurable override of their priority.
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
public @interface OverridePriority {

}
Loading