Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent exception with other world generators #449

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

Browsit
Copy link
Contributor

@Browsit Browsit commented Feb 2, 2024

Pull Request

Description

When defining generators for worlds that Bukkit loads by default, other plugins may trigger an exception within Terra as they, of course, do not use colons followed by pack IDs. Here is an example of such using PlotSquared on Paper 1.20.4:

[11:45:46] [Server thread/WARN]: java.lang.IllegalArgumentException: No such config pack ""
[11:45:46] [Server thread/WARN]: 	at Terra-bukkit-6.4.3-BETA+ab60f14ff-shaded.jar//com.dfsek.terra.bukkit.TerraBukkitPlugin.lambda$getDefaultWorldGenerator$2(TerraBukkitPlugin.java:194)
[11:45:46] [Server thread/WARN]: 	at java.base/java.util.Optional.orElseThrow(Optional.java:403)
[11:45:46] [Server thread/WARN]: 	at Terra-bukkit-6.4.3-BETA+ab60f14ff-shaded.jar//com.dfsek.terra.bukkit.TerraBukkitPlugin.lambda$getDefaultWorldGenerator$3(TerraBukkitPlugin.java:193)
[11:45:46] [Server thread/WARN]: 	at java.base/java.util.HashMap.computeIfAbsent(HashMap.java:1220)
[11:45:46] [Server thread/WARN]: 	at Terra-bukkit-6.4.3-BETA+ab60f14ff-shaded.jar//com.dfsek.terra.bukkit.TerraBukkitPlugin.getDefaultWorldGenerator(TerraBukkitPlugin.java:192)
[11:45:46] [Server thread/WARN]: 	at plotsquared-bukkit-7.3.2-Premium.jar//com.plotsquared.bukkit.util.BukkitSetupUtils.updateGenerators(BukkitSetupUtils.java:80)
[11:45:46] [Server thread/WARN]: 	at plotsquared-bukkit-7.3.2-Premium.jar//com.plotsquared.bukkit.BukkitPlatform.lambda$onEnable$1(BukkitPlatform.java:444)
[11:45:46] [Server thread/WARN]: 	at plotsquared-bukkit-7.3.2-Premium.jar//com.plotsquared.bukkit.util.task.BukkitPlotSquaredTask.runTask(BukkitPlotSquaredTask.java:39)
[11:45:46] [Server thread/WARN]: 	at plotsquared-bukkit-7.3.2-Premium.jar//com.plotsquared.core.util.task.PlotSquaredTask.run(PlotSquaredTask.java:44)
[11:45:46] [Server thread/WARN]: 	at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftTask.run(CraftTask.java:101)
[11:45:46] [Server thread/WARN]: 	at org.bukkit.craftbukkit.v1_20_R3.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:480)
[11:45:46] [Server thread/WARN]: 	at net.minecraft.server.MinecraftServer.w(MinecraftServer.java:1143)
[11:45:46] [Server thread/WARN]: 	at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:321)
[11:45:46] [Server thread/WARN]: 	at java.base/java.lang.Thread.run(Thread.java:833)

This PR resolves the issue by simply returning null when the generator being identified lacks an ID.

Fixes https://discord.com/channels/715448651786485780/1106498518807494676

Checklist

Mandatory checks

  • The base branch of this PR is an unreleased version branch (that has a ver/ prefix)
    or is a branch that is intended to be merged into a version branch.
  • There are no already existing PRs that provide the same changes.
  • The PR is within the scope of Terra (i.e. is something a configurable terrain generator should be doing).
  • Changes follow the code style for this project.
  • I have read the CONTRIBUTING.md
    document in the root of the git repository.

Types of changes

  • Bug Fix
  • Build system
  • Documentation
  • New Feature
  • Performance
  • Refactoring
  • Repository
  • Revert
  • Style
  • Tests
  • Translation

Compatibility

  • Introduces a breaking change
  • Introduces new functionality in a backwards compatible way.
  • Introduces bug fixes

Documentation

  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.

Testing

  • I have added tests to cover my changes.
  • All new and existing tests passed.

Licensing

  • I am the original author of this code, and I am willing to
    release it under GPLv3.
  • I am not the original author of this code, but it is in public domain or
    released under GPLv3 or a compatible license.

@duplexsystem duplexsystem merged commit 94949c9 into PolyhedralDev:ver/6.5.0 Feb 23, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants