diff --git a/build.gradle.kts b/build.gradle.kts index 7450d43..7a09353 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -14,7 +14,7 @@ dependencies { isChanging = true } compileOnly("com.alttd:AltitudeAPI:0.0.2") - compileOnly("me.filoghost.holographicdisplays:holographicdisplays-api:3.0.0") + compileOnly("com.github.decentsoftware-eu:decentholograms:2.8.9") compileOnly("org.jetbrains:annotations:16.0.2") testImplementation("org.powermock:powermock-module-junit4:1.7.4") testImplementation("org.powermock:powermock-api-mockito2:1.7.4") @@ -104,7 +104,7 @@ bukkit { name = rootProject.name main = "$group.${rootProject.name}" version = "${rootProject.version}" - apiVersion = "1.20" + apiVersion = "1.21" authors = listOf("Michael Ziluck", "destro174") - depend = listOf("AltitudeAPI", "HolographicDisplays") + depend = listOf("AltitudeAPI", "DecentHolograms") } \ No newline at end of file diff --git a/settings.gradle.kts b/settings.gradle.kts index 8941a69..6330f20 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,6 +6,7 @@ dependencyResolutionManagement { mavenCentral() maven("https://repo.destro.xyz/snapshots") // Altitude - Galaxy maven("https://repo.codemc.io/repository/maven-public/") + maven("https://jitpack.io/") maven("https://repo.maven.apache.org/maven2/") } } diff --git a/src/main/java/com/alttd/altitudetag/AltitudeTag.java b/src/main/java/com/alttd/altitudetag/AltitudeTag.java index a5dedca..92ccefb 100644 --- a/src/main/java/com/alttd/altitudetag/AltitudeTag.java +++ b/src/main/java/com/alttd/altitudetag/AltitudeTag.java @@ -12,7 +12,6 @@ import com.alttd.altitudetag.configuration.Config; import com.alttd.altitudetag.configuration.Lang; import com.alttd.altitudetag.listeners.ConnectionListener; import com.alttd.altitudetag.listeners.InteractListener; -import me.filoghost.holographicdisplays.api.HolographicDisplaysAPI; import org.bukkit.Bukkit; import org.bukkit.boss.BossBar; import org.bukkit.entity.Player; @@ -32,8 +31,6 @@ public class AltitudeTag extends JavaPlugin private BukkitTask tagTimeLimitTask; - private HolographicDisplaysAPI holographicDisplaysAPI; - /** * Enable the plugin */ @@ -41,9 +38,9 @@ public class AltitudeTag extends JavaPlugin { instance = this; - if (!Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays")) + if (!Bukkit.getPluginManager().isPluginEnabled("DecentHolograms")) { - getLogger().severe("*** HolographicDisplays is not installed or not enabled. ***"); + getLogger().severe("*** DecentHolograms is not installed or not enabled. ***"); getLogger().severe("*** This plugin will be disabled. ***"); this.setEnabled(false); return; @@ -79,7 +76,6 @@ public class AltitudeTag extends JavaPlugin Bukkit.getPluginManager().registerEvents(new ConnectionListener(), this); Bukkit.getPluginManager().registerEvents(new InteractListener(), this); - holographicDisplaysAPI = HolographicDisplaysAPI.get(this); } private static void reloadConfiguration() @@ -197,7 +193,4 @@ public class AltitudeTag extends JavaPlugin return instance; } - public HolographicDisplaysAPI getHolographicDisplaysAPI() { - return holographicDisplaysAPI; - } } diff --git a/src/main/java/com/alttd/altitudetag/Leaderboard.java b/src/main/java/com/alttd/altitudetag/Leaderboard.java index 7a6eb7f..87d79bf 100644 --- a/src/main/java/com/alttd/altitudetag/Leaderboard.java +++ b/src/main/java/com/alttd/altitudetag/Leaderboard.java @@ -10,8 +10,8 @@ import java.util.function.Consumer; import com.alttd.altitudetag.configuration.Config; import com.alttd.altitudetag.configuration.Lang; -import me.filoghost.holographicdisplays.api.hologram.Hologram; -import me.filoghost.holographicdisplays.api.hologram.line.TextHologramLine; +import eu.decentsoftware.holograms.api.DHAPI; +import eu.decentsoftware.holograms.api.holograms.Hologram; import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.configuration.file.FileConfiguration; @@ -133,7 +133,7 @@ public class Leaderboard config.set("leaderboard.location.z", Config.LEADERBOARD_LOCATION_Z.getValue()); AltitudeTag.getInstance().saveConfig(); - hologram.setPosition(location); + hologram.setLocation(location); refreshLeaderboard(); } @@ -141,16 +141,14 @@ public class Leaderboard { if (Config.LEADERBOARD_ENABLED.getValue()) { - hologram = AltitudeTag.getInstance().getHolographicDisplaysAPI().createHologram( - new Location(Bukkit.getWorld(Config.LEADERBOARD_LOCATION_WORLD.getValue()), - Config.LEADERBOARD_LOCATION_X.getValue(), - Config.LEADERBOARD_LOCATION_Y.getValue(), - Config.LEADERBOARD_LOCATION_Z.getValue())); - hologram.getLines().appendText(Config.LEADERBOARD_TITLE.getValue()); - + hologram = getOrCreateHologram(new Location(Bukkit.getWorld(Config.LEADERBOARD_LOCATION_WORLD.getValue()), + Config.LEADERBOARD_LOCATION_X.getValue(), + Config.LEADERBOARD_LOCATION_Y.getValue(), + Config.LEADERBOARD_LOCATION_Z.getValue())); + DHAPI.setHologramLine(hologram, 0, Config.LEADERBOARD_TITLE.getValue()); for (int i = 0; i < Config.LEADERBOARD_TOP.getValue(); i++) { - hologram.getLines().appendText(("")); + DHAPI.setHologramLine(hologram, 1 + i, ""); } refreshLeaderboard(); @@ -175,7 +173,6 @@ public class Leaderboard ResultSet rs = ps.executeQuery(); for (int i = 0; i < Config.LEADERBOARD_TOP.getValue(); i++) { - final int finalInt = i; String text; if (rs != null && rs.next()) { @@ -188,10 +185,7 @@ public class Leaderboard { text = ""; } - if (!((TextHologramLine) hologram.getLines().get(finalInt + 1)).getText().equals(text)) - { - Bukkit.getScheduler().runTask(AltitudeTag.getInstance(), () -> ((TextHologramLine) hologram.getLines().get(finalInt + 1)).setText(text)); - } + DHAPI.setHologramLine(hologram, 1 + i, text); } } catch (SQLException ex) @@ -201,4 +195,12 @@ public class Leaderboard }); } + + public static Hologram getOrCreateHologram(Location location) { + Hologram hologram1 = DHAPI.getHologram("TagLeaderBoard"); + if (hologram1 != null) + return hologram1; + + return DHAPI.createHologram("TagLeaderBoard", location); + } }