From 99bc0a0756c8677444d9b6e962fe5371d1d65a97 Mon Sep 17 00:00:00 2001 From: LoJoSho Date: Thu, 2 Feb 2023 21:30:07 -0600 Subject: [PATCH] Add color to apply command --- .../hmccosmetics/command/CosmeticCommand.java | 7 ++++++- .../command/CosmeticCommandTabComplete.java | 11 ++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java index cd3e3cea..3645ea61 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommand.java @@ -87,12 +87,17 @@ public class CosmeticCommand implements CommandExecutor { return true; } Cosmetic cosmetic; + Color color = Color.WHITE; if (sender instanceof Player) player = ((Player) sender).getPlayer(); if (sender.hasPermission("hmccosmetics.cmd.apply.other")) { if (args.length >= 3) player = Bukkit.getPlayer(args[2]); } + if (sender.hasPermission("hmccosmetics.cmd.apply.color")) { + if (args.length >= 4) color = ServerUtils.hex2Rgb(args[3]); + } + if (args.length == 1) { if (!silent) MessagesUtil.sendMessage(player, "not-enough-args"); return true; @@ -124,7 +129,7 @@ public class CosmeticCommand implements CommandExecutor { if (!silent) MessagesUtil.sendMessage(player, "equip-cosmetic", placeholders); - user.addPlayerCosmetic(cosmetic); + user.addPlayerCosmetic(cosmetic, color); user.updateCosmetic(cosmetic.getSlot()); return true; } diff --git a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommandTabComplete.java b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommandTabComplete.java index b112fa8b..6acb56d5 100644 --- a/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommandTabComplete.java +++ b/common/src/main/java/com/hibiscusmc/hmccosmetics/command/CosmeticCommandTabComplete.java @@ -91,11 +91,20 @@ public class CosmeticCommandTabComplete implements TabCompleter { completions.add(player.getName()); } } - } StringUtil.copyPartialMatches(args[2], completions, finalCompletitons); } + if (args.length == 4) { + String subcommand = args[0].toLowerCase(); + switch (subcommand) { + case "apply" -> { + completions.add("#FFFFFF"); + } + } + StringUtil.copyPartialMatches(args[3], completions, finalCompletitons); + } + Collections.sort(finalCompletitons); return finalCompletitons; }