Skip to content

Commit e72b892

Browse files
authored
Merge pull request #70 from TheNextLvl-net/trash-command
Add TrashCommand to manage player inventory disposal
2 parents ab6f95d + a6d144a commit e72b892

File tree

5 files changed

+39
-0
lines changed

5 files changed

+39
-0
lines changed

Diff for: build.gradle.kts

+1
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,7 @@ paper {
210210
"tweaks.command.seen",
211211
"tweaks.command.speed",
212212
"tweaks.command.suicide",
213+
"tweaks.command.trash",
213214
"tweaks.command.vanish"
214215
)
215216
}

Diff for: src/main/java/net/thenextlvl/tweaks/TweaksPlugin.java

+1
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ private void registerPlayerCommands(Commands registrar) {
181181
if (commands().seen().enabled()) new SeenCommand(this).register(registrar);
182182
if (commands().speed().enabled()) new SpeedCommand(this).register(registrar);
183183
if (commands().suicide().enabled()) new SuicideCommand(this).register(registrar);
184+
if (commands().trash().enabled()) new TrashCommand(this).register(registrar);
184185
if (commands().vanish().enabled()) new VanishCommand(this).register(registrar);
185186
}
186187

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
}

Diff for: src/main/java/net/thenextlvl/tweaks/model/CommandConfig.java

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ public class CommandConfig {
5656
private @SerializedName("seen") CommandDefinition seen = new CommandDefinition("seen", "find");
5757
private @SerializedName("speed") CommandDefinition speed = new CommandDefinition("speed");
5858
private @SerializedName("suicide") CommandDefinition suicide = new CommandDefinition("suicide");
59+
private @SerializedName("trash") CommandDefinition trash = new CommandDefinition("trash", "dispose", "garbage");
5960
private @SerializedName("vanish") CommandDefinition vanish = new CommandDefinition("vanish", "v", "invisible");
6061

6162
private @SerializedName("broadcast") CommandDefinition broadcast = new CommandDefinition("broadcast", "bc");

Diff for: src/main/resources/tweaks.properties

+1
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ gui.placeholder.helmet=<dark_gray>»</dark_gray> <green>Helmet</green>
136136
gui.placeholder.leggings=<dark_gray>»</dark_gray> <green>Leggings</green>
137137
gui.placeholder.off-hand=<dark_gray>»</dark_gray> <aqua>Off Hand</aqua>
138138
gui.title.homes=Your Homes
139+
gui.title.trash=Trash
139140
gui.title.warps=Warps
140141
nothing.changed=<red><prefix> Nothing could be changed</red>
141142
player.connected=<gray><prefix> <click:suggest_command:'/tell <player> '><green><chat_display_name></green></click> joined the game</gray>

0 commit comments

Comments
 (0)