|
| 1 | +package net.thenextlvl.tweaks.command.player; |
| 2 | + |
| 3 | +import com.mojang.brigadier.Command; |
| 4 | +import com.mojang.brigadier.context.CommandContext; |
| 5 | +import io.papermc.paper.command.brigadier.CommandSourceStack; |
| 6 | +import io.papermc.paper.command.brigadier.Commands; |
| 7 | +import lombok.RequiredArgsConstructor; |
| 8 | +import net.thenextlvl.tweaks.TweaksPlugin; |
| 9 | +import org.bukkit.entity.Player; |
| 10 | +import org.bukkit.inventory.MenuType; |
| 11 | +import org.jspecify.annotations.NullMarked; |
| 12 | + |
| 13 | +@NullMarked |
| 14 | +@RequiredArgsConstructor |
| 15 | +@SuppressWarnings("UnstableApiUsage") |
| 16 | +public class TrashCommand { |
| 17 | + private final TweaksPlugin plugin; |
| 18 | + |
| 19 | + public void register(Commands registrar) { |
| 20 | + var command = Commands.literal(plugin.commands().trash().command()) |
| 21 | + .requires(stack -> stack.getSender() instanceof Player player |
| 22 | + && player.hasPermission("tweaks.command.trash")) |
| 23 | + .executes(this::trash) |
| 24 | + .build(); |
| 25 | + registrar.register(command, "Dispose of your unwanted items", plugin.commands().hat().aliases()); |
| 26 | + } |
| 27 | + |
| 28 | + private int trash(CommandContext<CommandSourceStack> context) { |
| 29 | + var player = (Player) context.getSource().getSender(); |
| 30 | + player.openInventory(MenuType.GENERIC_9X4.create(player, |
| 31 | + plugin.bundle().component(player, "gui.title.trash") |
| 32 | + )); |
| 33 | + return Command.SINGLE_SUCCESS; |
| 34 | + } |
| 35 | +} |
0 commit comments