Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TrashCommand to manage player inventory disposal #70

Merged
merged 1 commit into from
Jan 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading