Skip to content

Commit

Permalink
Merge pull request #70 from TheNextLvl-net/trash-command
Browse files Browse the repository at this point in the history
Add TrashCommand to manage player inventory disposal
  • Loading branch information
NonSwag authored Jan 8, 2025
2 parents ab6f95d + a6d144a commit e72b892
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 0 deletions.
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ paper {
"tweaks.command.seen",
"tweaks.command.speed",
"tweaks.command.suicide",
"tweaks.command.trash",
"tweaks.command.vanish"
)
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/net/thenextlvl/tweaks/TweaksPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ private void registerPlayerCommands(Commands registrar) {
if (commands().seen().enabled()) new SeenCommand(this).register(registrar);
if (commands().speed().enabled()) new SpeedCommand(this).register(registrar);
if (commands().suicide().enabled()) new SuicideCommand(this).register(registrar);
if (commands().trash().enabled()) new TrashCommand(this).register(registrar);
if (commands().vanish().enabled()) new VanishCommand(this).register(registrar);
}

Expand Down
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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public class CommandConfig {
private @SerializedName("seen") CommandDefinition seen = new CommandDefinition("seen", "find");
private @SerializedName("speed") CommandDefinition speed = new CommandDefinition("speed");
private @SerializedName("suicide") CommandDefinition suicide = new CommandDefinition("suicide");
private @SerializedName("trash") CommandDefinition trash = new CommandDefinition("trash", "dispose", "garbage");
private @SerializedName("vanish") CommandDefinition vanish = new CommandDefinition("vanish", "v", "invisible");

private @SerializedName("broadcast") CommandDefinition broadcast = new CommandDefinition("broadcast", "bc");
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/tweaks.properties
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ gui.placeholder.helmet=<dark_gray>»</dark_gray> <green>Helmet</green>
gui.placeholder.leggings=<dark_gray>»</dark_gray> <green>Leggings</green>
gui.placeholder.off-hand=<dark_gray>»</dark_gray> <aqua>Off Hand</aqua>
gui.title.homes=Your Homes
gui.title.trash=Trash
gui.title.warps=Warps
nothing.changed=<red><prefix> Nothing could be changed</red>
player.connected=<gray><prefix> <click:suggest_command:'/tell <player> '><green><chat_display_name></green></click> joined the game</gray>
Expand Down

0 comments on commit e72b892

Please sign in to comment.