mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2025-12-31 12:56:31 +00:00
Remade how hologram spawner worked, added GHolo support
This commit is contained in:
12
build.gradle
12
build.gradle
@@ -15,6 +15,14 @@ plugins {
|
||||
id 'java'
|
||||
}
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
maven(MavenPublication) {
|
||||
from(components.java)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(":eco-core").getSubprojects()
|
||||
}
|
||||
@@ -42,7 +50,7 @@ allprojects {
|
||||
|
||||
dependencies {
|
||||
compileOnly 'com.willfp:eco:6.11.0'
|
||||
|
||||
compileOnly fileTree(dir: '../../lib', include: ['*.jar'])
|
||||
compileOnly 'org.jetbrains:annotations:19.0.0'
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21'
|
||||
}
|
||||
@@ -77,7 +85,7 @@ shadowJar {
|
||||
}
|
||||
|
||||
jar {
|
||||
archiveFileName = findProperty("plugin-name") + " v" + findProperty("version") + " " + "unshaded" + ".jar"
|
||||
archiveFileName = findProperty("plugin-name") + " v" + findProperty("version") + ".jar"
|
||||
}
|
||||
|
||||
group = 'com.willfp'
|
||||
|
||||
@@ -18,6 +18,9 @@ import com.willfp.ecoskills.effects.Effects;
|
||||
import com.willfp.ecoskills.integrations.EcoEnchantsEnchantingLeveller;
|
||||
import com.willfp.ecoskills.integrations.afk.AFKHandlerKt;
|
||||
import com.willfp.ecoskills.integrations.afk.impl.AFKIntegrationEssentials;
|
||||
import com.willfp.ecoskills.integrations.hologram.HologramManager;
|
||||
import com.willfp.ecoskills.integrations.hologram.wrappers.GHoloWrapper;
|
||||
import com.willfp.ecoskills.integrations.hologram.wrappers.HolographicDisplaysWrapper;
|
||||
import com.willfp.ecoskills.skills.Skill;
|
||||
import com.willfp.ecoskills.skills.SkillDisplayListener;
|
||||
import com.willfp.ecoskills.skills.SkillLevellingListener;
|
||||
@@ -117,7 +120,8 @@ public class EcoSkillsPlugin extends EcoPlugin {
|
||||
new SkillDisplayListener(this),
|
||||
new StatModifierListener(),
|
||||
new DataListener(),
|
||||
new PlayerBlockListener(this)
|
||||
new PlayerBlockListener(this),
|
||||
new DamageIndicatorListener(this)
|
||||
);
|
||||
}
|
||||
|
||||
@@ -132,7 +136,8 @@ public class EcoSkillsPlugin extends EcoPlugin {
|
||||
@Override
|
||||
protected List<IntegrationLoader> loadIntegrationLoaders() {
|
||||
return Arrays.asList(
|
||||
new IntegrationLoader("HolographicDisplays", () -> this.getEventManager().registerListener(new DamageIndicatorListener(this))),
|
||||
new IntegrationLoader("HolographicDisplays", () -> HologramManager.Companion.register(new HolographicDisplaysWrapper())),
|
||||
new IntegrationLoader("GHolo", () -> HologramManager.Companion.register(new GHoloWrapper())),
|
||||
new IntegrationLoader("EcoEnchants", () -> this.getEventManager().registerListener(new EcoEnchantsEnchantingLeveller(this))),
|
||||
new IntegrationLoader("Essentials", () -> AFKHandlerKt.registerIntegration(new AFKIntegrationEssentials()))
|
||||
);
|
||||
|
||||
@@ -12,7 +12,7 @@ import java.util.*
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
class MySQLDataHandler(
|
||||
private val plugin: EcoSkillsPlugin
|
||||
plugin: EcoSkillsPlugin
|
||||
) : DataHandler {
|
||||
init {
|
||||
Database.connect(
|
||||
|
||||
@@ -6,7 +6,7 @@ import java.util.*
|
||||
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
class YamlDataHandler(
|
||||
private val plugin: EcoSkillsPlugin
|
||||
plugin: EcoSkillsPlugin
|
||||
) : DataHandler {
|
||||
private val dataYml = DataYml(plugin)
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.willfp.ecoskills.integrations.hologram
|
||||
|
||||
import org.bukkit.Location
|
||||
|
||||
class HologramManager {
|
||||
|
||||
companion object {
|
||||
|
||||
private var hologramWrappers: MutableList<HologramWrapper> = ArrayList()
|
||||
|
||||
fun register(wrapper: HologramWrapper) {
|
||||
hologramWrappers.add(wrapper)
|
||||
}
|
||||
|
||||
fun spawnHolo(loc: Location, contents: List<String>, removeAfter: Int) {
|
||||
if (hologramWrappers.isEmpty()) return
|
||||
hologramWrappers[0].spawnHolo(loc, contents, removeAfter)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.willfp.ecoskills.integrations.hologram
|
||||
|
||||
import org.bukkit.Location
|
||||
|
||||
interface HologramWrapper {
|
||||
fun spawnHolo(loc: Location, contents: List<String>, toRemove: Int)
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.willfp.ecoskills.integrations.hologram.wrappers
|
||||
|
||||
import com.willfp.ecoskills.integrations.hologram.HologramWrapper
|
||||
import me.gholo.api.GHoloAPI
|
||||
import com.willfp.ecoskills.EcoSkillsPlugin
|
||||
import org.bukkit.Location
|
||||
|
||||
class GHoloWrapper : HologramWrapper {
|
||||
var id = 0
|
||||
override fun spawnHolo(loc: Location, contents: List<String>, toRemove: Int) {
|
||||
val api = GHoloAPI()
|
||||
val res = id++
|
||||
api.insertHolo(res.toString(), loc, contents)
|
||||
EcoSkillsPlugin.getInstance().scheduler.runLater(
|
||||
{ api.removeHolo(res.toString()) },
|
||||
30
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.willfp.ecoskills.integrations.hologram.wrappers
|
||||
|
||||
import com.willfp.ecoskills.integrations.hologram.HologramWrapper
|
||||
import com.gmail.filoghost.holographicdisplays.api.Hologram
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI
|
||||
import com.willfp.ecoskills.EcoSkillsPlugin
|
||||
import org.bukkit.Location
|
||||
|
||||
class HolographicDisplaysWrapper : HologramWrapper {
|
||||
override fun spawnHolo(loc: Location, contents: List<String>, toRemove: Int) {
|
||||
val hologram = HologramsAPI.createHologram(EcoSkillsPlugin.getInstance(), loc)
|
||||
for (s in contents) {
|
||||
hologram.appendTextLine(s)
|
||||
}
|
||||
EcoSkillsPlugin.getInstance().scheduler.runLater({ hologram.delete() }, 30)
|
||||
}
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.willfp.ecoskills.stats
|
||||
|
||||
import com.gmail.filoghost.holographicdisplays.api.HologramsAPI
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.util.NumberUtils
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import com.willfp.ecoskills.integrations.hologram.HologramManager
|
||||
import com.willfp.ecoskills.isCrit
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.EventPriority
|
||||
@@ -36,8 +36,6 @@ class DamageIndicatorListener(
|
||||
NumberUtils.randFloat(-z, z)
|
||||
)
|
||||
|
||||
val hologram = HologramsAPI.createHologram(plugin, location)
|
||||
|
||||
var text: String = if (event.isCrit) {
|
||||
plugin.configYml.getString("damage-indicators.format.crit", false)
|
||||
} else {
|
||||
@@ -46,14 +44,8 @@ class DamageIndicatorListener(
|
||||
|
||||
text = text.replace("%damage%", NumberUtils.format(event.damage))
|
||||
|
||||
try {
|
||||
text = StringUtils.format(text)
|
||||
text = StringUtils.format(text)
|
||||
|
||||
hologram.appendTextLine(text)
|
||||
|
||||
plugin.scheduler.runLater({
|
||||
hologram.delete()
|
||||
}, 30)
|
||||
} catch (ignored: Exception) {}
|
||||
HologramManager.spawnHolo(location, listOf(text), 30);
|
||||
}
|
||||
}
|
||||
@@ -309,7 +309,7 @@ stats:
|
||||
chance-per-level: 0.5
|
||||
|
||||
damage-indicators:
|
||||
# Requires HolographicDisplays to be installed
|
||||
# Requires HolographicDisplays/GHolo to be installed
|
||||
enabled: true
|
||||
format:
|
||||
normal: "&7%damage%"
|
||||
|
||||
BIN
lib/GHolo.jar
Normal file
BIN
lib/GHolo.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user