Use diktat directly instead of the spotless gradle plugin and improve a few files

This commit is contained in:
Username404 2021-06-19 12:24:22 +02:00
parent 59370fab4c
commit b34cb151ab
Signed by: Username404-59
GPG Key ID: 7AB361FBB257A5D1
5 changed files with 34 additions and 20 deletions

View File

@ -7,6 +7,13 @@
- name: SAY_NO_TO_VAR
enabled: true
- name: TRAILING_COMMA
enabled: true
configuration:
valueArgument: true
valueParameter: true
collectionLiteral: true
- name: UNUSED_IMPORT
enabled: true
@ -15,6 +22,10 @@
- name: WRONG_INDENTATION
enabled: true
configuration:
extendedIndentOfParameters: false
alignedParameters: true
indentationSize: 4
- name: TYPEALIAS_NAME_INCORRECT_CASE
enabled: false

View File

@ -17,7 +17,7 @@ plugins {
id("dev.architectury.loom") version "[0.7.2.110, 0.9.0[" apply false
id("com.github.ben-manes.versions") version "0.39.0"
id("net.kyori.indra.git") version "2.0.5"
id("com.diffplug.spotless") version "5.12.5"
id("org.cqfn.diktat.diktat-gradle-plugin") version "0.6.2"
id("com.modrinth.minotaur") version "1.2.1"
}
@ -39,6 +39,12 @@ val kotlinX: String = "org.jetbrains.kotlinx"
subprojects {
group = rootProject.group.toString()
apply(plugin = "org.cqfn.diktat.diktat-gradle-plugin")
diktat {
inputs = files("src/**/*.kt")
diktatConfigFile = file("$rootDir/Formatting.yml")
ignoreFailures = true
}
lateinit var mappingsDep: Dependency
apply(plugin = "dev.architectury.loom")
apply(plugin = "org.jetbrains.kotlin.plugin.serialization")
@ -146,6 +152,7 @@ subprojects {
input.set(shrinkedJar)
if (!archiveFileName.get().contains("common")) destinationDirectory.set(file("$rootDir/remappedJars"))
}
build.get().dependsOn(diktatCheck)
}
}
@ -162,16 +169,6 @@ allprojects {
**/
apply(plugin = "java")
apply(plugin = "org.jetbrains.kotlin.jvm")
apply(plugin = "com.diffplug.spotless")
spotless {
encoding = Charsets.UTF_8
kotlin {
ignoreErrorForStep("diktat")
diktat("0.6.1").configFile("$rootDir/Formatting.yml")
trimTrailingWhitespace(); endWithNewline()
}
}
tasks.spotlessCheck.get().finalizedBy(tasks.spotlessApply)
apply(plugin = "architectury-plugin")
val compiler = javaToolchains.compilerFor { languageVersion.set(JavaLanguageVersion.of(sourceJavaVer.toInt())) }
dependencies {

View File

@ -2,7 +2,10 @@ package fr.username404.snowygui.config
import com.typesafe.config.Config
import com.typesafe.config.ConfigException
import com.typesafe.config.ConfigFactory.*
import com.typesafe.config.ConfigFactory.empty
import com.typesafe.config.ConfigFactory.parseFile
import com.typesafe.config.ConfigFactory.load
import com.typesafe.config.ConfigFactory.parseString
import com.typesafe.config.ConfigRenderOptions
import com.typesafe.config.ConfigValueFactory
import fr.username404.snowygui.ClickGui

View File

@ -4,12 +4,13 @@ import net.minecraft.client.Minecraft
@ButtonInfo(Category.MISC)
object GammaBoost: ButtonImpl() {
private const val boost = 1400.0
private var oldGamma = 0.0
override fun execAction() {
with(Minecraft.getInstance().options) {
gamma = if (toggled) {
if (gamma < 1400.0) oldGamma = gamma
1400.0
if (gamma < boost) oldGamma = gamma
boost
} else oldGamma
}
}

View File

@ -13,12 +13,14 @@ private typealias privateLambda = (() -> Unit)?
object AddKeyMaps {
private const val prefix = "snowy"
@JvmOverloads
internal fun mkMap(translationSuffix: String, key: Int, category: String = "keycategory", lambda: privateLambda = null): Pair<KeyMapping, privateLambda> {
return KeyMapping(
"key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM,
key, "category.$prefix.$category"
) to lambda
}
internal fun mkMap(
translationSuffix: String,
key: Int, category: String = "keycategory",
lambda: privateLambda = null
): Pair<KeyMapping, privateLambda> = KeyMapping(
"key.$prefix.$translationSuffix", InputConstants.Type.KEYSYM,
key, "category.$prefix.$category"
) to lambda
val list: MutableMap<KeyMapping, privateLambda> = with(Minecraft.getInstance()) {
mutableMapOf(
mkMap("opengui", GLFW_KEY_Y) { setScreen(ClickGui) },