
dev.jorel.commandapi.BukkitExecutable Maven / Gradle / Ivy
package dev.jorel.commandapi;
import dev.jorel.commandapi.commandsenders.BukkitCommandSender;
import dev.jorel.commandapi.exceptions.WrapperCommandSyntaxException;
import dev.jorel.commandapi.executors.*;
import org.bukkit.command.CommandSender;
public interface BukkitExecutable
/// @endcond
> extends PlatformExecutable {
// Regular command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (CommandSender, Object[]) -> ()
that will be executed when the command is run
* @param types A list of executor types to use this executes method for.
* @return this command builder
*/
default Impl executes(CommandExecutor executor, ExecutorType... types) {
if (types == null || types.length == 0) {
getExecutor().addNormalExecutor(executor);
} else {
for (ExecutorType type : types) {
getExecutor().addNormalExecutor(new CommandExecutor() {
@Override
public void run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
executor.executeWith(new BukkitExecutionInfo<>(sender, CommandAPIBukkit.get().wrapCommandSender(sender), args));
}
@Override
public ExecutorType getType() {
return type;
}
});
}
}
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (BukkitCommandExecutionInfo) -> ()
that will be executed when the command is run
* @param types A list of executor types to use this executes method for.
* @return this command builder
*/
default Impl executes(CommandExecutionInfo executor, ExecutorType... types) {
if (types == null || types.length == 0) {
getExecutor().addNormalExecutor(executor);
} else {
for (ExecutorType type : types) {
getExecutor().addNormalExecutor(new CommandExecutionInfo() {
@Override
public void run(ExecutionInfo> info) throws WrapperCommandSyntaxException {
executor.executeWith(info);
}
@Override
public ExecutorType getType() {
return type;
}
});
}
}
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (CommandSender, CommandArguments) -> int
that will be executed when the command is run
* @param types A list of executor types to use this executes method for.
* @return this command builder
*/
default Impl executes(ResultingCommandExecutor executor, ExecutorType... types) {
if (types == null || types.length == 0) {
getExecutor().addResultingExecutor(executor);
} else {
for (ExecutorType type : types) {
getExecutor().addResultingExecutor(new ResultingCommandExecutor() {
@Override
public int run(CommandSender sender, CommandArguments args) throws WrapperCommandSyntaxException {
executor.executeWith(new BukkitExecutionInfo<>(sender, CommandAPIBukkit.get().wrapCommandSender(sender), args));
return 1;
}
@Override
public ExecutorType getType() {
return type;
}
});
}
}
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (BukkitCommandExecutionInfo) -> int
that will be executed when the command is run
* @param types A list of executor types to use this executes method for.
* @return this command builder
*/
default Impl executes(ResultingCommandExecutionInfo executor, ExecutorType... types) {
if (types == null || types.length == 0) {
getExecutor().addResultingExecutor(executor);
} else {
for (ExecutorType type : types) {
getExecutor().addResultingExecutor(new ResultingCommandExecutionInfo() {
@Override
public int run(ExecutionInfo> info) throws WrapperCommandSyntaxException {
executor.executeWith(info);
return 1;
}
@Override
public ExecutorType getType() {
return type;
}
});
}
}
return instance();
}
// Player command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (Player, CommandArguments) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesPlayer(PlayerCommandExecutor executor) {
getExecutor().addNormalExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesPlayer(PlayerExecutionInfo info) {
getExecutor().addNormalExecutor(info);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (Player, CommandArguments) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesPlayer(PlayerResultingCommandExecutor executor) {
getExecutor().addResultingExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesPlayer(PlayerResultingExecutionInfo info) {
getExecutor().addResultingExecutor(info);
return instance();
}
// Entity command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (Entity, CommandArguments) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesEntity(EntityCommandExecutor executor) {
getExecutor().addNormalExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesEntity(EntityExecutionInfo info) {
getExecutor().addNormalExecutor(info);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (Entity, CommandArguments) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesEntity(EntityResultingCommandExecutor executor) {
getExecutor().addResultingExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesEntity(EntityResultingExecutionInfo info) {
getExecutor().addResultingExecutor(info);
return instance();
}
// Proxy command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (Entity, CommandArguments) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesProxy(ProxyCommandExecutor executor) {
getExecutor().addNormalExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesProxy(ProxyExecutionInfo info) {
getExecutor().addNormalExecutor(info);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (Entity, CommandArguments) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesProxy(ProxyResultingCommandExecutor executor) {
getExecutor().addResultingExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesProxy(ProxyResultingExecutionInfo info) {
getExecutor().addResultingExecutor(info);
return instance();
}
// Command block command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (BlockCommandSender, CommandArguments) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesCommandBlock(CommandBlockCommandExecutor executor) {
getExecutor().addNormalExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesCommandBlock(CommandBlockExecutionInfo info) {
getExecutor().addNormalExecutor(info);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (BlockCommandSender, CommandArguments) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesCommandBlock(CommandBlockResultingCommandExecutor executor) {
getExecutor().addResultingExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesCommandBlock(CommandBlockResultingExecutionInfo info) {
getExecutor().addResultingExecutor(info);
return instance();
}
// Console command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (ConsoleCommandSender, CommandArguments) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesConsole(ConsoleCommandExecutor executor) {
getExecutor().addNormalExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesConsole(ConsoleExecutionInfo info) {
getExecutor().addNormalExecutor(info);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (ConsoleCommandSender, CommandArguments) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesConsole(ConsoleResultingCommandExecutor executor) {
getExecutor().addResultingExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesConsole(ConsoleResultingExecutionInfo info) {
getExecutor().addResultingExecutor(info);
return instance();
}
// Native command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (NativeCommandExecutor, CommandArguments) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesNative(NativeCommandExecutor executor) {
getExecutor().addNormalExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesNative(NativeExecutionInfo info) {
getExecutor().addNormalExecutor(info);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (NativeCommandExecutor, CommandArguments) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesNative(NativeResultingCommandExecutor executor) {
getExecutor().addResultingExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesNative(NativeResultingExecutionInfo info) {
getExecutor().addResultingExecutor(info);
return instance();
}
// RemoteConsole command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (RemoteConsoleCommandExecutor, CommandArguments) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesRemoteConsole(RemoteConsoleCommandExecutor executor) {
getExecutor().addNormalExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesRemoteConsole(RemoteConsoleExecutionInfo info) {
getExecutor().addNormalExecutor(info);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (RemoteConsoleResultingCommandExecutor, CommandArguments) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesRemoteConsole(RemoteConsoleResultingCommandExecutor executor) {
getExecutor().addResultingExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesRemoteConsole(RemoteConsoleResultingExecutionInfo info) {
getExecutor().addResultingExecutor(info);
return instance();
}
// Feedback-forwarding command executor
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (FeedbackForwardingCommandExecutor, CommandArguments) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesFeedbackForwarding(FeedbackForwardingCommandExecutor executor) {
getExecutor().addNormalExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> ()
that will be executed when the command is run
* @return this command builder
*/
default Impl executesFeedbackForwarding(FeedbackForwardingExecutionInfo info) {
getExecutor().addNormalExecutor(info);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param executor A lambda of type (FeedbackForwardingCommandExecutor, CommandArguments) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesFeedbackForwarding(FeedbackForwardingResultingCommandExecutor executor) {
getExecutor().addResultingExecutor(executor);
return instance();
}
/**
* Adds an executor to the current command builder
*
* @param info A lambda of type (ExecutionInfo) -> int
that will be executed when the command is run
* @return this command builder
*/
default Impl executesFeedbackForwarding(FeedbackForwardingResultingExecutionInfo info) {
getExecutor().addResultingExecutor(info);
return instance();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy