Skip to content

Commit 122e351

Browse files
committed
Fix some formatting and documentation
1 parent 25eeefb commit 122e351

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

src/main/java/org/mvplugins/multiverse/core/utils/compatibility/BukkitCompatibility.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
@ApiStatus.AvailableSince("5.6")
1919
public final class BukkitCompatibility {
2020

21-
private static final Option<Method> getLevelDirectoryMethod;
22-
private static final Option<Method> getWorldNamespacedKeyMethod;
21+
private static final Option<Method> GET_LEVEL_DIRECTORY_METHOD;
22+
private static final Option<Method> GET_WORLD_NAMESPACED_KEY_METHOD;
2323

2424
static {
25-
getLevelDirectoryMethod = Option.of(ReflectHelper.getMethod(Server.class, "getLevelDirectory"));
26-
getWorldNamespacedKeyMethod = Option.of(ReflectHelper.getMethod(Bukkit.class, "getWorld", NamespacedKey.class));
25+
GET_LEVEL_DIRECTORY_METHOD = Option.of(ReflectHelper.getMethod(Server.class, "getLevelDirectory"));
26+
GET_WORLD_NAMESPACED_KEY_METHOD = Option.of(ReflectHelper.getMethod(Bukkit.class, "getWorld", NamespacedKey.class));
2727
}
2828

2929
/**
@@ -39,15 +39,19 @@ public final class BukkitCompatibility {
3939
@NotNull
4040
public static Path getWorldFoldersDirectory() {
4141
Server server = Bukkit.getServer();
42-
return getLevelDirectoryMethod.map(method -> ReflectHelper.invokeMethod(server, method))
42+
return GET_LEVEL_DIRECTORY_METHOD.map(method -> ReflectHelper.invokeMethod(server, method))
4343
.filter(Path.class::isInstance)
4444
.map(Path.class::cast)
4545
.map(path -> path.resolve("dimensions/minecraft"))
4646
.getOrElse(() -> server.getWorldContainer().toPath());
4747
}
4848

4949
/**
50-
* Check if the world with the given name or namespaced key (e.g. minecraft:overworld) exists, and return it if it does.
50+
* Check if the world with the given name or namespaced key (e.g. minecraft:overworld) exists,
51+
* and return it if it does.
52+
* <br />
53+
* Note that some default world names have different namespaced key matched with them.
54+
* E.g.: world -> minecraft:overworld, world_nether -> minecraft:the_nether, world_the_end -> minecraft:the_end.
5155
*
5256
* @param nameOrKey Either a name or namespaced key string representation.
5357
* @return The world if it exists
@@ -56,7 +60,7 @@ public static Path getWorldFoldersDirectory() {
5660
@NotNull
5761
public static Option<World> getWorldByNameOrKey(@NotNull String nameOrKey) {
5862
return Option.of(Bukkit.getWorld(nameOrKey))
59-
.orElse(() -> getWorldNamespacedKeyMethod
63+
.orElse(() -> GET_WORLD_NAMESPACED_KEY_METHOD
6064
.map(method -> ReflectHelper.invokeMethod(null, method, NamespacedKey.fromString(nameOrKey)))
6165
.filter(World.class::isInstance)
6266
.map(World.class::cast));

src/main/java/org/mvplugins/multiverse/core/world/helpers/WorldNameChecker.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ private boolean folderWorldSchemaCheck(@NotNull File worldFolder) {
155155
}
156156

157157
/**
158-
* Helper class to check if a file or folder exist
158+
* Helper class to check if a file or folder exist.
159159
*/
160160
private interface WorldFolderSchema {
161161

@@ -169,7 +169,7 @@ static WorldFolderSchema folder(String path) {
169169

170170
boolean check(File worldFolder);
171171

172-
class WorldFile implements WorldFolderSchema {
172+
final class WorldFile implements WorldFolderSchema {
173173
private final String path;
174174

175175
private WorldFile(String path) {
@@ -183,7 +183,7 @@ public boolean check(File worldFolder) {
183183
}
184184
}
185185

186-
class WorldFolder implements WorldFolderSchema {
186+
final class WorldFolder implements WorldFolderSchema {
187187
private final String path;
188188

189189
private WorldFolder(String path) {

0 commit comments

Comments
 (0)