Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release latest patch version #94

Merged
merged 14 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[*.{kt,kts}]
max_line_length = 120
2 changes: 1 addition & 1 deletion .github/workflows/publish_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK 17
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/pull_request_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:

steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/setup-java-jdk
- name: Set up JDK 17
Expand All @@ -39,13 +39,13 @@ jobs:

steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/run-ktlint-with-reviewdog
- uses: ScaCap/action-ktlint@v1.7
- uses: ScaCap/action-ktlint@v1.8.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
ktlint_version: '0.50.0'
ktlint_version: '1.0.1'
reporter: github-pr-review
fail_on_error: true

Expand All @@ -54,11 +54,11 @@ jobs:

steps:
# https://github.com/marketplace/actions/checkout
- uses: actions/checkout@v3
- uses: actions/checkout@v4

# https://github.com/marketplace/actions/run-detekt-with-reviewdog
- name: Run detekt with reviewdog
uses: alaegin/[email protected].0
uses: alaegin/[email protected].3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
detekt_config: config/detekt/detekt.yml
Expand Down
8 changes: 3 additions & 5 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/detekt.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .idea/kotlinc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions .idea/ktlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .idea/modules/Projects.GitHub.Gateway.main.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 7 additions & 7 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
plugins {
// https://kotlinlang.org/
kotlin("jvm") version "1.9.0"
kotlin("jvm") version "1.9.21"
// https://kotlinlang.org/docs/serialization.html
kotlin("plugin.serialization") version "1.9.0"
kotlin("plugin.serialization") version "1.9.21"
// https://github.com/johnrengelman/shadow
id("com.github.johnrengelman.shadow") version "8.1.1"
// https://github.com/jpenilla/run-paper
id("xyz.jpenilla.run-paper") version "2.1.0"
id("xyz.jpenilla.run-paper") version "2.2.2"
// https://github.com/jlleitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "11.5.0"
id("org.jlleitschuh.gradle.ktlint") version "11.6.1"
// https://detekt.dev/
id("io.gitlab.arturbosch.detekt") version "1.23.1"
id("io.gitlab.arturbosch.detekt") version "1.23.3"
}

val version: String by project
Expand All @@ -21,7 +21,7 @@ val ktlintVersion: String by project
val minecraftVersion: String by project
val paperApiRevision: String by project
val kordexVersion: String by project
val lixyVersion: String by project
val tegralVersion: String by project
val kamlVersion: String by project
val ktorVersion: String by project
val hopliteVersion: String by project
Expand Down Expand Up @@ -61,7 +61,7 @@ dependencies {
// Library for Discord bots.
implementation("com.kotlindiscord.kord.extensions:kord-extensions:$kordexVersion")
// Lexer library that supports regex.
implementation("guru.zoroark.lixy:lixy:$lixyVersion")
implementation("guru.zoroark.tegral:tegral-niwen-lexer:$tegralVersion")
}

ktlint {
Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
# Project info
version=1.6.1
version=1.6.2
group=com.rose.gateway
# Plugin configuration
# https://github.com/pinterest/ktlint
ktlintVersion=0.50.0
ktlintVersion=1.0.1
# Dependencies
minecraftVersion=1.20.1
minecraftVersion=1.20.2
# https://docs.papermc.io/paper/dev/project-setup
paperApiRevision=R0.1
# https://github.com/sksamuel/hoplite
hopliteVersion=2.7.4
hopliteVersion=2.7.5
# https://github.com/charleskorn/kaml
kamlVersion=0.55.0
# https://kordex.kotlindiscord.com/
kordexVersion=1.5.8-SNAPSHOT
# https://github.com/utybo/Lixy
lixyVersion=master-SNAPSHOT
kordexVersion=1.6.0-SNAPSHOT
# https://tegral.zoroark.guru/docs/modules/core/niwen/
tegralVersion=0.0.4
# https://ktor.io/
ktorVersion=2.3.3
ktorVersion=2.3.6
# Compilation options for Kotlin
jvmVersion=17
kotlinLanguageVersion=1.9
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 4 additions & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -130,10 +130,13 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.

Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
Expand Down
11 changes: 9 additions & 2 deletions src/main/kotlin/com/rose/gateway/config/ConfigStringMap.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ class ConfigStringMap : KoinComponent {
* @param config The config class to pull items from
* @param prefix The string path up to this config class
*/
private fun fillInItemMap(config: KClass<*>, prefix: String? = null) {
private fun fillInItemMap(
config: KClass<*>,
prefix: String? = null,
) {
for (property in config.memberProperties) {
val configAnnotations = property.annotations.filterIsInstance<ConfigItem>()

Expand All @@ -51,7 +54,11 @@ class ConfigStringMap : KoinComponent {
* @param prefix The string prefix, if any, to put in front of this property's path
* @param configAnnotation The config annotation attached to this property
*/
private fun addPropertyToMap(property: KProperty1<out Any, *>, prefix: String?, configAnnotation: ConfigItem) {
private fun addPropertyToMap(
property: KProperty1<out Any, *>,
prefix: String?,
configAnnotation: ConfigItem,
) {
val propertyString = if (prefix == null) property.name else "$prefix.${property.name}"
val propertyType = property.returnType

Expand Down
39 changes: 21 additions & 18 deletions src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ class GatewayConfigFile : KoinComponent {
/**
* The default configuration that is used as an internal fallback
*/
val defaultConfig = run {
Logger.info("Loading fallback config...")
val defaultConfig =
run {
Logger.info("Loading fallback config...")

loadConfig(DEFAULT_CONFIG_FILE_RESOURCE_PATH).notNullWithMissingDefaultConfigMessage()
}
loadConfig(DEFAULT_CONFIG_FILE_RESOURCE_PATH).notNullWithMissingDefaultConfigMessage()
}

/**
* Loads the gateway config file, creating it if it is missing
Expand Down Expand Up @@ -92,9 +93,10 @@ class GatewayConfigFile : KoinComponent {
*/
private suspend fun createConfigurationFile() {
withContext(Dispatchers.IO) {
val defaultConfig = plugin.loader.getResourceAsStream(DEFAULT_CONFIG_FILE_RESOURCE_NAME)
.notNullWithMissingDefaultConfigMessage()
.readAllBytes()
val defaultConfig =
plugin.loader.getResourceAsStream(DEFAULT_CONFIG_FILE_RESOURCE_NAME)
.notNullWithMissingDefaultConfigMessage()
.readAllBytes()

Files.createDirectories(configPath.parent)
Files.createFile(configPath)
Expand All @@ -113,17 +115,18 @@ class GatewayConfigFile : KoinComponent {
Logger.info("Loading configuration...")

return try {
val config: Config = ConfigLoaderBuilder
.empty()
.withClassLoader(plugin.loader)
.addDefaultDecoders()
.addDefaultPreprocessors()
.addDefaultParamMappers()
.addDefaultPropertySources()
.addDefaultParsers()
.addDecoder(CommonDecoder())
.build()
.loadConfigOrThrow(path)
val config: Config =
ConfigLoaderBuilder
.empty()
.withClassLoader(plugin.loader)
.addDefaultDecoders()
.addDefaultPreprocessors()
.addDefaultParamMappers()
.addDefaultPropertySources()
.addDefaultParsers()
.addDecoder(CommonDecoder())
.build()
.loadConfigOrThrow(path)
Logger.info("Configuration loaded successfully.")
config
} catch (error: ConfigException) {
Expand Down
17 changes: 9 additions & 8 deletions src/main/kotlin/com/rose/gateway/config/Item.kt
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,16 @@ data class Item<ValueType>(
val configProperties = source::class.memberProperties.filterConfigItems()

for (member in configProperties) {
val result = if (member == property) {
source
} else if (member.returnType canBe typeOf<ConfigObject>()) {
val memberValue = member.getter.call(source) as ConfigObject
val result =
if (member == property) {
source
} else if (member.returnType canBe typeOf<ConfigObject>()) {
val memberValue = member.getter.call(source) as ConfigObject

containingObject(memberValue)
} else {
null
}
containingObject(memberValue)
} else {
null
}

return result ?: continue
}
Expand Down
12 changes: 8 additions & 4 deletions src/main/kotlin/com/rose/gateway/config/PluginConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ class PluginConfig : KoinComponent {
/**
* The instance of the config the plugin is using
*/
var config: Config = runBlocking {
configFile.safelyLoadConfig()
}
var config: Config =
runBlocking {
configFile.safelyLoadConfig()
}

/**
* Reload the full config from the disk
Expand Down Expand Up @@ -92,7 +93,10 @@ class PluginConfig : KoinComponent {
*
* @see KType
*/
operator fun <ItemValueType : Any> get(type: KType, item: String): Item<ItemValueType>? {
operator fun <ItemValueType : Any> get(
type: KType,
item: String,
): Item<ItemValueType>? {
val match = get(item)

return if (match != null && match.type == type) {
Expand Down
16 changes: 9 additions & 7 deletions src/main/kotlin/com/rose/gateway/config/markers/CommonDecoder.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,22 @@ open class CommonDecoder : NullHandlingDecoder<Any> {
private val DECODER = DataClassDecoder()
}

override fun safeDecode(node: Node, type: KType, context: DecoderContext): ConfigResult<Any> {
override fun safeDecode(
node: Node,
type: KType,
context: DecoderContext,
): ConfigResult<Any> {
return DECODER.safeDecode(node, type, context)
}

override fun supports(type: KType): Boolean {
val classifier = type.classifier

return if (classifier is KClass<*>) {
(
!classifier.isData &&
!classifier.isSealed &&
!classifier.isInline() &&
classifier canBe ConfigObject::class
)
!classifier.isData &&
!classifier.isSealed &&
!classifier.isInline() &&
classifier canBe ConfigObject::class
} else {
false
}
Expand Down
Loading
Loading