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

Cutting a release for Minecraft 1.20.1 #85

Merged
merged 5 commits into from
Jul 13, 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
4 changes: 2 additions & 2 deletions .github/workflows/pull_request_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
- uses: ScaCap/action-ktlint@v1.7
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
ktlint_version: '0.45.2'
ktlint_version: '0.50.0'
reporter: github-pr-review
fail_on_error: true

Expand All @@ -58,7 +58,7 @@ jobs:

# https://github.com/marketplace/actions/run-detekt-with-reviewdog
- name: Run detekt with reviewdog
uses: alaegin/Detekt-Action@v1.22.0
uses: alaegin/Detekt-Action@v1.23.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
detekt_config: config/detekt/detekt.yml
Expand Down
7 changes: 7 additions & 0 deletions .idea/codeStyles/Project.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.

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.

8 changes: 8 additions & 0 deletions .idea/modules/Gateway.iml

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

35 changes: 20 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
# Gateway

A Paper server plugin that adds Discord-to-Minecraft interactions and vice versa.
A [Paper](https://papermc.io/) server plugin that adds [Discord](https://discord.com/)
-to-[Minecraft](https://www.minecraft.net/en-us) interactions and vice versa.
It has a number of extensions that can be enabled or disabled in its configuration, so you don't need to use them all.

Available extensions:
## Available extensions:

- About Extension – Lets Discord users view the plugin version and have fun.
- About Extension – Lets Discord users view the server version and have fun.
- Chat Extension – Adds cross-chat capabilities between Minecraft and Discord.
- IP Extension – Adds a way for Discord users to query for the server's IP address.
- List Extension – Lets Discord users list the names of online users.
- TPS Extension - Lets Discord users see how the server is doing by checking its TPS.
- Whitelist Extension – Lets Discord users add and remove people from the whitelist.
- Whitelist Extension – Lets Discord users add and remove people from the server whitelist.

## Installing the Plugin:

1. Install just like any other Paper plugin: plop the jar in your plugin's directory.
2. After you install the plugin, you will need to add a configuration file for it.
You can get a sample configuration file from examples/Gateway.yaml in this repository.
Place this configuration file inside your server's 'plugins' directory in a new directory called 'Gateway'
(i.e., {SERVER_FOLDER}/plugins/Gateway/Gateway.yaml).
3. Next, modify the configuration file by adding a Discord bot token and list of the text channels in which you wish to
have the bot respond detect commands and/or post messages.
1. Install just like any other Paper plugin: plop the `Gateway.jar` file in your `plugins/` directory.
2. Start your server to create the default configuration in the `plugins/Gateway/` directory.
3. Next, modify the configuration. You can do this in two ways:

a. Modify the `plugins/Gateway/config.yaml` file by adding a Discord bot token and list of the text channels in which
you wish to have the bot post and detect messages.
You can reload from the file with `/gateway config reload` in-game.

b. Use `/gateway config set bot.token TOKEN` and `/gateway config add bot.botChannels CHANNEL_NAME` to update the bot
configuration.

You can play with the other settings, too.
Those have further elaboration in the example yaml.
Information about those settings is viewable in-game via `/gateway config help` and in the YAML comments.
4. Play!

## Discord Bot Tokens
Expand Down Expand Up @@ -57,7 +62,7 @@ This is an easy process, though:
First, go the 'Scopes' label within this section and click only 'bot'.
9. At the bottom of the 'Scopes' box, there will now be a URL copy this, as it will be what you use for adding the bot
to your server.
10. Above the 'OAuth2 URL Generator' will be a section labelled 'Redirects'.
10. Above the 'OAuth2 URL Generator' will be a section labeled 'Redirects'.
Click 'Add Redirect' and paste your URL in.
Save your changes with the pop-up now at the bottom of your screen.
11. Add your bot to the server using the link still in your clipboard.
Expand All @@ -66,8 +71,8 @@ This is an easy process, though:
## Building the Plugin

If you are a developer and wish to be able to modify the plugin or contribute, you can clone this repository and use
gradle to build and test the plugin.
The following useful gradle commands are available:
[Gradle](https://gradle.org/) to build and test the plugin.
The following useful Gradle commands are available:

`gradlew build` - Builds the jar, and nothing more.

Expand Down
14 changes: 5 additions & 9 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.8.21"
kotlin("jvm") version "1.9.0"
// https://kotlinlang.org/docs/serialization.html
kotlin("plugin.serialization") version "1.8.21"
kotlin("plugin.serialization") version "1.9.0"
// 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"
// https://github.com/jlleitschuh/ktlint-gradle
id("org.jlleitschuh.gradle.ktlint") version "11.3.2"
id("org.jlleitschuh.gradle.ktlint") version "11.5.0"
// https://detekt.dev/
id("io.gitlab.arturbosch.detekt") version "1.22.0"
id("io.gitlab.arturbosch.detekt") version "1.23.0"
}

val version: String by project
Expand Down Expand Up @@ -58,10 +58,6 @@ dependencies {
implementation("com.sksamuel.hoplite:hoplite-yaml:$hopliteVersion")
// Library that supports loading and (more importantly) saving to YAML files.
implementation("com.charleskorn.kaml:kaml:$kamlVersion")
// HTTP client library.
// Disabled until I implement update checking.
// implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
// implementation("io.ktor:ktor-client-cio-jvm:$ktorVersion")
// Library for Discord bots.
implementation("com.kotlindiscord.kord.extensions:kord-extensions:$kordexVersion")
// Lexer library that supports regex.
Expand All @@ -73,7 +69,7 @@ ktlint {
}

detekt {
config = files("config/detekt/detekt.yml")
config.from("config/detekt/detekt.yml")
buildUponDefaultConfig = true
}

Expand Down
16 changes: 8 additions & 8 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
# Project info
version=1.6.0-alpha-3
version=1.7.0
group=com.rose.gateway
# Plugin configuration
# https://github.com/pinterest/ktlint
ktlintVersion=0.45.2
ktlintVersion=0.50.0
# Dependencies
minecraftVersion=1.19.4
minecraftVersion=1.20.1
# https://docs.papermc.io/paper/dev/project-setup
paperApiRevision=R0.1
# https://github.com/sksamuel/hoplite
hopliteVersion=2.7.4
# https://github.com/charleskorn/kaml
kamlVersion=0.53.0
kamlVersion=0.54.0
# https://kordex.kotlindiscord.com/
kordexVersion=1.5.7-SNAPSHOT
kordexVersion=1.5.8-SNAPSHOT
# https://github.com/utybo/Lixy
lixyVersion=master-SNAPSHOT
# https://ktor.io/
ktorVersion=2.3.0
ktorVersion=2.3.2
# Compilation options for Kotlin
jvmVersion=17
kotlinLanguageVersion=1.8
kotlinApiVersion=1.8
kotlinLanguageVersion=1.9
kotlinApiVersion=1.9
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
7 changes: 4 additions & 3 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,6 @@ done
APP_BASE_NAME=${0##*/}
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum

Expand Down Expand Up @@ -197,6 +194,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/com/rose/gateway/config/GatewayConfigFile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ class GatewayConfigFile : KoinComponent {
Logger.warning("Fell back to default config.")

defaultConfig
} else config
} else {
config
}
}

/**
Expand Down
11 changes: 7 additions & 4 deletions src/main/kotlin/com/rose/gateway/config/Item.kt
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import kotlin.reflect.typeOf
data class Item<ValueType>(
val property: KMutableProperty<ValueType>,
val path: String,
val description: String
val description: String,
) : KoinComponent {
private val pluginConfig: PluginConfig by inject()

Expand Down Expand Up @@ -59,12 +59,15 @@ 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 result = if (member == property) {
source
} else if (member.returnType canBe typeOf<ConfigObject>()) {
val memberValue = member.getter.call(source) as ConfigObject

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

return result ?: continue
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/kotlin/com/rose/gateway/config/PluginConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ class PluginConfig : KoinComponent {
return if (match != null && match.type == type) {
@Suppress("UNCHECKED_CAST")
match as Item<ItemValueType>
} else null
} else {
null
}
}
}
17 changes: 10 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 @@ -31,12 +31,15 @@ open class CommonDecoder : NullHandlingDecoder<Any> {
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
)
else false
return if (classifier is KClass<*>) {
(
!classifier.isData &&
!classifier.isSealed &&
!classifier.isInline() &&
classifier canBe ConfigObject::class
)
} else {
false
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.koin.core.component.inject
*/
open class CommonExtensionConfig(
enabled: Boolean,
@Transient val extensionName: String = "None"
@Transient val extensionName: String = "None",
) : KoinComponent, ConfigObject {
private val bot: DiscordBot by inject()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ package com.rose.gateway.config.markers
*/
@Target(AnnotationTarget.PROPERTY)
annotation class ConfigItem(
val description: String = "NO DESCRIPTION"
val description: String = "NO DESCRIPTION",
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import kotlinx.serialization.Serializable
*/
@Serializable(with = AboutConfigSerializer::class)
class AboutConfig(
enabled: Boolean
enabled: Boolean,
) : CommonExtensionConfig(enabled, AboutExtension.extensionName())

/**
Expand Down
10 changes: 5 additions & 5 deletions src/main/kotlin/com/rose/gateway/config/schema/BotConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import org.koin.core.component.inject
class BotConfig(
token: String,
botChannels: List<String>,
@ConfigItem val extensions: ExtensionsConfig
@ConfigItem val extensions: ExtensionsConfig,
) : KoinComponent, ConfigObject {
private val pluginCoroutineScope: PluginCoroutineScope by inject()
private val bot: DiscordBot by inject()
Expand All @@ -36,7 +36,7 @@ class BotConfig(
* The Discord bot's bot token
*/
@ConfigItem(
"The token used by the bot to access discord. Accessible at https://discord.com/developers/applications/."
"The token used by the bot to access discord. Accessible at https://discord.com/developers/applications/.",
)
var token = token
set(value) {
Expand Down Expand Up @@ -72,19 +72,19 @@ class BotConfig(
data class BotConfigSurrogate(
val token: String,
val botChannels: List<String>,
val extensions: ExtensionsConfig
val extensions: ExtensionsConfig,
) {
companion object : SurrogateConverter<BotConfig, BotConfigSurrogate> {
override fun fromBase(base: BotConfig): BotConfigSurrogate = BotConfigSurrogate(
base.token,
base.botChannels,
base.extensions
base.extensions,
)

override fun toBase(surrogate: BotConfigSurrogate): BotConfig = BotConfig(
surrogate.token,
surrogate.botChannels,
surrogate.extensions
surrogate.extensions,
)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/rose/gateway/config/schema/ChatConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import kotlinx.serialization.Serializable
@Serializable(with = ChatConfigSerializer::class)
class ChatConfig(
enabled: Boolean,
@ConfigItem("Whether Discord role colors are shown in Minecraft chat") val showRoleColor: Boolean
@ConfigItem("Whether Discord role colors are shown in Minecraft chat") val showRoleColor: Boolean,
) : CommonExtensionConfig(enabled, ChatExtension.extensionName())

/**
Expand All @@ -36,12 +36,12 @@ data class ChatConfigSurrogate(val enabled: Boolean, val showRoleColor: Boolean)
companion object : SurrogateConverter<ChatConfig, ChatConfigSurrogate> {
override fun fromBase(base: ChatConfig): ChatConfigSurrogate = ChatConfigSurrogate(
base.enabled,
base.showRoleColor
base.showRoleColor,
)

override fun toBase(surrogate: ChatConfigSurrogate): ChatConfig = ChatConfig(
surrogate.enabled,
surrogate.showRoleColor
surrogate.showRoleColor,
)
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/kotlin/com/rose/gateway/config/schema/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ import kotlinx.serialization.Serializable
@Serializable
data class Config(
@ConfigItem val bot: BotConfig,
@ConfigItem val minecraft: MinecraftConfig
@ConfigItem val minecraft: MinecraftConfig,
) : ConfigObject
Loading
Loading