summaryrefslogtreecommitdiff
path: root/src/main/java/net/uomc/mineshaft/resources/commands/SetPrimaryResourceCommand.java
diff options
context:
space:
mode:
authordavidovski <david@davidovski.xyz>2025-10-11 04:55:51 +0100
committerdavidovski <david@davidovski.xyz>2025-10-11 04:55:51 +0100
commit10b327e9f6441a8863227ce3e075a5a587654065 (patch)
tree5e94ecc91290febacf5181d3596563a7a24bd010 /src/main/java/net/uomc/mineshaft/resources/commands/SetPrimaryResourceCommand.java
v0.3.1
Diffstat (limited to 'src/main/java/net/uomc/mineshaft/resources/commands/SetPrimaryResourceCommand.java')
-rw-r--r--src/main/java/net/uomc/mineshaft/resources/commands/SetPrimaryResourceCommand.java47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/main/java/net/uomc/mineshaft/resources/commands/SetPrimaryResourceCommand.java b/src/main/java/net/uomc/mineshaft/resources/commands/SetPrimaryResourceCommand.java
new file mode 100644
index 0000000..6515d06
--- /dev/null
+++ b/src/main/java/net/uomc/mineshaft/resources/commands/SetPrimaryResourceCommand.java
@@ -0,0 +1,47 @@
+package net.uomc.mineshaft.resources.commands;
+
+import com.mouldycheerio.dbot.CustomBot;
+import com.mouldycheerio.dbot.commands.CommandDetails;
+import com.mouldycheerio.dbot.util.PeelingUtils;
+
+import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
+import net.uomc.mineshaft.resources.Resource;
+import net.uomc.mineshaft.resources.ResourceManager;
+
+public class SetPrimaryResourceCommand extends ResourceCommand {
+
+ public SetPrimaryResourceCommand(ResourceManager resourceManager) {
+ super(resourceManager);
+ setCommandDetails(CommandDetails.hidden("setPrimaryItem"));
+ }
+
+ @Override
+ public void execute(MessageReceivedEvent e, CustomBot op, String[] args) {
+ String ownerid = op.getConfig().getString("ownerid");
+ if (ownerid.equals(e.getAuthor().getId())) {
+ if (args.length > 0) {
+ Resource resource = getResourceManager().getResource(args[0]);
+ if (resource != null) {
+ PeelingUtils.askQuestion(e, "This will reset all users balance for this item, type `confirm` to continue", r -> {
+ if (r.equals("confirm")) {
+ getResourceManager().setPrimaryResource(resource.getName());
+
+ e.getGuild().loadMembers().onSuccess(members -> {
+ members.forEach(m -> getResourceManager().getPrimaryResource().set(m, 0));
+ });
+
+ op.sendMessage(e, "primary item", "Set **" + resource.getName() + "** to the primary item");
+ }
+ });
+ } else {
+ op.sendErrorMessage(e, "This item was not found");
+ }
+ } else {
+ op.sendMessage(e, "primary resource", "This will be the default item that will be used for trading\nUsage: `.setPrimaryResource [item name]`");
+ }
+ } else {
+ op.sendErrorMessage(e, ":x: this command is not intended for you");
+ }
+ }
+
+}