Skip to content

Commit

Permalink
Replace deprecated API use
Browse files Browse the repository at this point in the history
  • Loading branch information
jpenilla committed Jan 10, 2025
1 parent af8a5ea commit 2ccdaed
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ private data class Hash(
val hash: String,
val type: String
) {
fun type() = HashingAlgorithm.valueOf(type.toUpperCase(Locale.ENGLISH))
fun type() = HashingAlgorithm.valueOf(type.uppercase(Locale.ENGLISH))

fun check(file: Path): Boolean = toHexString(file.calculateHash(type())) == hash
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import org.gradle.kotlin.dsl.registerIfAbsent
import xyz.jpenilla.runtask.paperapi.DownloadsAPI
import xyz.jpenilla.runtask.paperapi.Projects
import xyz.jpenilla.runtask.util.Constants
import xyz.jpenilla.runtask.util.capitalized
import xyz.jpenilla.runtask.util.set
import xyz.jpenilla.runtask.util.sharedCaches
import java.nio.file.Path
Expand Down Expand Up @@ -80,7 +81,7 @@ public interface DownloadsAPIService {
}

private fun String.defaultDisplayName(): String =
split('-').joinToString(" ") { it.capitalize() }
split('-').joinToString(" ") { it.capitalized() }

/**
* Get the default [DownloadsAPIService] used to download Paper.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,4 @@ internal fun Duration.prettyPrint(): String =
toString()
.substring(2)
.replace("(\\d[HMS])(?!$)".toRegex(), "$1 ")
.toLowerCase(Locale.ENGLISH)
.lowercase(Locale.ENGLISH)
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.gradle.jvm.toolchain.JavaToolchainService
import org.gradle.kotlin.dsl.findByType
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.register
import java.util.Locale
import kotlin.reflect.KClass

internal fun Project.findJavaLauncher(): Provider<JavaLauncher>? {
Expand Down Expand Up @@ -59,3 +60,6 @@ internal fun <T : Any, U : T> PolymorphicDomainObjectContainer<T>.configure(
}

internal fun <T : Any, U : T> ExtensiblePolymorphicDomainObjectContainer<T>.registerFactory(type: KClass<U>, config: (String) -> U): Unit = registerFactory(type.java, config)

internal fun String.capitalized(locale: Locale = Locale.ROOT): String =
replaceFirstChar { if (it.isLowerCase()) it.titlecase(locale) else it.toString() }

0 comments on commit 2ccdaed

Please sign in to comment.