blob: 2d3df02feb9413c16156f9e6feec0782cbcd0010 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
|
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;
}
}
|