Skip to content

Commit 68f7ef5

Browse files
committed
Improve the default world keys.
The API made an assumption these keys would always be the same key id. While I highly doubt Mojang would change, there is no reason to make it contract. Also deprecate defaultWorld in WorldManager and OVERWORLD to better match what we are doing. Signed-off-by: Chris Sanders <[email protected]>
1 parent 6fb79af commit 68f7ef5

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

src/main/java/org/spongepowered/api/world/DefaultWorldKeys.java

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,46 @@
2525
package org.spongepowered.api.world;
2626

2727
import org.spongepowered.api.ResourceKey;
28+
import org.spongepowered.api.Sponge;
2829
import org.spongepowered.api.world.server.ServerWorld;
2930

3031
/**
3132
* A listing of the {@link ResourceKey keys} of the default {@link ServerWorld worlds} in Minecraft.
3233
*/
3334
public final class DefaultWorldKeys {
3435

36+
/**
37+
* @deprecated Use {@link #DEFAULT} instead
38+
*/
39+
@Deprecated
3540
public static final ResourceKey OVERWORLD = ResourceKey.minecraft("overworld");
3641

37-
public static final ResourceKey THE_NETHER = ResourceKey.minecraft("the_nether");
42+
/**
43+
* The default "world" of a running game session. Typically, the Overworld.
44+
* <p>
45+
* Refer to: <a href="https://minecraft.fandom.com/wiki/Overworld">Overworld</a>
46+
*/
47+
public static final ResourceKey DEFAULT = Sponge.game().factoryProvider().provide(DefaultWorldKeys.Factory.class).defaultWorld();
3848

39-
public static final ResourceKey THE_END = ResourceKey.minecraft("the_end");
49+
/**
50+
* Refer to: <a href="https://minecraft.fandom.com/wiki/The_Nether">The Nether</a>
51+
*/
52+
public static final ResourceKey THE_NETHER = Sponge.game().factoryProvider().provide(DefaultWorldKeys.Factory.class).theNether();
53+
54+
/**
55+
* Refer to: <a href="https://minecraft.fandom.com/wiki/The_End">The End</a>
56+
*/
57+
public static final ResourceKey THE_END = Sponge.game().factoryProvider().provide(DefaultWorldKeys.Factory.class).theEnd();
4058

4159
private DefaultWorldKeys() {
4260
}
61+
62+
public interface Factory {
63+
64+
ResourceKey defaultWorld();
65+
66+
ResourceKey theNether();
67+
68+
ResourceKey theEnd();
69+
}
4370
}

src/main/java/org/spongepowered/api/world/server/WorldManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,10 @@ public interface WorldManager {
7474
* <p>It is up to the implementation to define what the default world actually is.</p>
7575
*
7676
* @return The default world
77+
*
78+
* @deprecated Use {@link #world(ResourceKey)} with {@link org.spongepowered.api.world.DefaultWorldKeys#DEFAULT} instead
7779
*/
80+
@Deprecated
7881
ServerWorld defaultWorld();
7982

8083
/**

0 commit comments

Comments
 (0)