From 0f196f59c6a4cb76ab8409da62ff1f35505f94a8 Mon Sep 17 00:00:00 2001 From: Dico Karssiens Date: Sun, 11 Nov 2018 14:06:45 +0000 Subject: Changes I made before breaking my local repository. Hoping this works. --- .../command/parameter/type/EnumParameterType.java | 92 +++++++++++----------- 1 file changed, 46 insertions(+), 46 deletions(-) (limited to 'dicore3/command/src/main/java/io/dico/dicore/command/parameter/type/EnumParameterType.java') diff --git a/dicore3/command/src/main/java/io/dico/dicore/command/parameter/type/EnumParameterType.java b/dicore3/command/src/main/java/io/dico/dicore/command/parameter/type/EnumParameterType.java index c23e09b..063d381 100644 --- a/dicore3/command/src/main/java/io/dico/dicore/command/parameter/type/EnumParameterType.java +++ b/dicore3/command/src/main/java/io/dico/dicore/command/parameter/type/EnumParameterType.java @@ -1,46 +1,46 @@ -package io.dico.dicore.command.parameter.type; - -import io.dico.dicore.command.CommandException; -import io.dico.dicore.command.parameter.ArgumentBuffer; -import io.dico.dicore.command.parameter.Parameter; -import org.bukkit.Location; -import org.bukkit.command.CommandSender; - -import java.util.ArrayList; -import java.util.List; - -public class EnumParameterType extends SimpleParameterType { - private final E[] universe; - - public EnumParameterType(Class returnType) { - super(returnType); - universe = returnType.getEnumConstants(); - if (universe == null) { - throw new IllegalArgumentException("returnType must be an enum"); - } - } - - @Override - protected E parse(Parameter parameter, CommandSender sender, String input) throws CommandException { - for (E constant : universe) { - if (constant.name().equalsIgnoreCase(input)) { - return constant; - } - } - - throw CommandException.invalidArgument(parameter.getName(), "the enum value does not exist"); - } - - @Override - public List complete(Parameter parameter, CommandSender sender, Location location, ArgumentBuffer buffer) { - String input = buffer.next().toUpperCase(); - List result = new ArrayList<>(); - for (E constant : universe) { - if (constant.name().toUpperCase().startsWith(input.toUpperCase())) { - result.add(constant.name().toLowerCase()); - } - } - return result; - } - -} +package io.dico.dicore.command.parameter.type; + +import io.dico.dicore.command.CommandException; +import io.dico.dicore.command.parameter.ArgumentBuffer; +import io.dico.dicore.command.parameter.Parameter; +import org.bukkit.Location; +import org.bukkit.command.CommandSender; + +import java.util.ArrayList; +import java.util.List; + +public class EnumParameterType extends SimpleParameterType { + private final E[] universe; + + public EnumParameterType(Class returnType) { + super(returnType); + universe = returnType.getEnumConstants(); + if (universe == null) { + throw new IllegalArgumentException("returnType must be an enum"); + } + } + + @Override + protected E parse(Parameter parameter, CommandSender sender, String input) throws CommandException { + for (E constant : universe) { + if (constant.name().equalsIgnoreCase(input)) { + return constant; + } + } + + throw CommandException.invalidArgument(parameter.getName(), "the enum value does not exist"); + } + + @Override + public List complete(Parameter parameter, CommandSender sender, Location location, ArgumentBuffer buffer) { + String input = buffer.next().toUpperCase(); + List result = new ArrayList<>(); + for (E constant : universe) { + if (constant.name().toUpperCase().startsWith(input.toUpperCase())) { + result.add(constant.name().toLowerCase()); + } + } + return result; + } + +} -- cgit v1.2.3