mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Rename Priority to PostOrder
This commit is contained in:
parent
30303d5f16
commit
2277b98dfd
4 changed files with 14 additions and 17 deletions
|
@ -26,7 +26,6 @@
|
|||
package org.geysermc.geyser.api.event;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
import org.geysermc.geyser.api.extension.Extension;
|
||||
|
||||
import java.util.function.Consumer;
|
||||
|
@ -67,11 +66,11 @@ public interface EventSubscription<T extends Event> {
|
|||
Extension owner();
|
||||
|
||||
/**
|
||||
* Gets the priority of this event subscription.
|
||||
* Gets the post order of this event subscription.
|
||||
*
|
||||
* @return the priority of this event subscription
|
||||
* @return the post order of this event subscription
|
||||
*/
|
||||
Subscribe.Priority priority();
|
||||
Subscribe.PostOrder order();
|
||||
|
||||
/**
|
||||
* Gets if this event subscription is active.
|
||||
|
|
|
@ -28,7 +28,6 @@ package org.geysermc.geyser.api.event;
|
|||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
|
@ -50,20 +49,19 @@ import java.lang.annotation.Target;
|
|||
public @interface Subscribe {
|
||||
|
||||
/**
|
||||
* The {@link Priority} of the event
|
||||
* The {@link PostOrder} of the event
|
||||
*
|
||||
* @return the priority of the event
|
||||
* @return the post order of the event
|
||||
*/
|
||||
@NonNull
|
||||
Priority priority() default Priority.NORMAL;
|
||||
Subscribe.PostOrder postOrder() default PostOrder.NORMAL;
|
||||
|
||||
/**
|
||||
* Represents the priority of an event.
|
||||
* Represents the post order of an event.
|
||||
*/
|
||||
@Accessors(fluent = true)
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
enum Priority {
|
||||
enum PostOrder {
|
||||
|
||||
/**
|
||||
* The lowest priority. Called first to
|
||||
|
|
|
@ -47,7 +47,7 @@ public class GeyserEventBus implements EventBus {
|
|||
@NonNull
|
||||
@Override
|
||||
public <T extends Event> EventSubscription<T> subscribe(@NonNull Extension extension, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> consumer) {
|
||||
return this.subscribe(eventClass, consumer, extension, Subscribe.Priority.NORMAL);
|
||||
return this.subscribe(eventClass, consumer, extension, Subscribe.PostOrder.NORMAL);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -78,7 +78,7 @@ public class GeyserEventBus implements EventBus {
|
|||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}, extension, subscribe.priority());
|
||||
}, extension, subscribe.postOrder());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,8 +103,8 @@ public class GeyserEventBus implements EventBus {
|
|||
.collect(Collectors.toSet());
|
||||
}
|
||||
|
||||
private <T extends Event> EventSubscription<T> subscribe(Class<T> eventClass, Consumer<? super T> handler, Extension extension, Subscribe.Priority priority) {
|
||||
GeyserEventSubscription<T> eventSubscription = new GeyserEventSubscription<>(this, eventClass, handler, extension, priority);
|
||||
private <T extends Event> EventSubscription<T> subscribe(Class<T> eventClass, Consumer<? super T> handler, Extension extension, Subscribe.PostOrder postOrder) {
|
||||
GeyserEventSubscription<T> eventSubscription = new GeyserEventSubscription<>(this, eventClass, handler, extension, postOrder);
|
||||
this.bus.register(eventClass, eventSubscription);
|
||||
return eventSubscription;
|
||||
}
|
||||
|
|
|
@ -47,7 +47,7 @@ public class GeyserEventSubscription<T extends Event> implements EventSubscripti
|
|||
private final Class<T> eventClass;
|
||||
private final Consumer<? super T> eventConsumer;
|
||||
private final Extension owner;
|
||||
private final Subscribe.Priority priority;
|
||||
private final Subscribe.PostOrder order;
|
||||
@Getter(AccessLevel.NONE) private boolean active;
|
||||
|
||||
@Override
|
||||
|
@ -77,6 +77,6 @@ public class GeyserEventSubscription<T extends Event> implements EventSubscripti
|
|||
|
||||
@Override
|
||||
public int postOrder() {
|
||||
return this.priority.postOrder();
|
||||
return this.order.postOrder();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue