From 6e15acd03f03cc5df20ec4adde7ceb3f576a1e82 Mon Sep 17 00:00:00 2001 From: Jonathing Date: Wed, 23 Apr 2025 20:17:43 -0400 Subject: [PATCH] Turn Priority into a non-extendable interface --- .../eventbus/api/listener/Priority.java | 18 +++++++++--------- .../eventbus/internal/UtilityInterface.java | 9 +++++++++ 2 files changed, 18 insertions(+), 9 deletions(-) create mode 100644 src/main/java/net/minecraftforge/eventbus/internal/UtilityInterface.java diff --git a/src/main/java/net/minecraftforge/eventbus/api/listener/Priority.java b/src/main/java/net/minecraftforge/eventbus/api/listener/Priority.java index c3e7c91c..11684106 100644 --- a/src/main/java/net/minecraftforge/eventbus/api/listener/Priority.java +++ b/src/main/java/net/minecraftforge/eventbus/api/listener/Priority.java @@ -4,41 +4,41 @@ */ package net.minecraftforge.eventbus.api.listener; +import net.minecraftforge.eventbus.internal.UtilityInterface; + /** * Some common priority values, spread out evenly across the range of a Java signed byte, factoring in the special * {@link Priority#MONITOR} priority. */ -public final class Priority { - private Priority() {} - +public sealed interface Priority permits UtilityInterface { /** * Runs first */ - public static final byte HIGHEST = Byte.MAX_VALUE; + byte HIGHEST = Byte.MAX_VALUE; /** * Runs before {@link #NORMAL} but after {@link #HIGHEST} */ - public static final byte HIGH = 64; + byte HIGH = 64; /** * The default priority */ - public static final byte NORMAL = 0; + byte NORMAL = 0; /** * Runs after {@link #NORMAL} but before {@link #LOWEST} */ - public static final byte LOW = -64; + byte LOW = -64; /** * The last priority that can mutate the event instance */ - public static final byte LOWEST = Byte.MIN_VALUE + 1; + byte LOWEST = Byte.MIN_VALUE + 1; /** * A special priority that is only used for monitoring purposes and typically doesn't allow cancelling or mutation. *

Monitoring listeners are always called last - even if the event is cancelled.

*/ - public static final byte MONITOR = Byte.MIN_VALUE; + byte MONITOR = Byte.MIN_VALUE; } diff --git a/src/main/java/net/minecraftforge/eventbus/internal/UtilityInterface.java b/src/main/java/net/minecraftforge/eventbus/internal/UtilityInterface.java new file mode 100644 index 00000000..9b537d6c --- /dev/null +++ b/src/main/java/net/minecraftforge/eventbus/internal/UtilityInterface.java @@ -0,0 +1,9 @@ +/* + * Copyright (c) Forge Development LLC + * SPDX-License-Identifier: LGPL-2.1-only + */ +package net.minecraftforge.eventbus.internal; + +import net.minecraftforge.eventbus.api.listener.Priority; + +public non-sealed interface UtilityInterface extends Priority {}