Skip to content

Commit

Permalink
Add PayCommand to support player-to-player payments
Browse files Browse the repository at this point in the history
This commit introduces the PayCommand class, enabling the functionality for players to send payments to each other. The command requires appropriate permissions and is registered using the plugin's lifecycle manager upon initialization.
  • Loading branch information
NonSwag committed Sep 2, 2024
1 parent 41d760b commit 22a0a2d
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/main/java/net/thenextlvl/economist/command/PayCommand.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package net.thenextlvl.economist.command;

import io.papermc.paper.command.brigadier.Commands;
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import lombok.RequiredArgsConstructor;
import net.thenextlvl.economist.EconomistPlugin;

@RequiredArgsConstructor
@SuppressWarnings("UnstableApiUsage")
public class PayCommand {
private final EconomistPlugin plugin;

public void register() {
var command = Commands.literal("pay")
.requires(stack -> stack.getSender().hasPermission("economist.pay"))
.build();
plugin.getLifecycleManager().registerEventHandler(LifecycleEvents.COMMANDS.newHandler(event ->
event.registrar().register(command, "Pay another player")));
}
}

0 comments on commit 22a0a2d

Please sign in to comment.