Skip to content

Commit

Permalink
Merge pull request #50 from toxicity188/bubble
Browse files Browse the repository at this point in the history
multi-line text
  • Loading branch information
toxicity188 authored Nov 10, 2024
2 parents a85ff8e + f3707b9 commit d016196
Show file tree
Hide file tree
Showing 54 changed files with 775 additions and 389 deletions.
4 changes: 1 addition & 3 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ name: Java CI with Gradle
on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

permissions:
contents: read
Expand All @@ -26,7 +24,7 @@ jobs:
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build all file.
- name: Build all file
run: ./gradlew build --stacktrace
- name: Publish to Modrinth
run: ./gradlew modrinthPublish --stacktrace
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
package kr.toxicity.hud.api.manager;

import org.jetbrains.annotations.NotNull;

public interface TextManager {
int getWidth(@NotNull String textName, double scale, @NotNull String text);
}
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,70 @@ class MythicMobsCompatibility : Compatibility {
} ?: 0
}
}
},
// entity
"entity_current_cooldown" to object : HudPlaceholder<Number> {
override fun getRequiredArgsLength(): Int = 1
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Number> {
return reason.unwrap { event: EntityEvent ->
val skill = MythicBukkit.inst().skillManager.getSkill(args[0]).orElseThrow {
RuntimeException("this skill doesn't exist: ${args[0]}")
} as AbstractSkill
Function {
skill.getCooldown(object : SkillCaster {
override fun getEntity(): AbstractEntity = BukkitAdapter.adapt(event.entity)
override fun setUsingDamageSkill(p0: Boolean) {}
override fun isUsingDamageSkill(): Boolean = false
})
}
}
}
},
"entity_aura_stack" to object : HudPlaceholder<Number> {
override fun getRequiredArgsLength(): Int = 1
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Number> {
return reason.unwrap { event: EntityEvent ->
Function get@ {
(MythicBukkit.inst().mobManager.getMythicMobInstance(event.entity) ?: return@get -1).getAuraStacks(args[0])
}
}
}
},
"entity_aura_max_duration" to object : HudPlaceholder<Number> {
override fun getRequiredArgsLength(): Int = 1
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Number> {
return reason.unwrap { event: EntityEvent ->
Function get@ {
(MythicBukkit.inst().mobManager.getMythicMobInstance(event.entity) ?: return@get -1).auraRegistry.auras[args[0]]?.maxOfOrNull { aura ->
aura.startDuration
} ?: 0
}
}
}
},
"entity_aura_duration" to object : HudPlaceholder<Number> {
override fun getRequiredArgsLength(): Int = 1
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Number> {
return reason.unwrap { event: EntityEvent ->
Function get@ {
(MythicBukkit.inst().mobManager.getMythicMobInstance(event.entity) ?: return@get -1).auraRegistry.auras[args[0]]?.maxOfOrNull { aura ->
aura.ticksRemaining
} ?: 0
}
}
}
},
"entity_aura_duration_reversed" to object : HudPlaceholder<Number> {
override fun getRequiredArgsLength(): Int = 1
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Number> {
return reason.unwrap { event: EntityEvent ->
Function get@ {
(MythicBukkit.inst().mobManager.getMythicMobInstance(event.entity) ?: return@get -1).auraRegistry.auras[args[0]]?.maxOfOrNull { aura ->
aura.startDuration - aura.ticksRemaining
} ?: 0
}
}
}
}
)
override val strings: Map<String, HudPlaceholder<String>>
Expand Down Expand Up @@ -150,6 +214,16 @@ class MythicMobsCompatibility : Compatibility {
MythicBukkit.inst().mobManager.isMythicMob(e.entity)
}
}
},
"entity_has_aura" to object : HudPlaceholder<Boolean> {
override fun getRequiredArgsLength(): Int = 1
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Boolean> {
return reason.unwrap { event: EntityEvent ->
Function get@ { _ ->
(MythicBukkit.inst().mobManager.getMythicMobInstance(event.entity) ?: return@get false).auraRegistry.hasAura(args[0])
}
}
}
}
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ class OraxenCompatibility : Compatibility {
}
else -> warn("Unknown Oraxen Version.")
}
info("Successfully handle Oraxen $version.")
info(
"BetterHud hooks Oraxen $version.",
"Be sure to set 'pack-type' to 'none' in your config."
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import kr.toxicity.hud.api.placeholder.HudPlaceholder
import kr.toxicity.hud.api.update.UpdateEvent
import kr.toxicity.hud.api.yaml.YamlObject
import kr.toxicity.hud.bootstrap.bukkit.module.BukkitModule
import kr.toxicity.hud.bootstrap.bukkit.util.ATTRIBUTE_MAX_HEALTH
import kr.toxicity.hud.bootstrap.bukkit.util.bukkitPlayer
import kr.toxicity.hud.bootstrap.bukkit.util.createBukkitTrigger
import kr.toxicity.hud.bootstrap.bukkit.util.unwrap
import org.bukkit.Material
import kr.toxicity.hud.bootstrap.bukkit.util.*
import org.bukkit.entity.LivingEntity
import org.bukkit.entity.Player
import org.bukkit.entity.Projectile
Expand Down Expand Up @@ -83,7 +79,15 @@ class BukkitEntityModule : BukkitModule {
"max_health" to HudPlaceholder.of { _, u ->
u.unwrap { e: EntityEvent ->
Function {
(e.entity as? LivingEntity)?.getAttribute(ATTRIBUTE_MAX_HEALTH)?.value ?: 0.0
(e.entity as? LivingEntity)?.maximumHealth ?: 0.0
}
}
},
"health_percentage" to HudPlaceholder.of { _, u ->
u.unwrap { e: EntityEvent ->
Function get@ {
val entity = e.entity as? LivingEntity ?: return@get 0.0
entity.health / entity.maximumHealth
}
}
},
Expand Down Expand Up @@ -120,17 +124,7 @@ class BukkitEntityModule : BukkitModule {
e.entity.isDead
}
}
},
"has_off_hand" to HudPlaceholder.of { _, _ ->
Function {
it.bukkitPlayer.inventory.itemInOffHand.type != Material.AIR
}
},
"has_main_hand" to HudPlaceholder.of { _, _ ->
Function {
it.bukkitPlayer.inventory.itemInMainHand.type != Material.AIR
}
},
}
)

}
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ class BukkitStandardModule : BukkitModule {
"health" to { _ ->
{
HudListener { p ->
p.bukkitPlayer.health / p.bukkitPlayer.getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value
p.bukkitPlayer.health / p.bukkitPlayer.maximumHealth
}
}
},
"vehicle_health" to { _ ->
{
HudListener { p ->
(p.bukkitPlayer.vehicle as? LivingEntity)?.let { entity ->
entity.health / entity.getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value
entity.health / entity.maximumHealth
} ?: 0.0
}
}
Expand Down Expand Up @@ -82,7 +82,7 @@ class BukkitStandardModule : BukkitModule {
"absorption" to { _ ->
{
HudListener { p ->
p.bukkitPlayer.absorptionAmount / p.bukkitPlayer.getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value
p.bukkitPlayer.absorptionAmount / p.bukkitPlayer.maximumHealth
}
}
},
Expand Down Expand Up @@ -121,35 +121,36 @@ class BukkitStandardModule : BukkitModule {
},
"max_health" to HudPlaceholder.of { _, _ ->
Function { p ->
p.bukkitPlayer.getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value
p.bukkitPlayer.maximumHealth
}
},
"health_percentage" to HudPlaceholder.of { _, _ ->
Function { p ->
val bukkit = p.bukkitPlayer
bukkit.health / bukkit.maximumHealth
}
},
"vehicle_max_health" to HudPlaceholder.of { _, _ ->
Function { p ->
(p.bukkitPlayer.vehicle as? LivingEntity)?.getAttribute(ATTRIBUTE_MAX_HEALTH)?.value ?: 0.0
(p.bukkitPlayer.vehicle as? LivingEntity)?.maximumHealth ?: 0.0
}
},
"max_health_with_absorption" to HudPlaceholder.of { _, _ ->
Function { p ->
p.bukkitPlayer.getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value + p.bukkitPlayer.absorptionAmount
p.bukkitPlayer.maximumHealth + p.bukkitPlayer.absorptionAmount
}
},
"vehicle_max_health_with_absorption" to HudPlaceholder.of { _, _ ->
Function { p ->
(p.bukkitPlayer.vehicle as? LivingEntity)?.let { entity ->
entity.getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value + entity.absorptionAmount
entity.maximumHealth + entity.absorptionAmount
} ?: 0.0
}
},
"health_percentage" to HudPlaceholder.of { _, _ ->
Function { p ->
p.bukkitPlayer.health / p.bukkitPlayer.getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value * 100.0
}
},
"vehicle_health_percentage" to HudPlaceholder.of { _, _ ->
Function { p ->
(p.bukkitPlayer.vehicle as? LivingEntity)?.let { entity ->
entity.health / entity.getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value * 100.0
entity.health / entity.maximumHealth * 100.0
} ?: 0.0
}
},
Expand Down Expand Up @@ -254,6 +255,16 @@ class BukkitStandardModule : BukkitModule {
p.bukkitPlayer.isFrozen
}
},
"has_off_hand" to HudPlaceholder.of { _, _ ->
Function {
it.bukkitPlayer.inventory.itemInOffHand.type != Material.AIR
}
},
"has_main_hand" to HudPlaceholder.of { _, _ ->
Function {
it.bukkitPlayer.inventory.itemInMainHand.type != Material.AIR
}
},
"has_permission" to object : HudPlaceholder<Boolean> {
override fun invoke(args: MutableList<String>, reason: UpdateEvent): Function<HudPlayer, Boolean> {
return Function {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package kr.toxicity.hud.bootstrap.bukkit.util

import org.bukkit.entity.LivingEntity

val LivingEntity.maximumHealth
get() = getAttribute(ATTRIBUTE_MAX_HEALTH)!!.value
Original file line number Diff line number Diff line change
Expand Up @@ -49,5 +49,9 @@ class PolymerResourcePackCompatibility : Compatibility {
is OnReload -> warn("This mod is still on reload!")
}
}
info(
"BetterHud hooks Polymer resource pack.",
"Be sure to set 'pack-type' to 'none' in your config."
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import kr.toxicity.hud.bootstrap.fabric.module.Module
import net.minecraft.resources.ResourceLocation
import net.minecraft.world.entity.LivingEntity
import net.minecraft.world.entity.ai.attributes.Attributes
import net.minecraft.world.item.ItemStack
import java.util.function.Function

class FabricStandardModule : Module {
Expand Down Expand Up @@ -206,8 +207,17 @@ class FabricStandardModule : Module {
it.fabricPlayer.hasPermission(args[0])
}
}

override fun getRequiredArgsLength(): Int = 1
}
},
"has_main_hand" to HudPlaceholder.of { _, _ ->
Function { p ->
!p.fabricPlayer.mainHandItem.`is`(ItemStack.EMPTY.item)
}
},
"has_off_hand" to HudPlaceholder.of { _, _ ->
Function { p ->
!p.fabricPlayer.offhandItem.`is`(ItemStack.EMPTY.item)
}
},
)
}
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ val platform = "4.3.4"
val targetJavaVersion = 21
val velocity = "3.4.0"
val bStats = "3.1.0"
val betterCommand = "1.1"
val betterCommand = "1.2"

val supportedMinecraftVersions = listOf(
//1.17
Expand Down Expand Up @@ -95,7 +95,7 @@ allprojects {
apply(plugin = "org.jetbrains.dokka")

group = "kr.toxicity.hud"
version = "1.8" + (System.getenv("BUILD_NUMBER")?.let { ".DEV-$it" } ?: "")
version = "1.9" + (System.getenv("BUILD_NUMBER")?.let { ".DEV-$it" } ?: "")

repositories {
mavenCentral()
Expand Down
Loading

0 comments on commit d016196

Please sign in to comment.