From 8c50ca38bf6d8363fd1c8c2e6dd3566a60dc5d4b Mon Sep 17 00:00:00 2001 From: TeamHRLive Date: Tue, 3 Sep 2024 18:34:45 +0530 Subject: [PATCH] [Fixed] Heads in some GUI Menus [Fixed] ItemDupe with Double Drop Upgrade --- .../skyblock/listeners/EntityListeners.java | 20 ++++++++++++------- .../craftaro/skyblock/menus/Leaderboard.java | 8 ++++++-- .../craftaro/skyblock/menus/Levelling.java | 1 + .../craftaro/skyblock/menus/Ownership.java | 6 ++++-- 4 files changed, 24 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/craftaro/skyblock/listeners/EntityListeners.java b/src/main/java/com/craftaro/skyblock/listeners/EntityListeners.java index f9ed59d2..911ada63 100644 --- a/src/main/java/com/craftaro/skyblock/listeners/EntityListeners.java +++ b/src/main/java/com/craftaro/skyblock/listeners/EntityListeners.java @@ -582,9 +582,9 @@ public class EntityListeners implements Listener { EntityEquipment equipment = livingEntity.getEquipment(); if (equipment != null) { for (ItemStack item : event.getDrops()) { - if (item.equals(equipment.getHelmet()) || item.equals(equipment.getChestplate()) - || item.equals(equipment.getLeggings()) || item.equals(equipment.getBoots()) - || item.equals(equipment.getItemInMainHand()) || item.equals(equipment.getItemInOffHand())) { + if (item.isSimilar(equipment.getHelmet()) || item.isSimilar(equipment.getChestplate()) + || item.isSimilar(equipment.getLeggings()) || item.isSimilar(equipment.getBoots()) + || item.isSimilar(equipment.getItemInMainHand()) || item.isSimilar(equipment.getItemInOffHand())) { dontMultiply.add(item); } } @@ -607,12 +607,18 @@ public class EntityListeners implements Listener { } } - for (ItemStack is : event.getDrops()) { - for (ItemStack is2 : dontMultiply) { - if (!is2.isSimilar(is)) { - livingEntity.getWorld().dropItemNaturally(livingEntity.getLocation(), is); + // Only drop items that are not in the dontMultiply set + for (ItemStack item : event.getDrops()) { + boolean shouldDrop = true; + for (ItemStack dontMultiplyItem : dontMultiply) { + if (item.isSimilar(dontMultiplyItem)) { + shouldDrop = false; + break; } } + if (shouldDrop) { + livingEntity.getWorld().dropItemNaturally(livingEntity.getLocation(), item); + } } } } diff --git a/src/main/java/com/craftaro/skyblock/menus/Leaderboard.java b/src/main/java/com/craftaro/skyblock/menus/Leaderboard.java index 9c9e4628..1af08a9b 100644 --- a/src/main/java/com/craftaro/skyblock/menus/Leaderboard.java +++ b/src/main/java/com/craftaro/skyblock/menus/Leaderboard.java @@ -1,5 +1,6 @@ package com.craftaro.skyblock.menus; +import com.craftaro.core.utils.ItemUtils; import com.craftaro.core.utils.NumberUtils; import com.craftaro.core.utils.SkullItemCreator; import com.craftaro.skyblock.SkyBlock; @@ -11,9 +12,12 @@ import com.craftaro.skyblock.utils.player.OfflinePlayer; import com.craftaro.skyblock.visit.Visit; import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial; import com.craftaro.third_party.com.cryptomorin.xseries.XSound; +import com.craftaro.third_party.com.cryptomorin.xseries.profiles.builder.XSkull; +import com.craftaro.third_party.com.cryptomorin.xseries.profiles.objects.Profileable; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; +import org.bukkit.block.Skull; import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.entity.Player; import org.bukkit.event.inventory.InventoryType; @@ -290,9 +294,9 @@ public class Leaderboard { ItemStack phead; if (playerTexture.length >= 1 && playerTexture[0] != null) { - phead = SkullItemCreator.byTextureValue(playerTexture[0]); + phead = XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply(); } else { - phead = SkullItemCreator.byUuid(visit.getOwnerUUID()); + phead = XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply(); } nInv.addItem( diff --git a/src/main/java/com/craftaro/skyblock/menus/Levelling.java b/src/main/java/com/craftaro/skyblock/menus/Levelling.java index 87b2154f..5831886d 100644 --- a/src/main/java/com/craftaro/skyblock/menus/Levelling.java +++ b/src/main/java/com/craftaro/skyblock/menus/Levelling.java @@ -190,6 +190,7 @@ public class Levelling { long value = testIslandMaterials.get(materialName); Optional materials = CompatibleMaterial.getMaterial(materialName); + if (!materials.isPresent()) { continue; } diff --git a/src/main/java/com/craftaro/skyblock/menus/Ownership.java b/src/main/java/com/craftaro/skyblock/menus/Ownership.java index 5d8324bc..337489e5 100644 --- a/src/main/java/com/craftaro/skyblock/menus/Ownership.java +++ b/src/main/java/com/craftaro/skyblock/menus/Ownership.java @@ -15,6 +15,8 @@ import com.craftaro.skyblock.playerdata.PlayerDataManager; import com.craftaro.skyblock.sound.SoundManager; import com.craftaro.skyblock.utils.item.nInventoryUtil; import com.craftaro.skyblock.utils.player.OfflinePlayer; +import com.craftaro.third_party.com.cryptomorin.xseries.profiles.builder.XSkull; +import com.craftaro.third_party.com.cryptomorin.xseries.profiles.objects.Profileable; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Material; @@ -228,9 +230,9 @@ public class Ownership { ItemStack phead; if (playerTexture.length >= 1 && playerTexture[0] != null) { - phead = SkullItemCreator.byTextureValue(playerTexture[0]); + phead = XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply(); } else { - phead = SkullItemCreator.byUuid(originalOwnerUUID); + phead = XSkull.createItem().profile(new Profileable.PlayerProfileable(player)).apply(); } nInv.addItem(nInv.createItem(XMaterial.OAK_FENCE_GATE.parseItem(),