|
| 1 | +package net.swofty.type.skyblockgeneric.commands; |
| 2 | + |
| 3 | +import net.kyori.adventure.text.Component; |
| 4 | +import net.kyori.adventure.text.event.ClickEvent; |
| 5 | +import net.minestom.server.command.builder.arguments.ArgumentWord; |
| 6 | +import net.swofty.type.generic.command.CommandParameters; |
| 7 | +import net.swofty.type.generic.command.HypixelCommand; |
| 8 | +import net.swofty.type.generic.user.categories.Rank; |
| 9 | +import net.swofty.type.skyblockgeneric.data.datapoints.DatapointStash; |
| 10 | +import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer; |
| 11 | + |
| 12 | +@CommandParameters(aliases = "clearstash", |
| 13 | + description = "Clear your stash", |
| 14 | + usage = "/clearstash", |
| 15 | + permission = Rank.DEFAULT, |
| 16 | + allowsConsole = false) |
| 17 | +public class ClearStashCommand extends HypixelCommand { |
| 18 | + @Override |
| 19 | + public void registerUsage(MinestomCommand command) { |
| 20 | + ArgumentWord confirmArg = new ArgumentWord("confirm").from("confirm"); |
| 21 | + |
| 22 | + // No args - show confirmation message |
| 23 | + command.addSyntax((sender, context) -> { |
| 24 | + if (!permissionCheck(sender)) return; |
| 25 | + |
| 26 | + SkyBlockPlayer player = (SkyBlockPlayer) sender; |
| 27 | + DatapointStash.PlayerStash stash = player.getStash(); |
| 28 | + |
| 29 | + if (stash.isEmpty()) { |
| 30 | + player.sendMessage("§cYour stash is already empty!"); |
| 31 | + return; |
| 32 | + } |
| 33 | + |
| 34 | + int totalItems = stash.getItemStashCount() + stash.getMaterialStashCount(); |
| 35 | + |
| 36 | + player.sendMessage("§cWARNING: This action is irreversible and deletes all " + |
| 37 | + totalItems + " stashed items. If you still wish to continue, click below."); |
| 38 | + player.sendMessage(Component.text("§eCLEAR STASH YES I AM SURE") |
| 39 | + .clickEvent(ClickEvent.runCommand("/clearstash confirm"))); |
| 40 | + }); |
| 41 | + |
| 42 | + // With confirm argument - actually clear |
| 43 | + command.addSyntax((sender, context) -> { |
| 44 | + if (!permissionCheck(sender)) return; |
| 45 | + |
| 46 | + SkyBlockPlayer player = (SkyBlockPlayer) sender; |
| 47 | + DatapointStash.PlayerStash stash = player.getStash(); |
| 48 | + |
| 49 | + if (stash.isEmpty()) { |
| 50 | + player.sendMessage("§cYour stash is already empty!"); |
| 51 | + return; |
| 52 | + } |
| 53 | + |
| 54 | + stash.clear(); |
| 55 | + player.sendMessage("§aYour stash has been cleared!"); |
| 56 | + }, confirmArg); |
| 57 | + } |
| 58 | +} |
0 commit comments