diff --git a/src/main/java/de/hysky/skyblocker/skyblock/shortcut/Shortcuts.java b/src/main/java/de/hysky/skyblocker/skyblock/shortcut/Shortcuts.java index 58d6f62643..7dab70a332 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/shortcut/Shortcuts.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/shortcut/Shortcuts.java @@ -21,7 +21,9 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.*; +import java.io.BufferedReader; +import java.io.BufferedWriter; +import java.io.IOException; import java.lang.reflect.Type; import java.nio.file.Files; import java.nio.file.NoSuchFileException; @@ -59,8 +61,7 @@ protected static void loadShortcuts() { } shortcutsLoaded = CompletableFuture.runAsync(() -> { try (BufferedReader reader = Files.newBufferedReader(SHORTCUTS_FILE)) { - Type shortcutsType = new TypeToken>>() { - }.getType(); + Type shortcutsType = new TypeToken>>() {}.getType(); Map> shortcuts = SkyblockerMod.GSON.fromJson(reader, shortcutsType); commands.clear(); commandArgs.clear(); @@ -84,6 +85,7 @@ private static void registerDefaultShortcuts() { commands.put("/s", "/skyblock"); commands.put("/i", "/is"); commands.put("/h", "/hub"); + commands.put("/g", "/warp garden"); // Dungeon commands.put("/d", "/warp dungeon_hub"); @@ -170,8 +172,7 @@ private static void registerCommands(CommandDispatcher> shortcutMaps = new ArrayList<>(); /** - * @param width the width of the widget - * @param height the height of the widget - * @param y the y coordinate to start rendering/placing the widget from + * @param width the width of the widget + * @param height the height of the widget + * @param y the y coordinate to start rendering/placing the widget from * @param itemHeight the height of each item */ public ShortcutsConfigListWidget(MinecraftClient minecraftClient, ShortcutsConfigScreen screen, int width, int height, int y, int itemHeight) { @@ -77,6 +78,11 @@ protected void updatePositions() { } } + /** + * Returns true if the client is in debug mode and the entry at the given index is selected. + *

+ * Used to show the box around the selected entry in debug mode. + */ @Override protected boolean isSelectedEntry(int index) { return Debug.debugEnabled() ? Objects.equals(getSelectedOrNull(), children().get(index)) : super.isSelectedEntry(index); @@ -113,15 +119,15 @@ protected class ShortcutCategoryEntry extends AbstractShortcutEntry { @Nullable private final Text tooltip; - private ShortcutCategoryEntry(Map shortcutsMap, String targetName, String replacementName) { + private ShortcutCategoryEntry(Map shortcutsMap, @Translatable String targetName, @Translatable String replacementName) { this(shortcutsMap, targetName, replacementName, (Text) null); } - private ShortcutCategoryEntry(Map shortcutsMap, String targetName, String replacementName, String tooltip) { + private ShortcutCategoryEntry(Map shortcutsMap, @Translatable String targetName, @Translatable String replacementName, @Translatable String tooltip) { this(shortcutsMap, targetName, replacementName, Text.translatable(tooltip)); } - private ShortcutCategoryEntry(Map shortcutsMap, String targetName, String replacementName, @Nullable Text tooltip) { + private ShortcutCategoryEntry(Map shortcutsMap, @Translatable String targetName, @Translatable String replacementName, @Nullable Text tooltip) { this.shortcutsMap = shortcutsMap; this.targetName = Text.translatable(targetName); this.replacementName = Text.translatable(replacementName); @@ -158,6 +164,14 @@ public void render(DrawContext context, int index, int y, int x, int entryWidth, screen.setTooltip(tooltip); } } + + /** + * Returns true so that category entries can be focused and selected, so that we can add shortcut entries after them. + */ + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + return true; + } } private class ShortcutLoadingEntry extends AbstractShortcutEntry {