protected void processExplosives(ExplosiveTracker explosive, PlayerDeath death) { if (death.getCause() == EntityDamageEvent.DamageCause.BLOCK_EXPLOSION) { if (((EntityDamageByEntityEvent) death.getEvent()).getDamager() instanceof TNTPrimed) { TNTPrimed tnt = (TNTPrimed) ((EntityDamageByEntityEvent) death.getEvent()).getDamager(); if (explosive.getOwner(tnt) != null) { Player killer = explosive.getOwner(tnt); death.setAction("was exploded"); death.setItemStack("TNT"); death.setKiller(killer); } } } }
@Override public void onEnable() { // basic operation listeners this.registerEvents(new LifetimeListener()); this.registerEvents(new WorldListener(Trackers.getManager())); EntityDamageEventListener damageEventListener = new EntityDamageEventListener(); damageEventListener.register(this); // initialize timer this.tickTimer = new TickTimer(this); this.tickTimer.start(); // tracker setup TrackerManager tm = Trackers.getManager(); ExplosiveTracker explosiveTracker = new SimpleExplosiveTracker(); SimpleGravityKillTracker gravityKillTracker = new SimpleGravityKillTracker(this, this.tickTimer); explosiveTracker.enable(); gravityKillTracker.enable(); this.registerEvents(new ExplosiveListener(explosiveTracker)); this.registerEvents(new GravityListener(this, gravityKillTracker, this.tickTimer)); tm.setTracker(ExplosiveTracker.class, explosiveTracker); tm.setTracker(SimpleGravityKillTracker.class, gravityKillTracker); DispenserTracker dispenserTracker = new SimpleDispenserTracker(); dispenserTracker.enable(); this.registerEvents(new DispenserListener(dispenserTracker)); tm.setTracker(DispenserTracker.class, dispenserTracker); ProjectileDistanceTracker projectileDistanceTracker = new SimpleProjectileDistanceTracker(); projectileDistanceTracker.enable(); this.registerEvents(new ProjectileDistanceListener(projectileDistanceTracker)); tm.setTracker(ProjectileDistanceTracker.class, projectileDistanceTracker); OwnedMobTracker ownedMobTracker = new SimpleOwnedMobTracker(); ownedMobTracker.enable(); this.registerEvents(new OwnedMobListener(ownedMobTracker)); tm.setTracker(OwnedMobTracker.class, ownedMobTracker); AnvilTracker anvilTracker = new SimpleAnvilTracker(); anvilTracker.enable(); this.registerEvents(new AnvilListener(anvilTracker)); tm.setTracker(AnvilTracker.class, anvilTracker); // register damage resolvers DamageResolverManager drm = DamageResolvers.getManager(); drm.register(new BlockDamageResolver()); drm.register(new FallDamageResolver()); drm.register(new LavaDamageResolver()); drm.register(new MeleeDamageResolver()); drm.register(new ProjectileDamageResolver(projectileDistanceTracker)); drm.register(new TNTDamageResolver(explosiveTracker, dispenserTracker)); drm.register(new VoidDamageResolver()); drm.register(new GravityDamageResolver(gravityKillTracker, this.tickTimer)); drm.register( new DispensedProjectileDamageResolver(projectileDistanceTracker, dispenserTracker)); drm.register(new OwnedMobDamageResolver(ownedMobTracker)); drm.register(new AnvilDamageResolver(anvilTracker)); // debug // this.registerEvents(new DebugListener()); }