summaryrefslogtreecommitdiff
path: root/src/main/java/net/uomc/mineshaft/resources/commands/ValuesCommand.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/net/uomc/mineshaft/resources/commands/ValuesCommand.java')
-rw-r--r--src/main/java/net/uomc/mineshaft/resources/commands/ValuesCommand.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/main/java/net/uomc/mineshaft/resources/commands/ValuesCommand.java b/src/main/java/net/uomc/mineshaft/resources/commands/ValuesCommand.java
new file mode 100644
index 0000000..c094d83
--- /dev/null
+++ b/src/main/java/net/uomc/mineshaft/resources/commands/ValuesCommand.java
@@ -0,0 +1,45 @@
+package net.uomc.mineshaft.resources.commands;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import com.mouldycheerio.dbot.CustomBot;
+import com.mouldycheerio.dbot.commands.CommandDetails;
+import com.mouldycheerio.dbot.commands.CommandFail;
+
+import net.dv8tion.jda.api.events.message.MessageReceivedEvent;
+import net.uomc.mineshaft.resources.Resource;
+import net.uomc.mineshaft.resources.ResourceManager;
+
+public class ValuesCommand extends ResourceCommand {
+
+ public ValuesCommand(ResourceManager resourceManager) {
+ super(resourceManager);
+ setCommandDetails(CommandDetails.from("marketValue,values,prices", "Show estimated market values of all the items"));
+ }
+
+ @Override
+ public void execute(MessageReceivedEvent e, CustomBot b, String[] args) throws CommandFail {
+ long total = getResourceManager().getPrimaryResource().total();
+
+ List<Resource> resources = new ArrayList<Resource>(getResourceManager().getResources());
+ Collections.sort(resources, (r1, r2) -> Long.compare(r2.getValue(),r1.getValue()));
+
+ StringBuilder stringBuilder = new StringBuilder();
+ resources.forEach((r) -> {
+ long v = r.getValue();
+ stringBuilder.append("**1** " + r.getName() + r.getSymbol() + " : ");
+ if (v < 0) {
+ stringBuilder.append("**???**");
+ } else {
+ stringBuilder.append("**" + getResourceManager().getPrimaryResource().prettyValue(v) + "**");
+ }
+ stringBuilder.append("\n");
+ });
+
+ b.sendMessage(e, "Estimated Market Values", stringBuilder.toString());
+ }
+
+
+}