Eclipse Formatting (#114)

* Switch to Eclipse JDT formatting

* Remove examplecode bloat

* Add maven/CF dependency deobfuscation

Credits to @FalsePattern

* Apply spotless

* Revert "Switch to Eclipse JDT formatting"

This reverts commit 96104db65b4e2630637e9f05b3bbb8fb3a762531.

* Rerun actions

* spotlessApply (#115)

Co-authored-by: GitHub GTNH Actions <>

---------

Co-authored-by: Raven Szewczyk <git@eigenraven.me>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
authored and GitHub committed 2023-01-28 20:08:45 +00:00
1 parent 408c4febad
commit ef147fa538
7 files changed
+57 -125

No files matched your search

+23 -3
View File
@@ -121,10 +121,7 @@ checkPropertyExists("autoUpdateBuildScript")
checkPropertyExists("minecraftVersion")
checkPropertyExists("forgeVersion")
checkPropertyExists("replaceGradleTokenInFile")
checkPropertyExists("gradleTokenModId")
checkPropertyExists("gradleTokenModName")
checkPropertyExists("gradleTokenVersion")
checkPropertyExists("gradleTokenGroupName")
checkPropertyExists("apiPackage")
checkPropertyExists("accessTransformersFile")
checkPropertyExists("usesMixins")
@@ -146,6 +143,11 @@ propertyDefaultIfUnset("curseForgeProjectId", "")
propertyDefaultIfUnset("curseForgeRelations", "")
propertyDefaultIfUnset("minimizeShadowedDependencies", true)
// Deprecated properties (kept for backwards compat)
propertyDefaultIfUnset("gradleTokenModId", "")
propertyDefaultIfUnset("gradleTokenModName", "")
propertyDefaultIfUnset("gradleTokenGroupName", "")
String javaSourceDir = "src/main/java/"
String scalaSourceDir = "src/main/scala/"
String kotlinSourceDir = "src/main/kotlin/"
@@ -1014,6 +1016,24 @@ def deobf(String sourceURL) {
}
}
def deobfMaven(String repoURL, String mavenDep) {
if (!repoURL.endsWith("/")) {
repoURL += "/"
}
String[] parts = mavenDep.split(":")
parts[0] = parts[0].replace('.', '/')
def jarURL = repoURL + parts[0] + "/" + parts[1] + "/" + parts[2] + "/" + parts[1] + "-" + parts[2] + ".jar"
return deobf(jarURL)
}
def deobfCurse(String curseDep) {
try {
return deobfMaven("https://www.cursemaven.com/", "curse.maven:$curseDep")
} catch (Exception ignored) {
out.style(Style.Failure).println("Failed to get $curseDep from cursemaven.")
}
}
// The method above is to be preferred. Use this method if the filename is not at the end of the URL.
def deobf(String sourceURL, String rawFileName) {
String bon2Version = "2.5.1"
-3
View File
@@ -35,10 +35,7 @@ developmentEnvironmentUserName = Developer
# version in @Mod([...], version = VERSION, [...])
# Leave these properties empty to skip individual token replacements
replaceGradleTokenInFile = Tags.java
gradleTokenModId = GRADLETOKEN_MODID
gradleTokenModName = GRADLETOKEN_MODNAME
gradleTokenVersion = GRADLETOKEN_VERSION
gradleTokenGroupName = GRADLETOKEN_GROUPNAME
# In case your mod provides an API for other mods to implement you may declare its package here. Otherwise, you can
# leave this property empty.
@@ -1,43 +1,8 @@
package com.myname.mymodid;
import cpw.mods.fml.common.event.*;
public class ClientProxy extends CommonProxy {
// preInit "Run before anything else. Read your config, create blocks, items,
// etc, and register them with the GameRegistry."
public void preInit(FMLPreInitializationEvent event) {
super.preInit(event);
}
// Override CommonProxy methods here, if you want a different behaviour on the client (e.g. registering renders).
// Don't forget to call the super methods aswell.
// load "Do your mod setup. Build whatever data structures you care about. Register recipes."
public void init(FMLInitializationEvent event) {
super.init(event);
}
// postInit "Handle interaction with other mods, complete your setup based on this."
public void postInit(FMLPostInitializationEvent event) {
super.postInit(event);
}
public void serverAboutToStart(FMLServerAboutToStartEvent event) {
super.serverAboutToStart(event);
}
// register server commands in this event handler
public void serverStarting(FMLServerStartingEvent event) {
super.serverStarting(event);
}
public void serverStarted(FMLServerStartedEvent event) {
super.serverStarted(event);
}
public void serverStopping(FMLServerStoppingEvent event) {
super.serverStopping(event);
}
public void serverStopped(FMLServerStoppedEvent event) {
super.serverStopped(event);
}
}
@@ -1,32 +1,27 @@
package com.myname.mymodid;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
public class CommonProxy {
// preInit "Run before anything else. Read your config, create blocks, items,
// etc, and register them with the GameRegistry."
// preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the
// GameRegistry." (Remove if not needed)
public void preInit(FMLPreInitializationEvent event) {
Config.syncronizeConfiguration(event.getSuggestedConfigurationFile());
Config.synchronizeConfiguration(event.getSuggestedConfigurationFile());
MyMod.info(Config.greeting);
MyMod.info("I am " + Tags.MODNAME + " at version " + Tags.VERSION + " and group name " + Tags.GROUPNAME);
MyMod.LOG.info(Config.greeting);
MyMod.LOG.info("I am " + Tags.MODNAME + " at version " + Tags.VERSION);
}
// load "Do your mod setup. Build whatever data structures you care about. Register recipes."
// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed)
public void init(FMLInitializationEvent event) {}
// postInit "Handle interaction with other mods, complete your setup based on this."
// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed)
public void postInit(FMLPostInitializationEvent event) {}
public void serverAboutToStart(FMLServerAboutToStartEvent event) {}
// register server commands in this event handler
// register server commands in this event handler (Remove if not needed)
public void serverStarting(FMLServerStartingEvent event) {}
public void serverStarted(FMLServerStartedEvent event) {}
public void serverStopping(FMLServerStoppingEvent event) {}
public void serverStopped(FMLServerStoppedEvent event) {}
}
+3 -15
View File
@@ -2,27 +2,15 @@ package com.myname.mymodid;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
public class Config {
private static class Defaults {
public static final String greeting = "Hello World";
}
public static String greeting = "Hello World";
private static class Categories {
public static final String general = "general";
}
public static String greeting = Defaults.greeting;
public static void syncronizeConfiguration(File configFile) {
public static void synchronizeConfiguration(File configFile) {
Configuration configuration = new Configuration(configFile);
configuration.load();
Property greetingProperty =
configuration.get(Categories.general, "greeting", Defaults.greeting, "How shall I greet?");
greeting = greetingProperty.getString();
greeting = configuration.getString("greeting", Configuration.CATEGORY_GENERAL, greeting, "How shall I greet?");
if (configuration.hasChanged()) {
configuration.save();
+11 -44
View File
@@ -2,76 +2,43 @@ package com.myname.mymodid;
import cpw.mods.fml.common.Mod;
import cpw.mods.fml.common.SidedProxy;
import cpw.mods.fml.common.event.*;
import cpw.mods.fml.common.event.FMLInitializationEvent;
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
import cpw.mods.fml.common.event.FMLServerStartingEvent;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@Mod(modid = Tags.MODID, version = Tags.VERSION, name = Tags.MODNAME, acceptedMinecraftVersions = "[1.7.10]")
public class MyMod {
private static Logger LOG = LogManager.getLogger(Tags.MODID);
public static final Logger LOG = LogManager.getLogger(Tags.MODID);
@SidedProxy(clientSide = Tags.GROUPNAME + ".ClientProxy", serverSide = Tags.GROUPNAME + ".CommonProxy")
@SidedProxy(clientSide = "com.myname.mymodid.ClientProxy", serverSide = "com.myname.mymodid.CommonProxy")
public static CommonProxy proxy;
@Mod.EventHandler
// preInit "Run before anything else. Read your config, create blocks, items,
// etc, and register them with the GameRegistry."
// preInit "Run before anything else. Read your config, create blocks, items, etc, and register them with the
// GameRegistry." (Remove if not needed)
public void preInit(FMLPreInitializationEvent event) {
proxy.preInit(event);
}
@Mod.EventHandler
// load "Do your mod setup. Build whatever data structures you care about. Register recipes."
// load "Do your mod setup. Build whatever data structures you care about. Register recipes." (Remove if not needed)
public void init(FMLInitializationEvent event) {
proxy.init(event);
}
@Mod.EventHandler
// postInit "Handle interaction with other mods, complete your setup based on this."
// postInit "Handle interaction with other mods, complete your setup based on this." (Remove if not needed)
public void postInit(FMLPostInitializationEvent event) {
proxy.postInit(event);
}
@Mod.EventHandler
public void serverAboutToStart(FMLServerAboutToStartEvent event) {
proxy.serverAboutToStart(event);
}
@Mod.EventHandler
// register server commands in this event handler
// register server commands in this event handler (Remove if not needed)
public void serverStarting(FMLServerStartingEvent event) {
proxy.serverStarting(event);
}
@Mod.EventHandler
public void serverStarted(FMLServerStartedEvent event) {
proxy.serverStarted(event);
}
@Mod.EventHandler
public void serverStopping(FMLServerStoppingEvent event) {
proxy.serverStopping(event);
}
@Mod.EventHandler
public void serverStopped(FMLServerStoppedEvent event) {
proxy.serverStopped(event);
}
public static void debug(String message) {
LOG.debug(message);
}
public static void info(String message) {
LOG.info(message);
}
public static void warn(String message) {
LOG.warn(message);
}
public static void error(String message) {
LOG.error(message);
}
}
+6 -6
View File
@@ -1,12 +1,12 @@
package com.myname.mymodid;
// Use this class for Strings only. Do not import any classes here. It will lead to issues with Mixins if in use!
// Use this class for Strings only. Do not import any classes here. It will lead
// to issues with Mixins if in use!
public class Tags {
// GRADLETOKEN_* will be replaced by your configuration values at build time
public static final String MODID = "GRADLETOKEN_MODID";
public static final String MODNAME = "GRADLETOKEN_MODNAME";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String GROUPNAME = "GRADLETOKEN_GROUPNAME";
public static final String MODID = "examplemod";
public static final String MODNAME = "Example Mod";
public static final String VERSION = "GRADLETOKEN_VERSION"; // will be replaced by your configuration values at
// build time
}