Skip to content

Commit

Permalink
Apply checkstyle and nullabillity crackdowns
Browse files Browse the repository at this point in the history
Minestom was a pretty different codebase to ours
  • Loading branch information
Geolykt committed Oct 31, 2021
1 parent d017aea commit 0526b70
Show file tree
Hide file tree
Showing 20 changed files with 166 additions and 159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,4 @@ public void setRunAfter(Runnable r) {
public Version getDirectly() {
return hash;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,10 @@
* If an instance of this runnable is processed by the main task queue, then the main tasks queue will be stopped and the main thread exits.
* This however does not mean that the VM exits, as other threads will be still happily around.
*/
public class KillTaskQueueTask implements Runnable {
final class KillTaskQueueTask implements Runnable {

@Override
public void run() {
// Do nothing; it isn't really intended to be used as such
}

}
1 change: 1 addition & 0 deletions src/main/java/de/geolykt/starloader/launcher/Launcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ public static void main(String[] args) {
r.run();
}
} catch (InterruptedException e) {
continue;
} catch (Throwable e) {
e.printStackTrace();
System.exit(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public File getPatchesFolder() {
}

/**
* Obtains the file where the configuration will be saved to
* Obtains the file where the configuration will be saved to.
*
* @return The file
*/
Expand Down Expand Up @@ -200,7 +200,7 @@ public void setStorageFile(File file) {
}

/**
* Sets the jar that should be loaded when the "Play" button is pressed
* Sets the jar that should be loaded when the "Play" button is pressed.
*
* @param selected The java archive file to load
*/
Expand Down
14 changes: 6 additions & 8 deletions src/main/java/de/geolykt/starloader/launcher/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
import org.spongepowered.asm.mixin.MixinEnvironment.Phase;
import org.spongepowered.asm.mixin.Mixins;

import net.minestom.server.extras.selfmodification.MinestomRootClassLoader;

import de.geolykt.starloader.UnlikelyEventException;
import de.geolykt.starloader.launcher.service.SLMixinService;
import de.geolykt.starloader.util.Version;
import de.geolykt.starloader.util.Version.Stabillity;
import net.minestom.server.extras.selfmodification.MinestomRootClassLoader;

/**
* Collection of static utility methods.
Expand Down Expand Up @@ -59,18 +60,17 @@ private Utils() {
* @return registry value or null if not found
* @author Oleg Ryaboy, based on work by Miguel Enriquez; Made blocking by Geolykt
*/
public static final String readWindowsRegistry(String location, String key){
public static final String readWindowsRegistry(String location, String key) {
try {
// Run reg query, then read output with StreamReader (internal class)
Process process = Runtime.getRuntime().exec("reg query " +
'"'+ location + "\" /v " + key);
Process process = Runtime.getRuntime().exec("reg query " + '"' + location + "\" /v " + key);

process.waitFor();
InputStream is = process.getInputStream();
String output = new String(is.readAllBytes(), StandardCharsets.UTF_8);
is.close();

if(!output.contains(location) ||!output.contains(key)){
if (!output.contains(location) || !output.contains(key)) {
return null;
}

Expand All @@ -83,7 +83,6 @@ public static final String readWindowsRegistry(String location, String key){
e.printStackTrace();
return null;
}

}

public static final File getSteamExecutableDir() {
Expand Down Expand Up @@ -117,8 +116,7 @@ public static File getGameDir(String game) {
File steamExec = getSteamExecutableDir();
if (steamExec == null || !steamExec.exists()) {
if (OPERATING_SYSTEM.toLowerCase(Locale.ROOT).startsWith("win")) {
steamExec = getOneOfExistingFiles("C:\\Steam\\", "C:\\Program Files (x86)\\Steam\\",
"C:\\Program Files\\Steam\\", "D:\\Steam\\", "C:\\Programmes\\Steam\\", "D:\\Programmes\\Steam\\");
steamExec = getOneOfExistingFiles("C:\\Steam\\", "C:\\Program Files (x86)\\Steam\\", "C:\\Program Files\\Steam\\", "D:\\Steam\\", "C:\\Programmes\\Steam\\", "D:\\Programmes\\Steam\\");
} else {
// Assuming my install
String homeDir = System.getProperty("user.home");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ public void onClose(JFrame parent) {
e.printStackTrace();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,5 @@ public interface StarloaderTab {
*
* @param parent The parent JFrame
*/
public default void onOpen(JFrame parent) {

}
public default void onOpen(JFrame parent) { }
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* Services used by the SLL bootstrap. Most of those are required to get basic functionallity working.
*
*
* @author Geolykt
*
*/
Expand Down
18 changes: 8 additions & 10 deletions src/main/java/de/geolykt/starloader/mod/DiscoveredExtension.java
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package de.geolykt.starloader.mod;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.io.File;
import java.net.URL;
import java.util.LinkedList;
import java.util.List;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public final class DiscoveredExtension {

public final static Logger LOGGER = LoggerFactory.getLogger(DiscoveredExtension.class);
private static final Logger LOGGER = LoggerFactory.getLogger(DiscoveredExtension.class);

public static final String NAME_REGEX = "[A-Za-z][_A-Za-z0-9]+";
private String name;
Expand All @@ -26,7 +26,7 @@ public final class DiscoveredExtension {
private ExternalDependencies externalDependencies;
public transient List<URL> files = new LinkedList<>();
public transient LoadStatus loadStatus = LoadStatus.LOAD_SUCCESS;
transient private File originalJar;
private transient File originalJar;

@SuppressWarnings("null")
@NotNull
Expand Down Expand Up @@ -150,7 +150,6 @@ public static void verifyIntegrity(@NotNull DiscoveredExtension extension) {
if (extension.externalDependencies == null) {
extension.externalDependencies = new ExternalDependencies();
}

}

public enum LoadStatus {
Expand All @@ -159,8 +158,7 @@ public enum LoadStatus {
INVALID_NAME("Invalid name."),
NO_ENTRYPOINT("No entrypoint specified."),
FAILED_TO_SETUP_CLASSLOADER("Extension classloader could not be setup."),
LOAD_FAILED("Load failed. See logs for more information."),
;
LOAD_FAILED("Load failed. See logs for more information.");

@NotNull
private final String message;
Expand Down
39 changes: 11 additions & 28 deletions src/main/java/de/geolykt/starloader/mod/Extension.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package de.geolykt.starloader.mod;

import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;

import java.util.ArrayList;
import java.util.List;

import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger;

public abstract class Extension {
// Set by reflection
// FIXME issue: null within the constructor
Expand All @@ -14,21 +14,13 @@ public abstract class Extension {
// FIXME issue: null within the constructor
private Logger logger;

protected Extension() {
protected Extension() { }

}

public void preInitialize() {

}

public void initialize() {
public void preInitialize() { }

}
public void initialize() { }

public void postInitialize() {

}
public void postInitialize() { }

/**
* @deprecated This method is a boilerplate solution, for more info see below
Expand All @@ -41,9 +33,7 @@ public void postInitialize() {
* Other extension libraries might offer similar alternatives that are a lot more safer to use.
*/
@Deprecated(forRemoval = false)
public void preTerminate() {

}
public void preTerminate() { }

/**
* @deprecated This method is a boilerplate solution, for more info see below
Expand All @@ -56,9 +46,7 @@ public void preTerminate() {
* Other extension libraries might offer similar alternatives that are a lot more safer to use.
*/
@Deprecated(forRemoval = false)
public void terminate() {

}
public void terminate() { }

/**
* @deprecated This method is a boilerplate solution, for more info see below
Expand All @@ -71,9 +59,7 @@ public void terminate() {
* Other extension libraries might offer similar alternatives that are a lot more safer to use.
*/
@Deprecated(forRemoval = false)
public void postTerminate() {

}
public void postTerminate() { }

/**
* @deprecated This method is a boilerplate solution, for more info see below
Expand All @@ -89,9 +75,7 @@ public void postTerminate() {
* become unusable.
*/
@Deprecated(forRemoval = false)
public void unload() {

}
public void unload() { }

@NotNull
public final ExtensionDescription getDescription() {
Expand All @@ -111,7 +95,6 @@ public final Logger getLogger() {
return logger;
}


public static class ExtensionDescription {

@NotNull
Expand Down
Loading

0 comments on commit 0526b70

Please sign in to comment.