1
0
mirror of https://github.com/Zrips/Jobs.git synced 2025-01-02 14:29:07 +01:00

Fix for checking if the object is mypet

Fixes #930
This commit is contained in:
montlikadani 2020-10-02 12:14:09 +02:00
parent 0efedc0124
commit 3032802fad
4 changed files with 29 additions and 22 deletions

View File

@ -969,7 +969,7 @@ public class PlayerManager {
}
}
if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent)) {
if (ent != null && HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(ent, player.getPlayer())) {
if (petPay == null)
petPay = Jobs.getPermissionManager().getMaxPermission(player, "jobs.petpay");
if (petPay != null)

View File

@ -144,6 +144,8 @@ public class ShopManager {
GUIitem.setAmount(item.getIconAmount());
ItemMeta meta = GUIitem.getItemMeta();
if (meta == null)
continue;
if (item.getIconName() != null)
meta.setDisplayName(item.getIconName());
@ -190,6 +192,9 @@ public class ShopManager {
GUIitem = CMIMaterial.PLAYER_HEAD.newItemStack();
SkullMeta skullMeta = (SkullMeta) GUIitem.getItemMeta();
if (skullMeta == null)
continue;
// Fix skull meta
skullMeta.setDisplayName(item.getIconName());
skullMeta.setLore(Lore);
@ -262,8 +267,10 @@ public class ShopManager {
}
ItemStack Item = new ItemStack(Material.ARROW);
ItemMeta meta = Item.getItemMeta();
if (meta == null)
return false;
int prevSlot = getPrevButtonSlot(GuiSize.getFields(), page);
if (prevSlot != -1 && page > 1) {
meta.setDisplayName(Jobs.getLanguage().getMessage("command.help.output.prevPage"));

View File

@ -2,29 +2,35 @@ package com.gamingmesh.jobs.hooks.MyPet;
import java.util.UUID;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import de.Keyle.MyPet.MyPetApi;
import de.Keyle.MyPet.api.entity.MyPet;
import de.Keyle.MyPet.api.entity.MyPetBukkitEntity;
import de.Keyle.MyPet.api.player.MyPetPlayer;
import de.Keyle.MyPet.api.repository.PlayerManager;
public class MyPetManager {
PlayerManager mp;
de.Keyle.MyPet.api.repository.MyPetManager mppm;
private boolean enabled = false;
private final PlayerManager mp = MyPetApi.getPlayerManager();
public MyPetManager() {
mp = MyPetApi.getPlayerManager();
mppm = MyPetApi.getMyPetManager();
enabled = true;
public boolean isMyPet(Entity entity, Player owner) {
if (owner == null) {
return entity instanceof MyPetBukkitEntity;
}
if (!mp.isMyPetPlayer(owner)) {
return false;
}
MyPetPlayer myPetPlayer = mp.getMyPetPlayer(owner);
return myPetPlayer.hasMyPet() && myPetPlayer.getMyPet().getEntity().isPresent() &&
myPetPlayer.getMyPet().getEntity().get().getType() == entity.getType();
}
public boolean isMyPet(Object ent) {
return enabled && ent instanceof MyPetBukkitEntity;
}
public UUID getOwnerOfPet(Object ent) {
if (!enabled || !(ent instanceof MyPetBukkitEntity))
public UUID getOwnerOfPet(Entity ent) {
if (!(ent instanceof MyPetBukkitEntity))
return null;
MyPet myPet = ((MyPetBukkitEntity) ent).getMyPet();

View File

@ -302,8 +302,6 @@ public class JobsPaymentListener implements Listener {
Jobs.action(jDamager, new CustomKillInfo(((Sheep) stacked.getLivingEntity()).getColor().name(), ActionType.SHEAR));
}
}
return;
}
Jobs.action(jDamager, new CustomKillInfo(sheep.getColor().name(), ActionType.SHEAR));
@ -546,8 +544,6 @@ public class JobsPaymentListener implements Listener {
Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.TAME));
}
}
return;
}
Jobs.action(jDamager, new EntityActionInfo(animal, ActionType.TAME));
@ -1190,7 +1186,7 @@ public class JobsPaymentListener implements Listener {
if (e.getDamager() instanceof Player) {
pDamager = (Player) e.getDamager();
// Checking if killer is MyPet animal
} else if (HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager())) {
} else if (HookManager.getMyPetManager() != null && HookManager.getMyPetManager().isMyPet(e.getDamager(), null)) {
UUID uuid = HookManager.getMyPetManager().getOwnerOfPet(e.getDamager());
if (uuid != null)
pDamager = Bukkit.getPlayer(uuid);
@ -1248,8 +1244,6 @@ public class JobsPaymentListener implements Listener {
Jobs.action(jDamager, new EntityActionInfo(stacked.getLivingEntity(), ActionType.KILL), pDamager, stacked.getLivingEntity());
}
}
return;
}
Jobs.action(jDamager, new EntityActionInfo(lVictim, ActionType.KILL), pDamager, lVictim);