From 3fa36c3442a7cdfab6d9cb9bfdb0271925b98364 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Mon, 27 Dec 2021 14:12:02 +0100 Subject: [PATCH] Update SkullCommand Signed-off-by: yoyosource --- BauSystem_Main/src/BauSystem.properties | 3 ++ .../bausystem/features/util/SkullCommand.java | 34 ++++++++++++++----- 2 files changed, 28 insertions(+), 9 deletions(-) diff --git a/BauSystem_Main/src/BauSystem.properties b/BauSystem_Main/src/BauSystem.properties index 35e540f0..4ad139fb 100644 --- a/BauSystem_Main/src/BauSystem.properties +++ b/BauSystem_Main/src/BauSystem.properties @@ -1053,6 +1053,9 @@ PANZERN_PROGRESS = §e{0} §7Blöcke übrig, §e{1} §7Blöcke pro Sekunde, §e{ PANZERN_DONE = §aZuende gepanzert # UTILS +SKULL_HELP = §8/§eskull §8[§eSpieler§8] §8-§7 Gibt einen SpielerKopf +SKULL_ITEM = §e{0}§8s Kopf + SPEED_HELP = §8/§espeed §8[§71§8-§710§8|§edefault§8] §8-§7 Setzte deine Flug- und Laufgeschindigkeit. SPEED_CURRENT = §7Aktuelle geschwindigkeit§8: §e{0} SPEED_TOO_SMALL = §c{0} ist zu klein diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java index 3cbbebfb..9fb358ca 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/util/SkullCommand.java @@ -19,16 +19,22 @@ package de.steamwar.bausystem.features.util; +import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.SWUtils; -import de.steamwar.bausystem.config.ColorConfig; import de.steamwar.bausystem.linkage.LinkageType; import de.steamwar.bausystem.linkage.Linked; import de.steamwar.command.SWCommand; +import de.steamwar.command.TypeMapper; import de.steamwar.inventory.SWItem; +import org.bukkit.Bukkit; +import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.SkullMeta; +import java.util.List; +import java.util.stream.Collectors; + @Linked(LinkageType.COMMAND) public class SkullCommand extends SWCommand { @@ -36,18 +42,28 @@ public class SkullCommand extends SWCommand { super("skull", "head"); } - @Register(help = true) - public void genericHelp(Player p, String... args) { - p.sendMessage(ColorConfig.OTHER + "/" + ColorConfig.HIGHLIGHT + "skull " + ColorConfig.OTHER + "[" + ColorConfig.HIGHLIGHT + "Spieler" + ColorConfig.OTHER + "] - " + ColorConfig.BASE + "Gibt einen SpielerKopf"); - } - - @Register - public void giveCommand(Player p, String skull) { + @Register(description = "SKULL_HELP") + public void giveCommand(Player p, @Mapper("player") String skull) { ItemStack is = SWItem.getPlayerSkull(skull).getItemStack(); SkullMeta sm = (SkullMeta) is.getItemMeta(); assert sm != null; - sm.setDisplayName(ColorConfig.HIGHLIGHT + skull + ColorConfig.OTHER + "s Kopf"); + sm.setDisplayName(BauSystem.MESSAGE.parse("SKULL_ITEM", p, skull)); is.setItemMeta(sm); SWUtils.giveItemToPlayer(p, is); } + + @Mapper(value = "player", local = true) + public TypeMapper typeMapper() { + return new TypeMapper() { + @Override + public String map(CommandSender commandSender, String[] previousArguments, String s) { + return s; + } + + @Override + public List tabCompletes(CommandSender commandSender, String[] strings, String s) { + return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList()); + } + }; + } } \ No newline at end of file