From 1565fab35da934243bd279d12369eacac56f6d24 Mon Sep 17 00:00:00 2001 From: Zeanon Date: Thu, 1 Apr 2021 23:45:10 +0200 Subject: [PATCH] added tab completion for bau toggle commands --- .../bausystem/commands/CommandBau.java | 38 ++++++++++++++++--- 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java index c34e4d4..43c92f3 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/commands/CommandBau.java @@ -22,8 +22,13 @@ package de.steamwar.bausystem.commands; import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.world.Welt; import de.steamwar.command.SWCommand; +import de.steamwar.command.SWCommandUtils; +import de.steamwar.command.TypeMapper; +import de.steamwar.comms.handlers.BungeeHandler; import de.steamwar.sql.BauweltMember; import de.steamwar.sql.SteamwarUser; +import java.util.stream.Collectors; +import org.bukkit.Bukkit; import org.bukkit.entity.Player; public class CommandBau extends SWCommand { @@ -45,21 +50,21 @@ public class CommandBau extends SWCommand { } @Register("togglebuild") - public void toggleBuildCommand(Player p, String arg) { + public void toggleBuildCommand(Player p, LocalPlayer arg) { if (!permissionCheck(p)) return; - onToggleBD(p, arg); + onToggleBD(p, arg.getName()); } @Register("togglewe") - public void toggleWECommand(Player p, String arg) { + public void toggleWECommand(Player p, LocalPlayer arg) { if (!permissionCheck(p)) return; - onToggleWE(p, arg); + onToggleWE(p, arg.getName()); } @Register("toggleworld") - public void toggleWorldCommand(Player p, String arg) { + public void toggleWorldCommand(Player p, LocalPlayer arg) { if (!permissionCheck(p)) return; - onToggleWorld(p, arg); + onToggleWorld(p, arg.getName()); } @@ -116,4 +121,25 @@ public class CommandBau extends SWCommand { return true; } } + + + @ClassMapper(value = LocalPlayer.class, local = true) + private TypeMapper mapCommandConfirmation() { + return SWCommandUtils.createMapper(LocalPlayer::new, + s -> Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList())); + } + + + public class LocalPlayer { + + private String name; + + public LocalPlayer(String name) { + this.name = name; + } + + public String getName() { + return name; + } + } } \ No newline at end of file