public static EventData getEventData(EntityDamageEvent event) { if (event == null) return null; DamageType damageElement = DamageType.get(event.getCause()); Entity attacker = null; Projectile projectile = null; Entity target = event.getEntity(); World world = target.getWorld(); if (event instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event_EE = (EntityDamageByEntityEvent) event; Entity damager = event_EE.getDamager(); if (damager instanceof Projectile) { projectile = (Projectile) damager; attacker = projectile.getShooter(); } else { attacker = damager; } } return myInfo.makeData( attacker, projectile, target, world, damageElement, event.getDamage(), event.isCancelled()); }
@Override public IRoutineBuilder getNew(Matcher matcher, ScriptLine scriptLine, EventInfo info) { String name = matcher.group(1).toLowerCase(); IDataProvider<Location> locationDP = DataProvider.parse(info, Location.class, name); if (locationDP == null) return null; Collection<ModDamageItemStack> items = ItemAliaser.match(matcher.group(2), info); if (items == null || items.isEmpty()) return null; IDataProvider<? extends Number> quantity; if (matcher.group(3) != null) quantity = DataProvider.parse(info, Integer.class, matcher.group(3)); else quantity = new LiteralNumber(1); if (quantity == null) return null; ModDamageLogger.info("Drop item at " + locationDP + ": " + items); DropItem routine = new DropItem(scriptLine, locationDP, items, quantity); return new NestedRoutineBuilder(routine, routine.routines, info.chain(myInfo)); }