aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz <lo.scherf@gmail.com>2022-09-11 13:45:46 +0200
committerLorenz <lo.scherf@gmail.com>2022-09-11 13:45:46 +0200
commita5692f1aa2fd445056cc463e1316ef79d9f269a6 (patch)
treee217bc5692a1aa18092661bbc9f4d3054a4c925c
parentc2f903d30782264cdecd26266e789b20d9c5b650 (diff)
downloadNotEnoughUpdates-a5692f1aa2fd445056cc463e1316ef79d9f269a6.tar.gz
NotEnoughUpdates-a5692f1aa2fd445056cc463e1316ef79d9f269a6.tar.bz2
NotEnoughUpdates-a5692f1aa2fd445056cc463e1316ef79d9f269a6.zip
added debugplayer command to test other players view of the minion helper
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/MinionHelperManager.java44
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperApiLoader.java25
-rw-r--r--src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java8
3 files changed, 67 insertions, 10 deletions
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 8df6cebf..b9e99c5f 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
@@ -53,6 +53,9 @@ public class MinionHelperManager {
private final MinionHelperRepoLoader repo = new MinionHelperRepoLoader(this);
private final MinionHelperOverlay overlay = new MinionHelperOverlay(this);
private final MinionHelperInventoryLoader inventoryLoader = new MinionHelperInventoryLoader(this);
+ private String debugPlayerUuid;
+ private String debugProfileName;
+ private int debugNeedForNextSlot;
public static MinionHelperManager getInstance() {
if (instance == null) {
@@ -165,6 +168,27 @@ public class MinionHelperManager {
if (args.length > 1) {
String parameter = args[1];
+ if (parameter.equals("debugplayer")) {
+ if (args.length == 3) {
+ if (args[2].equals("reset")) {
+ Utils.addChatMessage("§e[NEU] Minion debug player reset.");
+ setDebugPlayer(null, null, -1);
+ return;
+ }
+ }
+ if (args.length < 4) {
+ Utils.addChatMessage("§c[NEU] Usage: /neudevtest minion " +
+ "setplayer <player-uuid> <player-profile-name> [need-for-next-slot]");
+ return;
+ }
+ String playerUuid = args[2];
+ String playerProfileName = args[3];
+ int need = args.length == 5 ? Integer.parseInt(args[4]) : -1;
+ setDebugPlayer(playerUuid, playerProfileName, need);
+ Utils.addChatMessage("§e[NEU] Minion debug player set.");
+ return;
+ }
+
if (args.length == 2) {
if (parameter.equals("clearminion")) {
minions.clear();
@@ -221,6 +245,14 @@ public class MinionHelperManager {
Utils.addChatMessage("");
}
+ private void setDebugPlayer(String playerUuid, String playerProfileName, int fakeNeedForNextSlot) {
+ this.debugPlayerUuid = playerUuid;
+ this.debugProfileName = playerProfileName;
+ this.debugNeedForNextSlot = fakeNeedForNextSlot;
+
+ onProfileSwitch();
+ }
+
public MinionHelperPriceCalculation getPriceCalculation() {
return priceCalculation;
}
@@ -271,4 +303,16 @@ public class MinionHelperManager {
}
}
}
+
+ public String getDebugPlayerUuid() {
+ return debugPlayerUuid;
+ }
+
+ public String getDebugProfileName() {
+ return debugProfileName;
+ }
+
+ public int getDebugNeedForNextSlot() {
+ return debugNeedForNextSlot;
+ }
}
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 adaf782b..7bbd5682 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
@@ -86,11 +86,10 @@ public class MinionHelperApiLoader {
private void load() {
lastLoaded = System.currentTimeMillis();
- EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer;
- if (thePlayer == null) return;
dirty = false;
- String uuid = thePlayer.getUniqueID().toString().replace("-", "");
+ String uuid = getUuid();
+ if (uuid == null) return;
HashMap<String, String> map = new HashMap<String, String>() {{
put("uuid", uuid);
}};
@@ -103,6 +102,16 @@ public class MinionHelperApiLoader {
).thenAccept(this::updateInformation);
}
+ private String getUuid() {
+ EntityPlayerSP thePlayer = Minecraft.getMinecraft().thePlayer;
+ if (thePlayer == null) return null;
+
+ String debugPlayerUuid = manager.getDebugPlayerUuid();
+ if (debugPlayerUuid != null) return debugPlayerUuid;
+
+ return thePlayer.getUniqueID().toString().replace("-", "");
+ }
+
private void updateInformation(JsonObject entireApiResponse) {
if (entireApiResponse == null) {
invalidApiKey = true;
@@ -116,12 +125,12 @@ public class MinionHelperApiLoader {
JsonObject profile = element.getAsJsonObject();
String profileName = profile.get("cute_name").getAsString();
JsonObject members = profile.getAsJsonObject("members");
- JsonObject player = members.getAsJsonObject(Minecraft.getMinecraft().thePlayer
- .getUniqueID()
- .toString()
- .replace("-", ""));
+ JsonObject player = members.getAsJsonObject(getUuid());
+
+ String debugProfileName = manager.getDebugProfileName();
+ String currentProfile = debugProfileName != null ? debugProfileName : SBInfo.getInstance().currentProfile;
- if (profileName.equals(SBInfo.getInstance().currentProfile)) {
+ if (profileName.equals(currentProfile)) {
readData(player, members);
return;
}
diff --git a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
index 14571cb3..7fc703e6 100644
--- a/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
+++ b/src/main/java/io/github/moulberry/notenoughupdates/miscgui/minionhelper/loaders/MinionHelperInventoryLoader.java
@@ -86,7 +86,9 @@ public class MinionHelperInventoryLoader {
checkNextSlot(openContainer);
checkLocalPelts();
}
- loadMinionData(openContainer);
+ if (manager.getDebugPlayerUuid() == null) {
+ loadMinionData(openContainer);
+ }
}
}
@@ -110,7 +112,9 @@ public class MinionHelperInventoryLoader {
for (String line : ItemUtils.getLore(informationStack)) {
Matcher matcher = PATTERN_MINIONS_NEEDED.matcher(line);
if (matcher.matches()) {
- int needForNextSlot = Integer.parseInt(matcher.group(1));
+ int debugNeedForNextSlot = manager.getDebugNeedForNextSlot();
+ int needForNextSlot = debugNeedForNextSlot != -1 ? debugNeedForNextSlot : Integer.parseInt(matcher.group(1));
+
manager.setNeedForNextSlot(needForNextSlot);
return;
}