org.spongepowered.api.entity.projectile.Projectile Java Examples
The following examples show how to use
org.spongepowered.api.entity.projectile.Projectile.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SpongeDeathListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private void handleKill(long time, Living dead, Entity killerEntity) { Runnable processor = null; UUID victimUUID = getUUID(dead); if (killerEntity instanceof Player) { processor = handlePlayerKill(time, victimUUID, (Player) killerEntity); } else if (killerEntity instanceof Wolf) { processor = handleWolfKill(time, victimUUID, (Wolf) killerEntity); } else if (killerEntity instanceof Projectile) { processor = handleProjectileKill(time, victimUUID, (Projectile) killerEntity); } if (processor != null) { processing.submit(processor); } }
Example #2
Source File: SpongeDeathListener.java From Plan with GNU Lesser General Public License v3.0 | 5 votes |
private Runnable handleProjectileKill(long time, UUID victimUUID, Projectile projectile) { ProjectileSource source = projectile.getShooter(); if (!(source instanceof Player)) { return null; } Player player = (Player) source; String projectileName = new EntityNameFormatter().apply(projectile.getType().getName()); return victimUUID != null ? new PlayerKillProcessor(player.getUniqueId(), time, victimUUID, projectileName) : new MobKillProcessor(player.getUniqueId()); }
Example #3
Source File: GlobalListener.java From RedProtect with GNU General Public License v3.0 | 4 votes |
@Listener(order = Order.FIRST, beforeModifications = true) public void onProjectileHit(CollideEntityEvent event, @Root Projectile proj) { RedProtect.get().logger.debug(LogLevel.ENTITY, "Is CollideEntityEvent(onProjectileHit) event."); RedProtect.get().logger.debug(LogLevel.ENTITY, "Projectile: " + proj.getType().getName()); if (RedProtect.get().rm.getTopRegion(proj.getLocation(), this.getClass().getName()) != null) return; for (Entity ent : event.getEntities()) { RedProtect.get().logger.debug(LogLevel.ENTITY, "Entity: " + ent.getType().getName()); if (proj.getShooter() instanceof Player) { Player p = (Player) proj.getShooter(); if (ent instanceof Player) { if (!p.equals(ent) && !RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).pvp && !p.hasPermission("redprotect.world.bypass")) { event.setCancelled(true); return; } } if (ent instanceof Animal || ent instanceof Villager || ent instanceof Golem || ent instanceof Ambient) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).player_hurt_passives && !p.hasPermission("redprotect.world.bypass")) { event.setCancelled(true); return; } } if (ent instanceof Monster) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).player_hurt_monsters && !p.hasPermission("redprotect.world.bypass")) { event.setCancelled(true); return; } } if (ent instanceof Hanging || ent instanceof ArmorStand) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).build && !p.hasPermission("redprotect.world.bypass")) { event.setCancelled(true); } } } else { if (ent instanceof Hanging || ent instanceof ArmorStand) { if (!RedProtect.get().config.globalFlagsRoot().worlds.get(ent.getWorld().getName()).entity_block_damage) { event.setCancelled(true); return; } } } } }