Skip to content

Commit

Permalink
Ido (#40)
Browse files Browse the repository at this point in the history
* bump deps

* update ido
  • Loading branch information
Boy0000 authored Oct 18, 2022
1 parent bc60b0e commit b0e9904
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 110 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/publish-packages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,29 @@ jobs:
with:
distribution: temurin
java-version: 17
cache: gradle

- name: Run gradle build and publish
run: gradle build publish dokkaHtml -PmineinabyssMavenUsername=${{ secrets.MAVEN_PUBLISH_USERNAME }} -PmineinabyssMavenPassword=${{ secrets.MAVEN_PUBLISH_PASSWORD }}
- name: Set env variable from latest maven version
run: >
echo "RELEASE_VERSION=$( \
curl https://repo.mineinabyss.com/releases/com/mineinabyss/bonfire/maven-metadata.xml | \
grep -oP '(?!<latest>)[\d\.]*(?=</latest>)' \
)" >> $GITHUB_ENV
- name: Publish documentation to GitHub Pages
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./build/dokka/htmlMultiModule
force_orphan: true
- name: Run gradle build and publish
run: gradle build publish -PmineinabyssMavenUsername=${{ secrets.MAVEN_PUBLISH_USERNAME }} -PmineinabyssMavenPassword=${{ secrets.MAVEN_PUBLISH_PASSWORD }}

- name: Get version from gradle
shell: bash
id: extract_version
run: |
version=`gradle properties --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 for shaded idofront platfrom
- name: Create GitHub Release
uses: marvinpinto/action-automatic-releases@latest
with:
repo_token: "${{ secrets.GITHUB_TOKEN }}"
prerelease: false
automatic_release_tag: v${{ steps.extract_version.outputs.version }}
files: |
build/libs/*[0-9]-all.jar
build/libs/*-all.jar
6 changes: 1 addition & 5 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,5 @@ dependencies {
compileOnly(bfLibs.deeperworld)

// Shaded
implementation(libs.idofront.core)
}

tasks.shadowJar {
minimize()
implementation(libs.bundles.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=1.7
kotlinVersion=1.6.10
kotlinVersion=1.7.10
serverVersion=1.19.2-R0.1-SNAPSHOT
idofrontVersion=0.12.112
idofrontVersion=0.14.7
10 changes: 5 additions & 5 deletions gradle/bfLibs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
[versions]
geary = "0.20.115"
mobzy = "0.19.85"
looty = "0.8.69"
deeperworld = "0.6.84"
protocolburrito = "0.5.38"
geary = "0.21.2"
mobzy = "0.20.1"
looty = "0.9.1"
deeperworld = "0.7.0"
protocolburrito = "0.6.3"

[libraries]
protocolburrito = { module = "com.mineinabyss:protocolburrito", version.ref = "protocolburrito" }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mineinabyss.bonfire

import com.github.shynixn.mccoroutine.bukkit.launch
import com.mineinabyss.bonfire.config.BonfireConfig
import com.mineinabyss.bonfire.config.bonfireConfig
import com.mineinabyss.bonfire.data.Bonfire
import com.mineinabyss.bonfire.data.Players
import com.mineinabyss.bonfire.ecs.components.BonfireCooldown
Expand All @@ -16,6 +16,7 @@ import com.mineinabyss.idofront.commands.arguments.stringArg
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 @@ -38,6 +39,11 @@ import org.jetbrains.exposed.sql.transactions.transaction
object BonfireCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
override val commands: CommandHolder = commands(bonfirePlugin) {
("bonfire" / "bf")(desc = "Commands for Bonfire") {
"reload" {
action {
bonfirePlugin.config = config("config") { bonfirePlugin.fromPluginPath(loadDefault = true) }
}
}
"respawn"(desc = "Commands to manipulate the Bonfire respawn of players") {
val targetPlayerStr by stringArg { name = "player" }

Expand Down Expand Up @@ -224,7 +230,7 @@ object BonfireCommandExecutor : IdofrontCommandExecutor(), TabCompleter {
}
"give"(desc = "Give yourself a bonfire") { //TODO: Add this command to idofront/MiA for any custom item
playerAction {
player.inventory.addItem(BonfireConfig.data.bonfireItem.toItemStack())
player.inventory.addItem(bonfireConfig.bonfireItem.toItemStack())
}
}
"debug"(desc = "Debug commands") {
Expand Down
29 changes: 15 additions & 14 deletions src/main/kotlin/com/mineinabyss/bonfire/BonfirePlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,15 @@ import com.mineinabyss.bonfire.data.Players
import com.mineinabyss.bonfire.listeners.BlockListener
import com.mineinabyss.bonfire.listeners.DWListener
import com.mineinabyss.bonfire.listeners.PlayerListener
import com.mineinabyss.deeperworld.deeperWorld
import com.mineinabyss.geary.addon.autoscan
import com.mineinabyss.geary.papermc.dsl.gearyAddon
import com.mineinabyss.idofront.platforms.IdofrontPlatforms
import com.mineinabyss.idofront.plugin.getService
import com.mineinabyss.idofront.plugin.isPluginEnabled
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.Services
import com.mineinabyss.idofront.plugin.listeners
import com.mineinabyss.idofront.plugin.service
import org.bukkit.plugin.java.JavaPlugin
import org.jetbrains.exposed.sql.Database
import org.jetbrains.exposed.sql.SchemaUtils
Expand All @@ -25,20 +27,20 @@ import org.jetbrains.exposed.sql.transactions.transaction
val bonfirePlugin: BonfirePlugin by lazy { JavaPlugin.getPlugin(BonfirePlugin::class.java) }

interface BonfireContext {
companion object : BonfireContext by getService()
companion object : BonfireContext by Services.get()

val db: Database
}

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

override fun onEnable() {
saveDefaultConfig()
BonfireConfig.load()
registerService<BonfireContext>(object : BonfireContext {
config = config("config") { fromPluginPath(loadDefault = true)}
service<BonfireContext>(object : BonfireContext {
override val db = Database.connect("jdbc:sqlite:" + dataFolder.path + "/data.db", "org.sqlite.JDBC")
})

Expand All @@ -51,7 +53,7 @@ class BonfirePlugin : JavaPlugin() {

server.pluginManager.registerSuspendingEvents(PlayerListener, this)

registerEvents(
listeners(
BlockListener
)

Expand All @@ -63,9 +65,8 @@ class BonfirePlugin : JavaPlugin() {

BonfireCommandExecutor

if (isPluginEnabled("DeeperWorld")) {
registerEvents(DWListener)
}
if (deeperWorld.isEnabled)
listeners(DWListener)
}

override fun onDisable() {
Expand Down
35 changes: 15 additions & 20 deletions src/main/kotlin/com/mineinabyss/bonfire/config/BonfireConfig.kt
Original file line number Diff line number Diff line change
@@ -1,29 +1,24 @@
@file:UseSerializers(DurationSerializer::class)

package com.mineinabyss.bonfire.config

import com.mineinabyss.bonfire.bonfirePlugin
import com.mineinabyss.bonfire.ecs.components.SoundEffect
import com.mineinabyss.idofront.config.IdofrontConfig
import com.mineinabyss.idofront.serialization.DurationSerializer
import com.mineinabyss.idofront.serialization.SerializableItemStack
import kotlinx.serialization.Serializable
import kotlinx.serialization.UseSerializers
import kotlin.time.Duration

object BonfireConfig : IdofrontConfig<BonfireConfig.Data>(bonfirePlugin, Data.serializer()) {
@Serializable
data class Data(
var bonfireItem: SerializableItemStack,
var modelItem: SerializableItemStack,
var maxPlayerCount: Int,
var bonfireExpirationTime: Duration,
var bonfireInteractCooldown: Duration,
var respawnSetSound: SoundEffect,
var respawnUnsetSound: SoundEffect,
var minFallDist: Int,
var effectRadius: Double,
var effectStrength: Float,
var effectRegenRate: Int
)
}
val bonfireConfig get() = bonfirePlugin.config.data
@Serializable
data class BonfireConfig(
var bonfireItem: SerializableItemStack,
var modelItem: SerializableItemStack,
var maxPlayerCount: Int,
var bonfireExpirationTime: @Serializable(with = DurationSerializer::class) Duration,
var bonfireInteractCooldown: @Serializable(with = DurationSerializer::class) Duration,
var respawnSetSound: SoundEffect,
var respawnUnsetSound: SoundEffect,
var minFallDist: Int,
var effectRadius: Double,
var effectStrength: Float,
var effectRegenRate: Int
)
4 changes: 2 additions & 2 deletions src/main/kotlin/com/mineinabyss/bonfire/data/Bonfire.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mineinabyss.bonfire.data

import com.mineinabyss.bonfire.config.BonfireConfig
import com.mineinabyss.bonfire.config.bonfireConfig
import com.mineinabyss.bonfire.extensions.location
import org.jetbrains.exposed.dao.id.EntityID
import org.jetbrains.exposed.dao.id.IdTable
Expand All @@ -17,7 +17,7 @@ object Bonfire : IdTable<UUID>() {
val location = location("location")
val stateChangedTimestamp = datetime("stateChangedTimestamp").clientDefault { LocalDateTime.now() }
val timeUntilDestroy = duration("timeUntilDestroy")
.default(BonfireConfig.data.bonfireExpirationTime.toJavaDuration())
.default(bonfireConfig.bonfireExpirationTime.toJavaDuration())
override val id: Column<EntityID<UUID>>
get() = entityUUID.entityId()
}
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
package com.mineinabyss.bonfire.ecs.systems

import com.mineinabyss.bonfire.config.BonfireConfig
import com.mineinabyss.bonfire.config.bonfireConfig
import com.mineinabyss.bonfire.ecs.components.BonfireEffectArea
import com.mineinabyss.bonfire.extensions.isBonfireModel
import com.mineinabyss.geary.annotations.AutoScan
import com.mineinabyss.geary.systems.RepeatingSystem
import com.mineinabyss.geary.systems.accessors.TargetScope
import com.mineinabyss.idofront.time.ticks
import org.bukkit.Particle
import org.bukkit.entity.ArmorStand
import org.bukkit.entity.Player

@AutoScan
class BonfireEffectSystem : RepeatingSystem(1.ticks) {
private val TargetScope.player by get<Player>()
private val TargetScope.effect by get<BonfireEffectArea>()

override fun TargetScope.tick() {
// Check if still near a bonfire
player.location.getNearbyLivingEntities(BonfireConfig.data.effectRadius).firstOrNull {
player.location.getNearbyLivingEntities(bonfireConfig.effectRadius).firstOrNull {
it is ArmorStand && it.isBonfireModel() && it.uniqueId == effect.uuid
}?.let {
player.location.world.spawnParticle(
listOf(Particle.SOUL, Particle.SOUL_FIRE_FLAME).random(),
player.location, 1, 0.5, 1.0, 0.5, 0.0
)

player.saturation = BonfireConfig.data.effectStrength
player.saturatedRegenRate = BonfireConfig.data.effectRegenRate
player.saturation = bonfireConfig.effectStrength
player.saturatedRegenRate = bonfireConfig.effectRegenRate
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.mineinabyss.bonfire.extensions

import com.mineinabyss.bonfire.config.BonfireConfig
import com.mineinabyss.bonfire.config.bonfireConfig
import com.mineinabyss.bonfire.ecs.components.BonfireModel
import com.mineinabyss.geary.papermc.store.encode
import com.mineinabyss.geary.papermc.store.has
Expand All @@ -18,7 +18,7 @@ fun ArmorStand.setDefaults(): ArmorStand {
this.isSmall = true
this.isMarker = true
this.setBonfireModel()
this.equipment.helmet = BonfireConfig.data.modelItem.toItemStack()
this.equipment.helmet = bonfireConfig.modelItem.toItemStack()

return this
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fun Campfire.getModel(): ArmorStand? {
}

fun Campfire.error(): Nothing =
error("Bonfire data not found for campfire $this")
error("Bonfire data not found for campfire at ${this.location}")

fun Campfire.createBonfire(newBonfireUUID: UUID, playerUUID: UUID) {
val bonfireData = BonfireData(newBonfireUUID)
Expand Down
6 changes: 3 additions & 3 deletions src/main/kotlin/com/mineinabyss/bonfire/extensions/Player.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.mineinabyss.bonfire.extensions

import com.mineinabyss.bonfire.BonfireContext
import com.mineinabyss.bonfire.config.BonfireConfig
import com.mineinabyss.bonfire.config.bonfireConfig
import com.mineinabyss.bonfire.data.Bonfire
import com.mineinabyss.bonfire.data.Players
import com.mineinabyss.bonfire.ecs.components.BonfireEffectArea
Expand Down Expand Up @@ -69,7 +69,7 @@ fun OfflinePlayer.setRespawnLocation(bonfireUUID: UUID) {
}

newCampfire.markStateChanged()
this@setRespawnLocation.player?.let { BonfireConfig.data.respawnSetSound.playSound(it) }
this@setRespawnLocation.player?.let { bonfireConfig.respawnSetSound.playSound(it) }
this@setRespawnLocation.player?.success("Respawn point set")
val p = this@setRespawnLocation.player
p?.toGeary()?.setPersisting(BonfireEffectArea(newCampfire.uuid))
Expand All @@ -94,7 +94,7 @@ fun OfflinePlayer.removeBonfireSpawnLocation(bonfireUUID: UUID): Boolean {
}
if (deleteCode == 0) return@transaction false

this@removeBonfireSpawnLocation.player?.let { BonfireConfig.data.respawnUnsetSound.playSound(it) }
this@removeBonfireSpawnLocation.player?.let { bonfireConfig.respawnUnsetSound.playSound(it) }
this@removeBonfireSpawnLocation.player?.error("Respawn point has been removed")

val p = this@removeBonfireSpawnLocation.player
Expand Down
Loading

0 comments on commit b0e9904

Please sign in to comment.