-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #70 from TheNextLvl-net/trash-command
Add TrashCommand to manage player inventory disposal
- Loading branch information
Showing
5 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/main/java/net/thenextlvl/tweaks/command/player/TrashCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package net.thenextlvl.tweaks.command.player; | ||
|
||
import com.mojang.brigadier.Command; | ||
import com.mojang.brigadier.context.CommandContext; | ||
import io.papermc.paper.command.brigadier.CommandSourceStack; | ||
import io.papermc.paper.command.brigadier.Commands; | ||
import lombok.RequiredArgsConstructor; | ||
import net.thenextlvl.tweaks.TweaksPlugin; | ||
import org.bukkit.entity.Player; | ||
import org.bukkit.inventory.MenuType; | ||
import org.jspecify.annotations.NullMarked; | ||
|
||
@NullMarked | ||
@RequiredArgsConstructor | ||
@SuppressWarnings("UnstableApiUsage") | ||
public class TrashCommand { | ||
private final TweaksPlugin plugin; | ||
|
||
public void register(Commands registrar) { | ||
var command = Commands.literal(plugin.commands().trash().command()) | ||
.requires(stack -> stack.getSender() instanceof Player player | ||
&& player.hasPermission("tweaks.command.trash")) | ||
.executes(this::trash) | ||
.build(); | ||
registrar.register(command, "Dispose of your unwanted items", plugin.commands().hat().aliases()); | ||
} | ||
|
||
private int trash(CommandContext<CommandSourceStack> context) { | ||
var player = (Player) context.getSource().getSender(); | ||
player.openInventory(MenuType.GENERIC_9X4.create(player, | ||
plugin.bundle().component(player, "gui.title.trash") | ||
)); | ||
return Command.SINGLE_SUCCESS; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters