9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-28 11:29:18 +00:00

Initial Commit

This commit is contained in:
LoJoSho
2022-11-06 10:21:01 -06:00
commit a2421cb6eb
53 changed files with 4072 additions and 0 deletions

View File

@@ -0,0 +1,58 @@
package com.hibiscusmc.hmccosmetics.command;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class CosmeticCommandTabComplete implements TabCompleter {
@Nullable
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command, @NotNull String alias, @NotNull String[] args) {
List<String> completions = new ArrayList<>();
if (args.length == 1) {
completions.add("apply");
completions.add("wardrobe");
completions.add("unapply");
completions.add("menu");
completions.add("reload");
}
if (args.length >= 2) {
if (args[0].equalsIgnoreCase("apply") || args[0].equalsIgnoreCase("unapply")) {
completions.addAll(applyCommandComplete(args));
} else if (args[0].equalsIgnoreCase("menu")) {
completions.addAll(Menus.getMenuNames());
}
}
Collections.sort(completions);
return completions;
}
private static List<String> applyCommandComplete(String[] args) {
List<String> completitions = new ArrayList<>();
if (args.length == 2) {
completitions.addAll(Cosmetics.keys());
} else {
if (args.length == 3) {
for (Player player : Bukkit.getOnlinePlayers()) {
completitions.add(player.getName());
}
}
}
return completitions;
}
}