From 6e6fe688165f09e2bee0824fd1a9a23d665d997d Mon Sep 17 00:00:00 2001 From: RappyTV Date: Fri, 27 Sep 2024 15:33:31 +0200 Subject: [PATCH 1/8] Update GlobalTagsJava --- api/build.gradle.kts | 2 +- core/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 591e203..fa7c5d3 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -3,7 +3,7 @@ import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtensi dependencies { labyProcessor() labyApi("api") - addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.0") + addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.1") } labyModAnnotationProcessor { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 3d09935..3c136c3 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -3,7 +3,7 @@ import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtensi dependencies { labyProcessor() api(project(":api")) - addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.0") + addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.1") } labyModAnnotationProcessor { From 01884ce661c72126f748c678c8e05438342e4527 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Fri, 27 Sep 2024 15:34:26 +0200 Subject: [PATCH 2/8] Use new abstract class instead of interface --- .../rappytv/globaltags/api/GlobalTagAPI.java | 19 +------------------ 1 file changed, 1 insertion(+), 18 deletions(-) diff --git a/api/src/main/java/com/rappytv/globaltags/api/GlobalTagAPI.java b/api/src/main/java/com/rappytv/globaltags/api/GlobalTagAPI.java index a18e028..0232e84 100644 --- a/api/src/main/java/com/rappytv/globaltags/api/GlobalTagAPI.java +++ b/api/src/main/java/com/rappytv/globaltags/api/GlobalTagAPI.java @@ -2,9 +2,6 @@ import com.rappytv.globaltags.wrapper.GlobalTagsAPI; import com.rappytv.globaltags.wrapper.enums.AuthProvider; -import com.rappytv.globaltags.wrapper.http.ApiHandler; -import com.rappytv.globaltags.wrapper.model.PlayerInfo; -import com.rappytv.globaltags.wrapper.model.PlayerInfo.Cache; import net.labymod.api.Laby; import net.labymod.api.client.component.Component; import net.labymod.api.client.component.serializer.legacy.LegacyComponentSerializer; @@ -16,10 +13,7 @@ import java.util.UUID; import java.util.function.Supplier; -public class GlobalTagAPI implements GlobalTagsAPI { - - private final Cache cache = new Cache<>(this); - private final ApiHandler apiHandler = new ApiHandler<>(this); +public class GlobalTagAPI extends GlobalTagsAPI { private final Agent agent; private final Supplier language; @@ -52,17 +46,6 @@ public GlobalTagAPI(Agent agent, Supplier language) { return Laby.labyAPI().getUniqueId(); } - @NotNull - @Override - public PlayerInfo.Cache getCache() { - return cache; - } - - @Override - public @NotNull ApiHandler getApiHandler() { - return apiHandler; - } - @Override public @NotNull AuthProvider getAuthType() { return AuthProvider.LABYCONNECT; From 83d44da5ac82ec05e5d45cfa3ab9c2a85d670a34 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Fri, 27 Sep 2024 15:34:46 +0200 Subject: [PATCH 3/8] Add new command to renew cache --- .../globaltags/command/GlobalTagCommand.java | 6 ++-- .../subcommands/RenewCacheCommand.java | 31 +++++++++++++++++++ 2 files changed, 35 insertions(+), 2 deletions(-) create mode 100644 core/src/main/java/com/rappytv/globaltags/command/subcommands/RenewCacheCommand.java diff --git a/core/src/main/java/com/rappytv/globaltags/command/GlobalTagCommand.java b/core/src/main/java/com/rappytv/globaltags/command/GlobalTagCommand.java index dd3d504..a1e098f 100644 --- a/core/src/main/java/com/rappytv/globaltags/command/GlobalTagCommand.java +++ b/core/src/main/java/com/rappytv/globaltags/command/GlobalTagCommand.java @@ -4,6 +4,7 @@ import com.rappytv.globaltags.api.GlobalTagAPI; import com.rappytv.globaltags.command.subcommands.ClearCacheCommand; import com.rappytv.globaltags.command.subcommands.LinkDiscordSubcommand; +import com.rappytv.globaltags.command.subcommands.RenewCacheCommand; import com.rappytv.globaltags.command.subcommands.UnlinkDiscordSubcommand; import net.labymod.api.client.chat.command.Command; import net.labymod.api.client.component.Component; @@ -25,6 +26,7 @@ public GlobalTagCommand(GlobalTagAddon addon) { withSubCommand(new ClearCacheCommand(api)); withSubCommand(new LinkDiscordSubcommand(api)); + withSubCommand(new RenewCacheCommand(api)); withSubCommand(new UnlinkDiscordSubcommand(api)); } @@ -38,7 +40,7 @@ public boolean execute(String prefix, String[] arguments) { NamedTextColor.GREEN, Component.text(this.version, NamedTextColor.AQUA) )) - .append("\n") + .append(Component.newline()) .append(GlobalTagAddon.prefix) .append(Component.translatable( "globaltags.commands.base.api.version", @@ -50,7 +52,7 @@ public boolean execute(String prefix, String[] arguments) { NamedTextColor.RED ) )) - .append("\n") + .append(Component.newline()) .append(GlobalTagAddon.prefix) .append(Component .translatable("globaltags.commands.base.clear_cache.label") diff --git a/core/src/main/java/com/rappytv/globaltags/command/subcommands/RenewCacheCommand.java b/core/src/main/java/com/rappytv/globaltags/command/subcommands/RenewCacheCommand.java new file mode 100644 index 0000000..d0fb371 --- /dev/null +++ b/core/src/main/java/com/rappytv/globaltags/command/subcommands/RenewCacheCommand.java @@ -0,0 +1,31 @@ +package com.rappytv.globaltags.command.subcommands; + +import com.rappytv.globaltags.GlobalTagAddon; +import com.rappytv.globaltags.api.GlobalTagAPI; +import net.labymod.api.client.chat.command.SubCommand; +import net.labymod.api.client.component.Component; +import net.labymod.api.client.component.format.NamedTextColor; + +public class RenewCacheCommand extends SubCommand { + + private final GlobalTagAPI api; + + public RenewCacheCommand(GlobalTagAPI api) { + super("renewcache", "rc"); + this.api = api; + } + + @Override + public boolean execute(String prefix, String[] arguments) { + api.getCache().renew(); + displayMessage( + Component.empty() + .append(GlobalTagAddon.prefix) + .append(Component.translatable( + "globaltags.commands.renew_cache.success", + NamedTextColor.GREEN + )) + ); + return true; + } +} From eb9d52aae88f14e11ae36cecc23b7b49bb22866c Mon Sep 17 00:00:00 2001 From: RappyTV Date: Fri, 27 Sep 2024 15:35:38 +0200 Subject: [PATCH 4/8] Add renew cache command translations --- core/src/main/resources/assets/globaltags/i18n/de_de.json | 3 +++ core/src/main/resources/assets/globaltags/i18n/en_us.json | 3 +++ 2 files changed, 6 insertions(+) diff --git a/core/src/main/resources/assets/globaltags/i18n/de_de.json b/core/src/main/resources/assets/globaltags/i18n/de_de.json index c64ed66..8153290 100644 --- a/core/src/main/resources/assets/globaltags/i18n/de_de.json +++ b/core/src/main/resources/assets/globaltags/i18n/de_de.json @@ -142,6 +142,9 @@ "clear_cache": { "success": "Der Cache wurde geleert!" }, + "renew_cache": { + "success": "Der Cache wurde erneuert!" + }, "link": { "discord": { "copied": "Der Code wurde in deine Zwischenablage kopiert!" diff --git a/core/src/main/resources/assets/globaltags/i18n/en_us.json b/core/src/main/resources/assets/globaltags/i18n/en_us.json index 3ff83e4..d67ebb9 100644 --- a/core/src/main/resources/assets/globaltags/i18n/en_us.json +++ b/core/src/main/resources/assets/globaltags/i18n/en_us.json @@ -142,6 +142,9 @@ "clear_cache": { "success": "The cache was cleared!" }, + "renew_cache": { + "success": "The cache was renewed!" + }, "link": { "discord": { "copied": "The code was copied to your clipboard!" From a0be432a822c83b1e5a18c30f189d14ee8962bd4 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Fri, 27 Sep 2024 15:36:08 +0200 Subject: [PATCH 5/8] Bump version --- build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle.kts b/build.gradle.kts index 2bf469d..4ff9748 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -5,7 +5,7 @@ plugins { val versions = providers.gradleProperty("net.labymod.minecraft-versions").get().split(";") group = "org.example" -version = providers.environmentVariable("VERSION").getOrElse("1.2.10") +version = providers.environmentVariable("VERSION").getOrElse("1.2.11") labyMod { defaultPackageName = "com.rappytv.globaltags" //change this to your main package name (used by all modules) From 9eaf9a406d37cb6e16fb246611928a8b88cbf82a Mon Sep 17 00:00:00 2001 From: RappyTV Date: Fri, 27 Sep 2024 16:00:52 +0200 Subject: [PATCH 6/8] Update GlobalTagsJava again because renewing was not working --- api/build.gradle.kts | 2 +- core/build.gradle.kts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/api/build.gradle.kts b/api/build.gradle.kts index fa7c5d3..2b2c294 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -3,7 +3,7 @@ import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtensi dependencies { labyProcessor() labyApi("api") - addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.1") + addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.2") } labyModAnnotationProcessor { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 3c136c3..8b98b66 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -3,7 +3,7 @@ import net.labymod.labygradle.common.extension.LabyModAnnotationProcessorExtensi dependencies { labyProcessor() api(project(":api")) - addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.1") + addonMavenDependency("com.rappytv.globaltags:GlobalTagsJava:1.1.2") } labyModAnnotationProcessor { From b1c84dc2941a835825b7b39209c7fdb41c2eaf32 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Fri, 27 Sep 2024 16:09:47 +0200 Subject: [PATCH 7/8] Add another /gt renewcache alias, use correct method to renew all --- .../globaltags/command/subcommands/RenewCacheCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/rappytv/globaltags/command/subcommands/RenewCacheCommand.java b/core/src/main/java/com/rappytv/globaltags/command/subcommands/RenewCacheCommand.java index d0fb371..d2ffb25 100644 --- a/core/src/main/java/com/rappytv/globaltags/command/subcommands/RenewCacheCommand.java +++ b/core/src/main/java/com/rappytv/globaltags/command/subcommands/RenewCacheCommand.java @@ -11,13 +11,13 @@ public class RenewCacheCommand extends SubCommand { private final GlobalTagAPI api; public RenewCacheCommand(GlobalTagAPI api) { - super("renewcache", "rc"); + super("renewcache", "renew", "rc"); this.api = api; } @Override public boolean execute(String prefix, String[] arguments) { - api.getCache().renew(); + api.getCache().renewAll(); displayMessage( Component.empty() .append(GlobalTagAddon.prefix) From bc3e32560211f0c0e410627d378eed5ab7a8ec81 Mon Sep 17 00:00:00 2001 From: RappyTV Date: Fri, 27 Sep 2024 16:09:55 +0200 Subject: [PATCH 8/8] Don't clear cache on tag change --- api/src/main/java/com/rappytv/globaltags/api/Util.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/api/src/main/java/com/rappytv/globaltags/api/Util.java b/api/src/main/java/com/rappytv/globaltags/api/Util.java index ff10bc4..51b6a7c 100644 --- a/api/src/main/java/com/rappytv/globaltags/api/Util.java +++ b/api/src/main/java/com/rappytv/globaltags/api/Util.java @@ -38,8 +38,7 @@ public static void update(GlobalTagAPI api, ResultType type, Component component Laby.labyAPI().minecraft().executeOnRenderThread(() -> { popup.displayInOverlay(); - api.getCache().clear(); - api.getCache().resolveSelf(); + api.getCache().renewSelf(); tagResponse = null; positionResponse = null; iconResponse = null;