Skip to content

Commit

Permalink
1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Oct 21, 2023
1 parent e31fc60 commit d3baee9
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml → .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Java CI
name: Java CI with Gradle

on:
pull_request:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Publish GitHub Packages
name: Publish

on:
push:
Expand All @@ -11,13 +11,14 @@ on:
jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- uses: MineInAbyss/publish-action@master
with:
maven-metadata-url: https://repo.mineinabyss.com/releases/com/mineinabyss/deeperworld/maven-metadata.xml
pages-path: build/dokka/htmlMultiModule/
dokka: dokkaHtmlMultiModule
maven-username: ${{ secrets.MAVEN_PUBLISH_USERNAME }}
maven-password: ${{ secrets.MAVEN_PUBLISH_PASSWORD }}
release-files: |
Expand Down
12 changes: 6 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
@Suppress("DSL_SCOPE_VIOLATION")
plugins {
alias(libs.plugins.kotlinx.serialization)
id("com.mineinabyss.conventions.kotlin.jvm")
id("com.mineinabyss.conventions.papermc")
id("com.mineinabyss.conventions.copyjar")
id("com.mineinabyss.conventions.publication")
id("com.mineinabyss.conventions.testing")
id("com.mineinabyss.conventions.autoversion")
alias(libs.plugins.mia.kotlin.jvm)
alias(libs.plugins.mia.papermc)
alias(libs.plugins.mia.copyjar)
alias(libs.plugins.mia.testing)
alias(libs.plugins.mia.publication)
alias(libs.plugins.mia.autoversion)
}

repositories {
Expand Down
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.mineinabyss
version=0.8
idofrontVersion=0.18.26
version=0.9
idofrontVersion=0.19.14
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-8.1.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ 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
import com.mineinabyss.idofront.plugin.Plugins
import com.sk89q.worldedit.EditSession
import com.sk89q.worldedit.WorldEdit
import com.sk89q.worldedit.bukkit.WorldEditPlugin
Expand All @@ -34,11 +34,12 @@ import org.bukkit.command.CommandSender
import org.bukkit.command.TabCompleter

class DeeperCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
override val commands = commands(deeperWorld) {
override val commands = commands(deeperWorld.plugin) {
("deeperworld" / "dw") {
"reload" {
action {
deeperWorld.config = config("config") { deeperWorld.fromPluginPath(loadDefault = true)}
deeperWorld.plugin.createDeeperWorldContext()
sender.success("Reloaded DeeperWorld")
}
}
"tp"(desc = "Enables or disables automatic teleports between sections for a player") {
Expand Down Expand Up @@ -66,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.time.mainWorld?.let { world ->
deeperWorld.config.time.mainWorld?.let { world ->
world.time = time.toLong()
} ?: command.stopCommand("No main world specified for time synchronization. Check the config!")

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

Expand All @@ -79,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.time.mainWorld?.let { mainWorld ->
deeperWorld.config.time.mainWorld?.let { mainWorld ->
mainWorld.time += time.toLong()

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

Expand All @@ -101,7 +102,7 @@ class DeeperCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
}

when {
DeeperContext.isFAWELoaded -> {
Plugins.isEnabled("FastAsyncWorldEdit") -> {
try {
val pos1 = BlockVector3.at(
(player.location.x + range),
Expand Down
28 changes: 23 additions & 5 deletions src/main/kotlin/com/mineinabyss/deeperworld/DeeperConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,32 @@

package com.mineinabyss.deeperworld

import com.charleskorn.kaml.YamlComment
import com.mineinabyss.deeperworld.world.Region
import com.mineinabyss.deeperworld.world.section.Section
import com.mineinabyss.idofront.di.DI
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.Bukkit
import org.bukkit.World
import kotlin.time.Duration
import kotlin.time.Duration.Companion.seconds

val deeperConfig get() = deeperWorld.config.data
val deeperWorld by DI.observe<DeeperContext>()
@Serializable
data class DeeperWorldConfig(
val sections: List<Section> = emptyList(),
val damageOutsideSections: Double = 0.0,
val sections: List<Section> = listOf(
Section("section1", Region(0,0,0,1000,256,1000), Bukkit.getWorld("world")!!, "0, 0, 0", "0, 16, 0"),
Section("section2", Region(1000, 0, 0, 2000 ,256, 1000), Bukkit.getWorld("world")!!, "1000, 240, 0", "2000, 16, 0"),
),
@YamlComment("The damage players will take when outside a managed section.")
val damageOutsideSections: Double = 1.0,
@YamlComment("Worlds which shouldn't damage players when outside of a section.")
val damageExcludedWorlds: Set<@Serializable(with = WorldSerializer::class) World> = emptySet(),
@YamlComment("Sends an additional remount packet after this delay to prevent client-side mount bugs when moving between sections.\n")
val remountPacketDelay: Duration = 40.ticks,
val fall: FallDamageConfig = FallDamageConfig(),
val time: TimeConfig = TimeConfig(),
Expand All @@ -26,17 +36,25 @@ data class DeeperWorldConfig(

@Serializable
data class FallDamageConfig(
@YamlComment("The maximum safe falling distance, after which players will start taking damage. Set to -1 to disable falling damage")
val maxSafeDist: Float = -1f,
@YamlComment("The multiplier for damage taken while falling. Set to 0 to deal consistent damage.")
val fallDistanceDamageScaler: Double = 0.01,
@YamlComment("The minimum damage to deal.")
val startingDamage: Double = 1.0,
@YamlComment("How often to damage players in ticks")
val hitDelay: @Serializable(DurationSerializer::class) Duration = 10.ticks,
@YamlComment("Whether to spawn cloud particles when the player is being damaged.")
val spawnParticles: Boolean = true
)

@Serializable
data class TimeConfig(
@YamlComment("How often to synchronize time between worlds")
val updateInterval: @Serializable(DurationSerializer::class) Duration = 1800.seconds,
val mainWorld: @Serializable(WorldSerializer::class) World? = null,
val syncedWorlds: Map<@Serializable(WorldSerializer::class) World, Long> = emptyMap(),
@YamlComment("The main synchronization world. Other worlds will get synchronized based on the time in this world.")
val mainWorld: @Serializable(WorldSerializer::class) World? = Bukkit.getWorld("world"),
@YamlComment("The worlds where time should be synchronized with the mainWorld. Optionally specify a time offset (leave 0 if no offset is desired)")
val syncedWorlds: Map<@Serializable(WorldSerializer::class) World, Long> = mutableMapOf(Bukkit.getWorld("world")!! to 0L)
)
}
6 changes: 3 additions & 3 deletions src/main/kotlin/com/mineinabyss/deeperworld/DeeperContext.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package com.mineinabyss.deeperworld
/**
* Easy access to information related to the [DeeperWorldPlugin] plugin.
*/
object DeeperContext {
val isBlockLockerLoaded: Boolean = deeperWorld.server.pluginManager.isPluginEnabled("BlockLocker")
val isFAWELoaded: Boolean = deeperWorld.server.pluginManager.isPluginEnabled("FastAsyncWorldEdit")
interface DeeperContext {
val plugin: DeeperWorldPlugin
val config: DeeperWorldConfig
}
40 changes: 23 additions & 17 deletions src/main/kotlin/com/mineinabyss/deeperworld/DeeperWorldPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ 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.config.IdofrontConfig
import com.mineinabyss.idofront.config.config
import com.mineinabyss.idofront.di.DI
import com.mineinabyss.idofront.platforms.Platforms
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.idofront.plugin.service
Expand All @@ -27,25 +27,23 @@ import org.bukkit.plugin.java.JavaPlugin
val protocolManager: ProtocolManager = ProtocolLibrary.getProtocolManager()

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

override fun onEnable() {
config = config("config") { fromPluginPath(loadDefault = true)}

createDeeperWorldContext()
service<WorldManager>(WorldManagerImpl())
service<PlayerManager>(PlayerManagerImpl())

// Register aboveKey / belowKey as new config breaks this
for (section in deeperConfig.sections) {
for (section in deeperWorld.config.sections) {
when (section) {
deeperConfig.sections.first() -> section.belowKey = deeperConfig.sections[1].key
deeperConfig.sections.last() -> section.aboveKey = deeperConfig.sections[deeperConfig.sections.size - 2].key
deeperWorld.config.sections.first() -> section.belowKey = deeperWorld.config.sections[1].key
deeperWorld.config.sections.last() -> section.aboveKey = deeperWorld.config.sections[deeperWorld.config.sections.size - 2].key
else -> {
section.aboveKey = deeperConfig.sections[deeperConfig.sections.indexOf(section) - 1].key
section.belowKey = deeperConfig.sections[deeperConfig.sections.indexOf(section) + 1].key
section.aboveKey = deeperWorld.config.sections[deeperWorld.config.sections.indexOf(section) - 1].key
section.belowKey = deeperWorld.config.sections[deeperWorld.config.sections.indexOf(section) + 1].key
}
}
}
Expand All @@ -62,9 +60,9 @@ class DeeperWorldPlugin : JavaPlugin() {
DeeperCommandExecutor()

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

// Initialize time synchronization task
if (deeperConfig.time.syncedWorlds.isNotEmpty()) {
deeperConfig.time.mainWorld?.let { mainWorld ->
val updateInterval = deeperConfig.time.updateInterval.coerceAtLeast(1.ticks)
deeperWorld.launch {
if (deeperWorld.config.time.syncedWorlds.isNotEmpty()) {
deeperWorld.config.time.mainWorld?.let { mainWorld ->
val updateInterval = deeperWorld.config.time.updateInterval.coerceAtLeast(1.ticks)
deeperWorld.plugin.launch {
while (true) {
val mainWorldTime = mainWorld.time
deeperConfig.time.syncedWorlds.forEach { (world, offset) ->
deeperWorld.config.time.syncedWorlds.forEach { (world, offset) ->
world.time = (mainWorldTime + offset) % FULL_DAY_TIME
}
delay(updateInterval)
Expand All @@ -91,6 +89,14 @@ class DeeperWorldPlugin : JavaPlugin() {
}
}

fun createDeeperWorldContext() {
DI.remove<DeeperContext>()
DI.add<DeeperContext>(object : DeeperContext {
override val plugin = this@DeeperWorldPlugin
override val config: DeeperWorldConfig by config("config", dataFolder.toPath(), DeeperWorldConfig())
})
}

override fun onDisable() {
MovementListener.temporaryBedrock.forEach {
it.type = Material.AIR
Expand Down
8 changes: 0 additions & 8 deletions src/main/kotlin/com/mineinabyss/deeperworld/Helpers.kt

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class BedrockBlockingInvalidTeleportHandler(player: Player, from: Location, to:

// Keep bedrock spawned if there are players within a 1.5 radius (regular jump height).
// If no players are in this radius, destroy the bedrock.
deeperWorld.launch {
deeperWorld.plugin.launch {
while (spawnedBedrock.location.up(1).getNearbyPlayers(1.5).isNotEmpty()) {
delay(5.ticks)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mineinabyss.deeperworld.movement

import com.mineinabyss.deeperworld.deeperConfig
import com.mineinabyss.deeperworld.deeperWorld
import com.mineinabyss.deeperworld.movement.transition.ConfigSectionChecker
import com.mineinabyss.deeperworld.movement.transition.SectionTransition
import com.mineinabyss.deeperworld.movement.transition.TransitionKind
Expand Down Expand Up @@ -39,13 +39,13 @@ object MovementHandler {

//TODO abstract this away. Should instead do out of bounds action if out of bounds.
private fun Player.applyOutOfBoundsDamage() {
if (deeperConfig.damageOutsideSections > 0.0
&& location.world !in deeperConfig.damageExcludedWorlds
if (deeperWorld.config.damageOutsideSections > 0.0
&& location.world !in deeperWorld.config.damageExcludedWorlds
&& (gameMode == GameMode.SURVIVAL || gameMode == GameMode.ADVENTURE)
&& location.world in deeperConfig.worlds
&& location.world in deeperWorld.config.worlds
) {
damage(0.01) //give a damage effect
health = (health - deeperConfig.damageOutsideSections / 10)
health = (health - deeperWorld.config.damageOutsideSections / 10)
.coerceIn(0.0, getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value) //ignores armor
showTitle(
Title.title(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import com.comphenix.protocol.events.PacketContainer
import com.comphenix.protocol.events.PacketEvent
import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.deeperworld.datastructures.VehicleTree
import com.mineinabyss.deeperworld.deeperConfig
import com.mineinabyss.deeperworld.deeperWorld
import com.mineinabyss.deeperworld.protocolManager
import com.mineinabyss.idofront.time.ticks
Expand All @@ -29,7 +28,7 @@ class SectionTeleportPacketAdapter(
private val oldVelocity: Vector,
private val vehicleTree: VehicleTree? = null
) : PacketAdapter(
deeperWorld,
deeperWorld.plugin,
PacketType.Play.Client.POSITION,
PacketType.Play.Client.POSITION_LOOK
) {
Expand All @@ -38,7 +37,7 @@ class SectionTeleportPacketAdapter(

protocolManager.removePacketListener(this)

deeperWorld.launch {
deeperWorld.plugin.launch {
delay(1.ticks)

oldLeashedEntities.toSet().forEach {
Expand All @@ -64,7 +63,7 @@ class SectionTeleportPacketAdapter(
vehicleTree.root.value.fallDistance = oldFallDistance
vehicleTree.root.value.velocity = oldVelocity

delay(deeperConfig.remountPacketDelay)
delay(deeperWorld.config.remountPacketDelay)

player.vehicle?.let { vehicle ->
val playerVehicleID = vehicle.entityId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class TransitionTeleportHandler(val player: Player, val from: Location, val to:

// Delay the teleportation by 1 tick after passenger removal to avoid occasional
// "Removing ticking entity!" exceptions.
deeperWorld.launch {
deeperWorld.plugin.launch {
delay(1.ticks)

player.teleportWithSpectatorsAsync(to) {
Expand Down
Loading

0 comments on commit d3baee9

Please sign in to comment.