Skip to content

Commit

Permalink
bump ido and redo configs (#95)
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 authored Oct 3, 2022
1 parent 793895b commit e46df71
Show file tree
Hide file tree
Showing 17 changed files with 111 additions and 139 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish Snapshot
name: Publish GitHub Packages

on:
push:
Expand All @@ -12,17 +12,20 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- name: Set up JDK
uses: actions/setup-java@v2
uses: actions/setup-java@v3
with:
distribution: temurin
java-version: 17
cache: gradle

- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Set env variable from latest maven version
run: >
echo "RELEASE_VERSION=$( \
curl https://repo.mineinabyss.com/releases/com/mineinabyss/deeperworld/maven-metadata.xml | \
grep -oP '(?!<latest>)[\d\.]*(?=</latest>)' \
)" >> $GITHUB_ENV
- name: Run gradle build and publish
run: gradle build publish -PmineinabyssMavenUsername=${{ secrets.MAVEN_PUBLISH_USERNAME }} -PmineinabyssMavenPassword=${{ secrets.MAVEN_PUBLISH_PASSWORD }}
Expand All @@ -31,7 +34,7 @@ jobs:
shell: bash
id: extract_version
run: |
version=`./gradlew properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}'`
version=`gradle properties --no-daemon --console=plain -q | grep "^version:" | awk '{printf $2}'`
echo "::set-output name=version::$version"
- name: Create GitHub Release
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@ dependencies {
compileOnly(deeperLibs.minecraft.plugin.blocklocker)

// Shaded
implementation(libs.idofront.core)
implementation(libs.bundles.idofront.core)
}
6 changes: 3 additions & 3 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.mineinabyss
version=0.6
kotlinVersion=1.6.10
version=0.7
kotlinVersion=1.7.10
serverVersion=1.19.2-R0.1-SNAPSHOT
idofrontVersion=0.12.112
idofrontVersion=0.14.6
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package com.mineinabyss.deeperworld

import com.fastasyncworldedit.core.util.TaskManager
import com.mineinabyss.deeperworld.MinecraftConstants.FULL_DAY_TIME
import com.mineinabyss.deeperworld.config.DeeperConfig
import com.mineinabyss.deeperworld.services.WorldManager
import com.mineinabyss.deeperworld.services.canMoveSections
import com.mineinabyss.deeperworld.synchronization.sync
Expand All @@ -16,6 +15,7 @@ import com.mineinabyss.idofront.commands.arguments.intArg
import com.mineinabyss.idofront.commands.execution.IdofrontCommandExecutor
import com.mineinabyss.idofront.commands.execution.stopCommand
import com.mineinabyss.idofront.commands.extensions.actions.playerAction
import com.mineinabyss.idofront.config.config
import com.mineinabyss.idofront.messaging.error
import com.mineinabyss.idofront.messaging.info
import com.mineinabyss.idofront.messaging.success
Expand All @@ -37,6 +37,11 @@ import org.bukkit.command.TabCompleter
class DeeperCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
override val commands: CommandHolder = commands(deeperWorld) {
("deeperworld" / "dw") {
"reload" {
action {
deeperWorld.config = config("config.yml") { deeperWorld.fromPluginPath(loadDefault = true)}
}
}
"tp"(desc = "Enables or disables automatic teleports between sections for a player") {
val state by booleanArg()
playerAction {
Expand All @@ -62,11 +67,11 @@ class DeeperCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
val time by intArg()
"set"(desc = "Set the time of the main synchronization world and the other worlds with their respective offsets") {
playerAction {
DeeperConfig.data.time.mainWorld?.let { world ->
deeperConfig.time.mainWorld?.let { world ->
world.time = time.toLong()
} ?: command.stopCommand("No main world specified for time synchronization. Check the config!")

DeeperConfig.data.time.syncedWorlds.forEach { (world, offset) ->
deeperConfig.time.syncedWorlds.forEach { (world, offset) ->
world.time = (time.toLong() + offset) % FULL_DAY_TIME
}

Expand All @@ -75,10 +80,10 @@ class DeeperCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
}
"add"(desc = "Add to the main synchronization world time and the other worlds with their respective offsets") {
playerAction {
DeeperConfig.data.time.mainWorld?.let { mainWorld ->
deeperConfig.time.mainWorld?.let { mainWorld ->
mainWorld.time += time.toLong()

DeeperConfig.data.time.syncedWorlds.forEach { (world, offset) ->
deeperConfig.time.syncedWorlds.forEach { (world, offset) ->
world.time = (mainWorld.time + offset) % FULL_DAY_TIME
}

Expand Down Expand Up @@ -197,6 +202,7 @@ class DeeperCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
): List<String> {
return when (args.size) {
1 -> listOf(
"reload",
"linfo",
"tp",
"time",
Expand Down
45 changes: 45 additions & 0 deletions src/main/kotlin/com/mineinabyss/deeperworld/DeeperConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
@file:UseSerializers(DurationSerializer::class)

package com.mineinabyss.deeperworld

import com.mineinabyss.deeperworld.world.section.Section
import com.mineinabyss.idofront.serialization.DurationSerializer
import com.mineinabyss.idofront.serialization.WorldSerializer
import com.mineinabyss.idofront.time.ticks
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
import org.bukkit.World
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds

val deeperConfig get() = deeperWorld.config.data.deeperConfig
@Serializable
data class DeeperWorldConfig(val deeperConfig: DeeperConfig = DeeperConfig()) {
@Serializable
data class DeeperConfig(
val sections: List<Section> = emptyList(),
val damageOutsideSections: Double = 0.0,
val damageExcludedWorlds: Set<@Serializable(with = WorldSerializer::class) World> = emptySet(),
val remountPacketDelay: Duration = 40.ticks,
val fall: FallDamageConfig = FallDamageConfig(),
val time: TimeConfig = TimeConfig(),
) {
val worlds = sections.map { it.world }.toSet()
}

@Serializable
data class FallDamageConfig(
val maxSafeDist: Float = -1f,
val fallDistanceDamageScaler: Double = 0.01,
val startingDamage: Double = 1.0,
val hitDelay: Duration = 10.ticks,
val spawnParticles: Boolean = true
)

@Serializable
data class TimeConfig(
val updateInterval: Duration = 1800.seconds,
val mainWorld: World? = null,
val syncedWorlds: Map<World, Long> = emptyMap(),
)
}
33 changes: 17 additions & 16 deletions src/main/kotlin/com/mineinabyss/deeperworld/DeeperWorldPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.comphenix.protocol.ProtocolLibrary
import com.comphenix.protocol.ProtocolManager
import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.deeperworld.MinecraftConstants.FULL_DAY_TIME
import com.mineinabyss.deeperworld.config.DeeperConfig
import com.mineinabyss.deeperworld.listeners.MovementListener
import com.mineinabyss.deeperworld.listeners.PlayerListener
import com.mineinabyss.deeperworld.player.FallingDamageManager
Expand All @@ -15,9 +14,11 @@ import com.mineinabyss.deeperworld.synchronization.ContainerSyncListener
import com.mineinabyss.deeperworld.synchronization.ExploitPreventionListener
import com.mineinabyss.deeperworld.synchronization.SectionSyncListener
import com.mineinabyss.deeperworld.world.WorldManagerImpl
import com.mineinabyss.idofront.platforms.IdofrontPlatforms
import com.mineinabyss.idofront.plugin.registerEvents
import com.mineinabyss.idofront.plugin.registerService
import com.mineinabyss.idofront.config.IdofrontConfig
import com.mineinabyss.idofront.config.config
import com.mineinabyss.idofront.platforms.Platforms
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.idofront.plugin.service
import com.mineinabyss.idofront.time.ticks
import kotlinx.coroutines.delay
import org.bukkit.Material
Expand All @@ -26,18 +27,18 @@ import org.bukkit.plugin.java.JavaPlugin
val protocolManager: ProtocolManager = ProtocolLibrary.getProtocolManager()

class DeeperWorldPlugin : JavaPlugin() {
lateinit var config: IdofrontConfig<DeeperWorldConfig>
override fun onLoad() {
IdofrontPlatforms.load(this, "mineinabyss")
Platforms.load(this, "mineinabyss")
}

override fun onEnable() {
saveDefaultConfig()
registerService<WorldManager>(WorldManagerImpl(config))
config = config("config.yml") { fromPluginPath(loadDefault = true)}

DeeperConfig.load()
service<WorldManager>(WorldManagerImpl())
service<PlayerManager>(PlayerManagerImpl())

registerService<PlayerManager>(PlayerManagerImpl())
registerEvents(
listeners(
MovementListener,
PlayerListener,
SectionSyncListener,
Expand All @@ -49,8 +50,8 @@ class DeeperWorldPlugin : JavaPlugin() {
DeeperCommandExecutor()

// Initialize falling damage task
if (DeeperConfig.data.fall.maxSafeDist >= 0f && DeeperConfig.data.fall.fallDistanceDamageScaler >= 0.0) {
val hitDellay = DeeperConfig.data.fall.hitDelay.coerceAtLeast(1.ticks)
if (deeperConfig.fall.maxSafeDist >= 0f && deeperConfig.fall.fallDistanceDamageScaler >= 0.0) {
val hitDellay = deeperConfig.fall.hitDelay.coerceAtLeast(1.ticks)
deeperWorld.launch {
while (true) {
server.onlinePlayers.forEach {
Expand All @@ -62,13 +63,13 @@ class DeeperWorldPlugin : JavaPlugin() {
}

// Initialize time synchronization task
if (DeeperConfig.data.time.syncedWorlds.isNotEmpty()) {
DeeperConfig.data.time.mainWorld?.let { mainWorld ->
val updateInterval = DeeperConfig.data.time.updateInterval.coerceAtLeast(1.ticks)
if (deeperConfig.time.syncedWorlds.isNotEmpty()) {
deeperConfig.time.mainWorld?.let { mainWorld ->
val updateInterval = deeperConfig.time.updateInterval.coerceAtLeast(1.ticks)
deeperWorld.launch {
while (true) {
val mainWorldTime = mainWorld.time
DeeperConfig.data.time.syncedWorlds.forEach { (world, offset) ->
deeperConfig.time.syncedWorlds.forEach { (world, offset) ->
world.time = (mainWorldTime + offset) % FULL_DAY_TIME
}
delay(updateInterval)
Expand Down
45 changes: 0 additions & 45 deletions src/main/kotlin/com/mineinabyss/deeperworld/config/DeeperConfig.kt

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/kotlin/com/mineinabyss/deeperworld/config/TimeConfig.kt

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package com.mineinabyss.deeperworld.movement

import com.mineinabyss.deeperworld.config.DeeperConfig
import com.mineinabyss.deeperworld.deeperConfig
import com.mineinabyss.deeperworld.movement.transition.ConfigSectionChecker
import com.mineinabyss.deeperworld.movement.transition.SectionTransition
import com.mineinabyss.deeperworld.movement.transition.TransitionKind
import com.mineinabyss.deeperworld.movement.transition.toEvent
import com.mineinabyss.idofront.events.call
import com.mineinabyss.idofront.messaging.miniMsg
import com.mineinabyss.idofront.textcomponents.miniMsg
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.title.Title
import org.bukkit.GameMode
import org.bukkit.Location
Expand Down Expand Up @@ -38,18 +39,18 @@ object MovementHandler {

//TODO abstract this away. Should instead do out of bounds action if out of bounds.
private fun Player.applyOutOfBoundsDamage() {
if (DeeperConfig.data.damageOutsideSections > 0.0
&& location.world !in DeeperConfig.data.damageExcludedWorlds
if (deeperConfig.damageOutsideSections > 0.0
&& location.world !in deeperConfig.damageExcludedWorlds
&& (gameMode == GameMode.SURVIVAL || gameMode == GameMode.ADVENTURE)
&& location.world in (DeeperConfig.data.worlds)
&& location.world in deeperConfig.worlds
) {
damage(0.01) //give a damage effect
health = (health - DeeperConfig.data.damageOutsideSections / 10)
health = (health - deeperConfig.damageOutsideSections / 10)
.coerceIn(0.0, getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value) //ignores armor
showTitle(
Title.title(
"<red>You are not in a managed section".miniMsg(),
"<gray>You will take damage upon moving!".miniMsg(),
"You are not in a managed section".miniMsg().color(NamedTextColor.RED),
"You will take damage upon moving!".miniMsg().color(NamedTextColor.GRAY),
Title.Times.times(
0.seconds.toJavaDuration(),
1.seconds.toJavaDuration(),
Expand Down
Loading

0 comments on commit e46df71

Please sign in to comment.