mirror of
https://github.com/Minestom/Minestom.git
synced 2025-01-06 00:17:58 +01:00
Fix ArgumentMap when the argument accepts space
This commit is contained in:
parent
b50c2831bf
commit
4b31e27348
@ -1,7 +1,10 @@
|
||||
package net.minestom.server.command.builder.arguments;
|
||||
|
||||
import com.google.common.annotations.Beta;
|
||||
import net.minestom.server.command.builder.*;
|
||||
import net.minestom.server.command.builder.ArgumentCallback;
|
||||
import net.minestom.server.command.builder.Command;
|
||||
import net.minestom.server.command.builder.CommandExecutor;
|
||||
import net.minestom.server.command.builder.NodeMaker;
|
||||
import net.minestom.server.command.builder.exception.ArgumentSyntaxException;
|
||||
import net.minestom.server.command.builder.suggestion.SuggestionCallback;
|
||||
import net.minestom.server.network.packet.server.play.DeclareCommandsPacket;
|
||||
@ -221,12 +224,11 @@ public abstract class Argument<T> {
|
||||
* Maps this argument's output to another result.
|
||||
*
|
||||
* @param mapper The mapper to use (this argument's input --> desired output)
|
||||
* @param <O> The type of output expected.
|
||||
*
|
||||
* @param <O> The type of output expected.
|
||||
* @return A new ArgumentMap that can get this complex object type.
|
||||
*/
|
||||
@Beta
|
||||
public <O> ArgumentMap<T, O> map(ArgumentMap.ArgumentMapper<T, O> mapper) {
|
||||
public <O> @NotNull ArgumentMap<T, O> map(@NotNull ArgumentMap.Mapper<T, O> mapper) {
|
||||
return new ArgumentMap<>(this, mapper);
|
||||
}
|
||||
|
||||
|
@ -13,10 +13,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
public class ArgumentMap<I, O> extends Argument<O> {
|
||||
|
||||
final Argument<I> argument;
|
||||
final ArgumentMapper<I, O> mapper;
|
||||
final Mapper<I, O> mapper;
|
||||
|
||||
protected ArgumentMap(Argument<I> argument, ArgumentMapper<I, O> mapper) {
|
||||
super(argument.getId());
|
||||
protected ArgumentMap(@NotNull Argument<I> argument, @NotNull Mapper<I, O> mapper) {
|
||||
super(argument.getId(), argument.allowSpace(), argument.useRemaining());
|
||||
|
||||
this.argument = argument;
|
||||
this.mapper = mapper;
|
||||
@ -40,16 +40,15 @@ public class ArgumentMap<I, O> extends Argument<O> {
|
||||
* @param <O> The desired output type from this lambda.
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface ArgumentMapper<I, O> {
|
||||
public interface Mapper<I, O> {
|
||||
|
||||
/**
|
||||
* Accept's I data from the argument and returns O output
|
||||
* Accepts I data from the argument and returns O output
|
||||
*
|
||||
* @param i The input processed from an argument
|
||||
*
|
||||
* @return The complex data type that came as a result from this argument
|
||||
* @throws ArgumentSyntaxException If the input can not be turned into the desired output
|
||||
* (E.X. an invalid extension name)
|
||||
* (E.X. an invalid extension name)
|
||||
*/
|
||||
O accept(I i) throws ArgumentSyntaxException;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user