Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Commit 3d49763

Browse files
committed
Checkstyle fixes to patchwork-fml
1 parent babc466 commit 3d49763

5 files changed

Lines changed: 53 additions & 49 deletions

File tree

patchwork-fml/src/main/java/net/minecraftforge/api/distmarker/Dist.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,13 @@
2929
* <li>{@link #CLIENT} is the <em>client</em> distribution, it contains
3030
* the game client, and has code to render a viewport into a game world.</li>
3131
* <li>{@link #DEDICATED_SERVER} is the <em>dedicated server</em> distribution,
32-
* it contains a server, which can simulate the world and communicates via network.</li>
32+
* it contains a server, which can simulate the world and communicates via the network.</li>
3333
* </ul>
3434
*/
3535
public enum Dist {
36-
3736
/**
3837
* The client distribution. This is the game client players can purchase and play.
39-
* It contains the graphics and other rendering to present a viewport into the game world.
38+
* It contains graphics and other rendering to present a viewport into the game world.
4039
*/
4140
CLIENT,
4241
/**
@@ -55,14 +54,14 @@ public static Dist fromEnvType(EnvType type) {
5554
}
5655

5756
/**
58-
* @return If this marks a dedicated server.
57+
* @return {@code true} if this marks a dedicated server.
5958
*/
6059
public boolean isDedicatedServer() {
6160
return !isClient();
6261
}
6362

6463
/**
65-
* @return if this marks a client.
64+
* @return {@code true} if this marks a client.
6665
*/
6766
public boolean isClient() {
6867
return this == CLIENT;

patchwork-fml/src/main/java/net/minecraftforge/fml/DistExecutor.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,25 @@
1919

2020
package net.minecraftforge.fml;
2121

22-
import net.fabricmc.loader.api.FabricLoader;
22+
import java.util.concurrent.Callable;
23+
import java.util.function.Supplier;
24+
2325
import net.minecraftforge.api.distmarker.Dist;
2426
import net.minecraftforge.fml.loading.FMLEnvironment;
2527

26-
import java.util.concurrent.Callable;
27-
import java.util.function.Supplier;
28+
import net.fabricmc.loader.api.FabricLoader;
2829

2930
public final class DistExecutor {
3031
private DistExecutor() {
3132
}
3233

3334
/**
34-
* Run the callable in the supplier only on the specified {@link Dist}
35+
* Run the callable in the supplier only on the specified {@link Dist}.
3536
*
36-
* @param dist The dist to run on
37-
* @param toRun A supplier of the callable to run (Supplier wrapper to ensure classloading only on the appropriate dist)
38-
* @param <T> The return type from the callable
39-
* @return The callable's result
37+
* @param dist The {@link Dist} to run on
38+
* @param toRun A {@link Supplier} of the {@link Callable} to run ({@link Supplier} wrapper to ensure classloading only on the appropriate dist)
39+
* @param <T> The return type from the {@link Callable}
40+
* @return The {@link Callable}'s result
4041
*/
4142
public static <T> T callWhenOn(Dist dist, Supplier<Callable<T>> toRun) {
4243
if (dist == FMLEnvironment.dist) {
@@ -46,6 +47,7 @@ public static <T> T callWhenOn(Dist dist, Supplier<Callable<T>> toRun) {
4647
throw new RuntimeException(e);
4748
}
4849
}
50+
4951
return null;
5052
}
5153

@@ -57,12 +59,12 @@ public static void runWhenOn(Dist dist, Supplier<Runnable> toRun) {
5759

5860
public static <T> T runForDist(Supplier<Supplier<T>> clientTarget, Supplier<Supplier<T>> serverTarget) {
5961
switch (FabricLoader.getInstance().getEnvironmentType()) {
60-
case CLIENT:
61-
return clientTarget.get().get();
62-
case SERVER:
63-
return serverTarget.get().get();
64-
default:
65-
throw new IllegalArgumentException("UNSIDED?");
62+
case CLIENT:
63+
return clientTarget.get().get();
64+
case SERVER:
65+
return serverTarget.get().get();
66+
default:
67+
throw new IllegalArgumentException("UNSIDED?");
6668
}
6769
}
6870
}

patchwork-fml/src/main/java/net/minecraftforge/fml/loading/FMLEnvironment.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,10 @@
1919

2020
package net.minecraftforge.fml.loading;
2121

22-
import net.fabricmc.loader.api.FabricLoader;
2322
import net.minecraftforge.api.distmarker.Dist;
2423

24+
import net.fabricmc.loader.api.FabricLoader;
25+
2526
public class FMLEnvironment {
2627
public static final Dist dist = Dist.fromEnvType(FabricLoader.getInstance().getEnvironmentType());
2728

patchwork-fml/src/main/java/net/minecraftforge/fml/loading/FMLPaths.java

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,18 @@
1919

2020
package net.minecraftforge.fml.loading;
2121

22-
import net.fabricmc.loader.api.FabricLoader;
23-
import org.apache.logging.log4j.LogManager;
24-
import org.apache.logging.log4j.Logger;
22+
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
2523

2624
import java.nio.file.Path;
2725
import java.nio.file.Paths;
2826
import java.util.Arrays;
2927

30-
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
28+
import org.apache.logging.log4j.LogManager;
29+
import org.apache.logging.log4j.Logger;
3130

32-
public enum FMLPaths
33-
{
31+
import net.fabricmc.loader.api.FabricLoader;
32+
33+
public enum FMLPaths {
3434
GAMEDIR(),
3535
MODSDIR("mods"),
3636
CONFIGDIR("config"),
@@ -55,21 +55,20 @@ public enum FMLPaths
5555
this.isDirectory = isDir;
5656
}
5757

58-
private Path computePath(String... path)
59-
{
60-
return Paths.get(path[0], Arrays.copyOfRange(path, 1, path.length));
61-
}
62-
63-
// TODO: Implementation Detail: public static void setup(IEnvironment env)
64-
6558
public static void loadAbsolutePaths(Path rootPath) {
6659
throw new UnsupportedOperationException("Implementation detail");
6760
}
6861

62+
// TODO: Implementation Detail: public static void setup(IEnvironment env)
63+
6964
public static Path getOrCreateGameRelativePath(Path path, String name) {
7065
return FileUtils.getOrCreateDirectory(FMLPaths.GAMEDIR.get().resolve(path), name);
7166
}
7267

68+
private Path computePath(String... path) {
69+
return Paths.get(path[0], Arrays.copyOfRange(path, 1, path.length));
70+
}
71+
7372
public Path relative() {
7473
return relativePath;
7574
}
@@ -84,7 +83,7 @@ public Path get() {
8483
FileUtils.getOrCreateDirectory(absolutePath, name());
8584
}
8685

87-
LOGGER.debug(CORE,"Path {} is {}", this, absolutePath);
86+
LOGGER.debug(CORE, "Path {} is {}", this, absolutePath);
8887
}
8988

9089
return absolutePath;

patchwork-fml/src/main/java/net/minecraftforge/fml/loading/FileUtils.java

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,50 +19,53 @@
1919

2020
package net.minecraftforge.fml.loading;
2121

22-
import org.apache.logging.log4j.LogManager;
23-
import org.apache.logging.log4j.Logger;
22+
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
2423

2524
import java.io.IOException;
2625
import java.nio.file.FileAlreadyExistsException;
2726
import java.nio.file.Files;
2827
import java.nio.file.Path;
2928

30-
import static net.minecraftforge.fml.loading.LogMarkers.CORE;
29+
import org.apache.logging.log4j.LogManager;
30+
import org.apache.logging.log4j.Logger;
3131

32-
public class FileUtils
33-
{
32+
public class FileUtils {
3433
private static final Logger LOGGER = LogManager.getLogger();
3534

3635
public static Path getOrCreateDirectory(Path dirPath, String dirLabel) {
3736
if (!Files.isDirectory(dirPath.getParent())) {
38-
getOrCreateDirectory(dirPath.getParent(), "parent of "+dirLabel);
37+
getOrCreateDirectory(dirPath.getParent(), "parent of " + dirLabel);
3938
}
40-
if (!Files.isDirectory(dirPath))
41-
{
42-
LOGGER.debug(CORE,"Making {} directory : {}", dirLabel, dirPath);
39+
40+
if (!Files.isDirectory(dirPath)) {
41+
LOGGER.debug(CORE, "Making {} directory : {}", dirLabel, dirPath);
42+
4343
try {
4444
Files.createDirectory(dirPath);
4545
} catch (IOException e) {
4646
if (e instanceof FileAlreadyExistsException) {
47-
LOGGER.fatal(CORE,"Failed to create {} directory - there is a file in the way", dirLabel);
47+
LOGGER.fatal(CORE, "Failed to create {} directory - there is a file in the way", dirLabel);
4848
} else {
49-
LOGGER.fatal(CORE,"Problem with creating {} directory (Permissions?)", dirLabel, e);
49+
LOGGER.fatal(CORE, "Problem with creating {} directory (Permissions?)", dirLabel, e);
5050
}
51+
5152
throw new RuntimeException("Problem creating directory", e);
5253
}
53-
LOGGER.debug(CORE,"Created {} directory : {}", dirLabel, dirPath);
54+
55+
LOGGER.debug(CORE, "Created {} directory : {}", dirLabel, dirPath);
5456
} else {
55-
LOGGER.debug(CORE,"Found existing {} directory : {}", dirLabel, dirPath);
57+
LOGGER.debug(CORE, "Found existing {} directory : {}", dirLabel, dirPath);
5658
}
59+
5760
return dirPath;
5861
}
5962

60-
6163
public static String fileExtension(final Path path) {
6264
String fileName = path.getFileName().toString();
6365
int idx = fileName.lastIndexOf('.');
66+
6467
if (idx > -1) {
65-
return fileName.substring(idx+1);
68+
return fileName.substring(idx + 1);
6669
} else {
6770
return "";
6871
}

0 commit comments

Comments
 (0)