From 152d12a97ec22843af55a246235a0f2c75e55c7e Mon Sep 17 00:00:00 2001 From: Auxilor Date: Sat, 16 Jan 2021 18:00:47 +0000 Subject: [PATCH] Improved pull request codestyle --- .../ecoenchants/special/Soulbound.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java index d47b08e5..a27f84da 100644 --- a/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java +++ b/eco-core/core-plugin/src/main/java/com/willfp/ecoenchants/enchantments/ecoenchants/special/Soulbound.java @@ -2,6 +2,7 @@ package com.willfp.ecoenchants.enchantments.ecoenchants.special; import com.willfp.ecoenchants.enchantments.EcoEnchant; import com.willfp.ecoenchants.enchantments.meta.EnchantmentType; +import org.bukkit.Material; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; @@ -65,24 +66,24 @@ public class Soulbound extends EcoEnchant { player.setMetadata("soulbound-items", this.getPlugin().getMetadataValueFactory().create(soulboundItems)); } - public boolean hasEmptyInventory(Player p) { - for(ItemStack it : p.getInventory().getContents()) - { - if(it != null) return false; + public boolean hasEmptyInventory(@NotNull final Player player) { + for (ItemStack itemStack : player.getInventory().getContents()) { + if (itemStack != null && itemStack.getType() != Material.AIR) { + return false; + } } return true; } - + @EventHandler(priority = EventPriority.HIGHEST) public void onSoulboundRespawn(@NotNull final PlayerRespawnEvent event) { Player player = event.getPlayer(); - + this.getPlugin().getScheduler().runLater(() -> { - - if (!hasEmptyInventory(player)) { - return; - } - + if (!hasEmptyInventory(player)) { + return; + } + if (!player.hasMetadata("soulbound-items")) { return; } @@ -102,7 +103,6 @@ public class Soulbound extends EcoEnchant { meta.getPersistentDataContainer().remove(this.getPlugin().getNamespacedKeyFactory().create("soulbound")); soulboundItem.setItemMeta(meta); player.getInventory().addItem(soulboundItem); - } player.removeMetadata("soulbound-items", this.getPlugin());