diff options
20 files changed, 1070 insertions, 113 deletions
diff --git a/gradle/MoulConfig.xsd b/gradle/MoulConfig.xsd new file mode 100644 index 00000000..6826f5fc --- /dev/null +++ b/gradle/MoulConfig.xsd @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?><xs:schema xmlns="http://notenoughupdates.org/moulconfig" elementFormDefault="qualified" targetNamespace="http://notenoughupdates.org/moulconfig" xmlns:xs="http://www.w3.org/2001/XMLSchema"><xs:complexType name="Widgetless"/><xs:complexType name="SingleWidget"><xs:group ref="AnyWidget"/></xs:complexType><xs:complexType name="MultiWidget"><xs:group maxOccurs="unbounded" minOccurs="0" ref="AnyWidget"/></xs:complexType><xs:group name="AnyWidget"><xs:choice><xs:element name="Text" type="Text"/><xs:element name="Scale" type="Scale"/><xs:element name="Center" type="Center"/><xs:element name="Slider" type="Slider"/><xs:element name="Row" type="Row"/><xs:element name="Gui" type="Gui"/><xs:element name="TextField" type="TextField"/><xs:element name="ScrollPanel" type="ScrollPanel"/><xs:element name="ItemStack" type="ItemStack"/><xs:element name="Array" type="Array"/><xs:element name="Hover" type="Hover"/><xs:element name="Spacer" type="Spacer"/><xs:element name="Column" type="Column"/><xs:element name="Button" type="Button"/><xs:element name="Switch" type="Switch"/></xs:choice></xs:group><xs:element name="Root" type="Root"/><xs:complexType name="Text"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="split"/><xs:attribute name="shadow"/><xs:attribute name="textAlign"/><xs:attribute name="width"/><xs:attribute name="text" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Scale"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="scale" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Center"><xs:complexContent><xs:extension base="SingleWidget"/></xs:complexContent></xs:complexType><xs:complexType name="Root"><xs:complexContent><xs:extension base="SingleWidget"/></xs:complexContent></xs:complexType><xs:complexType name="Slider"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="minValue" use="required"/><xs:attribute name="maxValue" use="required"/><xs:attribute name="minStep"/><xs:attribute name="width"/><xs:attribute name="value" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Row"><xs:complexContent><xs:extension base="MultiWidget"/></xs:complexContent></xs:complexType><xs:complexType name="Gui"><xs:complexContent><xs:extension base="SingleWidget"/></xs:complexContent></xs:complexType><xs:complexType name="TextField"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="value" use="required"/><xs:attribute name="width"/><xs:attribute name="editable"/><xs:attribute name="suggestion"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="ScrollPanel"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="width" use="required"/><xs:attribute name="height" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="ItemStack"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="value" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Array"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="data" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Hover"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="lines" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Spacer"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="width"/><xs:attribute name="height"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Column"><xs:complexContent><xs:extension base="MultiWidget"/></xs:complexContent></xs:complexType><xs:complexType name="Button"><xs:complexContent><xs:extension base="SingleWidget"><xs:attribute name="margin"/><xs:attribute name="onClick" use="required"/></xs:extension></xs:complexContent></xs:complexType><xs:complexType name="Switch"><xs:complexContent><xs:extension base="Widgetless"><xs:attribute name="animationSpeed"/><xs:attribute name="value" use="required"/></xs:extension></xs:complexContent></xs:complexType></xs:schema>
\ No newline at end of file diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 49239396..f66463d6 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,5 +1,5 @@ [versions] -moulconfig = "1.3.0" +moulconfig = "2.2.0" [libraries] -moulconfig = { module = "org.notenoughupdates.moulconfig:MoulConfig", version.ref = "moulconfig" } +moulconfig = { module = "org.notenoughupdates.moulconfig:legacy", version.ref = "moulconfig" } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index f878dbf1..f20c5338 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -56,6 +56,7 @@ import io.github.moulberry.notenoughupdates.recipes.RecipeGenerator; import io.github.moulberry.notenoughupdates.util.Utils; import io.github.moulberry.notenoughupdates.util.brigadier.BrigadierRoot; import io.github.moulberry.notenoughupdates.util.hypixelapi.HypixelItemAPI; +import io.github.moulberry.notenoughupdates.util.kotlin.KotlinTypeAdapterFactory; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.FontRenderer; import net.minecraft.client.gui.GuiScreen; @@ -150,7 +151,8 @@ public class NotEnoughUpdates { put("MYTHIC", EnumChatFormatting.LIGHT_PURPLE.toString()); }}; public static ProfileViewer profileViewer; - private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation().create(); + private final Gson gson = new GsonBuilder().setPrettyPrinting().excludeFieldsWithoutExposeAnnotation() + .registerTypeAdapterFactory(KotlinTypeAdapterFactory.INSTANCE).create(); public NEUManager manager; public NEUOverlay overlay; public NEUConfig config; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java index 41208681..174650d9 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/GuiEnchantColour.java @@ -25,10 +25,12 @@ import com.google.gson.JsonArray; import com.google.gson.JsonParseException; import com.google.gson.JsonParser; import com.google.gson.JsonPrimitive; +import info.bliki.api.Template; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.lerp.LerpingInteger; import io.github.moulberry.notenoughupdates.itemeditor.GuiElementTextField; import io.github.moulberry.notenoughupdates.options.NEUConfig; +import io.github.moulberry.notenoughupdates.util.TemplateUtil; import io.github.moulberry.notenoughupdates.util.Utils; import net.minecraft.client.Minecraft; import net.minecraft.client.gui.Gui; @@ -51,6 +53,7 @@ import java.util.ArrayList; import java.util.Base64; import java.util.HashMap; import java.util.List; +import java.util.Objects; import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -527,16 +530,7 @@ public class GuiEnchantColour extends GuiScreen { private boolean validShareContents() { try { String base64 = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor); - - if (base64.length() <= sharePrefix.length()) return false; - - base64 = base64.trim(); - - try { - return new String(Base64.getDecoder().decode(base64)).startsWith(sharePrefix); - } catch (IllegalArgumentException e) { - return false; - } + return Objects.equals(TemplateUtil.getTemplatePrefix(base64), sharePrefix); } catch (HeadlessException | IOException | UnsupportedFlavorException | IllegalStateException e) { return false; } @@ -647,26 +641,7 @@ public class GuiEnchantColour extends GuiScreen { } catch (HeadlessException | IOException | UnsupportedFlavorException e) { return; } - - if (base64.length() <= sharePrefix.length()) return; - - base64 = base64.trim(); - - String jsonString; - try { - jsonString = new String(Base64.getDecoder().decode(base64)); - if (!jsonString.startsWith(sharePrefix)) return; - jsonString = jsonString.substring(sharePrefix.length()); - } catch (IllegalArgumentException e) { - return; - } - - JsonArray presetArray; - try { - presetArray = new JsonParser().parse(jsonString).getAsJsonArray(); - } catch (IllegalStateException | JsonParseException e) { - return; - } + JsonArray presetArray = TemplateUtil.maybeDecodeTemplate(sharePrefix, base64, JsonArray.class); ArrayList<String> presetList = new ArrayList<>(); for (int i = 0; i < presetArray.size(); i++) { @@ -690,8 +665,8 @@ public class GuiEnchantColour extends GuiScreen { for (String s : result) { jsonArray.add(new JsonPrimitive(s)); } - String base64String = Base64.getEncoder().encodeToString((sharePrefix + - jsonArray).getBytes(StandardCharsets.UTF_8)); + + String base64String = TemplateUtil.encodeTemplate(sharePrefix, jsonArray); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(new StringSelection(base64String), null); } else if (mouseY > guiTopSidebar + 2 + (24 * 2) && mouseY < guiTopSidebar + 20 + 2 + 24 * 2) { NotEnoughUpdates.INSTANCE.config.hidden.enchantColours = NEUConfig.createDefaultEnchantColours(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java index 2d64db59..200b1c0c 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/NEUConfig.java @@ -35,6 +35,7 @@ import io.github.moulberry.notenoughupdates.miscfeatures.IQTest; import io.github.moulberry.notenoughupdates.miscgui.GuiEnchantColour; import io.github.moulberry.notenoughupdates.miscgui.GuiInvButtonEditor; import io.github.moulberry.notenoughupdates.miscgui.NEUOverlayPlacements; +import io.github.moulberry.notenoughupdates.miscgui.customtodos.CustomTodo; import io.github.moulberry.notenoughupdates.options.customtypes.NEUDebugFlag; import io.github.moulberry.notenoughupdates.options.separatesections.AHGraph; import io.github.moulberry.notenoughupdates.options.separatesections.AHTweaks; @@ -493,6 +494,8 @@ public class NEUConfig extends Config { public static class Hidden { @Expose + public List<CustomTodo> customTodos = new ArrayList<>(); + @Expose public HashMap<String, NEUConfig.HiddenProfileSpecific> profileSpecific = new HashMap<>(); @Expose public HashMap<String, NEUConfig.HiddenLocationSpecific> locationSpecific = new HashMap<>(); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java index cefb6929..c4768b3e 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TextOverlay.java @@ -184,6 +184,9 @@ public abstract class TextOverlay { for (String s2 : s.split("\n")) { Vector2f pos = new Vector2f(x + paddingX, y + paddingY + yOff); renderLine(s2, pos, dummy); + if (s2.startsWith("CUSTOM")) { + s2 = s2.split(":", 2)[1]; + } int xPad = (int) pos.x; int yPad = (int) pos.y; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java index bf73e2ec..ca244303 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/overlays/TimersOverlay.java @@ -22,6 +22,7 @@ package io.github.moulberry.notenoughupdates.overlays; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.config.Position; import io.github.moulberry.notenoughupdates.events.SlotClickEvent; +import io.github.moulberry.notenoughupdates.miscgui.customtodos.CustomTodoHud; import io.github.moulberry.notenoughupdates.options.NEUConfig; import io.github.moulberry.notenoughupdates.util.ItemUtils; import io.github.moulberry.notenoughupdates.util.SBInfo; @@ -168,91 +169,97 @@ public class TimersOverlay extends TextTabOverlay { return; } GlStateManager.enableDepth(); - ItemStack icon = null; String clean = Utils.cleanColour(line); String beforeColon = clean.split(":")[0]; - switch (beforeColon) { - case "Cakes": - icon = CAKES_ICON; - break; - case "Puzzler": - icon = PUZZLER_ICON; - break; - case "Godpot": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("GOD_POTION")); - break; - case "Fetchur": { - if (FETCHUR_ICONS == null) { - FETCHUR_ICONS = new ItemStack[]{ - new ItemStack(Blocks.wool, 50, 14), - new ItemStack(Blocks.stained_glass, 20, 4), - new ItemStack(Items.compass, 1, 0), - new ItemStack(Items.prismarine_crystals, 20, 0), - new ItemStack(Items.fireworks, 1, 0), - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("CHEAP_COFFEE")), - new ItemStack(Items.oak_door, 1, 0), - new ItemStack(Items.rabbit_foot, 3, 0), - NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("SUPERBOOM_TNT")), - new ItemStack(Blocks.pumpkin, 1, 0), - new ItemStack(Items.flint_and_steel, 1, 0), - new ItemStack(Items.emerald, 50, 0), - //new ItemStack(Items.ender_pearl, 16, 0) - }; - } + if (beforeColon.startsWith("CUSTOM")) { + var item = Item.getByNameOrId(beforeColon.substring(6)); + if (item == null) { + item = Items.paper; + } + icon = new ItemStack(item); + } else + switch (beforeColon) { + case "Cakes": + icon = CAKES_ICON; + break; + case "Puzzler": + icon = PUZZLER_ICON; + break; + case "Godpot": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get("GOD_POTION")); + break; + case "Fetchur": { + if (FETCHUR_ICONS == null) { + FETCHUR_ICONS = new ItemStack[]{ + new ItemStack(Blocks.wool, 50, 14), + new ItemStack(Blocks.stained_glass, 20, 4), + new ItemStack(Items.compass, 1, 0), + new ItemStack(Items.prismarine_crystals, 20, 0), + new ItemStack(Items.fireworks, 1, 0), + NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get("CHEAP_COFFEE")), + new ItemStack(Items.oak_door, 1, 0), + new ItemStack(Items.rabbit_foot, 3, 0), + NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get("SUPERBOOM_TNT")), + new ItemStack(Blocks.pumpkin, 1, 0), + new ItemStack(Items.flint_and_steel, 1, 0), + new ItemStack(Blocks.emerald_ore, 50, 0), + //new ItemStack(Items.ender_pearl, 16, 0) + }; + } - ZonedDateTime currentTimeEST = ZonedDateTime.now(ZoneId.of("America/Atikokan")); + ZonedDateTime currentTimeEST = ZonedDateTime.now(ZoneId.of("America/Atikokan")); - long fetchurIndex = ((currentTimeEST.getDayOfMonth() + 1) % 12) - 1; - //Added because disabled fetchur and enabled it again but it was showing the wrong item - //Lets see if this stays correct + long fetchurIndex = ((currentTimeEST.getDayOfMonth() + 1) % 12) - 1; + //Added because disabled fetchur and enabled it again but it was showing the wrong item + //Lets see if this stays correct - if (fetchurIndex < 0) fetchurIndex += 12; + if (fetchurIndex < 0) fetchurIndex += 12; - icon = FETCHUR_ICONS[(int) fetchurIndex]; - break; + icon = FETCHUR_ICONS[(int) fetchurIndex]; + break; + } + case "Commissions": + icon = COMMISSIONS_ICON; + break; + case "Experiments": + icon = EXPERIMENTS_ICON; + break; + case "Cookie Buff": + icon = COOKIE_ICON; + break; + case "Mithril Powder": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get("MITHRIL_ORE")); + break; + case "Gemstone Powder": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get("PERFECT_AMETHYST_GEM")); + break; + case "Heavy Pearls": + icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager + .getItemInformation() + .get("HEAVY_PEARL")); + break; + case "Free Rift Infusion": + icon = new ItemStack(Blocks.double_plant, 1, 1); + break; + case "Crimson Isle Quests": + icon = QUEST_ICON; + break; + case "NPC Buy Daily Limit": + icon = SHOP_ICON; + break; } - case "Commissions": - icon = COMMISSIONS_ICON; - break; - case "Experiments": - icon = EXPERIMENTS_ICON; - break; - case "Cookie Buff": - icon = COOKIE_ICON; - break; - case "Mithril Powder": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("MITHRIL_ORE")); - break; - case "Gemstone Powder": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("PERFECT_AMETHYST_GEM")); - break; - case "Heavy Pearls": - icon = NotEnoughUpdates.INSTANCE.manager.jsonToStack(NotEnoughUpdates.INSTANCE.manager - .getItemInformation() - .get("HEAVY_PEARL")); - break; - case "Free Rift Infusion": - icon = new ItemStack(Blocks.double_plant, 1, 1); - break; - case "Crimson Isle Quests": - icon = QUEST_ICON; - break; - case "NPC Buy Daily Limit": - icon = SHOP_ICON; - break; - } if (icon != null) { GlStateManager.pushMatrix(); @@ -1047,6 +1054,9 @@ public class TimersOverlay extends TextTabOverlay { overlayStrings.add(text); } } + + CustomTodoHud.processInto(overlayStrings); + if (overlayStrings.isEmpty()) overlayStrings = null; } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index 82708669..ad0000d4 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -23,6 +23,7 @@ import com.google.common.reflect.TypeToken; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; +import io.github.moulberry.notenoughupdates.events.SidebarChangeEvent; import io.github.moulberry.notenoughupdates.miscfeatures.CookieWarning; import io.github.moulberry.notenoughupdates.miscfeatures.customblockzones.LocationChangeEvent; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager; @@ -310,6 +311,7 @@ public class SBInfo { public ArrayList<String> completedQuests = new ArrayList<>(); private static final Pattern SKILL_LEVEL_PATTERN = Pattern.compile("([^0-9:]+) (\\d{1,2})"); + private static List<String> lastLines = new ArrayList<>(); public void tick() { @@ -364,6 +366,11 @@ public class SBInfo { try { List<String> lines = SidebarUtil.readSidebarLines(true, false); + + if (lines.equals(lastLines)) return; + new SidebarChangeEvent(lines, lastLines).post(); + lastLines = lines; + boolean tempIsInDungeon = false; for (String line : lines) { if (line.contains("Cleared:") && line.contains("%")) { diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/TabListUtils.java b/src/main/java/io/github/moulberry/notenoughupdates/util/TabListUtils.java index a0266122..f36db034 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/TabListUtils.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/TabListUtils.java @@ -21,10 +21,14 @@ package io.github.moulberry.notenoughupdates.util; import com.google.common.collect.ComparisonChain; import com.google.common.collect.Ordering; +import io.github.moulberry.notenoughupdates.autosubscribe.NEUAutoSubscribe; +import io.github.moulberry.notenoughupdates.events.TabListChangeEvent; import net.minecraft.client.Minecraft; import net.minecraft.client.network.NetworkPlayerInfo; import net.minecraft.scoreboard.ScorePlayerTeam; import net.minecraft.world.WorldSettings; +import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; +import net.minecraftforge.fml.common.gameevent.TickEvent; import net.minecraftforge.fml.relauncher.Side; import net.minecraftforge.fml.relauncher.SideOnly; @@ -32,6 +36,7 @@ import java.util.ArrayList; import java.util.Comparator; import java.util.List; +@NEUAutoSubscribe public class TabListUtils { private static final Ordering<NetworkPlayerInfo> playerOrdering = Ordering.from(new PlayerComparator()); @@ -55,7 +60,23 @@ public class TabListUtils { } } + public static List<String> tabList = new ArrayList<>(); + public static List<String> tabListLastTick = new ArrayList<>(); + + @SubscribeEvent + public void onTick(TickEvent.ClientTickEvent event) { + if (Minecraft.getMinecraft().thePlayer == null) return; + if (event.phase != TickEvent.Phase.END) return; + tabListLastTick = tabList; + tabList = getTabList0(); + new TabListChangeEvent(tabList, tabListLastTick).post(); + } + public static List<String> getTabList() { + return tabList; + } + + private List<String> getTabList0() { List<NetworkPlayerInfo> players = playerOrdering.sortedCopy(Minecraft.getMinecraft().thePlayer.sendQueue.getPlayerInfoMap()); diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt index eb5d51b1..40919a8e 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/commands/help/SettingsCommand.kt @@ -21,6 +21,7 @@ package io.github.moulberry.notenoughupdates.commands.help import io.github.moulberry.moulconfig.GuiTextures import io.github.moulberry.moulconfig.annotations.ConfigOption +import io.github.moulberry.moulconfig.common.MyResourceLocation import io.github.moulberry.moulconfig.gui.GuiOptionEditor import io.github.moulberry.moulconfig.gui.GuiScreenElementWrapper import io.github.moulberry.moulconfig.gui.MoulConfigEditor @@ -34,7 +35,6 @@ import io.github.moulberry.notenoughupdates.miscfeatures.IQTest import io.github.moulberry.notenoughupdates.options.NEUConfig import io.github.moulberry.notenoughupdates.util.brigadier.* import net.minecraft.client.gui.GuiScreen -import net.minecraft.util.ResourceLocation import net.minecraftforge.fml.common.eventhandler.SubscribeEvent import java.lang.reflect.Field @@ -118,6 +118,7 @@ object SettingsCommand { return object : GuiScreenElementWrapper(createConfigElement(search)) { } } + fun createConfigElement(search: String): MoulConfigEditor<NEUConfig> { val processor = BlockingMoulConfigProcessor() BuiltinMoulConfigGuis.addProcessors(processor) @@ -131,7 +132,8 @@ object SettingsCommand { lastEditor = editor return editor } + init { - GuiTextures.setTextureRoot(ResourceLocation("notenoughupdates:core")) + GuiTextures.setTextureRoot(MyResourceLocation("notenoughupdates", "core")) } } diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/events/SidebarChangeEvent.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/events/SidebarChangeEvent.kt new file mode 100644 index 00000000..0dc4b9f6 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/events/SidebarChangeEvent.kt @@ -0,0 +1,25 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.events + +class SidebarChangeEvent( + val lines: List<String>, + val lastLines: List<String>, +) : NEUEvent() diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/events/TabListChangeEvent.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/events/TabListChangeEvent.kt new file mode 100644 index 00000000..b5677598 --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/events/TabListChangeEvent.kt @@ -0,0 +1,26 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.events + +class TabListChangeEvent( + val lastLines: List<String>, + val newLines: List<String>, +) : NEUEvent() { +} diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodo.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodo.kt new file mode 100644 index 00000000..7f8c6d1a --- /dev/null +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/miscgui/customtodos/CustomTodo.kt @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2023 NotEnoughUpdates contributors + * + * This file is part of NotEnoughUpdates. + * + * NotEnoughUpdates is free software: you can redistribute it + * and/or modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation, either + * version 3 of the License, or (at your option) any later version. + * + * NotEnoughUpdates is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with NotEnoughUpdates. If not, see <https://www.gnu.org/licenses/>. + */ + +package io.github.moulberry.notenoughupdates.miscgui.customtodos + +import com.google.gson.annotations.Expose +import io.github.moulberry.notenoughupdates.util.SBInfo +import io.github.moulberry.notenoughupdates.util.TemplateUtil +import io.github.moulberry.notenoughupdates.util.kotlin.KSerializable + +@KSerializable +data class CustomTodo( + @Expose var label: String, + @Expose var timer: Int, + @Expose var trigger: String, + @Expose var icon: String, + @Expose var isResetOffset: Boolean, + @Expose var triggerTarget: TriggerTarget = TriggerTarget.CHAT, + @Expose var triggerMatcher: TriggerMatcher = TriggerMatcher.CONTAINS, + @Expose var readyAt: MutableMap<String, Long> = mutableMapOf(), + @Expose var enabled: MutableMap<String, Boolean> = mutableMapOf(), +) { + enum class TriggerMatcher { + REGEX, STARTS_WITH, CONTAINS, EQUALS + } + + enum class TriggerTarget { + CHAT, ACTIONBAR, TAB_LIST, SIDEBAR + } + + fun isValid(): Boolean { + return timer >= 0 && !trigger.isBlank() + } + + fun setDoneNow() { |
