Java Code Examples for org.bukkit.event.entity.EntityDamageEvent#getEntityType()
The following examples show how to use
org.bukkit.event.entity.EntityDamageEvent#getEntityType() .
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: NoCleanListener.java From UhcCore with GNU General Public License v3.0 | 6 votes |
@EventHandler public void onPlayerDamage(EntityDamageEvent e){ if (e.getEntityType() != EntityType.PLAYER || e.isCancelled()){ return; } if ( e.getCause() != EntityDamageEvent.DamageCause.FIRE && e.getCause() != EntityDamageEvent.DamageCause.LAVA && e.getCause() != EntityDamageEvent.DamageCause.FIRE_TICK){ return; } Player player = (Player) e.getEntity(); if (pvpCooldown.containsKey(player.getUniqueId())){ if (pvpCooldown.get(player.getUniqueId()) > System.currentTimeMillis()){ e.setCancelled(true); } } }
Example 2
Source File: PlayerSneakListener.java From ViaVersion with MIT License | 6 votes |
@EventHandler(ignoreCancelled = true) public void playerDamage(EntityDamageEvent event) { if (!is1_14Fix) return; if (event.getCause() != EntityDamageEvent.DamageCause.SUFFOCATION) return; if (event.getEntityType() != EntityType.PLAYER) return; Player player = (Player) event.getEntity(); if (!sneakingUuids.contains(player.getUniqueId())) return; // Don't cancel when they should actually be suffocating; Essentially cancel when the head is in the top block only ever so slightly // ~0.041 should suffice, but gotta stay be safe double y = player.getEyeLocation().getY() + 0.045; y -= (int) y; if (y < 0.09) { event.setCancelled(true); } }
Example 3
Source File: Defender.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void damageHandler(EntityDamageEvent event) { if(event.getEntityType() == EntityType.PLAYER) { AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId()); if(p != null && p.getTeam() != null && !p.getTeam().isTeamDead() && p.getTeam().getNexus().getLocation() != null && p.getKit().equals(this)) { Player player = (Player)event.getEntity(); if(player.getLocation().distanceSquared(p.getTeam().getNexus().getLocation().toLocation()) <= 20*20) player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION,Integer.MAX_VALUE,0)); else player.removePotionEffect(PotionEffectType.REGENERATION); } } }
Example 4
Source File: Thor.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority= EventPriority.NORMAL) public void checkStrike(EntityDamageEvent event) { if(event.getEntityType() == EntityType.PLAYER && event.getCause() == DamageCause.LIGHTNING) { AnniPlayer player = AnniPlayer.getPlayer(event.getEntity().getUniqueId()); if(player != null && !player.getKit().equals(this)) { Object obj = player.getData("LH"); if(obj != null) { Long l = (Long)obj; if(System.currentTimeMillis()-l <= 30000) { event.setCancelled(true); player.setData("LH", null); return; } } event.setDamage(4); player.setData("LH", System.currentTimeMillis()); } } }
Example 5
Source File: BleedFeature.java From VoxelGamesLibv2 with MIT License | 5 votes |
@GameEvent public void onEntityDamage(EntityDamageEvent e) { if (e.getEntityType() == EntityType.PLAYER) { e.getEntity().getWorld().playEffect(e.getEntity().getLocation(), Effect.STEP_SOUND, Material.REDSTONE_WIRE); e.getEntity().playEffect(EntityEffect.HURT); } }
Example 6
Source File: VoidTeleportFeature.java From VoxelGamesLibv2 with MIT License | 5 votes |
@GameEvent public void onVoidDamage(@Nonnull EntityDamageEvent event) { if (event.getEntityType() != EntityType.PLAYER) return; if (event.getCause().equals(EntityDamageEvent.DamageCause.VOID)) { Player player = (Player) event.getEntity(); player.teleportAsync(getPhase().getFeature(SpawnFeature.class).getSpawn(player.getUniqueId())); event.setCancelled(true); } }
Example 7
Source File: Assassin.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void damageHandler(EntityDamageEvent event) { if(event.getEntityType() == EntityType.PLAYER) { AnniPlayer p = AnniPlayer.getPlayer(event.getEntity().getUniqueId()); if(p != null && p.getKit().equals(this) && p.getData("Cur") != null) { if(event.getCause() == DamageCause.FALL) event.setCancelled(true); else endLeap((Player)event.getEntity(),p); } } }
Example 8
Source File: InvisibilityListeners.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void playerDamageChecker(final EntityDamageEvent event) { if(event.getEntityType() == EntityType.PLAYER) { Player player = (Player)event.getEntity(); AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null) checkInvis(player); } }
Example 9
Source File: DamageControl.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(ignoreCancelled = true) public void immunityCheck(EntityDamageEvent event) { if(event.getEntityType() == EntityType.PLAYER) { if(hasImmunity(event.getEntity().getUniqueId(),event.getCause())) event.setCancelled(true); } }
Example 10
Source File: DeathStandsModule.java From UHC with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void on(EntityDamageEvent event) { if (event.getEntityType() != EntityType.ARMOR_STAND) return; if (!isProtectedArmourStand(event.getEntity())) return; // always cancel events, we choose when to break the stand event.setCancelled(true); final ArmorStand stand = (ArmorStand) event.getEntity(); final Location loc = stand.getLocation(); final World world = stand.getWorld(); // for the first 2 seconds don't allow breaking // to avoid accidental breaks after kill if (event.getEntity().getTicksLived() < 2 * TICKS_PER_SECOND) { world.playEffect(stand.getEyeLocation(), Effect.WITCH_MAGIC, 0); return; } // drop each of it's worn items for (final ItemStack stack : Maps.filterValues(getItems(stand), Predicates.not(EMPTY_ITEM)).values()) { world.dropItemNaturally(loc, stack); } // kill the stand now stand.remove(); }
Example 11
Source File: KeepHealth.java From HubBasics with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onDamage(EntityDamageEvent event) { if (event.getEntityType() != EntityType.PLAYER) return; String world = event.getEntity().getWorld().getName().toLowerCase(); Player player = (Player) event.getEntity(); if (this.worldHealthMap.containsKey(world)) { player.setHealth(this.worldHealthMap.get(world)); AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_MAX_HEALTH); if (attribute != null) { attribute.setBaseValue(this.worldMaxHealthMap.get(world)); } event.setCancelled(true); } }
Example 12
Source File: AntiVoid.java From HubBasics with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onVoidDamage(EntityDamageEvent event) { World world = event.getEntity().getWorld(); if (event.getCause() != EntityDamageEvent.DamageCause.VOID) return; if (event.getEntityType() != EntityType.PLAYER) return; Section worldConfiguration = getWorldConfiguration(world.getName()); if (worldConfiguration != null && isEnabledInWorld(world)) { HLocation location = HubBasics.getLocationManager().get(worldConfiguration.getString("Warp", null)); if (location == null) { event.getEntity().teleport(event.getEntity().getWorld().getSpawnLocation()); } else { location.teleport((Player) event.getEntity()); } } }
Example 13
Source File: KeepHealth.java From HubBasics with GNU Lesser General Public License v3.0 | 5 votes |
@EventHandler public void onDamage(EntityDamageEvent event) { if (event.getEntityType() != EntityType.PLAYER) return; String world = event.getEntity().getWorld().getName().toLowerCase(); Player player = (Player) event.getEntity(); if (this.worldHealthMap.containsKey(world)) { player.setHealth(this.worldHealthMap.get(world)); ReflectionUtils.invokeMethod(player, this.maxHealthMethod, this.worldMaxHealthMap.get(world)); event.setCancelled(true); } }
Example 14
Source File: SharedHealthListener.java From UhcCore with GNU General Public License v3.0 | 4 votes |
@EventHandler (priority = EventPriority.HIGH) public void onPlayerDamage(EntityDamageEvent e){ // Check if entity is player if (e.getEntityType() != EntityType.PLAYER){ return; } if (e.isCancelled()){ return; } // Check if GameState is Playing | Deathmatch GameState state = getGameManager().getGameState(); if (state != GameState.PLAYING && state != GameState.DEATHMATCH){ return; } UhcPlayer uhcPlayer = getPlayersManager().getUhcPlayer((Player) e.getEntity()); // Check if player is playing if (uhcPlayer.getState() != PlayerState.PLAYING){ return; } // If solo player don't share damage List<UhcPlayer> onlinePlayingMembers = uhcPlayer.getTeam().getOnlinePlayingMembers(); if (onlinePlayingMembers.size() <= 1){ return; } double damage = e.getDamage()/onlinePlayingMembers.size(); e.setDamage(damage); for (UhcPlayer uhcMember : onlinePlayingMembers){ if (uhcMember == uhcPlayer){ continue; } try { uhcMember.getPlayer().damage(damage); }catch (UhcPlayerNotOnlineException ex){ ex.printStackTrace(); } } }
Example 15
Source File: EventLocker.java From PlayerSQL with GNU General Public License v2.0 | 4 votes |
@EventHandler(ignoreCancelled = true, priority = HIGHEST) public void handle(EntityDamageEvent event) { if (event.getEntityType() == PLAYER && isLocked(event.getEntity().getUniqueId())) { event.setCancelled(true); } }