aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/ApiData.java10
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java8
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java39
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java1
4 files changed, 53 insertions, 5 deletions
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/ApiData.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/ApiData.java
index 716ed454..1155884b 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/ApiData.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/ApiData.java
@@ -19,6 +19,7 @@
package io.github.moulberry.notenoughupdates.miscgui.minionhelper;
+import java.util.List;
import java.util.Map;
public class ApiData {
@@ -28,19 +29,22 @@ public class ApiData {
private final int magesReputation;
private final int barbariansReputation;
private final boolean collectionApiDisabled;
+ private final List<String> craftedMinions;
public ApiData(
Map<String, Integer> highestCollectionTier,
Map<String, Integer> slayerTiers,
int magesReputation,
int barbariansReputation,
- boolean collectionApiDisabled
+ boolean collectionApiDisabled,
+ List<String> craftedMinions
) {
this.highestCollectionTier = highestCollectionTier;
this.slayerTiers = slayerTiers;
this.magesReputation = magesReputation;
this.barbariansReputation = barbariansReputation;
this.collectionApiDisabled = collectionApiDisabled;
+ this.craftedMinions = craftedMinions;
}
public Map<String, Integer> getHighestCollectionTier() {
@@ -62,4 +66,8 @@ public class ApiData {
public boolean isCollectionApiDisabled() {
return collectionApiDisabled;
}
+
+ public List<String> getCraftedMinions() {
+ return craftedMinions;
+ }
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
index 20917103..e0edef17 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java
@@ -379,4 +379,12 @@ public class MinionHelperManager {
MinionHelperApiLoader.getInstance().onProfileSwitch();
}
+
+ public void reloadCraftedMinions() {
+ if (apiData != null) {
+ for (String minion : apiData.getCraftedMinions()) {
+ getMinionById(minion).setCrafted(true);
+ }
+ }
+ }
}
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 2f6b21f9..e29c8157 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
@@ -23,6 +23,7 @@ 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.MiscUtils;
import io.github.moulberry.notenoughupdates.core.util.StringUtils;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.ApiData;
import io.github.moulberry.notenoughupdates.miscgui.minionhelper.MinionHelperManager;
@@ -37,8 +38,10 @@ 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;
import java.util.LinkedHashMap;
+import java.util.List;
import java.util.Map;
public class MinionHelperApiLoader {
@@ -101,19 +104,42 @@ public class MinionHelperApiLoader {
for (JsonElement element : profiles) {
JsonObject profile = element.getAsJsonObject();
String profileName = profile.get("cute_name").getAsString();
- JsonObject player = profile.getAsJsonObject("members").getAsJsonObject(Minecraft.getMinecraft().thePlayer
+ JsonObject members = profile.getAsJsonObject("members");
+ JsonObject player = members.getAsJsonObject(Minecraft.getMinecraft().thePlayer
.getUniqueID()
.toString()
.replace("-", ""));
if (profileName.equals(SBInfo.getInstance().currentProfile)) {
- readData(player);
+ readData(player, members);
return;
}
}
}
- private void readData(JsonObject player) {
+ private List<String> loadMinionData(JsonObject members) {
+ List<String> craftedMinions = new ArrayList<>();
+ for (Map.Entry<String, JsonElement> entry : members.entrySet()) {
+ JsonObject value = entry.getValue().getAsJsonObject();
+ if (value.has("crafted_generators")) {
+ for (JsonElement e : value.get("crafted_generators").getAsJsonArray()) {
+ String rawGenerator = e.getAsString();
+ String[] split = rawGenerator.split("_");
+ String tier = split[split.length - 1];
+ String name = rawGenerator.substring(0, rawGenerator.length() - tier.length() - 1);
+ String internalName = name + "_GENERATOR_" + tier;
+ craftedMinions.add(internalName);
+ }
+ }
+ }
+
+ return craftedMinions;
+ }
+
+ private void readData(JsonObject player, JsonObject members) {
+
+ Utils.addChatMessage("set clipboard!");
+ MiscUtils.copyToClipboard(player.toString());
Map<String, Integer> highestCollectionTier = new HashMap<>();
Map<String, Integer> slayerTier = new HashMap<>();
int magesReputation = 0;
@@ -187,14 +213,19 @@ public class MinionHelperApiLoader {
}
}
+ List<String> craftedMinions = loadMinionData(members);
+
manager.setApiData(new ApiData(
highestCollectionTier,
slayerTier,
magesReputation,
barbariansReputation,
- !collectionApiEnabled
+ !collectionApiEnabled,
+ craftedMinions
));
+
manager.reloadRequirements();
+ manager.reloadCraftedMinions();
apiReadyToUse = true;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
index fca1bcb1..0973b644 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperRepoLoader.java
@@ -98,6 +98,7 @@ public class MinionHelperRepoLoader {
testForMissingData();
manager.reloadRequirements();
+ manager.reloadCraftedMinions();
repoReadyToUse = true;
if (error) {