package net.uomc.mineshaft; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.Map; import java.util.Random; import java.util.stream.IntStream; import java.util.stream.LongStream; import com.mouldycheerio.dbot.CustomBot; import com.mouldycheerio.dbot.commands.CommandDetails; import com.mouldycheerio.dbot.commands.CommandFail; import com.mouldycheerio.dbot.commands.DetailedCommand; import com.mouldycheerio.dbot.commands.cooldowns.CooldownCommand; import com.mouldycheerio.dbot.util.PeelingUtils; import com.vdurmont.emoji.EmojiParser; import net.dv8tion.jda.api.EmbedBuilder; import net.dv8tion.jda.api.entities.Member; import net.dv8tion.jda.api.entities.emoji.CustomEmoji; import net.dv8tion.jda.api.entities.emoji.Emoji; import net.dv8tion.jda.api.events.message.MessageReceivedEvent; public class Portal extends CooldownCommand { private static final String COMMAND_IMAGE = "https://minecraft.wiki/images/Nether_portal_%28animated%29.png?26915"; private static final String NETHER_IMAGE = "https://minecraft.wiki/images/thumb/The_Nether.png/600px-The_Nether.png?92e82"; private static final String OVERWORLD_IMAGE = "https://minecraft.wiki/images/thumb/Overworld_1.18.png/640px-Overworld_1.18.png?9499d"; private static final String COMMAND_TITLE = "Portal"; Mineshaft bot; public Portal(Mineshaft bot) { super(bot); setCommandDetails(CommandDetails.from("portal", "go to the nether", "furnace")); this.bot = bot; setCooldown(2l * 1000l); } @Override public boolean trigger(MessageReceivedEvent e) { long furnaces = bot.getItem(e.getMember(), MineshaftItem.PORTAL); if (furnaces < 1) { bot.sendErrorMessage(e, ":x: You need to have at least **" + bot.getItem(MineshaftItem.PORTAL).prettyValue(1) + "** to use this!"); return false; } EmbedBuilder em = new EmbedBuilder(); em.setTitle(COMMAND_TITLE); em.setColor(PeelingUtils.hex2Rgb("#8947e8")); em.setThumbnail(COMMAND_IMAGE); if (bot.getPickaxes().isNether(e.getMember())) { bot.getPickaxes().setNether(e.getMember(), false); em.setDescription("You go through the potal... everything is back to normal\n\n**You are now in the overworld**"); em.setImage(OVERWORLD_IMAGE); } else { bot.getPickaxes().setNether(e.getMember(), true); em.setDescription("You go through the potal... things look different on this side...\n\n**You are now in the nether**"); em.setFooter(COMMAND_IMAGE); em.setImage(NETHER_IMAGE); em.setFooter(EmojiParser.parseToUnicode(":bulb:") + "Use " + bot.getPrefixManager().getPrefix(e.getGuild()) + "portal at any time to return"); } e.getMessage().replyEmbeds(em.build()).queue(); return true; } }