Skip to content

Commit

Permalink
reformat with kotlin coding conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
btwonion committed May 11, 2024
1 parent bd3ecc0 commit 84f35a0
Show file tree
Hide file tree
Showing 19 changed files with 621 additions and 301 deletions.
433 changes: 401 additions & 32 deletions .editorconfig

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# autodrop

This mod provides a function to automatically drop items from the
inventory if they are blacklisted. You can easily disable it by pressing a hotkey (`default: j`).

## Managing items

- use the configuration section of the modmenu integration
- press the keybinding for the config GUI (`default: o`)
- archives can be toggled by double-clicking the archive in the GUI

### Other
⚠️ The development version is always the latest stable release of Minecraft.
Therefore, new features will only be available for the current and following Minecraft versions.

If you need help with any of my mods just join my [discord server](https://nyon.dev/discord)
44 changes: 19 additions & 25 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@file:Suppress("SpellCheckingInspection")

import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import kotlin.io.path.readText

plugins {
kotlin("jvm") version "1.9.24"
Expand Down Expand Up @@ -50,12 +49,10 @@ repositories {

dependencies {
minecraft("com.mojang:minecraft:$mcVersion")
mappings(
loom.layered {
parchment("org.parchmentmc.data:parchment-${property("deps.parchment")}@zip")
officialMojangMappings()
}
)
mappings(loom.layered {

Check failure on line 52 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] build.gradle.kts#L52 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
build.gradle.kts:52:14: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)

Check failure on line 52 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] build.gradle.kts#L52 <standard:wrapping>

Missing newline after "("
Raw output
build.gradle.kts:52:14: error: Missing newline after "(" (standard:wrapping)
parchment("org.parchmentmc.data:parchment-${property("deps.parchment")}@zip")
officialMojangMappings()
})

Check failure on line 55 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] build.gradle.kts#L55 <standard:wrapping>

Missing newline before ")"
Raw output
build.gradle.kts:55:5: error: Missing newline before ")" (standard:wrapping)

implementation("org.vineflower:vineflower:1.10.1")
modImplementation("net.fabricmc:fabric-loader:0.15.11")
Expand All @@ -75,15 +72,14 @@ tasks {
val modName = "autodrop"
val modDescription = "Mod to automatically drop items from your inventory"

val props =
mapOf(
"id" to modId,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubRepo,
"mc" to mcVersionRange
)
val props = mapOf(

Check failure on line 75 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] build.gradle.kts#L75 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
build.gradle.kts:75:21: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
"id" to modId,
"name" to modName,
"description" to modDescription,
"version" to project.version,
"github" to githubRepo,
"mc" to mcVersionRange
)

props.forEach(inputs::property)

Expand All @@ -108,13 +104,13 @@ tasks {
}
}

val changelogText =
buildString {
append("# v${project.version}\n")
file("../../changelog.md").readText().also { append(it) }
}
val changelogText = buildString {

Check failure on line 107 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] build.gradle.kts#L107 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
build.gradle.kts:107:21: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
append("# v${project.version}\n")
file("../../changelog.md").readText().also { append(it) }
}

val supportedMcVersions: List<String> = property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty)
val supportedMcVersions: List<String> =
property("supportedMcVersions")!!.toString().split(',').map(String::trim).filter(String::isNotEmpty)

publishMods {
displayName = "v${project.version}"
Expand Down Expand Up @@ -171,9 +167,7 @@ publishing {
java {
withSourcesJar()

javaVersion.toInt()
.let { JavaVersion.values()[it - 1] }
.let {
javaVersion.toInt().let { JavaVersion.values()[it - 1] }.let {
sourceCompatibility = it

Check failure on line 171 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] build.gradle.kts#L171 <standard:indent>

Unexpected indentation (12) (should be 8)
Raw output
build.gradle.kts:171:1: error: Unexpected indentation (12) (should be 8) (standard:indent)
targetCompatibility = it

Check failure on line 172 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] build.gradle.kts#L172 <standard:indent>

Unexpected indentation (12) (should be 8)
Raw output
build.gradle.kts:172:1: error: Unexpected indentation (12) (should be 8) (standard:indent)
}

Check failure on line 173 in build.gradle.kts

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] build.gradle.kts#L173 <standard:indent>

Unexpected indentation (8) (should be 4)
Raw output
build.gradle.kts:173:1: error: Unexpected indentation (8) (should be 4) (standard:indent)
Expand Down
1 change: 0 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
kotlin.code.style=official

org.gradle.jvmargs=-Xmx4096M
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@
@Mixin(Minecraft.class)
public class MinecraftClientMixin {

@Inject(method = "tick", at = @At("TAIL"))
@Inject(
method = "tick",
at = @At("TAIL")
)
public void onTick(CallbackInfo ci) {
AutoDrop.INSTANCE.tick((Minecraft) (Object) this);
}
Expand Down
22 changes: 18 additions & 4 deletions src/main/java/dev/nyon/autodrop/mixins/PlayerInventoryMixin.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,27 @@
@Mixin(Inventory.class)
public class PlayerInventoryMixin {

@Inject(method = "add(ILnet/minecraft/world/item/ItemStack;)Z", at = @At(value = "RETURN"))
public void onTake(int slot, ItemStack stack, CallbackInfoReturnable<Boolean> cir) {
@Inject(
method = "add(ILnet/minecraft/world/item/ItemStack;)Z",
at = @At(value = "RETURN")
)
public void onTake(
int slot,
ItemStack stack,
CallbackInfoReturnable<Boolean> cir
) {
AutoDrop.INSTANCE.onTake();
}

@Inject(method = "setItem", at = @At(value = "RETURN"))
public void onTake(int i, ItemStack itemStack, CallbackInfo ci) {
@Inject(
method = "setItem",
at = @At(value = "RETURN")
)
public void onTake(
int i,
ItemStack itemStack,
CallbackInfo ci
) {
AutoDrop.INSTANCE.onTake();
}
}
99 changes: 35 additions & 64 deletions src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt
Original file line number Diff line number Diff line change
@@ -1,23 +1,12 @@
package dev.nyon.autodrop

import com.mojang.blaze3d.platform.InputConstants
import dev.nyon.autodrop.config.blockedSlots
import dev.nyon.autodrop.config.createYaclScreen
import dev.nyon.autodrop.config.currentItems
import dev.nyon.autodrop.config.migrate
import dev.nyon.autodrop.config.*

Check failure on line 4 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L4 <standard:no-wildcard-imports>

Wildcard import
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:4:1: error: Wildcard import (standard:no-wildcard-imports)
import dev.nyon.autodrop.config.models.Config
import dev.nyon.autodrop.config.reloadArchiveProperties
import dev.nyon.autodrop.config.settings
import dev.nyon.konfig.config.config
import dev.nyon.konfig.config.loadConfig
import dev.nyon.konfig.config.saveConfig
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.*

Check failure on line 9 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L9 <standard:no-wildcard-imports>

Wildcard import
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:9:1: error: Wildcard import (standard:no-wildcard-imports)
import net.fabricmc.api.ClientModInitializer
import net.fabricmc.fabric.api.client.keybinding.v1.KeyBindingHelper
import net.fabricmc.loader.api.FabricLoader
Expand All @@ -29,50 +18,33 @@ import net.minecraft.network.chat.Style
import net.minecraft.world.entity.player.Inventory
import net.minecraft.world.inventory.ClickType
import org.lwjgl.glfw.GLFW
import kotlin.io.path.createFile
import kotlin.io.path.deleteIfExists
import kotlin.io.path.exists
import kotlin.io.path.notExists
import kotlin.io.path.readText
import kotlin.io.path.writeText
import kotlin.time.Duration.Companion.milliseconds

lateinit var mcDispatcher: CoroutineDispatcher
lateinit var mcScope: CoroutineScope
lateinit var minecraft: Minecraft

object AutoDrop : ClientModInitializer {
private val toggleKeyBind =
KeyBindingHelper.registerKeyBinding(
KeyMapping(
"Toggle AutoDrop",
InputConstants.Type.KEYSYM,
GLFW.GLFW_KEY_J,
"autodrop"
)
private val toggleKeyBind = KeyBindingHelper.registerKeyBinding(

Check failure on line 28 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L28 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:28:33: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
KeyMapping(
"Toggle AutoDrop", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_J, "autodrop"

Check failure on line 30 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L30 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:30:32: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 30 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L30 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:30:60: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 30 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L30 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:30:77: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)
)
)

private val menuKeyBind =
KeyBindingHelper.registerKeyBinding(
KeyMapping(
"Open GUI",
InputConstants.Type.KEYSYM,
GLFW.GLFW_KEY_O,
"autodrop"
)
private val menuKeyBind = KeyBindingHelper.registerKeyBinding(

Check failure on line 34 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L34 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:34:31: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
KeyMapping(
"Open GUI", InputConstants.Type.KEYSYM, GLFW.GLFW_KEY_O, "autodrop"

Check failure on line 36 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L36 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:36:25: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 36 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L36 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:36:53: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 36 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L36 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:36:70: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)
)
)

fun tick(client: Minecraft) {
if (toggleKeyBind.consumeClick()) {
settings.enabled = !settings.enabled
saveConfig(settings)
client.gui.setOverlayMessage(
Component.translatable("menu.autodrop.name").append(" ")
.append(
Component.translatable("menu.autodrop.name").append(" ").append(
Component.translatable(if (settings.enabled) "menu.autodrop.overlay.enabled" else "menu.autodrop.overlay.disabled")

Check failure on line 46 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L46 <standard:indent>

Unexpected indentation (24) (should be 20)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:46:1: error: Unexpected indentation (24) (should be 20) (standard:indent)

Check failure on line 46 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L46 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:46:48: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 46 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L46 <standard:max-line-length>

Exceeded max line length (120)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:46:121: error: Exceeded max line length (120) (standard:max-line-length)

Check failure on line 46 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L46 <standard:argument-list-wrapping>

Missing newline before ")"
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:46:139: error: Missing newline before ")" (standard:argument-list-wrapping)
)
.withStyle(Style.EMPTY.withColor(0xF99147)),
false
).withStyle(Style.EMPTY.withColor(0xF99147)), false

Check failure on line 47 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L47 <standard:indent>

Unexpected indentation (20) (should be 16)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:47:1: error: Unexpected indentation (20) (should be 16) (standard:indent)

Check failure on line 47 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L47 <standard:wrapping>

Missing newline after ","
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:47:66: error: Missing newline after "," (standard:wrapping)

Check failure on line 47 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L47 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:47:67: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)
)
if (settings.enabled) onTake()
}
Expand All @@ -81,40 +53,39 @@ object AutoDrop : ClientModInitializer {

private var jobWaiting = false

fun onTake() =
runBlocking {
if (!settings.enabled) return@runBlocking
if (settings.activeArchives.isEmpty()) return@runBlocking
val player = minecraft.player ?: return@runBlocking
if (jobWaiting) return@runBlocking
jobWaiting = true

mcScope.launch {
delay(settings.dropDelay.milliseconds)
fun onTake() = runBlocking {

Check failure on line 56 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L56 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:56:20: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)

Check failure on line 56 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L56 <standard:function-signature>

Newline expected before expression body
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:56:20: error: Newline expected before expression body (standard:function-signature)
if (!settings.enabled) return@runBlocking
if (settings.activeArchives.isEmpty()) return@runBlocking
val player = minecraft.player ?: return@runBlocking
if (jobWaiting) return@runBlocking
jobWaiting = true

val screen = InventoryScreen(player)
screen.menu.slots.filter {
it.hasItem() && !blockedSlots.contains(it.index) && currentItems.contains(it.item.item) && it.container is Inventory
}.forEach { slot ->
minecraft.gameMode?.handleInventoryMouseClick(
screen.menu.containerId,
slot.index,
1,
ClickType.THROW,
player
)
}
mcScope.launch {
delay(settings.dropDelay.milliseconds)

jobWaiting = false
val screen = InventoryScreen(player)
screen.menu.slots.filter {
it.hasItem() && !blockedSlots.contains(it.index) && currentItems.contains(it.item.item) && it.container is Inventory

Check failure on line 68 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L68 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:68:56: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 68 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L68 <standard:argument-list-wrapping>

Missing newline before ")"
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:68:64: error: Missing newline before ")" (standard:argument-list-wrapping)

Check failure on line 68 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L68 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:68:91: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 68 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L68 <standard:argument-list-wrapping>

Missing newline before ")"
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:68:103: error: Missing newline before ")" (standard:argument-list-wrapping)

Check failure on line 68 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L68 <standard:max-line-length>

Exceeded max line length (120)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:68:121: error: Exceeded max line length (120) (standard:max-line-length)
}.forEach { slot ->
minecraft.gameMode?.handleInventoryMouseClick(
screen.menu.containerId, slot.index, 1, ClickType.THROW, player

Check failure on line 71 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L71 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:71:46: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 71 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L71 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:71:58: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 71 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L71 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:71:61: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)

Check failure on line 71 in src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt#L71 <standard:argument-list-wrapping>

Argument should be on a separate line (unless all arguments can fit a single line)
Raw output
src/main/kotlin/dev/nyon/autodrop/AutoDrop.kt:71:78: error: Argument should be on a separate line (unless all arguments can fit a single line) (standard:argument-list-wrapping)
)
}

jobWaiting = false
}
}

override fun onInitializeClient() {
minecraft = Minecraft.getInstance()
mcDispatcher = minecraft.asCoroutineDispatcher()
mcScope = CoroutineScope(SupervisorJob() + mcDispatcher)

config(FabricLoader.getInstance().configDir.resolve("autodrop.json"), 1, Config()) { jsonTree, version -> migrate(jsonTree, version) }
config(
FabricLoader.getInstance().configDir.resolve("autodrop.json"),
1,
Config()
) { jsonTree, version -> migrate(jsonTree, version) }
settings = loadConfig<Config>()

reloadArchiveProperties()
Expand Down
49 changes: 21 additions & 28 deletions src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,7 @@ package dev.nyon.autodrop.config

import dev.nyon.autodrop.config.models.Archive
import dev.nyon.autodrop.config.models.Config
import kotlinx.serialization.json.JsonElement
import kotlinx.serialization.json.contentOrNull
import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import kotlinx.serialization.json.longOrNull
import kotlinx.serialization.json.*

Check failure on line 5 in src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt#L5 <standard:no-wildcard-imports>

Wildcard import
Raw output
src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt:5:1: error: Wildcard import (standard:no-wildcard-imports)
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.item.Item
Expand All @@ -30,31 +25,29 @@ fun reloadArchiveProperties() {
}

internal fun migrate(
jsonTree: JsonElement,
version: Int?
jsonTree: JsonElement, version: Int?

Check failure on line 28 in src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt#L28 <standard:parameter-list-wrapping>

Parameter should start on a newline
Raw output
src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt:28:28: error: Parameter should start on a newline (standard:parameter-list-wrapping)

Check failure on line 28 in src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt#L28 <standard:function-signature>

Parameter should start on a newline
Raw output
src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt:28:28: error: Parameter should start on a newline (standard:function-signature)
): Config? {
val jsonObject = jsonTree.jsonObject
return when (version) {
null ->
Config(
jsonObject["enabled"]?.jsonPrimitive?.content?.toBooleanStrictOrNull() ?: return null,
jsonObject["archives"]?.jsonArray?.map {
val archiveObject = it.jsonObject
return@map Archive(
archiveObject["name"]?.jsonPrimitive?.content ?: return null,
archiveObject["items"]?.jsonArray?.map secMap@{ content ->
return@secMap ResourceLocation(
content.jsonPrimitive.contentOrNull ?: return null
)
}?.toMutableList() ?: return null,
archiveObject["lockedSlots"]?.jsonArray?.map secMap@{ content ->
content.jsonPrimitive.content.toIntOrNull() ?: return null
}?.toMutableList() ?: return null
)
}?.toMutableList() ?: return null,
jsonObject["activeArchives"]?.jsonArray?.map { it.jsonPrimitive.content }?.toMutableList() ?: return null,
jsonObject["dropDelay"]?.jsonPrimitive?.longOrNull ?: return null
)
null -> Config(

Check failure on line 32 in src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt

View workflow job for this annotation

GitHub Actions / ktlint

[ktlint] src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt#L32 <standard:multiline-expression-wrapping>

A multiline expression should start on a new line
Raw output
src/main/kotlin/dev/nyon/autodrop/config/ConfigHandler.kt:32:17: error: A multiline expression should start on a new line (standard:multiline-expression-wrapping)
jsonObject["enabled"]?.jsonPrimitive?.content?.toBooleanStrictOrNull() ?: return null,
jsonObject["archives"]?.jsonArray?.map {
val archiveObject = it.jsonObject
return@map Archive(
archiveObject["name"]?.jsonPrimitive?.content ?: return null,
archiveObject["items"]?.jsonArray?.map secMap@{ content ->
return@secMap ResourceLocation(
content.jsonPrimitive.contentOrNull ?: return null
)
}?.toMutableList() ?: return null,
archiveObject["lockedSlots"]?.jsonArray?.map secMap@{ content ->
content.jsonPrimitive.content.toIntOrNull() ?: return null
}?.toMutableList() ?: return null
)
}?.toMutableList() ?: return null,
jsonObject["activeArchives"]?.jsonArray?.map { it.jsonPrimitive.content }?.toMutableList() ?: return null,
jsonObject["dropDelay"]?.jsonPrimitive?.longOrNull ?: return null
)

else -> null
}
Expand Down
Loading

0 comments on commit 84f35a0

Please sign in to comment.