From 3a2b60db896d1e3c866fa4f70dcd10fb9216e161 Mon Sep 17 00:00:00 2001 From: Zrips Date: Wed, 22 Jun 2022 17:35:08 +0300 Subject: [PATCH] PetPay fix for mythicmobs plugin --- .../hooks/MythicMobs/MythicMobs5Listener.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5Listener.java b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5Listener.java index d9269778..05f203eb 100644 --- a/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5Listener.java +++ b/src/main/java/com/gamingmesh/jobs/hooks/MythicMobs/MythicMobs5Listener.java @@ -1,11 +1,18 @@ package com.gamingmesh.jobs.hooks.MythicMobs; +import java.util.UUID; + +import org.bukkit.Bukkit; import org.bukkit.entity.Entity; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; +import org.bukkit.entity.Tameable; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.entity.EntityDamageByEntityEvent; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.actions.MMKillInfo; import com.gamingmesh.jobs.container.ActionType; @@ -35,6 +42,23 @@ public final class MythicMobs5Listener implements Listener { // Checking if killer is tamed animal else if (event.getEntity().getLastDamageCause() instanceof EntityDamageByEntityEvent) { ent = ((EntityDamageByEntityEvent) event.getEntity().getLastDamageCause()).getDamager(); + + if (ent instanceof Tameable) { + Tameable tamed = (Tameable) ent; + + if (tamed.getOwner() == null) + return; + + @NotNull + UUID uuid = tamed.getOwner().getUniqueId(); + + @Nullable + Player owner = Bukkit.getPlayer(uuid); + + if (owner != null) + pDamager = owner; + + } } else return;