Mirror von
https://github.com/GeyserMC/Geyser.git
synchronisiert 2024-12-24 15:20:25 +01:00
Rename Priority to PostOrder
Dieser Commit ist enthalten in:
Ursprung
30303d5f16
Commit
2277b98dfd
@ -26,7 +26,6 @@
|
|||||||
package org.geysermc.geyser.api.event;
|
package org.geysermc.geyser.api.event;
|
||||||
|
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
|
||||||
import org.geysermc.geyser.api.extension.Extension;
|
import org.geysermc.geyser.api.extension.Extension;
|
||||||
|
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
@ -67,11 +66,11 @@ public interface EventSubscription<T extends Event> {
|
|||||||
Extension owner();
|
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.
|
* Gets if this event subscription is active.
|
||||||
|
@ -28,7 +28,6 @@ package org.geysermc.geyser.api.event;
|
|||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
@ -50,20 +49,19 @@ import java.lang.annotation.Target;
|
|||||||
public @interface Subscribe {
|
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
|
Subscribe.PostOrder postOrder() default PostOrder.NORMAL;
|
||||||
Priority priority() default Priority.NORMAL;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents the priority of an event.
|
* Represents the post order of an event.
|
||||||
*/
|
*/
|
||||||
@Accessors(fluent = true)
|
@Accessors(fluent = true)
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
enum Priority {
|
enum PostOrder {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The lowest priority. Called first to
|
* The lowest priority. Called first to
|
||||||
|
@ -47,7 +47,7 @@ public class GeyserEventBus implements EventBus {
|
|||||||
@NonNull
|
@NonNull
|
||||||
@Override
|
@Override
|
||||||
public <T extends Event> EventSubscription<T> subscribe(@NonNull Extension extension, @NonNull Class<T> eventClass, @NonNull Consumer<? super T> consumer) {
|
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
|
@Override
|
||||||
@ -78,7 +78,7 @@ public class GeyserEventBus implements EventBus {
|
|||||||
} catch (IllegalAccessException | InvocationTargetException ex) {
|
} catch (IllegalAccessException | InvocationTargetException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
}, extension, subscribe.priority());
|
}, extension, subscribe.postOrder());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,8 +103,8 @@ public class GeyserEventBus implements EventBus {
|
|||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
}
|
}
|
||||||
|
|
||||||
private <T extends Event> EventSubscription<T> subscribe(Class<T> eventClass, Consumer<? super T> handler, Extension extension, Subscribe.Priority 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, priority);
|
GeyserEventSubscription<T> eventSubscription = new GeyserEventSubscription<>(this, eventClass, handler, extension, postOrder);
|
||||||
this.bus.register(eventClass, eventSubscription);
|
this.bus.register(eventClass, eventSubscription);
|
||||||
return eventSubscription;
|
return eventSubscription;
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ public class GeyserEventSubscription<T extends Event> implements EventSubscripti
|
|||||||
private final Class<T> eventClass;
|
private final Class<T> eventClass;
|
||||||
private final Consumer<? super T> eventConsumer;
|
private final Consumer<? super T> eventConsumer;
|
||||||
private final Extension owner;
|
private final Extension owner;
|
||||||
private final Subscribe.Priority priority;
|
private final Subscribe.PostOrder order;
|
||||||
@Getter(AccessLevel.NONE) private boolean active;
|
@Getter(AccessLevel.NONE) private boolean active;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -77,6 +77,6 @@ public class GeyserEventSubscription<T extends Event> implements EventSubscripti
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int postOrder() {
|
public int postOrder() {
|
||||||
return this.priority.postOrder();
|
return this.order.postOrder();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren