mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2024-11-25 12:25:15 +01:00
Split Processable into NoArgument and Argument variants
This commit is contained in:
parent
639507e9db
commit
0185ef6e21
@ -40,11 +40,6 @@ public interface Processable extends Event {
|
||||
*/
|
||||
boolean isProcessed();
|
||||
|
||||
/**
|
||||
* Marks this event as processed. This cannot be reversed, events cannot be unprocessed.
|
||||
*/
|
||||
void markAsProcessed();
|
||||
|
||||
/**
|
||||
* Returns the {@link EventListener} that processed this event.
|
||||
*
|
||||
@ -63,4 +58,23 @@ public interface Processable extends Event {
|
||||
|
||||
return listener;
|
||||
}
|
||||
|
||||
interface NoArgument extends Processable {
|
||||
|
||||
/**
|
||||
* Marks this event as processed. This cannot be reversed.
|
||||
* @see #isProcessed()
|
||||
*/
|
||||
void markAsProcessed();
|
||||
}
|
||||
|
||||
interface Argument<T> extends Processable {
|
||||
|
||||
/**
|
||||
* Marks this event as processed with the given argument. This cannot be reversed.
|
||||
* @param input the argument for processing the event
|
||||
* @see #isProcessed()
|
||||
*/
|
||||
void process(T input);
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ import org.jetbrains.annotations.Nullable;
|
||||
*
|
||||
* @see #isDefault()
|
||||
*/
|
||||
public class GameChannelLookupEvent implements Processable {
|
||||
public class GameChannelLookupEvent implements Processable.Argument<GameChannel> {
|
||||
|
||||
private final String pluginName;
|
||||
private final String channelName;
|
||||
@ -90,6 +90,7 @@ public class GameChannelLookupEvent implements Processable {
|
||||
* @throws IllegalStateException if the event is already processed
|
||||
* @throws IllegalArgumentException if the provided channel doesn't match {@link #getChannelName()} and {@link #isDefault()} is {@code false}
|
||||
*/
|
||||
@Override
|
||||
public void process(@NotNull GameChannel channel) {
|
||||
if (processed) {
|
||||
throw new IllegalStateException("Already processed");
|
||||
@ -108,13 +109,4 @@ public class GameChannelLookupEvent implements Processable {
|
||||
this.channel = channel;
|
||||
this.processed = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link #process(GameChannel)}.
|
||||
*/
|
||||
@Override
|
||||
@Deprecated
|
||||
public void markAsProcessed() {
|
||||
throw new RuntimeException("Please use process(GameChannel) instead");
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ import com.discordsrv.api.event.events.Processable;
|
||||
* Indicates that a Discord message is about to be processed, this will run once per {@link GameChannel} destination,
|
||||
* meaning it could run multiple times for a single Discord message. This runs after {@link DiscordChatMessageReceiveEvent}.
|
||||
*/
|
||||
public class DiscordChatMessageProcessEvent implements Cancellable, Processable {
|
||||
public class DiscordChatMessageProcessEvent implements Cancellable, Processable.NoArgument {
|
||||
|
||||
private final DiscordMessageChannel discordChannel;
|
||||
private final ReceivedDiscordMessage message;
|
||||
|
@ -27,7 +27,7 @@ import com.discordsrv.api.event.events.Cancellable;
|
||||
import com.discordsrv.api.event.events.Processable;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public abstract class AbstractGameMessageReceiveEvent implements Processable, Cancellable {
|
||||
public abstract class AbstractGameMessageReceiveEvent implements Cancellable, Processable.NoArgument {
|
||||
|
||||
private final Object triggeringEvent;
|
||||
private boolean cancelled;
|
||||
|
@ -34,7 +34,7 @@ import java.util.Set;
|
||||
/**
|
||||
* An event for converting a placeholder's name and context into a {@link PlaceholderLookupResult}.
|
||||
*/
|
||||
public class PlaceholderLookupEvent implements Event, Processable {
|
||||
public class PlaceholderLookupEvent implements Event, Processable.Argument<PlaceholderLookupResult> {
|
||||
|
||||
private final String placeholder;
|
||||
private final Set<Object> contexts;
|
||||
@ -114,10 +114,4 @@ public class PlaceholderLookupEvent implements Event, Processable {
|
||||
this.result = result;
|
||||
this.processed = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void markAsProcessed() {
|
||||
throw new RuntimeException("Please use process(PlaceholderLookupResult) instead");
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user