diff --git a/eco-api/build.gradle b/eco-api/build.gradle index 3ffb422b..c8d7770b 100644 --- a/eco-api/build.gradle +++ b/eco-api/build.gradle @@ -9,15 +9,15 @@ dependencies { // Adventure compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0' compileOnly 'net.kyori:adventure-text-minimessage:4.1.0-SNAPSHOT' - compileOnly 'net.kyori:adventure-api:4.9.1' + compileOnly 'net.kyori:adventure-api:4.9.2' compileOnly 'net.kyori:adventure-text-serializer-gson:4.9.2' - compileOnly 'net.kyori:adventure-text-serializer-legacy:4.8.1' + compileOnly 'net.kyori:adventure-text-serializer-legacy:4.9.2' // Other compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT' - compileOnly 'org.apache.maven:maven-artifact:3.0.3' + compileOnly 'org.apache.maven:maven-artifact:3.8.1' compileOnly 'com.comphenix.protocol:ProtocolLib:4.7.1-SNAPSHOT' - compileOnly 'com.google.code.gson:gson:2.8.7' + compileOnly 'com.google.code.gson:gson:2.8.8' } java { diff --git a/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/DummyHologram.java b/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/DummyHologram.java new file mode 100644 index 00000000..9189325a --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/DummyHologram.java @@ -0,0 +1,20 @@ +package com.willfp.eco.core.integrations.hologram; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * Dummy hologram, created if no integrations are present on the server. + */ +class DummyHologram implements Hologram { + @Override + public void remove() { + // Do nothing. + } + + @Override + public void setContents(@NotNull List contents) { + // Do nothing. + } +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/Hologram.java b/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/Hologram.java new file mode 100644 index 00000000..207a8174 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/Hologram.java @@ -0,0 +1,22 @@ +package com.willfp.eco.core.integrations.hologram; + +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * Wrapper class for plugin-specific holograms. + */ +public interface Hologram { + /** + * Remove the hologram. + */ + void remove(); + + /** + * Set the hologram contents. + * + * @param contents The contents. + */ + void setContents(@NotNull List contents); +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/HologramManager.java b/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/HologramManager.java new file mode 100644 index 00000000..22a6eaf2 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/HologramManager.java @@ -0,0 +1,45 @@ +package com.willfp.eco.core.integrations.hologram; + +import lombok.experimental.UtilityClass; +import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; + +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Class to handle hologram integrations. + */ +@UtilityClass +public class HologramManager { + /** + * A set of all registered integrations. + */ + private final Set registered = new HashSet<>(); + + /** + * Register a new integration. + * + * @param integration The integration to register. + */ + public void register(@NotNull final HologramWrapper integration) { + registered.add(integration); + } + + /** + * Create hologram. + * + * @param location The location. + * @param contents The contents for the hologram. + * @return The hologram. + */ + public Hologram createHologram(@NotNull final Location location, + @NotNull final List contents) { + for (HologramWrapper wrapper : registered) { + return wrapper.createHologram(location, contents); + } + + return new DummyHologram(); + } +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/HologramWrapper.java b/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/HologramWrapper.java new file mode 100644 index 00000000..8f9beb12 --- /dev/null +++ b/eco-api/src/main/java/com/willfp/eco/core/integrations/hologram/HologramWrapper.java @@ -0,0 +1,22 @@ +package com.willfp.eco.core.integrations.hologram; + +import com.willfp.eco.core.integrations.Integration; +import org.bukkit.Location; +import org.jetbrains.annotations.NotNull; + +import java.util.List; + +/** + * Wrapper class for hologram integrations. + */ +public interface HologramWrapper extends Integration { + /** + * Create hologram. + * + * @param location The location. + * @param contents The contents for the hologram. + * @return The hologram. + */ + Hologram createHologram(@NotNull final Location location, + @NotNull final List contents); +} diff --git a/eco-api/src/main/java/com/willfp/eco/core/integrations/mcmmo/McmmoWrapper.java b/eco-api/src/main/java/com/willfp/eco/core/integrations/mcmmo/McmmoWrapper.java index 8d8f63d4..2c0cf52e 100644 --- a/eco-api/src/main/java/com/willfp/eco/core/integrations/mcmmo/McmmoWrapper.java +++ b/eco-api/src/main/java/com/willfp/eco/core/integrations/mcmmo/McmmoWrapper.java @@ -1,5 +1,6 @@ package com.willfp.eco.core.integrations.mcmmo; +import com.willfp.eco.core.integrations.Integration; import org.bukkit.block.Block; import org.bukkit.event.Event; import org.jetbrains.annotations.NotNull; @@ -7,7 +8,7 @@ import org.jetbrains.annotations.NotNull; /** * Wrapper class for mcmmo integrations. */ -public interface McmmoWrapper { +public interface McmmoWrapper extends Integration { /** * Get bonus drop count of block. * diff --git a/eco-core/core-plugin/build.gradle b/eco-core/core-plugin/build.gradle index 7ca890da..41995681 100644 --- a/eco-core/core-plugin/build.gradle +++ b/eco-core/core-plugin/build.gradle @@ -7,11 +7,11 @@ dependencies { exclude group: 'net.kyori', module: 'adventure-api' } compileOnly 'net.kyori:adventure-platform-bukkit:4.0.0' - compileOnly 'net.kyori:adventure-api:4.9.1' + compileOnly 'net.kyori:adventure-api:4.9.2' compileOnly 'net.kyori:adventure-text-serializer-gson:4.9.2' - compileOnly 'net.kyori:adventure-text-serializer-legacy:4.8.1' - compileOnly 'org.apache.maven:maven-artifact:3.0.3' - compileOnly 'com.google.code.gson:gson:2.8.7' + compileOnly 'net.kyori:adventure-text-serializer-legacy:4.9.2' + compileOnly 'org.apache.maven:maven-artifact:3.8.1' + compileOnly 'com.google.code.gson:gson:2.8.8' compileOnly 'org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT' compileOnly project(":eco-core:core-proxy") compileOnly project(":eco-core:core-backend") @@ -19,7 +19,7 @@ dependencies { compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.7-SNAPSHOT' compileOnly 'com.github.TechFortress:GriefPrevention:16.17.1' compileOnly 'com.massivecraft:Factions:1.6.9.5-U0.5.10' - compileOnly 'com.github.cryptomorin:kingdoms:1.10.14' + compileOnly 'com.github.cryptomorin:kingdoms:1.11.18' compileOnly 'com.github.TownyAdvanced:Towny:0.97.2.6' compileOnly 'com.github.angeschossen:LandsAPI:5.15.2' compileOnly 'fr.neatmonster:nocheatplus:3.16.1-SNAPSHOT' @@ -30,10 +30,11 @@ dependencies { compileOnly 'com.github.brcdev-minecraft:shopgui-api:2.2.0' compileOnly 'com.github.LoneDev6:API-ItemsAdder:2.4.7' compileOnly 'com.arcaniax:HeadDatabase-API:1.3.0' - compileOnly 'org.jetbrains.exposed:exposed-core:0.34.1' - compileOnly 'org.jetbrains.exposed:exposed-dao:0.34.1' - compileOnly 'org.jetbrains.exposed:exposed-jdbc:0.34.1' - compileOnly 'mysql:mysql-connector-java:5.1.48' + compileOnly 'org.jetbrains.exposed:exposed-core:0.35.1' + compileOnly 'org.jetbrains.exposed:exposed-dao:0.35.1' + compileOnly 'org.jetbrains.exposed:exposed-jdbc:0.35.1' + compileOnly 'mysql:mysql-connector-java:8.0.25' + compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0' // CombatLogX V10 + NewbieHelper Expansion compileOnly 'com.SirBlobman.combatlogx:CombatLogX-API:10.0.0.0-SNAPSHOT' diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt index 0e826ce4..eb7ba051 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/EcoSpigotPlugin.kt @@ -9,6 +9,7 @@ import com.willfp.eco.core.integrations.IntegrationLoader import com.willfp.eco.core.integrations.anticheat.AnticheatManager import com.willfp.eco.core.integrations.antigrief.AntigriefManager import com.willfp.eco.core.integrations.customitems.CustomItemsManager +import com.willfp.eco.core.integrations.hologram.HologramManager import com.willfp.eco.core.integrations.mcmmo.McmmoManager import com.willfp.eco.core.integrations.shop.ShopManager import com.willfp.eco.core.items.Items @@ -39,6 +40,9 @@ import com.willfp.eco.spigot.integrations.antigrief.* import com.willfp.eco.spigot.integrations.customitems.CustomItemsHeadDatabase import com.willfp.eco.spigot.integrations.customitems.CustomItemsItemsAdder import com.willfp.eco.spigot.integrations.customitems.CustomItemsOraxen +import com.willfp.eco.spigot.integrations.hologram.HologramCMI +import com.willfp.eco.spigot.integrations.hologram.HologramGHolo +import com.willfp.eco.spigot.integrations.hologram.HologramHolographicDisplays import com.willfp.eco.spigot.integrations.mcmmo.McmmoIntegrationImpl import com.willfp.eco.spigot.integrations.multiverseinventories.MultiverseInventoriesIntegration import com.willfp.eco.spigot.integrations.shop.ShopShopGuiPlus @@ -175,6 +179,11 @@ abstract class EcoSpigotPlugin : EcoPlugin( // Shop IntegrationLoader("ShopGUIPlus") { ShopManager.register(ShopShopGuiPlus()) }, + // Hologram + IntegrationLoader("HolographicDisplays") { HologramManager.register(HologramHolographicDisplays(this)) }, + IntegrationLoader("CMI") { HologramManager.register(HologramCMI()) }, + IntegrationLoader("GHolo") { HologramManager.register(HologramGHolo()) }, + // Misc IntegrationLoader("mcMMO") { McmmoManager.register(McmmoIntegrationImpl()) }, IntegrationLoader("Multiverse-Inventories") { diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramCMI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramCMI.kt new file mode 100644 index 00000000..88580d7c --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramCMI.kt @@ -0,0 +1,39 @@ +package com.willfp.eco.spigot.integrations.hologram + +import com.Zrips.CMI.CMI +import com.Zrips.CMI.Modules.Holograms.CMIHologram +import com.willfp.eco.core.integrations.hologram.Hologram +import com.willfp.eco.core.integrations.hologram.HologramWrapper +import net.Zrips.CMILib.Container.CMILocation +import org.bukkit.Location +import java.util.* + +@Suppress("DEPRECATION") +class HologramCMI : HologramWrapper { + override fun createHologram(location: Location, contents: MutableList): Hologram { + val cmiHolo = CMIHologram(UUID.randomUUID().toString(), CMILocation(location)) + cmiHolo.enable() + CMI.getInstance().hologramManager.addHologram(cmiHolo) + + val holo = HologramImplCMI(cmiHolo) + holo.setContents(contents) + + return holo + } + + override fun getPluginName(): String { + return "CMI" + } + + class HologramImplCMI( + private val handle: CMIHologram + ) : Hologram { + override fun remove() { + CMI.getInstance().hologramManager.removeHolo(handle) + } + + override fun setContents(contents: MutableList) { + handle.lines = contents + } + } +} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramGHolo.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramGHolo.kt new file mode 100644 index 00000000..da781f14 --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramGHolo.kt @@ -0,0 +1,38 @@ +package com.willfp.eco.spigot.integrations.hologram + +import com.willfp.eco.core.integrations.hologram.Hologram +import com.willfp.eco.core.integrations.hologram.HologramWrapper +import me.gholo.api.GHoloAPI +import org.bukkit.Location +import java.util.* + +@Suppress("DEPRECATION") +class HologramGHolo : HologramWrapper { + companion object { + private val api = GHoloAPI() + } + + override fun createHologram(location: Location, contents: MutableList): Hologram { + val id = UUID.randomUUID().toString() + + api.insertHolo(id, location, contents) + + return HologramImplGHolo(id) + } + + override fun getPluginName(): String { + return "GHolo" + } + + class HologramImplGHolo( + private val id: String + ) : Hologram { + override fun remove() { + api.removeHolo(id) + } + + override fun setContents(contents: MutableList) { + api.getHolo(id)?.content = contents + } + } +} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramHolographicDisplays.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramHolographicDisplays.kt new file mode 100644 index 00000000..18e6ee2e --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/eco/spigot/integrations/hologram/HologramHolographicDisplays.kt @@ -0,0 +1,41 @@ +package com.willfp.eco.spigot.integrations.hologram + +import com.gmail.filoghost.holographicdisplays.api.HologramsAPI +import com.willfp.eco.core.EcoPlugin +import com.willfp.eco.core.integrations.hologram.Hologram +import com.willfp.eco.core.integrations.hologram.HologramWrapper +import org.bukkit.Location + +class HologramHolographicDisplays( + private val plugin: EcoPlugin +) : HologramWrapper { + + override fun createHologram(location: Location, contents: MutableList): Hologram { + val hologram = HologramImplHolographicDisplays( + HologramsAPI.createHologram(plugin, location) + ) + + hologram.setContents(contents) + + return hologram + } + + override fun getPluginName(): String { + return "HolographicDisplays" + } + + class HologramImplHolographicDisplays( + private val handle: com.gmail.filoghost.holographicdisplays.api.Hologram + ) : Hologram { + override fun remove() { + handle.delete() + } + + override fun setContents(contents: MutableList) { + handle.clearLines() + for (line in contents) { + handle.appendTextLine(line) + } + } + } +} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index b274be34..6a500cf6 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -27,14 +27,17 @@ softdepend: - HeadDatabase - Multiverse-Inventories - Alice + - HolographicDisplays + - GHolo + - CMI libraries: - 'org.reflections:reflections:0.9.12' - 'org.apache.maven:maven-artifact:3.0.3' - 'org.jetbrains.kotlin:kotlin-stdlib:1.5.31' - 'net.kyori:adventure-platform-bukkit:4.0.0' - - 'net.kyori:adventure-api:4.9.1' + - 'net.kyori:adventure-api:4.9.2' - 'net.kyori:adventure-text-serializer-gson:4.9.2' - - 'net.kyori:adventure-text-serializer-legacy:4.8.1' + - 'net.kyori:adventure-text-serializer-legacy:4.9.2' - 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21' - 'org.jetbrains.exposed:exposed-core:0.34.1' - 'org.jetbrains.exposed:exposed-dao:0.34.1' diff --git a/lib/CMIAPI8.7.8.2.jar b/lib/CMIAPI8.7.8.2.jar new file mode 100644 index 00000000..69ba79a5 Binary files /dev/null and b/lib/CMIAPI8.7.8.2.jar differ diff --git a/lib/CMILib1.0.4.1.jar b/lib/CMILib1.0.4.1.jar new file mode 100644 index 00000000..0aaf6722 Binary files /dev/null and b/lib/CMILib1.0.4.1.jar differ diff --git a/lib/GHolo.jar b/lib/GHolo.jar new file mode 100644 index 00000000..b15de313 Binary files /dev/null and b/lib/GHolo.jar differ