Skip to content

Commit

Permalink
Added FancyHolograms integration
Browse files Browse the repository at this point in the history
  • Loading branch information
WillFP committed Jul 20, 2024
1 parent 25d572c commit a9a961f
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ allprojects {

// HuskPlugins
maven("https://repo.william278.net/releases")

// FancyHolograms
maven("https://repo.fancyplugins.de/releases")
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions eco-core/core-plugin/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ dependencies {
compileOnly("net.william278.huskclaims:huskclaims-bukkit:1.0.1")
compileOnly("net.william278:husktowns:2.6.1")
compileOnly("com.github.jojodmo:ItemBridge:b0054538c1")
compileOnly("de.oliver:FancyHolograms:2.3.0")

compileOnly(fileTree("../../lib") {
include("*.jar")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ import com.willfp.eco.internal.spigot.integrations.economy.EconomyVault
import com.willfp.eco.internal.spigot.integrations.entitylookup.EntityLookupModelEngine
import com.willfp.eco.internal.spigot.integrations.hologram.HologramCMI
import com.willfp.eco.internal.spigot.integrations.hologram.HologramDecentHolograms
import com.willfp.eco.internal.spigot.integrations.hologram.HologramFancyHolograms
import com.willfp.eco.internal.spigot.integrations.hologram.HologramHolographicDisplays
import com.willfp.eco.internal.spigot.integrations.mcmmo.McmmoIntegrationImpl
import com.willfp.eco.internal.spigot.integrations.multiverseinventories.MultiverseInventoriesIntegration
Expand Down Expand Up @@ -370,6 +371,7 @@ abstract class EcoSpigotPlugin : EcoPlugin() {
IntegrationLoader("CMI") { HologramManager.register(HologramCMI()) },
IntegrationLoader("DecentHolograms") { HologramManager.register(HologramDecentHolograms()) },
//IntegrationLoader("GHolo") { HologramManager.register(HologramGHolo()) },
IntegrationLoader("FancyHolograms") { HologramManager.register(HologramFancyHolograms()) },

// AFK
IntegrationLoader("Essentials") { AFKManager.register(AFKIntegrationEssentials()) },
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.willfp.eco.internal.spigot.integrations.hologram

import com.willfp.eco.core.integrations.hologram.Hologram
import com.willfp.eco.core.integrations.hologram.HologramIntegration
import de.oliver.fancyholograms.api.FancyHologramsPlugin
import de.oliver.fancyholograms.api.data.TextHologramData
import org.bukkit.Location
import java.util.UUID
import kotlin.jvm.optionals.getOrNull

class HologramFancyHolograms : HologramIntegration {
private val manager = FancyHologramsPlugin.get().hologramManager

override fun createHologram(location: Location, contents: List<String>): Hologram {
val id = UUID.randomUUID().toString()

val data = TextHologramData(id, location)
data.text = contents
data.isPersistent = false

val holo = manager.create(data)
FancyHologramsPlugin.get().hologramManager.addHologram(holo)

return HologramImplFancyHolograms(id)
}

override fun getPluginName(): String {
return "FancyHolograms"
}

inner class HologramImplFancyHolograms(
private val id: String,
) : Hologram {
override fun remove() {
val hologram = manager.getHologram(id).getOrNull() ?: return
manager.removeHologram(hologram)
}

override fun setContents(contents: List<String>) {
val hologram = manager.getHologram(id).getOrNull() ?: return
val data = hologram.data as? TextHologramData ?: return
data.text = contents
}
}
}
1 change: 1 addition & 0 deletions eco-core/core-plugin/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,3 +61,4 @@ softdepend:
- PlayerPoints
- Denizen
- RoyaleEconomy
- FancyHolograms

0 comments on commit a9a961f

Please sign in to comment.