diff options
| author | davidovski <david@davidovski.xyz> | 2025-10-11 04:55:51 +0100 |
|---|---|---|
| committer | davidovski <david@davidovski.xyz> | 2025-10-11 04:55:51 +0100 |
| commit | 10b327e9f6441a8863227ce3e075a5a587654065 (patch) | |
| tree | 5e94ecc91290febacf5181d3596563a7a24bd010 /src/main/java/net/uomc/mineshaft/resources/commands/ValuesCommand.java | |
v0.3.1
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.java | 45 |
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()); + } + + +} |
