Merge pull request #20 from BlazingGames/bugfixes
All checks were successful
Build, Test and Publish / test (push) Successful in 3m47s
Build, Test and Publish / build-and-publish (push) Successful in 3m3s

Fixes for slab shulkers dying
This commit is contained in:
sbot50 2025-02-02 18:37:14 +00:00 committed by GitHub
commit fe0cc82d53
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 11 additions and 1 deletions

View file

@ -88,11 +88,12 @@ public class EntityDamagedByEventListener implements Listener {
p.getWorld().playSound(p, Sound.ENCHANT_THORNS_HIT, 1, 1.5f);
}
}
} else if (damager instanceof Player p) {
} else {
PersistentDataContainer container = victim.getPersistentDataContainer();
if (container.has(BlazingGames.get().key("slab")) && container.has(BlazingGames.get().key("slab_type"))) {
event.setCancelled(true);
if (!(damager instanceof Player p)) return;
UUID displayBlockUUID = UUID.fromString(Objects.requireNonNull(container.get(BlazingGames.get().key("slab"), PersistentDataType.STRING)));
String slabType = container.get(BlazingGames.get().key("slab_type"), PersistentDataType.STRING);
ItemDisplay displayBlock = (ItemDisplay) p.getWorld().getEntity(displayBlockUUID);

View file

@ -15,6 +15,7 @@
*/
package de.blazemcworld.blazinggames.events;
import de.blazemcworld.blazinggames.BlazingGames;
import de.blazemcworld.blazinggames.enchantments.sys.CustomEnchantments;
import de.blazemcworld.blazinggames.enchantments.sys.EnchantmentHelper;
import org.bukkit.Material;
@ -26,6 +27,7 @@ import org.bukkit.event.Listener;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataContainer;
import java.util.ArrayList;
import java.util.List;
@ -43,6 +45,13 @@ public class EntityDeathEventListener implements Listener {
LivingEntity victim = event.getEntity();
Player killer = victim.getKiller();
PersistentDataContainer container = victim.getPersistentDataContainer();
if (container.has(BlazingGames.get().key("slab")) && container.has(BlazingGames.get().key("slab_type"))) {
event.setCancelled(true);
return;
}
if(killer == null) {
return;
}