Skip to content

Commit 4a69fd3

Browse files
authored
Merge pull request #559 from aunncodes/wikithis
Add WikiThis command
2 parents 283d25c + 5264a6e commit 4a69fd3

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
package net.swofty.type.skyblockgeneric.commands;
2+
3+
import net.minestom.server.command.builder.Command;
4+
import net.swofty.type.generic.command.CommandParameters;
5+
import net.swofty.type.generic.command.HypixelCommand;
6+
import net.swofty.type.generic.user.categories.Rank;
7+
import net.swofty.type.skyblockgeneric.item.SkyBlockItem;
8+
import net.swofty.type.skyblockgeneric.user.SkyBlockPlayer;
9+
10+
import net.kyori.adventure.text.Component;
11+
import net.kyori.adventure.text.event.ClickEvent;
12+
import net.kyori.adventure.text.format.NamedTextColor;
13+
import net.kyori.adventure.text.format.TextDecoration;
14+
15+
@CommandParameters(
16+
aliases = "wikithis wikihand wikiinhand",
17+
description = "Shows page link of the item held towards the official Hypixel Wiki.",
18+
usage = "/wikithis",
19+
permission = Rank.DEFAULT,
20+
allowsConsole = false
21+
)
22+
public class WikiThisCommand extends HypixelCommand {
23+
24+
private static final String WIKI_BASE = "https://wiki.hypixel.net/";
25+
26+
@Override
27+
public void registerUsage(MinestomCommand command) {
28+
29+
command.addSyntax((sender, context) -> {
30+
if (!permissionCheck(sender)) return;
31+
32+
SkyBlockPlayer player = (SkyBlockPlayer) sender;
33+
34+
if (player.getItemInMainHand() == null || player.getItemInMainHand().isAir()) {
35+
player.sendMessage("§cYou must be holding an item to use this command!");
36+
return;
37+
}
38+
39+
SkyBlockItem item = new SkyBlockItem(player.getItemInMainHand());
40+
String name = item.getDisplayName();
41+
42+
if (name == null || name.isBlank()) {
43+
player.sendMessage("§cThis item does not have a valid name.");
44+
return;
45+
}
46+
47+
String clean = name.replaceAll("§.", "");
48+
String url = WIKI_BASE + clean.replace(" ", "_");
49+
50+
Component line1 = Component.text("Found Item: ", NamedTextColor.GRAY)
51+
.append(Component.text(clean, NamedTextColor.GREEN));
52+
53+
Component here = Component.text("HERE", NamedTextColor.YELLOW, TextDecoration.BOLD)
54+
.clickEvent(ClickEvent.openUrl(url));
55+
56+
Component line2 = Component.text("Click ", NamedTextColor.GRAY)
57+
.append(here)
58+
.append(Component.text(" to find it on the ", NamedTextColor.GRAY))
59+
.append(Component.text("Official SkyBlock Wiki", NamedTextColor.GOLD))
60+
.append(Component.text("!", NamedTextColor.GRAY));
61+
62+
player.sendMessage(line1);
63+
player.sendMessage(line2);
64+
65+
});
66+
}
67+
}

0 commit comments

Comments
 (0)