Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1.20+ #76

Closed
wants to merge 15 commits into from
29 changes: 18 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<version>3.13.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>16</source>
<target>16</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.3.0-SNAPSHOT</version>
<version>3.5.3</version>
<configuration>
<relocations>
<relocation>
Expand Down Expand Up @@ -86,46 +86,53 @@
<id>codemc-repo</id>
<url>https://repo.codemc.io/repository/maven-public/</url>
</repository>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>
<dependencies>
<!-- Adventure Minimessage API -->
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-api</artifactId>
<version>4.11.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-text-minimessage</artifactId>
<version>4.11.0</version>
<version>4.17.0</version>
</dependency>
<dependency>
<groupId>net.kyori</groupId>
<artifactId>adventure-platform-bukkit</artifactId>
<version>4.1.1</version>
<version>4.3.2</version>
</dependency>

<!-- Adventure Minimessage API end-->

<dependency>
<groupId>org.spigotmc</groupId>
<artifactId>spigot-api</artifactId>
<version>1.17-R0.1-SNAPSHOT</version>
<version>1.20.6-R0.1-SNAPSHOT</version>
<type>jar</type>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.github.MilkBowl</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.gmail.filoghost.holographicdisplays</groupId>
<artifactId>holographicdisplays-api</artifactId>
<version>2.4.0</version>
<groupId>com.github.decentsoftware-eu</groupId>
<artifactId>decentholograms</artifactId>
<version>2.8.8</version>
<scope>provided</scope>
</dependency>

<dependency>
<groupId>com.hm.mcshared</groupId>
<artifactId>MCShared</artifactId>
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/com/hm/petmaster/PetMaster.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
30 changes: 20 additions & 10 deletions src/main/java/com/hm/petmaster/listener/PlayerInteractListener.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;

/**
Expand Down Expand Up @@ -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.");
}
}

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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<String> 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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down