9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-31 21:06:38 +00:00

Add color to apply command

This commit is contained in:
LoJoSho
2023-02-02 21:30:07 -06:00
parent e9afd6deb8
commit 99bc0a0756
2 changed files with 16 additions and 2 deletions

View File

@@ -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;
}

View File

@@ -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;
}