Skip to content

Commit

Permalink
Merge pull request #58 from Global-Tags/chore/cacheFlickering
Browse files Browse the repository at this point in the history
chore: Remove cache flickering, cache renew subcommand
  • Loading branch information
RappyTV authored Sep 27, 2024
2 parents b07f716 + bc3e325 commit 908935a
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 25 deletions.
2 changes: 1 addition & 1 deletion api/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.2")
}

labyModAnnotationProcessor {
Expand Down
19 changes: 1 addition & 18 deletions api/src/main/java/com/rappytv/globaltags/api/GlobalTagAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -16,10 +13,7 @@
import java.util.UUID;
import java.util.function.Supplier;

public class GlobalTagAPI implements GlobalTagsAPI<Component> {

private final Cache<Component> cache = new Cache<>(this);
private final ApiHandler<Component> apiHandler = new ApiHandler<>(this);
public class GlobalTagAPI extends GlobalTagsAPI<Component> {

private final Agent agent;
private final Supplier<String> language;
Expand Down Expand Up @@ -52,17 +46,6 @@ public GlobalTagAPI(Agent agent, Supplier<String> language) {
return Laby.labyAPI().getUniqueId();
}

@NotNull
@Override
public PlayerInfo.Cache<Component> getCache() {
return cache;
}

@Override
public @NotNull ApiHandler<Component> getApiHandler() {
return apiHandler;
}

@Override
public @NotNull AuthProvider getAuthType() {
return AuthProvider.LABYCONNECT;
Expand Down
3 changes: 1 addition & 2 deletions api/src/main/java/com/rappytv/globaltags/api/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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.2")
}

labyModAnnotationProcessor {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -25,6 +26,7 @@ public GlobalTagCommand(GlobalTagAddon addon) {

withSubCommand(new ClearCacheCommand(api));
withSubCommand(new LinkDiscordSubcommand(api));
withSubCommand(new RenewCacheCommand(api));
withSubCommand(new UnlinkDiscordSubcommand(api));
}

Expand All @@ -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",
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
@@ -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", "renew", "rc");
this.api = api;
}

@Override
public boolean execute(String prefix, String[] arguments) {
api.getCache().renewAll();
displayMessage(
Component.empty()
.append(GlobalTagAddon.prefix)
.append(Component.translatable(
"globaltags.commands.renew_cache.success",
NamedTextColor.GREEN
))
);
return true;
}
}
3 changes: 3 additions & 0 deletions core/src/main/resources/assets/globaltags/i18n/de_de.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down
3 changes: 3 additions & 0 deletions core/src/main/resources/assets/globaltags/i18n/en_us.json
Original file line number Diff line number Diff line change
Expand Up @@ -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!"
Expand Down

0 comments on commit 908935a

Please sign in to comment.