mirror of
https://github.com/Auxilor/EcoEnchants.git
synced 2024-11-26 15:45:12 +01:00
commit
74c019ebb8
@ -55,6 +55,10 @@ public class Necrotic extends EcoEnchant {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!event.getEntity().getMetadata("eco-target").isEmpty()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ItemStack item = new ItemStack(Material.WITHER_SKELETON_SKULL, 1);
|
ItemStack item = new ItemStack(Material.WITHER_SKELETON_SKULL, 1);
|
||||||
|
|
||||||
new DropQueue(player)
|
new DropQueue(player)
|
||||||
|
@ -5,7 +5,7 @@ import com.willfp.ecoenchants.enchantments.EcoEnchants;
|
|||||||
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
import com.willfp.ecoenchants.enchantments.meta.EnchantmentType;
|
||||||
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
import com.willfp.ecoenchants.enchantments.util.EnchantChecks;
|
||||||
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
import com.willfp.ecoenchants.enchantments.util.EnchantmentUtils;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.NamespacedKey;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -97,9 +97,10 @@ public class Soulbound extends EcoEnchant {
|
|||||||
player.setMetadata("soulbound-items", this.getPlugin().getMetadataValueFactory().create(soulboundItems));
|
player.setMetadata("soulbound-items", this.getPlugin().getMetadataValueFactory().create(soulboundItems));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasEmptyInventory(@NotNull final Player player) {
|
public boolean hasSoulboundItems(@NotNull final Player player) {
|
||||||
|
final NamespacedKey soulbound = this.getPlugin().getNamespacedKeyFactory().create("soulbound");
|
||||||
for (ItemStack itemStack : player.getInventory().getContents()) {
|
for (ItemStack itemStack : player.getInventory().getContents()) {
|
||||||
if (itemStack != null && itemStack.getType() != Material.AIR) {
|
if (itemStack != null && itemStack.getItemMeta().getPersistentDataContainer().has(soulbound, PersistentDataType.INTEGER)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -110,8 +111,8 @@ public class Soulbound extends EcoEnchant {
|
|||||||
public void onSoulboundRespawn(@NotNull final PlayerRespawnEvent event) {
|
public void onSoulboundRespawn(@NotNull final PlayerRespawnEvent event) {
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
this.getPlugin().getScheduler().runLater(() -> {
|
this.getPlugin().getScheduler().run(() -> {
|
||||||
if (!hasEmptyInventory(player)) {
|
if (!hasSoulboundItems(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,11 +138,12 @@ public class Soulbound extends EcoEnchant {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.removeMetadata("soulbound-items", this.getPlugin());
|
player.removeMetadata("soulbound-items", this.getPlugin());
|
||||||
}, 1);
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onDeath(@NotNull final PlayerDeathEvent event) {
|
public void onDeath(@NotNull final PlayerDeathEvent event) {
|
||||||
event.getDrops().removeIf(itemStack -> itemStack.getItemMeta().getPersistentDataContainer().has(this.getPlugin().getNamespacedKeyFactory().create("soulbound"), PersistentDataType.INTEGER));
|
final NamespacedKey soulbound = this.getPlugin().getNamespacedKeyFactory().create("soulbound");
|
||||||
|
event.getDrops().removeIf(itemStack -> itemStack.getItemMeta().getPersistentDataContainer().has(soulbound, PersistentDataType.INTEGER));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user