From 5a6b5a7f89eac000565cf63b6f0eb9f6e4473417 Mon Sep 17 00:00:00 2001 From: urtypicalblahajlunatic Date: Tue, 7 Jul 2026 12:03:49 +0200 Subject: [PATCH] message that endercrystals explode now --- .../net/ardakaz/griefalert/GriefAlert.java | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) diff --git a/src/main/java/net/ardakaz/griefalert/GriefAlert.java b/src/main/java/net/ardakaz/griefalert/GriefAlert.java index 11951a4..209062d 100644 --- a/src/main/java/net/ardakaz/griefalert/GriefAlert.java +++ b/src/main/java/net/ardakaz/griefalert/GriefAlert.java @@ -29,6 +29,7 @@ import org.bukkit.inventory.Inventory; import org.bukkit.inventory.ItemStack; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; +import org.bukkit.projectiles.ProjectileSource; import java.sql.*; import java.util.Arrays; @@ -811,6 +812,54 @@ public class GriefAlert extends JavaPlugin implements Listener { }, 1L); } + + //Ender Crystal shenanigans + @EventHandler + public void onEndCrystalDeath(EntityDamageByEntityEvent event){ + //if its not an endercrystal it should not do logic for enderCrystal + if(!(event.getEntity() instanceof EnderCrystal)) return; + Location loc = event.getEntity().getLocation(); + + int x = loc.getBlockX(); + int y = loc.getBlockY(); + int z = loc.getBlockZ(); + String world = loc.getWorld().getName(); + //Placeholder + Player damager = null; + //if its a Player then its a player (damage is like sword or fist or whatever) + if(event.getDamager() instanceof Player player){ + damager = player; + //if its not hit by a player, its from a projectile which we need ownership off + }else if(event.getDamager() instanceof Projectile projectile){ + ProjectileSource source = projectile.getShooter(); + + if(source instanceof Player player){ + damager = player; + } + } + if(damager == null){ + return; //idk what it is, (i do) but it wasnt a player + } + + if (isLocationIgnored(x, y, z, world)) { + return; + } + + Block block = loc.getBlock(); + + String target = inspectBlock(block, damager); + if (target == null) return; + //cuz BlÄhaj is cute so if you damage your own stuff u gucci + if (target.equals(damager.getName())) return; + + String message = ChatColor.GRAY + damager.getName() + " destroyed an ender crystal at " + x + " " + y + " " + z; + alert(message, damager.getName(), "[Map Link](" + MAP_LINK + "/?worldname=" + world + "&zoom=7&x=" + x + "&y=" + y + "&z=" + z + ")", target, x, y, z, world); + + + } + + + private CoreProtectAPI getCoreProtect() { Plugin plugin = getServer().getPluginManager().getPlugin("CoreProtect");