diff --git a/pom.xml b/pom.xml index 296a531..5e070e3 100644 --- a/pom.xml +++ b/pom.xml @@ -30,16 +30,16 @@ org.apache.maven.plugins maven-compiler-plugin - 3.8.1 + 3.13.0 - 1.8 - 1.8 + 16 + 16 org.apache.maven.plugins maven-shade-plugin - 3.3.0-SNAPSHOT + 3.5.3 @@ -86,23 +86,27 @@ codemc-repo https://repo.codemc.io/repository/maven-public/ + + jitpack.io + https://jitpack.io + net.kyori adventure-api - 4.11.0 + 4.17.0 net.kyori adventure-text-minimessage - 4.11.0 + 4.17.0 net.kyori adventure-platform-bukkit - 4.1.1 + 4.3.2 @@ -110,22 +114,25 @@ org.spigotmc spigot-api - 1.17-R0.1-SNAPSHOT + 1.20.6-R0.1-SNAPSHOT jar provided + com.github.MilkBowl VaultAPI 1.7 provided + - com.gmail.filoghost.holographicdisplays - holographicdisplays-api - 2.4.0 + com.github.decentsoftware-eu + decentholograms + 2.8.8 provided + com.hm.mcshared MCShared diff --git a/src/main/java/com/hm/petmaster/PetMaster.java b/src/main/java/com/hm/petmaster/PetMaster.java index 17727aa..ded56e7 100644 --- a/src/main/java/com/hm/petmaster/PetMaster.java +++ b/src/main/java/com/hm/petmaster/PetMaster.java @@ -96,10 +96,12 @@ public void onEnable() { this.adventure = BukkitAudiences.create(this); this.messageSender = new MessageSender(this); + getLogger().info("Server version..." + Bukkit.getServer().getBukkitVersion()); + getLogger().info("Registered subVersion..." + Bukkit.getServer().getBukkitVersion().replace(".", ",").split(",")[1].split("-")[0]); getLogger().info("Registering listeners..."); - + serverVersion = Integer.parseInt( - Bukkit.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3].split("_")[1]); + Bukkit.getServer().getBukkitVersion().replace(".", ",").split(",")[1].split("-")[0]); playerInteractListener = new PlayerInteractListener(this); playerLeashListener = new PlayerLeashListener(this); diff --git a/src/main/java/com/hm/petmaster/listener/PlayerInteractListener.java b/src/main/java/com/hm/petmaster/listener/PlayerInteractListener.java index a42c566..2dbcd01 100644 --- a/src/main/java/com/hm/petmaster/listener/PlayerInteractListener.java +++ b/src/main/java/com/hm/petmaster/listener/PlayerInteractListener.java @@ -1,9 +1,9 @@ package com.hm.petmaster.listener; -import com.gmail.filoghost.holographicdisplays.api.Hologram; -import com.gmail.filoghost.holographicdisplays.api.HologramsAPI; import com.hm.mcshared.event.PlayerChangeAnimalOwnershipEvent; import com.hm.petmaster.PetMaster; +import eu.decentsoftware.holograms.api.DHAPI; +import eu.decentsoftware.holograms.api.holograms.Hologram; import net.kyori.adventure.text.Component; import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder; import net.milkbowl.vault.economy.Economy; @@ -20,7 +20,7 @@ import org.bukkit.scheduler.BukkitRunnable; import java.lang.reflect.Method; -import java.util.ArrayList; +import java.util.Collections; import java.util.List; /** @@ -85,13 +85,13 @@ public void extractParameters() { showHealth = plugin.getPluginConfig().getBoolean("showHealth", true); disableRiding = plugin.getPluginConfig().getBoolean("disableRiding", false); - boolean holographicDisplaysAvailable = Bukkit.getPluginManager().isPluginEnabled("HolographicDisplays"); + boolean decentHologramsAvailable = Bukkit.getPluginManager().isPluginEnabled("DecentHolograms"); // Checking whether user configured plugin to display hologram but HolographicsDisplays not available. - if (hologramMessage && !holographicDisplaysAvailable) { + if (hologramMessage && !decentHologramsAvailable) { hologramMessage = false; actionBarMessage = true; plugin.getLogger().warning( - "HolographicDisplays was not found; disabling usage of holograms and enabling action bar messages."); + "DecentHolograms was not found; disabling usage of holograms and enabling action bar messages."); } } @@ -161,7 +161,7 @@ private void changeOwner(Player player, AnimalTamer oldOwner, Player newOwner, T + plugin.getPluginLang().getString("owner-changed", "This pet was given to a new owner!")); newOwner.sendMessage(plugin.getChatHeader() + plugin.getPluginLang().getString("new-owner", "Player PLAYER gave you ownership of a pet!") - .replace("PLAYER", player.getName())); + .replace("PLAYER", oldOwner.getName())); // Create new event to allow other plugins to be aware of the ownership change. PlayerChangeAnimalOwnershipEvent playerChangeAnimalOwnershipEvent = new PlayerChangeAnimalOwnershipEvent( @@ -248,19 +248,29 @@ private void displayHologramAndMessage(Player player, AnimalTamer owner, Tameabl Location hologramLocation = new Location(eventLocation.getWorld(), eventLocation.getX(), eventLocation.getY() + offset, eventLocation.getZ()); - final Hologram hologram = HologramsAPI.createHologram(plugin, hologramLocation); - hologram.appendTextLine(plugin.getMessageSender().parseMessageToString( + + String hologramname = player.getUniqueId() + "_pm"; + + List lines = Collections.singletonList(plugin.getMessageSender().parseMessageToString( "petmaster-hologram", Placeholder.component("owner", Component.text(owner.getName() != null ? owner.getName() : "null")) )); + if (DHAPI.getHologram(hologramname) == null) { + Hologram hologram = DHAPI.createHologram(hologramname, hologramLocation, lines); + } else { + return; + } + + // Runnable to delete hologram. + new BukkitRunnable() { @Override public void run() { - hologram.delete(); + DHAPI.removeHologram(hologramname); } }.runTaskLater(plugin, hologramDuration); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 7595345..291d5a1 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -18,7 +18,7 @@ # Enable or disable chat messages when right-clicking on a pet. chatMessage: false -# Enable or disable hologram messages when right-clicking on a pet (requires Holographic Displays). +# Enable or disable hologram messages when right-clicking on a pet (requires DecentHolograms). hologramMessage: false # Enable or disable action bar messages when right-clicking on a pet. diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 526506d..ec6e462 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -2,10 +2,10 @@ name: PetMaster main: com.hm.petmaster.PetMaster version: ${project.version} author: DarkPyves -softdepend: [HolographicDisplays,Vault] +softdepend: [DecentHolograms,Vault] description: Manage pets and display useful information via holograms, action bar or chat messages! website: https://github.com/PyvesB/PetMaster -api-version: 1.13 +api-version: 1.20 commands: petm: description: Main Pet Master command, use it to list sub-commands.