diff options
Diffstat (limited to 'src/main/java/net/uomc/mineshaft/resources/commands/CreateResourceCommand.java')
| -rw-r--r-- | src/main/java/net/uomc/mineshaft/resources/commands/CreateResourceCommand.java | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/main/java/net/uomc/mineshaft/resources/commands/CreateResourceCommand.java b/src/main/java/net/uomc/mineshaft/resources/commands/CreateResourceCommand.java new file mode 100644 index 0000000..a9f0dc6 --- /dev/null +++ b/src/main/java/net/uomc/mineshaft/resources/commands/CreateResourceCommand.java @@ -0,0 +1,44 @@ +package net.uomc.mineshaft.resources.commands; + +import java.util.ArrayList; +import java.util.List; + +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 CreateResourceCommand extends ResourceCommand { + private List<String> questions; + + public CreateResourceCommand(ResourceManager resourceManager) { + super(resourceManager); + setCommandDetails(CommandDetails.hidden("createItem")); + + questions = new ArrayList<String>(); + questions.add("What is the name of this item?"); + questions.add("What is the symbol for this item?"); + } + + @Override + public void execute(MessageReceivedEvent e, CustomBot op, String[] args) { + String ownerid = op.getConfig().getString("ownerid"); + if (ownerid.equals(e.getAuthor().getId())) { + PeelingUtils.askQuestions(e, questions, (responses) -> { + String name = responses.get(0); + String symbol = responses.get(1); + + Resource resource = new Resource(name, symbol, 1, getResourceManager()); + getResourceManager().addResource(resource); + + op.sendMessage(e, "Items", ":white_check_mark: added **" + name + "** to the list of items"); + }); + } else { + op.sendErrorMessage(e, ":x: this command is not intended for you"); + } + } + +} |
