Spotless autoformatter (#32)

* Fix editorconfig for language files

* Add spotless autoformatting plugin

* Autoformatting fixes

* Update build.gradle timestamp
This commit is contained in:
Raven Szewczyk authored and GitHub committed 2022-06-23 20:53:03 +01:00
1 parent 317e07e1cf
commit 2016e39dea
7 files changed
+56 -35

No files matched your search

+3
View File
@@ -17,3 +17,6 @@ end_of_line = crlf
[*.{dtd,json,info,mcmeta,md,sh,svg,xml,xsd,xsl,yaml,yml}]
indent_size = 2
[*.lang]
trim_trailing_whitespace = false
+35 -3
View File
@@ -1,4 +1,4 @@
//version: 1655755555
//version: 1656003794
/*
DO NOT CHANGE THIS FILE!
@@ -57,6 +57,7 @@ plugins {
id 'com.palantir.git-version' version '0.13.0' apply false
id 'de.undercouch.download' version '5.0.1'
id 'com.github.gmazzo.buildconfig' version '3.0.3' apply false
id "com.diffplug.spotless" version "6.7.2"
}
if (project.file('.git/HEAD').isFile()) {
@@ -83,6 +84,37 @@ idea {
}
}
// Spotless autoformatter
// See https://github.com/diffplug/spotless/tree/main/plugin-gradle
// Can be locally toggled via spotless:off/spotless:on comments
spotless {
encoding 'UTF-8'
format 'misc', {
target '*.md', '.gitignore'
trimTrailingWhitespace()
indentWithSpaces(4)
endWithNewline()
}
java {
toggleOffOn()
importOrder()
removeUnusedImports()
palantirJavaFormat('1.1.0') // last version supporting jvm 8
}
kotlin {
toggleOffOn()
ktfmt('0.39')
}
groovyGradle {
toggleOffOn()
importOrder()
target '*.gradle'
greclipse('4.19.0') // last version supporting jvm 8
}
}
if(JavaVersion.current() != JavaVersion.VERSION_1_8) {
throw new GradleException("This project requires Java 8, but it's running on " + JavaVersion.current())
}
@@ -699,7 +731,7 @@ task deobfParams {
println("Parsing params.csv ...")
Map<String, String> params = new HashMap<>()
Files.lines(Paths.get(paramsCSV)).forEach{line ->
Files.lines(Paths.get(paramsCSV)).forEach{line ->
String[] cells = line.split(",")
if(cells.length > 2 && cells[0].matches("p_i?\\d+_\\d+_")) {
params.put(cells[0], cells[1])
@@ -824,7 +856,7 @@ def deobf(String sourceURL, String rawFileName) {
String mappingsZIP = "$cacheDir/forge_gradle/maven_downloader/de/oceanlabs/mcp/mcp_snapshot_nodoc/$id/mcp_snapshot_nodoc-${id}.zip"
zipMappings(mappingsZIP, remoteMappings, bon2Dir)
mappingsVer = "snapshot_$id"
} else {
mappingsVer = "${channel}_$mappingsVersion"
@@ -6,7 +6,7 @@ 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) {
public void preInit(FMLPreInitializationEvent event) {
super.preInit(event);
}
@@ -40,4 +40,4 @@ public class ClientProxy extends CommonProxy {
public void serverStopped(FMLServerStoppedEvent event) {
super.serverStopped(event);
}
}
}
@@ -6,7 +6,7 @@ public class CommonProxy {
// preInit "Run before anything else. Read your config, create blocks, items,
// etc, and register them with the GameRegistry."
public void preInit(FMLPreInitializationEvent event) {
public void preInit(FMLPreInitializationEvent event) {
Config.syncronizeConfiguration(event.getSuggestedConfigurationFile());
MyMod.info(Config.greeting);
@@ -14,33 +14,19 @@ public class CommonProxy {
}
// load "Do your mod setup. Build whatever data structures you care about. Register recipes."
public void init(FMLInitializationEvent event) {
}
public void init(FMLInitializationEvent event) {}
// postInit "Handle interaction with other mods, complete your setup based on this."
public void postInit(FMLPostInitializationEvent event) {
public void postInit(FMLPostInitializationEvent event) {}
}
public void serverAboutToStart(FMLServerAboutToStartEvent event) {
}
public void serverAboutToStart(FMLServerAboutToStartEvent event) {}
// register server commands in this event handler
public void serverStarting(FMLServerStartingEvent event) {
public void serverStarting(FMLServerStartingEvent event) {}
}
public void serverStarted(FMLServerStartedEvent event) {}
public void serverStarted(FMLServerStartedEvent event) {
public void serverStopping(FMLServerStoppingEvent event) {}
}
public void serverStopping(FMLServerStoppingEvent event) {
}
public void serverStopped(FMLServerStoppedEvent event) {
}
public void serverStopped(FMLServerStoppedEvent event) {}
}
+5 -5
View File
@@ -1,10 +1,9 @@
package com.myname.mymodid;
import java.io.File;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import java.io.File;
public class Config {
private static class Defaults {
@@ -21,11 +20,12 @@ public class Config {
Configuration configuration = new Configuration(configFile);
configuration.load();
Property greetingProperty = configuration.get(Categories.general, "greeting", Defaults.greeting, "How shall I greet?");
Property greetingProperty =
configuration.get(Categories.general, "greeting", Defaults.greeting, "How shall I greet?");
greeting = greetingProperty.getString();
if(configuration.hasChanged()) {
if (configuration.hasChanged()) {
configuration.save();
}
}
}
}
+2 -2
View File
@@ -11,7 +11,7 @@ public class MyMod {
private static Logger LOG = LogManager.getLogger(Tags.MODID);
@SidedProxy(clientSide= Tags.GROUPNAME + ".ClientProxy", serverSide=Tags.GROUPNAME + ".CommonProxy")
@SidedProxy(clientSide = Tags.GROUPNAME + ".ClientProxy", serverSide = Tags.GROUPNAME + ".CommonProxy")
public static CommonProxy proxy;
@Mod.EventHandler
@@ -74,4 +74,4 @@ public class MyMod {
public static void error(String message) {
LOG.error(message);
}
}
}
+1 -1
View File
@@ -9,4 +9,4 @@ public class Tags {
public static final String MODNAME = "GRADLETOKEN_MODNAME";
public static final String VERSION = "GRADLETOKEN_VERSION";
public static final String GROUPNAME = "GRADLETOKEN_GROUPNAME";
}
}