SteamWar/SpigotCore
Archiviert
13
0

Optimize Argument.GAMEMODE

Dieser Commit ist enthalten in:
jojo 2020-12-30 13:39:05 +01:00
Ursprung cac4cd26e0
Commit 8d86ee4f16
2 geänderte Dateien mit 6 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -50,22 +50,14 @@ public class Argument<T> {
public static final Argument<Player> PLAYER = new Argument<>(Bukkit::getPlayer, Objects::nonNull, () -> Bukkit.getOnlinePlayers().stream().map(Player::getName).toArray(String[]::new));
public static final Argument<GameMode> GAMEMODE = new Argument<>(s -> {
switch (s) {
case "creative":
case "c":
case "1":
switch (s.toLowerCase()) {
case "creative": case "c": case "1":
return GameMode.CREATIVE;
case "survival":
case "s":
case "0":
case "survival": case "s": case "0":
return GameMode.SURVIVAL;
case "spectator":
case "sp":
case "3":
case "spectator": case "sp": case "3":
return GameMode.SPECTATOR;
case "adventure":
case "a":
case "2":
case "adventure": case "a": case "2":
return GameMode.ADVENTURE;
}
return null;
@ -107,9 +99,7 @@ public class Argument<T> {
public Optional<?> valueSupplier(String s) {
try {
T argumentMapped = mapper.apply(s);
if (constraint.test(argumentMapped)) {
return Optional.ofNullable(argumentMapped);
}
if (constraint.test(argumentMapped)) return Optional.ofNullable(argumentMapped);
} catch (NumberFormatException e) {
return Optional.empty();
} catch (Exception e) {

Datei anzeigen

@ -22,7 +22,6 @@ package de.steamwar.command;
import java.util.Arrays;
import java.util.function.BiPredicate;
import java.util.function.Function;
import java.util.function.Predicate;
public class ArgumentUtils {