Add a MaterialChoice constructor to accept Tag constants

By: Parker Hawke <hawkeboyz2@hotmail.com>
This commit is contained in:
Bukkit/Spigot 2019-04-25 16:40:38 -04:00
parent 1f963a1ee2
commit ed414d7d7c

View file

@ -8,6 +8,7 @@ import java.util.List;
import java.util.Objects;
import java.util.function.Predicate;
import org.bukkit.Material;
import org.bukkit.Tag;
import org.jetbrains.annotations.NotNull;
/**
@ -49,6 +50,17 @@ public interface RecipeChoice extends Predicate<ItemStack>, Cloneable {
this(Arrays.asList(choices));
}
/**
* Constructs a MaterialChoice with the current values of the specified
* tag.
*
* @param choices the tag
*/
public MaterialChoice(@NotNull Tag<Material> choices) {
Preconditions.checkArgument(choices != null, "choices");
this.choices = new ArrayList<>(choices.getValues());
}
public MaterialChoice(@NotNull List<Material> choices) {
Preconditions.checkArgument(choices != null, "choices");
Preconditions.checkArgument(!choices.isEmpty(), "Must have at least one choice");