Skip to content

Commit

Permalink
Update gradle deps, switch to MCCoroutine
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed May 1, 2022
1 parent 0330056 commit 362947b
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 50 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v2

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

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- uses: actions/checkout@v2

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

Expand Down
24 changes: 12 additions & 12 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
val idofrontVersion: String by project

plugins {
alias(libs.plugins.mia.kotlin)
alias(libs.plugins.mia.papermc)
alias(libs.plugins.mia.copyjar)
alias(libs.plugins.mia.publication)
alias(libs.plugins.mia.testing)
id("com.mineinabyss.conventions.kotlin")
id("com.mineinabyss.conventions.papermc")
id("com.mineinabyss.conventions.copyjar")
id("com.mineinabyss.conventions.publication")
id("com.mineinabyss.conventions.testing")
kotlin("plugin.serialization")
}

Expand All @@ -17,7 +17,6 @@ repositories {
maven("https://repo.mineinabyss.com/releases/")
maven("https://papermc.io/repo/repository/maven-public/") //Paper
maven("https://repo.codemc.org/repository/maven-public/")
//maven("https://mvn.intellectualsites.com/content/repositories/releases/") // FAWE
maven("https://jitpack.io")
}

Expand All @@ -26,14 +25,15 @@ dependencies {
compileOnly(libs.kotlin.stdlib)
compileOnly(libs.kotlinx.serialization.json)
compileOnly(libs.kotlinx.serialization.kaml)
compileOnly(libs.minecraft.skedule)
compileOnly(libs.kotlinx.coroutines)
compileOnly(libs.minecraft.mccoroutine)

// Plugin APIs
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Core:2.0.1")
compileOnly("com.fastasyncworldedit:FastAsyncWorldEdit-Bukkit:2.0.1") { isTransitive = false }
compileOnly("nl.rutgerkok:blocklocker:1.10.4")
compileOnly("com.comphenix.protocol:ProtocolLib:4.8.0-SNAPSHOT")
compileOnly(libs.minecraft.plugin.fawe.core)
compileOnly(libs.minecraft.plugin.fawe.bukkit) { isTransitive = false }
compileOnly(libs.minecraft.plugin.protocollib)
compileOnly(deeperlibs.minecraft.plugin.blocklocker)

// Shaded
implementation("com.mineinabyss:idofront:$idofrontVersion")
implementation(libs.idofront.core)
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
group=com.mineinabyss
version=0.4
kotlinVersion=1.6.20-RC
kotlinVersion=1.6.10
serverVersion=1.18.2-R0.1-SNAPSHOT
idofrontConventions=1.6.20-RC-70
idofrontVersion=0.10.90
2 changes: 2 additions & 0 deletions gradle/deeperlibs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[libraries]
minecraft-plugin-blocklocker = "nl.rutgerkok:blocklocker:1.10.4"
13 changes: 11 additions & 2 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,29 @@ pluginManagement {
maven("https://repo.mineinabyss.com/releases")
maven("https://papermc.io/repo/repository/maven-public/") //Paper
}

plugins {
val kotlinVersion: String by settings
id("org.jetbrains.kotlin.jvm") version kotlinVersion
id("org.jetbrains.kotlin.plugin.serialization") version kotlinVersion
}

val idofrontVersion: String by settings
resolutionStrategy.eachPlugin {
if (requested.id.id.startsWith("com.mineinabyss.conventions")) useVersion(idofrontVersion)
}
}

dependencyResolutionManagement {
val idofrontConventions: String by settings
val idofrontVersion: String by settings

repositories {
maven("https://repo.mineinabyss.com/releases")
}
versionCatalogs.create("libs").from("com.mineinabyss:catalog:$idofrontConventions")
versionCatalogs{
create("libs").from("com.mineinabyss:catalog:$idofrontVersion")
create("deeperlibs").from(files("gradle/deeperlibs.versions.toml"))
}
}

rootProject.name = "deeperworld"
17 changes: 9 additions & 8 deletions src/main/kotlin/com/mineinabyss/deeperworld/DeeperWorldPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.mineinabyss.deeperworld

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
Expand All @@ -17,8 +18,8 @@ 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.time.inWholeTicks
import com.okkero.skedule.schedule
import com.mineinabyss.idofront.time.ticks
import kotlinx.coroutines.delay
import org.bukkit.Material
import org.bukkit.plugin.java.JavaPlugin

Expand Down Expand Up @@ -49,28 +50,28 @@ class DeeperWorldPlugin : JavaPlugin() {

// Initialize falling damage task
if (DeeperConfig.data.fall.maxSafeDist >= 0f && DeeperConfig.data.fall.fallDistanceDamageScaler >= 0.0) {
deeperWorld.schedule {
repeating(DeeperConfig.data.fall.hitDelay.inWholeTicks.coerceAtLeast(1))
val hitDellay = DeeperConfig.data.fall.hitDelay.coerceAtLeast(1.ticks)
deeperWorld.launch {
while (true) {
server.onlinePlayers.forEach {
FallingDamageManager.updateFallingDamage(it)
}
yield()
delay(hitDellay)
}
}
}

// Initialize time synchronization task
if (DeeperConfig.data.time.syncedWorlds.isNotEmpty()) {
DeeperConfig.data.time.mainWorld?.let { mainWorld ->
deeperWorld.schedule {
repeating(DeeperConfig.data.time.updateInterval.inWholeTicks.coerceAtLeast(1))
val updateInterval = DeeperConfig.data.time.updateInterval.coerceAtLeast(1.ticks)
deeperWorld.launch {
while (true) {
val mainWorldTime = mainWorld.time
DeeperConfig.data.time.syncedWorlds.forEach { (world, offset) ->
world.time = (mainWorldTime + offset) % FULL_DAY_TIME
}
yield()
delay(updateInterval)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package com.mineinabyss.deeperworld.movement

import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.deeperworld.deeperWorld
import com.mineinabyss.deeperworld.listeners.MovementListener
import com.mineinabyss.idofront.location.up
import com.okkero.skedule.schedule
import com.mineinabyss.idofront.time.ticks
import kotlinx.coroutines.delay
import org.bukkit.Location
import org.bukkit.Material
import org.bukkit.entity.Player
Expand All @@ -18,11 +20,11 @@ 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.schedule {
this.repeating(1)
deeperWorld.launch {
while (spawnedBedrock.location.up(1).getNearbyPlayers(1.5).isNotEmpty()) {
yield()
delay(5.ticks)
}
}.invokeOnCompletion { //Will also run if plugin is unloaded
spawnedBedrock.type = Material.AIR
MovementListener.temporaryBedrock.remove(spawnedBedrock)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
package com.mineinabyss.deeperworld.movement

import com.mineinabyss.idofront.messaging.color
import org.bukkit.Location
import org.bukkit.entity.Player

abstract class InvalidTeleportHandler(val player: Player, val from: Location, val to: Location) :
TeleportHandler {
final override fun handleTeleport() {
handleInvalidTeleport()
player.sendMessage("&cThere is no where for you to teleport".color())
player.sendMessage("<red>There is no where for you to teleport")
}

override fun isValidTeleport(): Boolean {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,16 @@ 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.color
import com.mineinabyss.idofront.messaging.miniMsg
import net.kyori.adventure.text.Component
import net.kyori.adventure.text.format.NamedTextColor
import net.kyori.adventure.title.Title
import org.bukkit.GameMode
import org.bukkit.Location
import org.bukkit.attribute.Attribute
import org.bukkit.entity.Player
import kotlin.time.Duration.Companion.seconds
import kotlin.time.toJavaDuration

object MovementHandler {
private val sectionCheckers = listOf(ConfigSectionChecker)
Expand Down Expand Up @@ -46,10 +51,16 @@ object MovementHandler {
0.0,
player.getAttribute(Attribute.GENERIC_MAX_HEALTH)?.value
) //ignores armor
player.sendTitle(
"&cYou are not in a managed section".color(),
"&7You will take damage upon moving!".color(),
0, 20, 10
player.showTitle(
Title.title(
"<red>You are not in a managed section".miniMsg(),
"<gray>You will take damage upon moving!".miniMsg(),
Title.Times.times(
0.seconds.toJavaDuration(),
1.seconds.toJavaDuration(),
0.5.seconds.toJavaDuration()
)
)
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ import com.comphenix.protocol.PacketType
import com.comphenix.protocol.events.PacketAdapter
import com.comphenix.protocol.events.PacketContainer
import com.comphenix.protocol.events.PacketEvent
import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.deeperworld.config.DeeperConfig
import com.mineinabyss.deeperworld.datastructures.VehicleTree
import com.mineinabyss.deeperworld.deeperWorld
import com.mineinabyss.deeperworld.protocolManager
import com.mineinabyss.idofront.time.inWholeTicks
import com.okkero.skedule.schedule
import com.mineinabyss.idofront.time.ticks
import kotlinx.coroutines.delay
import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Player
import org.bukkit.util.Vector
Expand Down Expand Up @@ -37,8 +39,8 @@ class SectionTeleportPacketAdapter(

protocolManager.removePacketListener(this)

deeperWorld.schedule {
waitFor(1)
deeperWorld.launch {
delay(1.ticks)

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

waitFor(DeeperConfig.data.remountPacketDelay.inWholeTicks)
delay(DeeperConfig.data.remountPacketDelay)

player.vehicle?.let { vehicle ->
val playerVehicleID = vehicle.entityId
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
package com.mineinabyss.deeperworld.movement

import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.deeperworld.datastructures.VehicleTree
import com.mineinabyss.deeperworld.deeperWorld
import com.mineinabyss.deeperworld.extensions.getPassengersRecursive
import com.mineinabyss.deeperworld.extensions.getRootVehicle
import com.mineinabyss.deeperworld.protocolManager
import com.okkero.skedule.schedule
import com.mineinabyss.idofront.time.ticks
import kotlinx.coroutines.delay
import org.bukkit.Location
import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Player
Expand Down Expand Up @@ -49,8 +51,8 @@ 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.schedule {
waitFor(1)
deeperWorld.launch {
delay(1.ticks)

player.teleportWithSpectatorsAsync(to) {
protocolManager.addPacketListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import com.mineinabyss.deeperworld.DeeperContext
import com.mineinabyss.deeperworld.deeperWorld
import com.mineinabyss.deeperworld.world.section.*
import com.mineinabyss.idofront.destructure.component1
import com.mineinabyss.idofront.messaging.color
import com.mineinabyss.idofront.messaging.info
import nl.rutgerkok.blocklocker.BlockLockerAPIv2
import nl.rutgerkok.blocklocker.SearchMode
Expand Down Expand Up @@ -58,7 +57,7 @@ object ContainerSyncListener : Listener {
return
}

if(container is Lidded) {
if (container is Lidded) {
(linkedBlock.state as Lidded).open();
if (!section.isOnTopOf(linkedSection)) (container as Lidded).open()
}
Expand All @@ -77,7 +76,7 @@ object ContainerSyncListener : Listener {
//try adding items to the chest above, if something doesn't fit, drop it
invItems.map { linkedInventory.addItem(it).values }.flatten().also {
if (it.isNotEmpty())
player.info("&6This container had items in it, which have been ejected to synchronize it with the upper section.".color())
player.info("<gold>This container had items in it, which have been ejected to synchronize it with the upper section.")
}.dropItems(loc, true)
container.inventory.clear()
}
Expand All @@ -95,7 +94,7 @@ object ContainerSyncListener : Listener {
@EventHandler
fun InventoryCloseEvent.onCloseInventory() {
inventory.location?.block?.sync { original, corr ->
if(original.state is Lidded) {
if (original.state is Lidded) {
(original.state as Lidded).close()
(corr.state as Lidded).close()
}
Expand Down

0 comments on commit 362947b

Please sign in to comment.