org.bukkit.entity.Projectile Java Examples
The following examples show how to use
org.bukkit.entity.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: IslandGuard.java From askyblock with GNU General Public License v2.0 | 7 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true) public void onItemFrameDamage(final EntityDamageByEntityEvent e) { // Check world if (!inWorld(e.getEntity()) || !(e.getEntity() instanceof ItemFrame)) { return; } if (e.getDamager() instanceof Projectile) { if (DEBUG) plugin.getLogger().info("DEBUG: Projectile damage to itemframe"); // Find out who fired the arrow Projectile p = (Projectile) e.getDamager(); if (DEBUG) plugin.getLogger().info("DEBUG: Shooter is " + p.getShooter().toString()); if (p.getShooter() instanceof Skeleton || p.getShooter() instanceof Golem) { if (DEBUG) plugin.getLogger().info("DEBUG: Shooter is mob"); if (!Settings.allowMobDamageToItemFrames) { if (DEBUG) plugin.getLogger().info("DEBUG: Damage not allowed, cancelling"); e.setCancelled(true); } } } }
Example #2
Source File: ProjectileTrailMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 6 votes |
@Repeatable(scope = MatchScope.RUNNING) public void tick() { EntityUtils.entities(match.getWorld(), Projectile.class) .filter(projectile -> projectile.hasMetadata(TRAIL_META)) .forEach(projectile -> { if(projectile.isDead() || projectile.isOnGround()) { projectile.removeMetadata(TRAIL_META, PGM.get()); } else { final Color color = (Color) projectile.getMetadata(TRAIL_META, PGM.get()).value(); // Certain particles can have a specific color if: // - Count is 0 // - Speed is 1 // - Delta vectors are RGB values from (0,1] match.getWorld().spawnParticle( Particle.REDSTONE, projectile.getLocation(), 0, rgbToParticle(color.getRed()), rgbToParticle(color.getGreen()), rgbToParticle(color.getBlue()), 1 ); } }); }
Example #3
Source File: DefaultComparators.java From Skript with GNU General Public License v3.0 | 6 votes |
@Override public Relation compare(final DamageCause dc, final EntityData e) { switch (dc) { case ENTITY_ATTACK: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Entity.class))); case PROJECTILE: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Projectile.class))); case WITHER: return Relation.get(e.isSupertypeOf(EntityData.fromClass(Wither.class))); case FALLING_BLOCK: return Relation.get(e.isSupertypeOf(EntityData.fromClass(FallingBlock.class))); //$CASES-OMITTED$ default: return Relation.NOT_EQUAL; } }
Example #4
Source File: SentinelEventHandler.java From Sentinel with MIT License | 6 votes |
@EventHandler public void onEntityExplodes(EntityExplodeEvent event) { if (event.isCancelled()) { return; } if (!SentinelPlugin.instance.preventExplosionBlockDamage) { return; } if (event.getEntity() instanceof Projectile) { ProjectileSource source = ((Projectile) event.getEntity()).getShooter(); if (source instanceof Entity) { SentinelTrait sourceSentinel = SentinelUtilities.tryGetSentinel((Entity) source); if (sourceSentinel != null) { event.blockList().clear(); } } } }
Example #5
Source File: SentinelEventHandler.java From Sentinel with MIT License | 6 votes |
@EventHandler public void onBlockIgnites(BlockIgniteEvent event) { if (event.isCancelled()) { return; } if (!SentinelPlugin.instance.preventExplosionBlockDamage) { return; } if (event.getIgnitingEntity() instanceof Projectile) { ProjectileSource source = ((Projectile) event.getIgnitingEntity()).getShooter(); if (source instanceof Entity) { SentinelTrait sourceSentinel = SentinelUtilities.tryGetSentinel((Entity) source); if (sourceSentinel != null) { event.setCancelled(true); } } } }
Example #6
Source File: LWCPlayerListener.java From Modern-LWC with MIT License | 6 votes |
@EventHandler public void minecartBreak(VehicleDestroyEvent e) { Entity entity = e.getVehicle(); if (plugin.getLWC().isProtectable(e.getVehicle().getType())) { int A = 50000 + entity.getUniqueId().hashCode(); LWC lwc = LWC.getInstance(); Protection protection = lwc.getPhysicalDatabase().loadProtection(entity.getWorld().getName(), A, A, A); if ((((entity instanceof StorageMinecart)) || ((entity instanceof HopperMinecart))) && (protection != null)) { if (e.getAttacker() instanceof Projectile) { e.setCancelled(true); } Player p = (Player) e.getAttacker(); boolean canAccess = lwc.canAccessProtection(p, protection); if (canAccess) { protection.remove(); protection.removeAllPermissions(); protection.removeCache(); return; } e.setCancelled(true); } } }
Example #7
Source File: ProjectileUtils.java From Skript with GNU General Public License v3.0 | 6 votes |
@Nullable public static Object getShooter(final @Nullable Projectile p) { if (p == null) return null; try { return getShooter.invoke(p); } catch (final IllegalAccessException e) { assert false; return null; } catch (final IllegalArgumentException e) { assert false; return null; } catch (final InvocationTargetException e) { Skript.exception(e); return null; } }
Example #8
Source File: BountyHunter.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
@Override public void effect(Event e, ItemStack item, final int level) { if(e instanceof EntityDamageByEntityEvent) { EntityDamageByEntityEvent event = (EntityDamageByEntityEvent) e; Entity target = event.getEntity(); if(!(target instanceof Player)) return; Player p = (Player) ((Projectile) event.getDamager()).getShooter(); Material bountyDrop = getBounty(); for(int i = 10; i>0; i--) { p.getWorld().playEffect(p.getLocation(), Effect.COLOURED_DUST, 10); p.getWorld().playEffect(target.getLocation(), Effect.COLOURED_DUST, 10); } p.getInventory().addItem(new ItemStack(bountyDrop, Tools.random.nextInt(MaximumBounty+level)+1)); p.sendMessage(ChatColor.GOLD + "You have collected a bounty on " + target.getName() + "!"); this.generateCooldown(p, Cooldown); } }
Example #9
Source File: EntityListenerTest.java From AuthMeReloaded with GNU General Public License v3.0 | 6 votes |
@Test public void shouldAllowProjectileLaunchFromAuthedHuman() { // given Projectile projectile = mock(Projectile.class); Player player = mock(Player.class); given(projectile.getShooter()).willReturn(player); ProjectileLaunchEvent event = mock(ProjectileLaunchEvent.class); given(event.getEntity()).willReturn(projectile); given(listenerService.shouldCancelEvent(player)).willReturn(false); // when listener.onProjectileLaunch(event); // then verify(listenerService).shouldCancelEvent(player); verify(event, never()).setCancelled(anyBoolean()); }
Example #10
Source File: CEListener.java From ce with GNU Lesser General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void EntityDamageByEntityEvent(EntityDamageByEntityEvent e) { Entity damager = e.getDamager(); Entity damaged = e.getEntity(); // Block self damaging (Enderpearls cause weird behavior) if (damager.getUniqueId().equals(damaged.getUniqueId())) return; if (damaged instanceof Player) CEventHandler.handleEvent((Player) damaged, e, damageTaken); if (damager instanceof Player) CEventHandler.handleEvent((Player) damager, e, damageGiven); else if (damager instanceof Arrow) if (damager.hasMetadata("ce.bow.item") || damager.hasMetadata("ce.bow.enchantment")) CEventHandler.handleBows((Player) ((Projectile) damager).getShooter(), e); }
Example #11
Source File: ParticleEffectListener.java From SkyWarsReloaded with GNU General Public License v3.0 | 6 votes |
@EventHandler public void projectileLaunch(ProjectileLaunchEvent e) { Projectile projectile = e.getEntity(); if (projectile instanceof Snowball || projectile instanceof Egg || projectile instanceof Arrow) { if (projectile.getShooter() instanceof Player) { Player player = (Player) projectile.getShooter(); GameMap gMap = MatchManager.get().getPlayerMap(player); if (gMap != null) { PlayerStat ps = PlayerStat.getPlayerStats(player.getUniqueId()); if (ps != null) { String key = ps.getProjectileEffect(); ProjectileEffectOption peo = (ProjectileEffectOption) ProjectileEffectOption.getPlayerOptionByKey(key); if (peo != null) { List<ParticleEffect> effects = peo.getEffects(); if (key != null && effects != null) { if (!key.equalsIgnoreCase("none")) { SkyWarsReloaded.getOM().addProjectile(projectile, effects); } } } } } } } }
Example #12
Source File: Knockback.java From MineTinker with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onBlock(MTEntityDamageByEntityEvent event) { if (event.getPlayer().equals(event.getEvent().getDamager())) return; //Player is attacking if (event.getEvent().getDamager() instanceof Projectile) return; //Not a melee hit if (!event.isBlocking()) return; if (!event.getPlayer().hasPermission("minetinker.modifiers.knockback.use")) return; ItemStack shield = event.getTool(); if (!ToolType.SHIELD.contains(shield.getType())) return; //Not the shield int level = modManager.getModLevel(shield, this); if (level <= 0) return; //calculate vector Vector vector = event.getEvent().getDamager().getLocation().subtract(event.getPlayer().getLocation()).toVector(); vector = vector.normalize().multiply(new Vector(1, 0, 1)).add(new Vector(0, 0.2, 0)); vector = vector.multiply(new Vector(level * 0.2, 1, level * 0.2)); event.getEntity().setVelocity(vector); ChatWriter.logModifier(event.getPlayer(), event, this, shield, String.format("Vector(%.2f/%.2f/%.2f)", vector.getX(), vector.getY(), vector.getZ())); }
Example #13
Source File: PlayerDamageListener.java From UhcCore with GNU General Public License v3.0 | 6 votes |
private void handleArrow(EntityDamageByEntityEvent event){ PlayersManager pm = GameManager.getGameManager().getPlayersManager(); if(event.getEntity() instanceof Player && event.getDamager() instanceof Arrow){ Projectile arrow = (Projectile) event.getDamager(); final Player shot = (Player) event.getEntity(); if(arrow.getShooter() instanceof Player){ if(!GameManager.getGameManager().getPvp()){ event.setCancelled(true); return; } UhcPlayer uhcDamager = pm.getUhcPlayer((Player) arrow.getShooter()); UhcPlayer uhcDamaged = pm.getUhcPlayer(shot); if(!friendlyFire && uhcDamager.getState().equals(PlayerState.PLAYING) && uhcDamager.isInTeamWith(uhcDamaged)){ uhcDamager.sendMessage(Lang.PLAYERS_FF_OFF); event.setCancelled(true); } } } }
Example #14
Source File: TitleRespawn.java From CardinalPGM with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onEntityDamage(EntityDamageByEntityEvent event) { if (!(event.getEntity() instanceof Player)) return; Player player = (Player) event.getEntity(); double finalHealth = player.getHealth() - event.getFinalDamage(); if (finalHealth > 0.01) return; player.setMaxHealth(20); player.setHealth(player.getMaxHealth()); event.setDamage(1); player.setLastDamageCause(event); if (event.getActor() instanceof Player) { killPlayer(player, (Player)event.getActor(), event.getCause()); } else if (event.getActor() instanceof Projectile && ((Projectile) event.getActor()).getShooter() instanceof Player) { killPlayer(player, (Player)((Projectile) event.getActor()).getShooter(), event.getCause()); } else { killPlayer(player, null, event.getCause()); } }
Example #15
Source File: IslandGuard1_9.java From askyblock with GNU General Public License v2.0 | 6 votes |
@EventHandler(priority = EventPriority.LOW, ignoreCancelled=true) public void onLingeringPotionSplash(final LingeringPotionSplashEvent e) { if (!IslandGuard.inWorld(e.getEntity().getLocation())) { return; } // Try to get the shooter Projectile projectile = (Projectile) e.getEntity(); if (projectile.getShooter() != null && projectile.getShooter() instanceof Player) { UUID uuid = ((Player)projectile.getShooter()).getUniqueId(); // Store it and remove it when the effect is gone thrownPotions.put(e.getAreaEffectCloud().getEntityId(), uuid); plugin.getServer().getScheduler().runTaskLater(plugin, new Runnable() { @Override public void run() { thrownPotions.remove(e.getAreaEffectCloud().getEntityId()); }}, e.getAreaEffectCloud().getDuration()); } }
Example #16
Source File: KillerProjectiles.java From RedProtect with GNU General Public License v3.0 | 6 votes |
@EventHandler(ignoreCancelled = true) public void onDamagePlayer(ProjectileHitEvent event) { if (event.getHitEntity() instanceof Player) { Player player = (Player) event.getHitEntity(); Projectile projectile = event.getEntity(); Region r = RedProtect.get().rm.getTopRegion(projectile.getLocation()); double damage; if (getConfig().getString("projectile-damage").endsWith("%")) { damage = (player.getAttribute(Attribute.GENERIC_MAX_HEALTH).getBaseValue() / 100) * Double.valueOf(getConfig().getString("projectile-damage", "100%").replace("%", "")); } else { damage = getConfig().getInt("projectile-damage"); } if (r != null && r.getFlagBool("killer-projectiles") && getConfig().getStringList("allowed-types").contains(projectile.getType().name())) { player.setHealth(damage); } } }
Example #17
Source File: ListenerDamage.java From CombatLogX with GNU General Public License v3.0 | 5 votes |
private boolean checkDamageByEntity(EntityDamageEvent event) { if(!(event instanceof EntityDamageByEntityEvent)) return false; EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event; Entity damager = e.getDamager(); if(damager instanceof LivingEntity) return true; if(damager instanceof Projectile) { Projectile projectile = (Projectile) damager; ProjectileSource shooter = projectile.getShooter(); return (shooter instanceof LivingEntity); } return false; }
Example #18
Source File: ExprShooter.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override protected LivingEntity[] get(final Event e, final Projectile[] source) { return get(source, new Converter<Projectile, LivingEntity>() { @Override @Nullable public LivingEntity convert(final Projectile p) { final Object o = ProjectileUtils.getShooter(p); if (o instanceof LivingEntity) return (LivingEntity) o; return null; } }); }
Example #19
Source File: DamageStatListener.java From NyaaUtils with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onEntityDamaged(EntityDamageByEntityEvent ev) { if (!plugin.cfg.damageStatEnabled) return; if (!(ev.getEntity() instanceof LivingEntity)) return; UUID playerId = null; if (ev.getDamager() instanceof Player) { playerId = ev.getDamager().getUniqueId(); } else if (ev.getDamager() instanceof Projectile) { if (((Projectile) ev.getDamager()).getShooter() instanceof Player) { playerId = ((Player) ((Projectile) ev.getDamager()).getShooter()).getUniqueId(); } else { return; } } else { return; } UUID mobUid = ev.getEntity().getUniqueId(); double damage = ev.getFinalDamage(); double health = ((LivingEntity) ev.getEntity()).getHealth(); if (damage > health) damage = health; Map<UUID, Double> damageMap = entityList.getUnchecked(mobUid); if (damageMap.containsKey(playerId)) { damageMap.put(playerId, damageMap.get(playerId) + damage); } else { damageMap.put(playerId, damage); } }
Example #20
Source File: PreventTowerExploit.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onHit(EntityDamageByEntityEvent event) { if (!(event instanceof LivingEntity)) return; if (!EntityFinder.getRealDamager(event).getType().equals(EntityType.PLAYER)) return; EliteMobEntity eliteMobEntity = EntityTracker.getEliteMobEntity(event.getEntity()); if (eliteMobEntity == null) return; Location mobLocation = event.getEntity().getLocation().add(new Vector(0.5, 0, 0.5)); Location playerLocation; if (event.getDamager() instanceof Player) playerLocation = event.getDamager().getLocation(); else playerLocation = ((Player) ((Projectile) event.getDamager()).getShooter()).getLocation().getBlock().getLocation().add(new Vector(0.5, 0, 0.5)); if (playerLocation.getY() - mobLocation.getY() < 2) return; Block block1 = playerLocation.clone().add(new Vector(0, -1, 1)).getBlock(); Block block2 = playerLocation.clone().add(new Vector(0, -1, -1)).getBlock(); Block block3 = playerLocation.clone().add(new Vector(0, -2, 1)).getBlock(); Block block4 = playerLocation.clone().add(new Vector(0, -2, -1)).getBlock(); Block block5 = playerLocation.clone().add(new Vector(1, -1, 0)).getBlock(); Block block6 = playerLocation.clone().add(new Vector(-1, -1, 0)).getBlock(); Block block7 = playerLocation.clone().add(new Vector(1, -2, 0)).getBlock(); Block block8 = playerLocation.clone().add(new Vector(-1, -2, 0)).getBlock(); if (!(block1.getType().equals(Material.AIR) && block2.getType().equals(Material.AIR) && block3.getType().equals(Material.AIR) && block4.getType().equals(Material.AIR) && block5.getType().equals(Material.AIR) && block6.getType().equals(Material.AIR) && block7.getType().equals(Material.AIR) && block8.getType().equals(Material.AIR))) return; eliteMobEntity.setHasSpecialLoot(false); AntiExploitMessage.sendWarning((LivingEntity) event.getEntity()); }
Example #21
Source File: SentinelEventHandler.java From Sentinel with MIT License | 5 votes |
/** * Called when combat occurs in the world (and has not yet been processed by other plugins), * to handle things like cancelling invalid damage to/from a Sentinel NPC, * changing damage values given to or received from an NPC, * and if relevant handling config options that require overriding damage events. */ @EventHandler(priority = EventPriority.LOW) public void whenAttacksAreHappening(EntityDamageByEntityEvent event) { if (event.isCancelled()) { return; } UUID victimUuid = event.getEntity().getUniqueId(); for (SentinelTrait sentinel : cleanCurrentList()) { sentinel.whenSomethingMightDie(victimUuid); } SentinelTrait victim = SentinelUtilities.tryGetSentinel(event.getEntity()); SentinelTrait attacker = SentinelUtilities.tryGetSentinel(event.getDamager()); if (victim != null) { if (attacker != null && victim.getNPC().getId() == attacker.getNPC().getId()) { event.setCancelled(true); return; } victim.whenAttacksAreHappeningToMe(event); } if (attacker != null) { attacker.whenAttacksAreHappeningFromMe(event); } if (event.getDamager() instanceof Projectile) { ProjectileSource source = ((Projectile) event.getDamager()).getShooter(); if (source instanceof Entity) { SentinelTrait shooter = SentinelUtilities.tryGetSentinel((Entity) source); if (shooter != null) { shooter.whenAttacksAreHappeningFromMyArrow(event); } } } }
Example #22
Source File: CustomItemListener.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
@EventHandler private void entityShootBow(EntityShootBowEvent event) { if (event.getEntity() instanceof Player) { Player player = (Player) event.getEntity(); CustomItem customItem = CustomItemManager.getCustomItem(event.getBow()); if (verifyCustomItem(customItem, player, false)) { DelayedPlayerDetails details = new DelayedPlayerDetails(event.getBow(), player); ((CustomBow) customItem).onShootBow(event, details); if (!event.isCancelled() && event.getProjectile() instanceof Projectile) { details.lock(); event.getProjectile().setMetadata("CustomItem-bow", new FixedMetadataValue(CustomItemManager._plugin, new Object[] { customItem, details })); } } } }
Example #23
Source File: MutationModules.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerDamage(EntityDamageByEntityEvent event) { Entity damager = event.getDamager(); if ((damager instanceof Player && ItemUtils.isWeapon(((Player) damager).getItemInHand())) || (damager instanceof Projectile && ((Projectile) damager).getShooter() instanceof Player)) { event.setDamage(DAMAGE); } }
Example #24
Source File: KillerProjectiles.java From RedProtect with GNU General Public License v3.0 | 5 votes |
@EventHandler(ignoreCancelled = true) public void onEntityDamagePlayer(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Projectile && event.getEntity() instanceof Player) { Projectile projectile = (Projectile) event.getDamager(); Region r = RedProtect.get().rm.getTopRegion(projectile.getLocation()); if (r != null && r.getFlagBool("killer-projectiles") && getConfig().getStringList("allowed-types").contains(projectile.getType().name())) { // Set damage from projectile to 0 event.setDamage(0); } } }
Example #25
Source File: CombatTag.java From EliteMobs with GNU General Public License v3.0 | 5 votes |
private static Player playerFinder(EntityDamageByEntityEvent event) { if (event.getDamager() instanceof Player && EntityTracker.isEliteMob(event.getEntity())) return (Player) event.getDamager(); if (event.getEntity() instanceof Player && (EntityTracker.isEliteMob(event.getEntity()) || event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof LivingEntity && EntityTracker.isEliteMob(((LivingEntity) ((Projectile) event.getDamager()).getShooter())))) return (Player) event.getEntity(); if (event.getDamager() instanceof Projectile && ((Projectile) event.getDamager()).getShooter() instanceof Player && EntityTracker.isEliteMob(event.getEntity())) return (Player) ((Projectile) event.getDamager()).getShooter(); return null; }
Example #26
Source File: ProjectileUtils.java From Skript with GNU General Public License v3.0 | 5 votes |
public static void setShooter(final Projectile p, final @Nullable Object shooter) { try { setShooter.invoke(p, shooter); } catch (final IllegalAccessException e) { assert false; } catch (final IllegalArgumentException e) { Skript.exception(e, "invalid parameter passed to (" + p + ").setShooter: " + shooter); } catch (final InvocationTargetException e) { Skript.exception(e); } }
Example #27
Source File: GriefEvents.java From uSkyBlock with GNU General Public License v3.0 | 5 votes |
@EventHandler public void onEntityDamage(EntityDamageByEntityEvent event) { if ((!killAnimalsEnabled && !killMonstersEnabled) || !plugin.getWorldManager().isSkyAssociatedWorld(event.getDamager().getWorld())) { return; } if (!(event.getEntity() instanceof Creature)) { return; } if (event.getDamager() instanceof Player && !plugin.playerIsOnIsland((Player)event.getDamager())) { if (event.getDamager().hasPermission("usb.mod.bypassprotection")) { return; } cancelMobDamage(event); } else if (event.getDamager() instanceof Projectile) { ProjectileSource shooter = ((Projectile) event.getDamager()).getShooter(); if (!(shooter instanceof Player)) { return; } Player player = (Player) shooter; if (player.hasPermission("usb.mod.bypassprotection") || plugin.playerIsOnIsland(player)) { return; } cancelMobDamage(event); } }
Example #28
Source File: CustomItemListener.java From NBTEditor with GNU General Public License v3.0 | 5 votes |
@EventHandler private void projectileHit(ProjectileHitEvent event) { Projectile projectile = event.getEntity(); if (projectile.hasMetadata("CustomItem-bow")) { Object[] data = (Object[]) projectile.getMetadata("CustomItem-bow").get(0).value(); ((CustomBow) data[0]).onProjectileHit(event, (DelayedPlayerDetails) data[1]); } }
Example #29
Source File: EntityListener.java From Guilds with MIT License | 5 votes |
@EventHandler public void onDamage(EntityDamageByEntityEvent event) { if (!(event.getEntity() instanceof Player) || !(event.getDamager() instanceof Projectile)) { return; } Projectile projectile = (Projectile) event.getDamager(); if (!(projectile.getShooter() instanceof Player)) { return; } Player damaged = (Player) event.getEntity(); Player damager = (Player) projectile.getShooter(); if (settingsManager.getProperty(GuildSettings.RESPECT_WG_PVP_FLAG)) { event.setCancelled(ClaimUtils.checkPvpDisabled(damaged)); return; } if (guildHandler.isSameGuild(damaged, damager) && damaged != damager) { event.setCancelled(!settingsManager.getProperty(GuildSettings.GUILD_DAMAGE)); return; } if (guildHandler.isAlly(damaged, damager)) { event.setCancelled(!settingsManager.getProperty(GuildSettings.ALLY_DAMAGE)); } }
Example #30
Source File: ProjectileTrailMatchModule.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onProjectileLaunch(ProjectileLaunchEvent event) { match.player(event.getActor()).ifPresent(shooter -> { final Projectile projectile = event.getEntity(); projectile.setMetadata(TRAIL_META, new FixedMetadataValue(PGM.get(), shooter.getParty().getFullColor())); // Set critical metadata to false in order to remove default particle trail. // The metadata will be restored just before the arrow hits something. if(projectile instanceof Arrow) { final Arrow arrow = (Arrow) projectile; arrow.setMetadata(CRITICAL_META, new FixedMetadataValue(PGM.get(), arrow.isCritical())); arrow.setCritical(false); } }); }