From 050fcafc7183c0787efee076c59d2e72be28336d Mon Sep 17 00:00:00 2001 From: yoyosource Date: Fri, 12 Mar 2021 10:57:23 +0100 Subject: [PATCH] Fix Argument --- .../src/de/steamwar/command/Argument.java | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/SpigotCore_Main/src/de/steamwar/command/Argument.java b/SpigotCore_Main/src/de/steamwar/command/Argument.java index c04e9e2..635b868 100644 --- a/SpigotCore_Main/src/de/steamwar/command/Argument.java +++ b/SpigotCore_Main/src/de/steamwar/command/Argument.java @@ -20,7 +20,6 @@ package de.steamwar.command; -import de.steamwar.sql.Schematic; import de.steamwar.sql.SteamwarUser; import org.bukkit.Bukkit; import org.bukkit.GameMode; @@ -32,7 +31,6 @@ import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Predicate; import java.util.function.Supplier; -import java.util.logging.Level; import java.util.stream.Collectors; public class Argument { @@ -64,10 +62,6 @@ public class Argument { return null; }, Objects::nonNull, GameMode.class); public static final Argument USER = new Argument<>(SteamwarUser::get, Objects::nonNull, PLAYER.tabCompletes); - public static final Argument SCHEMATIC = new Argument<>((s, sender) -> { - if (sender instanceof Player) return Schematic.getSchemFromDB(s, ((Player) sender).getUniqueId()); - return null; - }, Objects::nonNull, s -> new String[]{""}); private BiFunction mapper; private Predicate constraint; @@ -100,7 +94,7 @@ public class Argument { T argumentMapped = mapper.apply(s, sender); if (constraint.test(argumentMapped)) return Optional.ofNullable(argumentMapped); } catch (Exception e) { - Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); + // Ignored } return Optional.empty(); } @@ -113,9 +107,12 @@ public class Argument { // Check number constraints if needed if (numbers.contains(argumentMapped.getClass()) && !constraint.test(argumentMapped)) return Optional.empty(); } + } catch (Exception e) { + // Ignored + } + try { return Optional.of(Arrays.stream(tabCompletes.apply(s)).filter(t -> t.startsWith(s)).collect(Collectors.toList())); } catch (Exception e) { - Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); return Optional.empty(); } }