Add Argument.GAMEMODE
Add Argument.MATERIAL
Dieser Commit ist enthalten in:
Ursprung
a65ce1c04d
Commit
52af8a71f5
@ -21,7 +21,10 @@
|
||||
|
||||
package de.steamwar.command;
|
||||
|
||||
import com.sk89q.worldedit.extent.world.SurvivalModeExtent;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.*;
|
||||
@ -38,8 +41,32 @@ public class Argument<T> {
|
||||
public static final Argument<Float> FLOAT = new Argument<>(ArgumentType.FLOAT, f -> true);
|
||||
public static final Argument<Double> DOUBLE = new Argument<>(ArgumentType.DOUBLE, d -> true);
|
||||
public static final Argument<String> STRING = new Argument<>(ArgumentType.STRING, string -> true);
|
||||
|
||||
public static final Argument<String> PLAYER = new Argument<>(ArgumentType.STRING, string -> Bukkit.getPlayer(string) == null, Bukkit::getPlayer, () -> Bukkit.getOnlinePlayers().stream().map(Player::getName).toArray(String[]::new));
|
||||
|
||||
public static final Argument<String> GAMEMODE = new Argument<>(ArgumentType.STRING,
|
||||
string -> string.equalsIgnoreCase("creative") ||
|
||||
string.equalsIgnoreCase("c") ||
|
||||
string.equalsIgnoreCase("1") ||
|
||||
string.equalsIgnoreCase("survival") ||
|
||||
string.equalsIgnoreCase("s") ||
|
||||
string.equalsIgnoreCase("0") ||
|
||||
string.equalsIgnoreCase("spectator") ||
|
||||
string.equalsIgnoreCase("sp") ||
|
||||
string.equalsIgnoreCase("3") ||
|
||||
string.equalsIgnoreCase("adventure") ||
|
||||
string.equalsIgnoreCase("a") ||
|
||||
string.equalsIgnoreCase("2"),
|
||||
s -> {
|
||||
if (s.equalsIgnoreCase("creative") || s.equalsIgnoreCase("c") || s.equalsIgnoreCase("1")) return GameMode.CREATIVE;
|
||||
if (s.equalsIgnoreCase("spectator") || s.equalsIgnoreCase("sp") || s.equalsIgnoreCase("3")) return GameMode.SPECTATOR;
|
||||
if (s.equalsIgnoreCase("adventure") || s.equalsIgnoreCase("a") || s.equalsIgnoreCase("2")) return GameMode.ADVENTURE;
|
||||
return GameMode.SURVIVAL;
|
||||
}, () -> new String[]{"creative", "survival", "adventure", "spectator"});
|
||||
|
||||
private static final String[] materialArray = Arrays.stream(Material.values()).map(Enum::name).toArray(String[]::new);
|
||||
public static final Argument<String> MATERIAL = new Argument<>(ArgumentType.STRING, string -> Material.valueOf(string) != null, Material::valueOf, () -> materialArray);
|
||||
|
||||
private ArgumentType<T> argumentType;
|
||||
private Predicate<T> constraint;
|
||||
private Supplier<String[]> tabCompletes;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren