From 5a008748459e230de0e875afff59e3b92c7aca0c Mon Sep 17 00:00:00 2001 From: davidovski Date: Fri, 31 Oct 2025 17:49:48 +0000 Subject: Work on v0.6 --- src/main/java/net/uomc/mineshaft/Mineshaft.java | 62 +++++++++++++++++++++---- 1 file changed, 54 insertions(+), 8 deletions(-) (limited to 'src/main/java/net/uomc/mineshaft/Mineshaft.java') diff --git a/src/main/java/net/uomc/mineshaft/Mineshaft.java b/src/main/java/net/uomc/mineshaft/Mineshaft.java index 41e4ce4..f2cbe4a 100644 --- a/src/main/java/net/uomc/mineshaft/Mineshaft.java +++ b/src/main/java/net/uomc/mineshaft/Mineshaft.java @@ -1,8 +1,14 @@ package net.uomc.mineshaft; +import net.uomc.mineshaft.blacksmith.Armour; +import net.uomc.mineshaft.blacksmith.BlacksmithCommand; +import net.uomc.mineshaft.blacksmith.Pickaxe; +import net.uomc.mineshaft.blacksmith.Sword; +import net.uomc.mineshaft.blacksmith.Tools; import net.uomc.mineshaft.crafting.Crafting; import net.uomc.mineshaft.farm.CompostCommand; import net.uomc.mineshaft.farm.FarmCommand; +import net.uomc.mineshaft.farm.CampfireCommand; import net.uomc.mineshaft.farm.TradeCommand; import net.uomc.mineshaft.resources.Resource; import java.io.IOException; @@ -12,19 +18,17 @@ import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import java.util.concurrent.atomic.AtomicLong; +import java.util.Optional; import java.util.stream.Collectors; import javax.security.auth.login.LoginException; -import org.apache.commons.collections4.map.LinkedMap; import org.json.JSONException; import org.json.JSONObject; import com.mouldycheerio.dbot.CustomBot; import com.mouldycheerio.dbot.commands.AvatarCommand; import com.mouldycheerio.dbot.commands.CommandDetails; -import com.mouldycheerio.dbot.commands.DetailedCommand; import com.mouldycheerio.dbot.commands.ProfileCommand; import com.mouldycheerio.dbot.commands.ServerInfoCommand; import com.mouldycheerio.dbot.commands.cooldowns.CooldownCommand; @@ -33,7 +37,6 @@ import com.mouldycheerio.dbot.starboard.StarboardController; import com.mouldycheerio.dbot.util.PeelingUtils; import net.dv8tion.jda.api.entities.Member; -import net.dv8tion.jda.api.events.message.MessageReceivedEvent; import net.uomc.mineshaft.resources.ResourceManager; import net.uomc.mineshaft.resources.market.MarketCommand; @@ -42,7 +45,8 @@ public class Mineshaft extends CustomBot { private StarboardController starboardController; private FullLogger logger; private ResourceManager resourceManager; - private Pickaxes pickaxes; + private PlayerStats playerStats; + private Tools tools; private Crafting crafting; private MineCommand mineCommand; private EnchantCommand enchantCommand; @@ -51,7 +55,8 @@ public class Mineshaft extends CustomBot { public Mineshaft(JSONObject config) throws LoginException, JSONException, IOException, InterruptedException { super(config); - pickaxes = new Pickaxes(this); + playerStats = new PlayerStats(this); + tools = new Tools(this); healths = new PlayerHealths(this); crafting = new Crafting(this); getCommandController().addCommand(crafting); @@ -81,6 +86,20 @@ public class Mineshaft extends CustomBot { getCommandController().addCommand(new RobCommand(this)); getCommandController().addCommand(new TradeCommand(this)); + // TODO remove this comand + getCommandController().addCommand(CommandDetails.from("setsword"), (e, b, args) -> { + List argList = Arrays.asList(args); + Optional level = argList.stream().filter(s -> PeelingUtils.isInteger(s)) + .map(s -> Integer.parseInt(s)).findFirst(); + getSword(e.getMember()).setLevel(level.get()); + sendSuccessMessage(e, "Set sword level of " + e.getMember().getAsMention() + " to " + level.get()); + }); + + // TODO remove this comand + getCommandController().addCommand(CommandDetails.from("getsword"), (e, b, args) -> { + sendSuccessMessage(e, + "" + e.getMember().getAsMention() + " has sword level: " + getSword(e.getMember()).getLevel()); + }); getCommandController().removeCommand("help"); getCommandController().addCommand(CommandDetails.from("help"), (e, b, args) -> { @@ -172,7 +191,10 @@ public class Mineshaft extends CustomBot { getCommandController().addCommand(new MineshaftGiveResourcesCommand(this)); getCommandController().addCommand(new FarmCommand(this)); + getCommandController().addCommand(new CampfireCommand(this)); getCommandController().addCommand(new CompostCommand(this)); + getCommandController().addCommand(new EatCommand(this)); + getCommandController().addCommand(new BlacksmithCommand(this)); logger = new FullLogger(this); } @@ -235,6 +257,14 @@ public class Mineshaft extends CustomBot { return resourceManager.getResource(member, item.toString()); } + public boolean hasItem(Member member, MineshaftItem item) { + return getItem(member, item) > 0; + } + + public String prettyValue(MineshaftItem item, long value) { + return getItem(item).prettyValue(value); + } + public Resource getItem(MineshaftItem item) { return resourceManager.getResource(item.toString()); } @@ -282,6 +312,7 @@ public class Mineshaft extends CustomBot { public String createItemList(Map items) { LinkedHashMap itemsLinked = new LinkedHashMap<>(items); return resourceManager.createResourceList(itemsLinked.entrySet().stream() + .filter(e -> e.getValue() > 0) .collect(Collectors.toMap( e -> e.getKey().toString(), Map.Entry::getValue @@ -325,8 +356,23 @@ public class Mineshaft extends CustomBot { }).reduce(Boolean.TRUE, Boolean::logicalAnd); } - public Pickaxes getPickaxes() { - return pickaxes; + public PlayerStats getPlayerStats() { + return playerStats; + } + public Tools getTools() { + return tools; + } + + public Pickaxe getPickaxe(Member member) { + return tools.getPickaxe(member); + } + + public Sword getSword(Member member) { + return tools.getSword(member); + } + + public Armour getArmour(Member member) { + return tools.getArmour(member); } public MineCommand getMineCommand() { -- cgit v1.2.3