9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-30 04:19:28 +00:00

cosmetic unapply now handles with slots

This commit is contained in:
LoJoSho
2022-11-30 11:55:08 -06:00
parent ceea1c24bd
commit 4a0c8489c2
2 changed files with 13 additions and 7 deletions

View File

@@ -54,23 +54,22 @@ public class CosmeticCommand implements CommandExecutor {
}
if (args[0].equalsIgnoreCase("unapply")) {
Player player = null;
Cosmetic cosmetic;
CosmeticSlot cosmeticSlot;
if (sender instanceof Player) player = ((Player) sender).getPlayer();
if (args.length >= 3) player = Bukkit.getPlayer(args[2]);
cosmetic = Cosmetics.getCosmetic(args[1]);
cosmeticSlot = CosmeticSlot.valueOf(args[1]);
if (player == null || cosmetic == null) {
if (player == null || cosmeticSlot == null) {
sender.sendMessage("Something was null");
return true;
}
CosmeticUser user = CosmeticUsers.getUser(player);
CosmeticSlot slot = cosmetic.getSlot();
user.removeCosmeticSlot(cosmetic);
user.updateCosmetic(slot);
user.removeCosmeticSlot(cosmeticSlot);
user.updateCosmetic(cosmeticSlot);
return true;
}
if (args[0].equalsIgnoreCase("wardrobe")) {

View File

@@ -1,7 +1,9 @@
package com.hibiscusmc.hmccosmetics.command;
import com.hibiscusmc.hmccosmetics.cosmetic.CosmeticSlot;
import com.hibiscusmc.hmccosmetics.cosmetic.Cosmetics;
import com.hibiscusmc.hmccosmetics.gui.Menus;
import com.hibiscusmc.hmccosmetics.user.CosmeticUser;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@@ -29,9 +31,14 @@ public class CosmeticCommandTabComplete implements TabCompleter {
completions.add("dataclear");
}
// This needs to be redone.
if (args.length >= 2) {
if (args[0].equalsIgnoreCase("apply") || args[0].equalsIgnoreCase("unapply")) {
if (args[0].equalsIgnoreCase("apply")) {
completions.addAll(applyCommandComplete(args));
} else if (args[0].equalsIgnoreCase("unapply")) {
for (CosmeticSlot slot : CosmeticSlot.values()) {
completions.add(slot.name());
}
} else if (args[0].equalsIgnoreCase("menu")) {
completions.addAll(Menus.getMenuNames());
} else if (args[0].equalsIgnoreCase("dataclear")) {