-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
...ain/kotlin/com/willfp/eco/internal/spigot/integrations/hologram/HologramFancyHolograms.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -61,3 +61,4 @@ softdepend: | |
- PlayerPoints | ||
- Denizen | ||
- RoyaleEconomy | ||
- FancyHolograms |