Java Code Examples for org.bukkit.entity.Arrow#getShooter()
The following examples show how to use
org.bukkit.entity.Arrow#getShooter() .
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: Compat19.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onEntityDamageByEntity(EntityDamageByEntityEvent e) { // Deny arrow booster Region r = RedProtect.get().rm.getTopRegion(e.getEntity().getLocation()); if (r == null && e.getEntity() instanceof Player && e.getDamager() instanceof Arrow) { Player p = (Player) e.getEntity(); Arrow arrow = (Arrow)e.getDamager(); if (arrow.getShooter() instanceof Player && p.isGliding()) { if (arrow.getShooter().equals(p) && !p.hasPermission("redprotect.bypass.glide") && !RedProtect.get().config.globalFlagsRoot().worlds.get(p.getWorld().getName()).player_glide.allow_boost) { e.setCancelled(true); arrow.remove(); RedProtect.get().lang.sendMessage(p, "globallistener.elytra.cantboost"); } } } }
Example 2
Source File: RageMatchModule.java From PGM with GNU Affero General Public License v3.0 | 5 votes |
private boolean isRage(Entity damager) { if (damager instanceof Player) { Player player = (Player) damager; return player.getItemInHand().containsEnchantment(Enchantment.DAMAGE_ALL); } else if (damager instanceof Arrow) { Arrow arrow = (Arrow) damager; // Arrows with damage > 2 are from power bows. return arrow.getShooter() instanceof Player && arrow.spigot().getDamage() > 2.0D; } return false; }
Example 3
Source File: FriendlyFireRefundMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.NORMAL) public void handleFriendlyFire(EntityDamageByEntityEvent event) { if(event.isCancelled() && event.getDamager() instanceof Arrow) { Arrow arrow = (Arrow) event.getDamager(); if(arrow.getPickupStatus() == Arrow.PickupStatus.ALLOWED && arrow.getShooter() != null && arrow.getShooter() instanceof Player){ Player owner = (Player) arrow.getShooter(); owner.getInventory().addItem(new ItemStack(Material.ARROW)); arrow.remove(); } } }
Example 4
Source File: EntityListener.java From Guilds with MIT License | 5 votes |
/** * Handles flame arrows * * @param event */ @EventHandler public void onFlameArrow(EntityCombustByEntityEvent event) { if (!(event.getEntity() instanceof Player)) return; if (!(event.getCombuster() instanceof Arrow)) return; Arrow arrow = (Arrow) event.getCombuster(); if (!(arrow.getShooter() instanceof Player)) return; Player damagee = (Player) event.getEntity(); Player damager = (Player) arrow.getShooter(); if (settingsManager.getProperty(GuildSettings.RESPECT_WG_PVP_FLAG)) { event.setCancelled(ClaimUtils.checkPvpDisabled(damagee)); return; } if (guildHandler.isSameGuild(damagee, damager)) { arrow.setFireTicks(0); event.setCancelled(!settingsManager.getProperty(GuildSettings.GUILD_DAMAGE)); return; } if (guildHandler.isAlly(damagee, damager)) { arrow.setFireTicks(0); event.setCancelled(!settingsManager.getProperty(GuildSettings.ALLY_DAMAGE)); } }
Example 5
Source File: SwitcherooListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onPlayerDamage(EntityDamageByEntityEvent e){ if (!(e.getEntity() instanceof Player)){ return; } Player player = ((Player) e.getEntity()).getPlayer(); if (!(e.getDamager() instanceof Arrow)){ return; } Arrow arrow = (Arrow) e.getDamager(); if (!(arrow.getShooter() instanceof Player)){ return; } Player shooter = ((Player) arrow.getShooter()).getPlayer(); if (player.equals(shooter)){ return; } arrow.remove(); Location playerLoc = player.getLocation(); Location shooterLoc = shooter.getLocation(); player.teleport(shooterLoc); shooter.teleport(playerLoc); player.sendMessage(Lang.SCENARIO_SWITCHEROO_SWITCH.replace("%player%", shooter.getName())); shooter.sendMessage(Lang.SCENARIO_SWITCHEROO_SWITCH.replace("%player%", player.getName())); }
Example 6
Source File: CEListener.java From ce with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void antiArrowSpam(ProjectileHitEvent event) { // Destroys the Arrows of the Minigun if (event.getEntityType().equals(EntityType.ARROW)) { Arrow arrow = (Arrow) event.getEntity(); ProjectileSource shooter = arrow.getShooter(); if (shooter instanceof Player) if (arrow.hasMetadata("ce.minigunarrow")) if (((Player) shooter).getGameMode().equals(GameMode.CREATIVE)) arrow.remove(); } }
Example 7
Source File: KillsMobsListener.java From Statz with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onDie(final EntityDeathEvent event) { final PlayerStat stat = PlayerStat.KILLS_MOBS; Entity e = event.getEntity(); if (!(e.getLastDamageCause() instanceof EntityDamageByEntityEvent)) { return; } PlayerStatSpecification specification; EntityDamageByEntityEvent nEvent = (EntityDamageByEntityEvent) e.getLastDamageCause(); if (nEvent.getDamager() instanceof Player) { // Entity died because of Player // Killer final Player player = (Player) nEvent.getDamager(); // Do general check if (!plugin.doGeneralCheck(player, stat)) return; if (e instanceof Player) { // Player killed player // Handled by other listener } else { // Player killed mob String mobType = StatzUtil.getMobType(e); String weapon = ""; ItemStack item = player.getInventory().getItemInMainHand(); if (item.getType() == Material.AIR) { weapon = "HAND"; } else { weapon = item.getType().toString(); } specification = new KillsMobsSpecification(player.getUniqueId(), 1, player.getWorld().getName(), mobType, weapon); // Update value to new stat. plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, specification.constructQuery()); } } else if (nEvent.getDamager() instanceof Arrow) { // Entity was killed by an arrow, now check if it was shot by a player Arrow killerArrow = (Arrow) nEvent.getDamager(); if (killerArrow.getShooter() instanceof Player) { Player shooter = (Player) killerArrow.getShooter(); specification = new KillsMobsSpecification(shooter.getUniqueId(), 1, shooter.getWorld().getName(), StatzUtil.getMobType(e), "BOW"); // Now update database. plugin.getDataManager().setPlayerInfo(shooter.getUniqueId(), stat, specification.constructQuery()); } } // }
Example 8
Source File: GrapplingHookListener.java From Slimefun4 with GNU General Public License v3.0 | 4 votes |
private void handleGrapplingHook(Arrow arrow) { if (arrow != null && arrow.isValid() && arrow.getShooter() instanceof Player) { Player p = (Player) arrow.getShooter(); GrapplingHookEntity hook = activeHooks.get(p.getUniqueId()); if (hook != null) { Location target = arrow.getLocation(); hook.drop(target); Vector velocity = new Vector(0.0, 0.2, 0.0); if (p.getLocation().distance(target) < 3.0) { if (target.getY() <= p.getLocation().getY()) { velocity = target.toVector().subtract(p.getLocation().toVector()); } } else { Location l = p.getLocation(); l.setY(l.getY() + 0.5); p.teleport(l); double g = -0.08; double d = target.distance(l); double t = d; double vX = (1.0 + 0.08 * t) * (target.getX() - l.getX()) / t; double vY = (1.0 + 0.04 * t) * (target.getY() - l.getY()) / t - 0.5D * g * t; double vZ = (1.0 + 0.08 * t) * (target.getZ() - l.getZ()) / t; velocity = p.getVelocity(); velocity.setX(vX); velocity.setY(vY); velocity.setZ(vZ); } p.setVelocity(velocity); hook.remove(); Slimefun.runSync(() -> activeHooks.remove(p.getUniqueId()), 20L); } } }