restructure dirs + add rawInput parameter at ArgumentType#checkValue
This commit is contained in:
parent
aae7a160ac
commit
f1e9ac5ea9
29 changed files with 85 additions and 81 deletions
|
|
@ -1,11 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.services.command;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.CommandContext;
|
||||
|
||||
public interface CommandExecutor {
|
||||
|
||||
/**
|
||||
* @return true on success, 1 on failure
|
||||
*/
|
||||
void execute(CommandContext ctx);
|
||||
}
|
||||
|
|
@ -1,7 +1,9 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.cmds2;
|
||||
package de.kentoj.scrow.bukkit.services.command;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.literal.Literal;
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.literal.RootLiteral;
|
||||
import de.kentoj.scrow.bukkit.services.command.execution.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.CommandArgument;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.Literal;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.RootLiteral;
|
||||
import de.kentoj.scrow.bukkit.services.command.type.ArgumentType;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
package de.kentoj.scrow.bukkit.services.command;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.literal.RootLiteral;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.RootLiteral;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public interface CommandManager {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.cmds2;
|
||||
package de.kentoj.scrow.bukkit.services.command;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.literal.Literal;
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.literal.RootLiteral;
|
||||
import de.kentoj.scrow.bukkit.services.command.execution.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.CommandArgument;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.Literal;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.RootLiteral;
|
||||
import de.kentoj.scrow.bukkit.services.command.type.ArgumentType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package de.kentoj.scrow.bukkit.services.command;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.execution.CommandContext;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface SuggestionProvider {
|
||||
|
||||
Set<String> suggest(CommandContext context);
|
||||
}
|
||||
|
|
@ -1,8 +0,0 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.cmds2;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
public interface SuggestionProvider {
|
||||
|
||||
Set<String> suggest(CommandContext context);
|
||||
}
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.cmds2;
|
||||
package de.kentoj.scrow.bukkit.services.command.execution;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.CommandArgument;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
public interface ArgumentData<T> {
|
||||
|
|
@ -11,5 +12,5 @@ public interface ArgumentData<T> {
|
|||
/**
|
||||
* @return null if the default value for the type was used
|
||||
*/
|
||||
@Nullable String getRawValue();
|
||||
@Nullable String getRawInput();
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.cmds2;
|
||||
package de.kentoj.scrow.bukkit.services.command.execution;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.exception.CommandInvocationException;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.CommandArgument;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.execution;
|
||||
|
||||
public interface CommandExecutor {
|
||||
|
||||
void execute(CommandContext ctx);
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.kentoj.scrow.bukkit.services.command;
|
||||
package de.kentoj.scrow.bukkit.services.command.literal;
|
||||
|
||||
public interface ArgumentReader {
|
||||
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.cmds2;
|
||||
package de.kentoj.scrow.bukkit.services.command.literal;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.execution.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.SuggestionProvider;
|
||||
import de.kentoj.scrow.bukkit.services.command.type.ArgumentType;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.cmds2.literal;
|
||||
package de.kentoj.scrow.bukkit.services.command.literal;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.CommandExecutor;
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.CommandArgument;
|
||||
import de.kentoj.scrow.bukkit.services.command.execution.CommandExecutor;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.cmds2.literal;
|
||||
package de.kentoj.scrow.bukkit.services.command.literal;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.type;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.ArgumentReader;
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.ArgumentReader;
|
||||
import de.kentoj.scrow.bukkit.services.command.execution.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.exception.CommandInvocationException;
|
||||
|
||||
import java.util.Set;
|
||||
|
|
@ -15,7 +15,7 @@ public interface ArgumentType<T> {
|
|||
/**
|
||||
* @throws CommandInvocationException if the given value may not be used
|
||||
*/
|
||||
void checkValue(CommandContext ctx, T value) throws CommandInvocationException;
|
||||
void checkValue(CommandContext ctx, T value, String rawInput) throws CommandInvocationException;
|
||||
|
||||
Set<String> getDefaultSuggestions(CommandContext ctx);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.type;
|
||||
|
||||
import com.google.common.base.Preconditions;
|
||||
import de.kentoj.scrow.bukkit.services.command.ArgumentReader;
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.ArgumentReader;
|
||||
import de.kentoj.scrow.bukkit.services.command.execution.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.exception.CommandInvocationException;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
|
@ -33,7 +33,7 @@ public class NumberArgumentType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkValue(CommandContext ctx, Integer value) throws CommandInvocationException {
|
||||
public void checkValue(CommandContext ctx, Integer value, String rawInput) throws CommandInvocationException {
|
||||
if (value < min) throw new CommandInvocationException("Value too small -- " + value);
|
||||
if (value > max) throw new CommandInvocationException("Value too large -- " + value);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
package de.kentoj.scrow.bukkit.services.command.type;
|
||||
|
||||
import de.kentoj.scrow.bukkit.services.command.ArgumentReader;
|
||||
import de.kentoj.scrow.bukkit.services.command.cmds2.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.literal.ArgumentReader;
|
||||
import de.kentoj.scrow.bukkit.services.command.execution.CommandContext;
|
||||
import de.kentoj.scrow.bukkit.services.command.exception.CommandInvocationException;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
|
@ -36,8 +36,8 @@ public class PlayerArgumentType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkValue(CommandContext ctx, Player value) throws CommandInvocationException {
|
||||
if (value == null) throw new CommandInvocationException("Player is not online");
|
||||
public void checkValue(CommandContext ctx, Player value, String rawInput) throws CommandInvocationException {
|
||||
if (value == null) throw new CommandInvocationException("Player is not online -- " + rawInput);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -74,7 +74,7 @@ public class PlayerArgumentType {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void checkValue(CommandContext ctx, OfflinePlayer value) throws CommandInvocationException {
|
||||
public void checkValue(CommandContext ctx, OfflinePlayer value, String rawInput) throws CommandInvocationException {
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue