Can't create world with key path that matches an existing level name even if namespace is different
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 12.7k
- Forks
- 3.5k
- Avg merge
- 3d 13h
- Merged PRs (30d)
- 11
Description
Expected behavior
Should be able to create a world with key key for which Bukkit.getWorld(key) returns null.
Observed/Actual behavior
Some keys fail as a world with that level name already exist.
[09:52:35 ERROR]: Error occurred while enabling Paper-Test-Plugin v1.0.0-SNAPSHOT (Is it up to date?)
java.lang.IllegalArgumentException: Cannot create a world with key plugin:world and name world one (or both) already match a world that exists
at org.bukkit.craftbukkit.CraftServer.createWorld(CraftServer.java:1152) ~[main/:?]
at org.bukkit.Bukkit.createWorld(Bukkit.java:767) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at io.papermc.paper.testplugin.TestPlugin.onEnable(TestPlugin.java:17) ~[test-plugin-1.0.0-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:264) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:370) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:541) ~[paper-api-1.18.2-R0.1-SNAPSHOT.jar:?]
at org.bukkit.craftbukkit.CraftServer.enablePlugin(CraftServer.java:560) ~[main/:?]
at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:474) ~[main/:?]
at net.minecraft.server.MinecraftServer.loadWorld0(MinecraftServer.java:664) ~[main/:?]
at net.minecraft.server.MinecraftServer.loadLevel(MinecraftServer.java:431) ~[main/:?]
at net.minecraft.server.dedicated.DedicatedServer.initServer(DedicatedServer.java:316) ~[main/:?]
at net.minecraft.server.MinecraftServer.runServer(MinecraftServer.java:1163) ~[main/:?]
at net.minecraft.server.MinecraftServer.lambda$spin$0(MinecraftServer.java:315) ~[main/:?]
at java.lang.Thread.run(Thread.java:833) ~[?:?]
Steps/models to reproduce
In a plugin onEnable, just run
final NamespacedKey worldKey = new NamespacedKey("plugin", "world");
if (Bukkit.getWorld(worldKey) == null) {
WorldCreator creator = new WorldCreator(worldKey);
Bukkit.createWorld(creator);
}
Plugin and Datapack List
none
Paper version
f210f67c4ad1560685e4354dfa242c120e42efe3
Other
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at CraftServer.createWorld, identified in the stack trace, and compare its handling of the NamespacedKey and world name with Bukkit.getWorld and WorldCreator. Reproduce the case using the TestPlugin.onEnable snippet with a namespaced key whose level name already exists. Done means the namespaced key can create a world when Bukkit.getWorld(key) returns null, while existing-world conflicts remain rejected.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100