mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-12-25 20:17:38 +01:00
Improved pull request codestyle
This commit is contained in:
parent
5afeb01acb
commit
152d12a97e
@ -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());
|
||||
|
Loading…
Reference in New Issue
Block a user