Skip to content

Commit

Permalink
feat: 1.20.6+ support
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed May 12, 2024
1 parent 2971722 commit a89af89
Show file tree
Hide file tree
Showing 9 changed files with 22 additions and 28 deletions.
1 change: 0 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ dependencies {
compileOnly(idofrontLibs.kotlinx.coroutines)
compileOnly(idofrontLibs.minecraft.mccoroutine)
compileOnly(libs.geary.papermc)
compileOnly(libs.bonehurtingjuice)

implementation(idofrontLibs.bundles.idofront.core)
implementation(idofrontLibs.idofront.nms)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.mineinabyss
version=0.22
idofrontVersion=0.23.0
idofrontVersion=0.24.0-dev.8
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[versions]
geary = "0.29.0"
geary = "0.30.1-dev.10"
bonehurtingjuice = "1.10.1"

[libraries]
Expand Down
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.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.7-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
5 changes: 4 additions & 1 deletion settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ pluginManagement {
repositories {
gradlePluginPortal()
maven("https://repo.mineinabyss.com/releases")
maven("https://repo.mineinabyss.com/snapshots")
maven("https://repo.papermc.io/repository/maven-public/")
mavenLocal()
google()
}

Expand All @@ -19,8 +21,9 @@ dependencyResolutionManagement {
val idofrontVersion: String by settings

repositories {
mavenLocal()
maven("https://repo.mineinabyss.com/releases")
maven("https://repo.mineinabyss.com/snapshots")
mavenLocal()
}

versionCatalogs {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,21 @@
package com.mineinabyss.staminaclimb.climbing

import com.mineinabyss.idofront.messaging.broadcast
import com.mineinabyss.staminaclimb.*
import com.mineinabyss.staminaclimb.modules.stamina
import com.mineinabyss.staminaclimb.stamina.StaminaBar
import com.mineinabyss.staminaclimb.stamina.removeProgress
import org.bukkit.GameMode
import org.bukkit.Material
import org.bukkit.Tag
import org.bukkit.block.BlockFace
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.EventPriority
import org.bukkit.event.Listener
import org.bukkit.event.block.Action
import org.bukkit.event.block.BlockBreakEvent
import org.bukkit.event.block.BlockPlaceEvent
import org.bukkit.event.entity.EntityDamageEvent
import org.bukkit.event.player.PlayerAnimationEvent
import org.bukkit.event.player.PlayerInteractEvent
import org.bukkit.event.player.PlayerMoveEvent
import org.bukkit.inventory.EquipmentSlot
import org.bukkit.util.Vector
import org.cultofclang.bonehurtingjuice.hurtBones
import java.util.*
import java.util.concurrent.ConcurrentHashMap

Expand All @@ -42,18 +35,18 @@ object ClimbBehaviour : Listener {
isClimbing.remove(uuid)
}

private val climbableMap = mutableMapOf<UUID, Float>()
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
fun PlayerMoveEvent.onScaleDownClimbable() {
if (!hasExplicitlyChangedBlock() || !player.isInClimbableBlock) return

val block = player.location.block
val increase = if (block.type == Material.SCAFFOLDING || !player.climbEnabled || !player.uniqueId.canClimb) 1 else 0
climbableMap.compute(player.uniqueId) { _, v -> (v ?: 0).toFloat() + increase }
if (block.getRelative(BlockFace.DOWN).type in Tag.CLIMBABLE.values) return
player.hurtBones(climbableMap[player.uniqueId] ?: 0f)
climbableMap.remove(player.uniqueId)
}
// private val climbableMap = mutableMapOf<UUID, Float>()
// @EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
// fun PlayerMoveEvent.onScaleDownClimbable() {
// if (!hasExplicitlyChangedBlock() || !player.isInClimbableBlock) return
//
// val block = player.location.block
// val increase = if (block.type == Material.SCAFFOLDING || !player.climbEnabled || !player.uniqueId.canClimb) 1 else 0
// climbableMap.compute(player.uniqueId) { _, v -> (v ?: 0).toFloat() + increase }
// if (block.getRelative(BlockFace.DOWN).type in Tag.CLIMBABLE.values) return
// player.hurtBones(climbableMap[player.uniqueId] ?: 0f)
// climbableMap.remove(player.uniqueId)
// }

@EventHandler
fun BlockPlaceEvent.onBlockPlace() {
Expand Down
3 changes: 1 addition & 2 deletions src/main/kotlin/com/mineinabyss/staminaclimb/nms/Tags.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,10 @@ import it.unimi.dsi.fastutil.ints.IntList
import net.minecraft.core.registries.BuiltInRegistries
import net.minecraft.core.registries.Registries
import net.minecraft.network.protocol.common.ClientboundUpdateTagsPacket
import net.minecraft.network.protocol.game.ServerboundEntityTagQuery
import net.minecraft.resources.ResourceLocation
import net.minecraft.tags.BlockTags
import net.minecraft.tags.TagNetworkSerialization.NetworkPayload
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer
import org.bukkit.craftbukkit.entity.CraftPlayer
import org.bukkit.entity.Player

object Tags {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import org.bukkit.Bukkit
import org.bukkit.GameMode.ADVENTURE
import org.bukkit.GameMode.SURVIVAL
import org.bukkit.Location
import org.bukkit.craftbukkit.v1_20_R3.entity.CraftPlayer
import org.bukkit.craftbukkit.entity.CraftPlayer
import org.bukkit.entity.Player
import org.bukkit.event.EventHandler
import org.bukkit.event.Listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class StaminaTask : BukkitRunnable() {

uuid.canClimb =
false //If player reaches red zone, they can't climb until they get back in green zone
player.addPotionEffect(PotionEffect(PotionEffectType.SLOW, 110, 2, false, false))
player.addPotionEffect(PotionEffect(PotionEffectType.SLOWNESS, 110, 2, false, false))
player.addPotionEffect(PotionEffect(PotionEffectType.WEAKNESS, 110, 2, false, false))
}

Expand Down

0 comments on commit a89af89

Please sign in to comment.