Use sealed types in command interfaces (#1239)
* Use sealed types in command interfaces * Some minor code fixes
This commit is contained in:
@@ -29,5 +29,5 @@ import com.velocitypowered.api.proxy.Player;
|
||||
*
|
||||
* </ul>
|
||||
*/
|
||||
public interface Command {
|
||||
public sealed interface Command permits BrigadierCommand, InvocableCommand {
|
||||
}
|
||||
|
@@ -21,7 +21,8 @@ import java.util.concurrent.CompletableFuture;
|
||||
*
|
||||
* @param <I> the type of the command invocation object
|
||||
*/
|
||||
public interface InvocableCommand<I extends CommandInvocation<?>> extends Command {
|
||||
public sealed interface InvocableCommand<I extends CommandInvocation<?>> extends Command
|
||||
permits RawCommand, SimpleCommand {
|
||||
|
||||
/**
|
||||
* Executes the command for the specified invocation.
|
||||
|
@@ -12,7 +12,7 @@ package com.velocitypowered.api.command;
|
||||
* the command and its arguments directly without further processing.
|
||||
* This is useful for bolting on external command frameworks to Velocity.
|
||||
*/
|
||||
public interface RawCommand extends InvocableCommand<RawCommand.Invocation> {
|
||||
public non-sealed interface RawCommand extends InvocableCommand<RawCommand.Invocation> {
|
||||
|
||||
/**
|
||||
* Contains the invocation data for a raw command.
|
||||
|
@@ -16,7 +16,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
* <p>Prefer using {@link BrigadierCommand}, which is also
|
||||
* backwards-compatible with older clients.
|
||||
*/
|
||||
public interface SimpleCommand extends InvocableCommand<SimpleCommand.Invocation> {
|
||||
public non-sealed interface SimpleCommand extends InvocableCommand<SimpleCommand.Invocation> {
|
||||
|
||||
/**
|
||||
* Contains the invocation data for a simple command.
|
||||
|
Reference in New Issue
Block a user