diff options
Diffstat (limited to 'src/main/java/de')
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/shortcut/Shortcuts.java | 11 | ||||
| -rw-r--r-- | src/main/java/de/hysky/skyblocker/skyblock/shortcut/ShortcutsConfigListWidget.java | 26 |
2 files changed, 26 insertions, 11 deletions
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 58d6f626..7dab70a3 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.jetbrains.annotations.Nullable; 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 @@ public class Shortcuts { } shortcutsLoaded = CompletableFuture.runAsync(() -> { try (BufferedReader reader = Files.newBufferedReader(SHORTCUTS_FILE)) { - Type shortcutsType = new TypeToken<Map<String, Map<String, String>>>() { - }.getType(); + Type shortcutsType = new TypeToken<Map<String, Map<String, String>>>() {}.getType(); Map<String, Map<String, String>> shortcuts = SkyblockerMod.GSON.fromJson(reader, shortcutsType); commands.clear(); commandArgs.clear(); @@ -84,6 +85,7 @@ public class Shortcuts { 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 @@ public class Shortcuts { } if (redirectLocation == null) { dispatcher.register(literal(set.getKey().substring(1)).then(argument("args", StringArgumentType.greedyString()))); - } - else { + } else { dispatcher.register(literal(set.getKey().substring(1)).redirect(redirectLocation)); } } diff --git a/src/main/java/de/hysky/skyblocker/skyblock/shortcut/ShortcutsConfigListWidget.java b/src/main/java/de/hysky/skyblocker/skyblock/shortcut/ShortcutsConfigListWidget.java index a6b5e62d..f6acb146 100644 --- a/src/main/java/de/hysky/skyblocker/skyblock/shortcut/ShortcutsConfigListWidget.java +++ b/src/main/java/de/hysky/skyblocker/skyblock/shortcut/ShortcutsConfigListWidget.java @@ -1,5 +1,6 @@ package de.hysky.skyblocker.skyblock.shortcut; +import com.demonwav.mcdev.annotations.Translatable; import de.hysky.skyblocker.debug.Debug; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.DrawContext; @@ -20,9 +21,9 @@ public class ShortcutsConfigListWidget extends ElementListWidget<ShortcutsConfig private final List<Map<String, String>> 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 @@ public class ShortcutsConfigListWidget extends ElementListWidget<ShortcutsConfig } } + /** + * Returns true if the client is in debug mode and the entry at the given index is selected. + * <p> + * 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 @@ public class ShortcutsConfigListWidget extends ElementListWidget<ShortcutsConfig @Nullable private final Text tooltip; - private ShortcutCategoryEntry(Map<String, String> shortcutsMap, String targetName, String replacementName) { + private ShortcutCategoryEntry(Map<String, String> shortcutsMap, @Translatable String targetName, @Translatable String replacementName) { this(shortcutsMap, targetName, replacementName, (Text) null); } - private ShortcutCategoryEntry(Map<String, String> shortcutsMap, String targetName, String replacementName, String tooltip) { + private ShortcutCategoryEntry(Map<String, String> shortcutsMap, @Translatable String targetName, @Translatable String replacementName, @Translatable String tooltip) { this(shortcutsMap, targetName, replacementName, Text.translatable(tooltip)); } - private ShortcutCategoryEntry(Map<String, String> shortcutsMap, String targetName, String replacementName, @Nullable Text tooltip) { + private ShortcutCategoryEntry(Map<String, String> 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 class ShortcutsConfigListWidget extends ElementListWidget<ShortcutsConfig 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 { |
