diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index 79b8d16..0f2bb22 100644 --- a/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -47,9 +47,9 @@ import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*; public class SchematicCommand extends SWCommand { - Map> searchMapper = new HashMap<>(); + private static final Map> searchMapper = new HashMap<>(); - { + static { searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new))); searchMapper.put("-owner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s))); Class clazz = Material.class; @@ -278,10 +278,19 @@ public class SchematicCommand extends SWCommand { int finalI = i; switch (current) { case "-type": - predicates.add(node -> node.getSchemtype().name().equals(query[finalI + 1])); + predicates.add(node -> node.getSchemtype().name().equalsIgnoreCase(query[finalI + 1])); break; case "-item": - predicates.add(node -> node.getItem().equals(query[finalI + 1])); + predicates.add(node -> node.getItem().equalsIgnoreCase(query[finalI + 1])); + break; + case "-owner": + try { + SteamwarUser steamwarUser = SteamwarUser.get(query[finalI + 1]); + predicates.add(node -> node.getOwner() == steamwarUser.getId()); + } catch (Exception e) { + player.sendMessage(SchematicSystem.PREFIX + "§cDer Spieler §e" + query[finalI + 1] + " §cexistiert nicht"); + return; + } } i++; } @@ -650,6 +659,9 @@ public class SchematicCommand extends SWCommand { @Override public List tabCompletes(CommandSender commandSender, String[] strings, String s) { + if (strings.length == 0) { + return Collections.singletonList(s); + } String last = strings[strings.length - 1]; if (searchMapper.containsKey(last)) { TypeMapper mapper = searchMapper.get(last);