diff options
author | Lulonaut <lulonaut@lulonaut.tech> | 2023-10-06 15:44:59 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-06 15:44:59 +0200 |
commit | 810a25eec4e6712acee145526d3017dd118b8492 (patch) | |
tree | 9dadcb47bb4d51d5329e48b40899458b104f1de1 /src/main/java | |
parent | ebdc4df69093d29c3334537f9267374773464a30 (diff) | |
download | NotEnoughUpdates-810a25eec4e6712acee145526d3017dd118b8492.tar.gz NotEnoughUpdates-810a25eec4e6712acee145526d3017dd118b8492.tar.bz2 NotEnoughUpdates-810a25eec4e6712acee145526d3017dd118b8492.zip |
Remove legacy API keys from the code base (#862)
Co-authored-by: nopo <nopotheemail@gmail.com>
Diffstat (limited to 'src/main/java')
4 files changed, 8 insertions, 99 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java index f81331ea..268fddd5 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/NotEnoughUpdates.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -228,11 +228,6 @@ public class NotEnoughUpdates { config = new NEUConfig(); saveConfig(); } else { - if (config.apiKey != null && config.apiKey.apiKey != null) { - config.apiData.apiKey = config.apiKey.apiKey; - config.apiKey = null; - } - //add the trophy fishing tab to the config if (config.profileViewer.pageLayout.size() == 8) { config.profileViewer.pageLayout.add(8); diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java index ed275c7a..6f488107 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 NotEnoughUpdates contributors + * Copyright (C) 2022-2023 NotEnoughUpdates contributors * * This file is part of NotEnoughUpdates. * @@ -22,7 +22,6 @@ package io.github.moulberry.notenoughupdates.miscgui.minionhelper.loaders; import com.google.gson.JsonArray; import com.google.gson.JsonElement; import com.google.gson.JsonObject; -import io.github.moulberry.notenoughupdates.NotEnoughUpdates; import io.github.moulberry.notenoughupdates.core.util.StringUtils; import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent; import io.github.moulberry.notenoughupdates.miscgui.minionhelper.ApiData; @@ -31,12 +30,11 @@ import io.github.moulberry.notenoughupdates.profileviewer.ProfileViewer; import io.github.moulberry.notenoughupdates.util.Constants; import io.github.moulberry.notenoughupdates.util.SBInfo; import io.github.moulberry.notenoughupdates.util.Utils; +import lombok.Getter; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.EntityPlayerSP; import net.minecraft.item.ItemStack; -import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; -import net.minecraftforge.fml.common.gameevent.TickEvent; import java.util.ArrayList; import java.util.HashMap; @@ -46,50 +44,20 @@ import java.util.Map; public class MinionHelperApiLoader { private final MinionHelperManager manager; - private boolean dirty = true; private boolean collectionApiEnabled = true; - private boolean ignoreWorldSwitches = false; + @Getter private boolean readyToUse = false; + @Getter private ApiData apiData = null; + @Getter private boolean notifyNoCollectionApi = false; - private long lastLoaded = 0; + @Getter private boolean invalidApiKey = true; public MinionHelperApiLoader(MinionHelperManager manager) { this.manager = manager; } - @SubscribeEvent - public void onWorldLoad(WorldEvent.Load event) { - if (ignoreWorldSwitches) return; - - setDirty(); - } - - @SubscribeEvent - public void onTick(TickEvent.ClientTickEvent event) { - if (Minecraft.getMinecraft().thePlayer == null) return; - if (!NotEnoughUpdates.INSTANCE.hasSkyblockScoreboard()) return; - if (!NotEnoughUpdates.INSTANCE.config.minionHelper.gui) return; - if (dirty && "Crafted Minions".equals(Utils.getOpenChestName())) { - load(); - } else { - if (System.currentTimeMillis() > lastLoaded + 60_000 * 3) { - dirty = true; - } - } - } - - private void load() { - lastLoaded = System.currentTimeMillis(); - - dirty = false; - String uuid = getUuid(); - if (uuid == null) return; - - NotEnoughUpdates.INSTANCE.manager.apiUtils.updateProfileData(uuid); - } - private String getUuid() { EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer; if (thePlayer == null) return null; @@ -254,30 +222,18 @@ public class MinionHelperApiLoader { } public void setDirty() { - dirty = true; readyToUse = false; } public void prepareProfileSwitch() { - ignoreWorldSwitches = true; readyToUse = false; } public void onProfileSwitch() { apiData = null; - setDirty(); - ignoreWorldSwitches = false; collectionApiEnabled = true; } - public boolean isReadyToUse() { - return readyToUse; - } - - public ApiData getApiData() { - return apiData; - } - public boolean isCollectionApiDisabled() { return apiData != null && apiData.isCollectionApiDisabled(); } @@ -290,11 +246,4 @@ public class MinionHelperApiLoader { this.notifyNoCollectionApi = notifyNoCollectionApi; } - public boolean isNotifyNoCollectionApi() { - return notifyNoCollectionApi; - } - - public boolean isInvalidApiKey() { - return invalidApiKey; - } } diff --git a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ApiData.java b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ApiData.java index 2266f9e4..f081c231 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ApiData.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/options/separatesections/ApiData.java @@ -37,14 +37,6 @@ public class ApiData { @ConfigEditorBoolean public boolean apiDataUnlocked = false; - @Expose - @ConfigOption( - name = "Api Key", - desc = "Hypixel API key." - ) - @ConfigEditorText - public String apiKey = ""; - @ConfigEditorAccordion(id = 0) @ConfigOption(name = "Repository", desc = "") public boolean repository = false; diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java index 9611f197..5f436eb6 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/ApiUtil.java @@ -23,9 +23,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.JsonObject; import io.github.moulberry.notenoughupdates.NotEnoughUpdates; -import io.github.moulberry.notenoughupdates.events.ProfileDataLoadedEvent; import io.github.moulberry.notenoughupdates.util.kotlin.KotlinTypeAdapterFactory; -import net.minecraft.client.Minecraft; import org.apache.commons.io.IOUtils; import org.apache.http.NameValuePair; import org.apache.http.client.utils.URIBuilder; @@ -104,25 +102,6 @@ public class ApiUtil { } } - public void updateProfileData() { - updateProfileData(Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", "")); - } - - public void updateProfileData(String playerUuid) { - if (true) return; - if (!updateTasks.getOrDefault(playerUuid, CompletableFuture.completedFuture(null)).isDone()) return; - - String uuid = Minecraft.getMinecraft().thePlayer.getUniqueID().toString().replace("-", ""); - updateTasks.put(playerUuid, newHypixelApiRequest("skyblock/profiles") - .queryArgument("uuid", uuid) - .requestJson() - .handle((jsonObject, throwable) -> { - new ProfileDataLoadedEvent(uuid, jsonObject).post(); - return null; - })); - - } - public static class Request { private final List<NameValuePair> queryArguments = new ArrayList<>(); @@ -291,7 +270,7 @@ public class ApiUtil { } }, executorService).handle((obj, t) -> { if (t != null) { - System.err.println(ErrorUtil.printStackTraceWithoutApiKey(t)); + t.printStackTrace(); } return obj; }); @@ -320,12 +299,6 @@ public class ApiUtil { return new Request(); } - @Deprecated - public Request newHypixelApiRequest(String apiPath) { - return newAnonymousHypixelApiRequest(apiPath) - .queryArgument("key", NotEnoughUpdates.INSTANCE.config.apiData.apiKey); - } - public Request newAnonymousHypixelApiRequest(String apiPath) { return new Request() .url("https://api.hypixel.net/" + apiPath); |