diff options
author | Roman / Linnea Gräf <roman.graef@gmail.com> | 2023-06-27 19:50:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-27 19:50:08 +0200 |
commit | 838913f0d6e9f0b4f4cd2d5a2d59419fb5cbce66 (patch) | |
tree | 8545d7a94ddcffd88e3845fc10ff43c394810a6e | |
parent | c18352ccb6b71b14961adab81032c44d7cc2b3d3 (diff) | |
download | NotEnoughUpdates-838913f0d6e9f0b4f4cd2d5a2d59419fb5cbce66.tar.gz NotEnoughUpdates-838913f0d6e9f0b4f4cd2d5a2d59419fb5cbce66.tar.bz2 NotEnoughUpdates-838913f0d6e9f0b4f4cd2d5a2d59419fb5cbce66.zip |
Fix crash in npc exporter when mode = null (#736)
4 files changed, 18 insertions, 11 deletions
diff --git a/build.gradle.kts b/build.gradle.kts index 9523c739..49c7f38c 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -149,6 +149,7 @@ dependencies { isTransitive = false // Dependencies of mixin are already bundled by minecraft } annotationProcessor("net.fabricmc:sponge-mixin:0.11.4+mixin.0.8.5") + compileOnly("org.jetbrains:annotations:24.0.1") @Suppress("VulnerableLibrariesLocal") shadowApi("info.bliki.wiki:bliki-core:3.1.0") diff --git a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java index 14a4d828..2d637ab8 100644 --- a/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java +++ b/src/main/java/io/github/moulberry/notenoughupdates/util/SBInfo.java @@ -46,6 +46,8 @@ import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.fml.common.eventhandler.EventPriority; import net.minecraftforge.fml.common.eventhandler.SubscribeEvent; import net.minecraftforge.fml.common.gameevent.TickEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; import java.io.File; import java.io.IOException; @@ -76,8 +78,8 @@ public class SBInfo { public IChatComponent footer; public IChatComponent header; - public String location = ""; - public String lastLocation = ""; + public @NotNull String location = ""; + public @NotNull String lastLocation = ""; public String date = ""; public String time = ""; public String objective = ""; @@ -85,7 +87,7 @@ public class SBInfo { public boolean stranded = false; public boolean bingo = false; - public String mode = null; + public @Nullable String mode = null; public Date currentTimeDate = null; @@ -275,7 +277,7 @@ public class SBInfo { /** * @return the current mode, as returned by /locraw, usually equivalent to a skyblock public island type. */ - public String getLocation() { + public @Nullable String getLocation() { return mode; } @@ -290,7 +292,7 @@ public class SBInfo { /** * @return the current location as displayed on the scoreboard */ - public String getScoreboardLocation() { + public @NotNull String getScoreboardLocation() { return location; } @@ -298,7 +300,7 @@ public class SBInfo { * @return the previous location as displayed on the scoreboard * @see #getScoreboardLocation() */ - public String getLastScoreboardLocation() { + public @NotNull String getLastScoreboardLocation() { return lastLocation; } diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt index 9cf98e25..b9bc32dd 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/ItemShopExporter.kt @@ -60,7 +60,7 @@ class ItemShopExporter : RepoExporter { baseNPCJson["x"] = context.mc.thePlayer.posX.toInt() baseNPCJson["y"] = context.mc.thePlayer.posY.toInt() baseNPCJson["z"] = context.mc.thePlayer.posZ.toInt() - baseNPCJson["island"] = SBInfo.getInstance().getLocation() + baseNPCJson["island"] = SBInfo.getInstance().getLocation() ?: "none" val recipes = mutableListOf<ItemShopRecipe>() for (slotNum in 0 until inventory.sizeInventory) { diff --git a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/NPCLocationExporter.kt b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/NPCLocationExporter.kt index 9df738ca..2b8c99ff 100644 --- a/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/NPCLocationExporter.kt +++ b/src/main/kotlin/io/github/moulberry/notenoughupdates/recipes/generators/NPCLocationExporter.kt @@ -126,6 +126,11 @@ class NPCLocationExporter { @SubscribeEvent fun onMouseClick(event: MouseEvent) { if (event.buttonstate || event.button != 2 || !NotEnoughUpdates.INSTANCE.config.apiData.repositoryEditing) return + val location = SBInfo.getInstance().getLocation() + if (location == null) { + Utils.addChatMessage("No location found") + return + } val pointedEntity = Minecraft.getMinecraft().pointedEntity if (pointedEntity == null) { Utils.addChatMessage("Could not find entity under cursor") @@ -137,7 +142,7 @@ class NPCLocationExporter { // Just use jerry pet skin, idk, this will probably cause texture packs to overwrite us, but uhhhhh uhhhhhhh UUID.fromString("c9540683-51e4-3942-ad17-4f2c3f3ae4b7"), pointedEntity.position, - SBInfo.getInstance().getLocation(), + location, "822d8e751c8f2fd4c8942c44bdb2f5ca4d8ae8e575ed3eb34c18a86e93b" ) ) @@ -149,7 +154,7 @@ class NPCLocationExporter { NPCNamePrompt( pointedEntity.uniqueID, pointedEntity.position, - SBInfo.getInstance().getLocation(), + location, pointedEntity.getCurrentArmor(3)?.takeIf { it.stackSize > 0 } ?: ItemUtils.createQuestionMarkSkull("") ) @@ -161,12 +166,11 @@ class NPCLocationExporter { } val uuid = pointedEntity.uniqueID val position = pointedEntity.position - val island = SBInfo.getInstance().getLocation() val skin = pointedEntity.locationSkin.resourcePath?.replace("skins/", "") if (skin == null) { Utils.addChatMessage("Could not load skin") return } - Minecraft.getMinecraft().displayGuiScreen(NPCNamePrompt(uuid, position, island, skin)) + Minecraft.getMinecraft().displayGuiScreen(NPCNamePrompt(uuid, position, location, skin)) } } |