Java Code Examples for org.bukkit.entity.EntityType#PLAYER
The following examples show how to use
org.bukkit.entity.EntityType#PLAYER .
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: 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 2
Source File: Vampire.java From AnnihilationPro with MIT License | 6 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void damageHandler(EntityDamageByEntityEvent event) { if(event.getDamager().getType() == EntityType.PLAYER) { Player player = (Player)event.getDamager(); AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null && p.getKit().equals(this)) { if(rand.nextInt(3) == 1) { double health = player.getHealth()+1D; if(health > player.getMaxHealth()) health = player.getMaxHealth(); player.setHealth(health); } } } }
Example 3
Source File: EntityListener.java From BedwarsRel with GNU General Public License v3.0 | 6 votes |
@EventHandler(priority = EventPriority.HIGH) public void onRegainHealth(EntityRegainHealthEvent rhe) { if (rhe.getEntityType() != EntityType.PLAYER) { return; } Player player = (Player) rhe.getEntity(); Game game = BedwarsRel.getInstance().getGameManager().getGameOfPlayer(player); if (game == null) { return; } if (game.getState() != GameState.RUNNING) { return; } if (player.getHealth() >= player.getMaxHealth()) { game.setPlayerDamager(player, null); } }
Example 4
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 5
Source File: HorsesModule.java From UHC with MIT License | 5 votes |
@EventHandler public void on(EntityMountEvent event) { if (isEnabled() || event.getEntityType() != EntityType.PLAYER) return; if (event.getMount().getType() == EntityType.HORSE) { event.setCancelled(true); event.getEntity().sendMessage(messages.getRaw("disabled message")); } }
Example 6
Source File: Acrobat.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH) public void fallDamage(EntityDamageEvent event) { if(event.getEntity().getType() == EntityType.PLAYER && event.getCause() == DamageCause.FALL) { Player p = (Player)event.getEntity(); AnniPlayer pl = AnniPlayer.getPlayer(p.getUniqueId()); if(pl != null && pl.getKit().equals(this)) { event.setCancelled(true); } } }
Example 7
Source File: SeismicAxe.java From Slimefun4 with GNU General Public License v3.0 | 5 votes |
private void pushEntity(Player p, Entity entity) { Vector vector = entity.getLocation().toVector().subtract(p.getLocation().toVector()).normalize(); vector.multiply(STRENGTH); vector.setY(0.9); entity.setVelocity(vector); if (entity.getType() != EntityType.PLAYER || p.getWorld().getPVP()) { EntityDamageByEntityEvent event = new EntityDamageByEntityEvent(p, entity, DamageCause.ENTITY_ATTACK, 6D); Bukkit.getPluginManager().callEvent(event); if (!event.isCancelled()) { ((LivingEntity) entity).damage(DAMAGE); } } }
Example 8
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 9
Source File: Berserker.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.MONITOR) public void damageListener(final EntityDamageByEntityEvent event) { if(event.getEntity().getType() == EntityType.PLAYER && event.getDamager().getType() == EntityType.PLAYER) { Player one = (Player)event.getDamager(); AnniPlayer p = AnniPlayer.getPlayer(one.getUniqueId()); if(p != null && p.getKit().equals(this)) { if((one.getHealth() / one.getMaxHealth()) <= .42) event.setDamage(event.getDamage()+1); } } }
Example 10
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 11
Source File: Assassin.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) public void damageHandler(EntityDamageByEntityEvent event) { if(event.getDamager().getType() == EntityType.PLAYER) { Player player = (Player)event.getDamager(); AnniPlayer p = AnniPlayer.getPlayer(player.getUniqueId()); if(p != null && p.getKit().equals(this) && p.getData("Cur") != null) endLeap(player,p); } }
Example 12
Source File: Scout.java From AnnihilationPro with MIT License | 5 votes |
@EventHandler(priority = EventPriority.NORMAL) public void fallDamage(EntityDamageEvent event) { if(event.getEntity().getType() == EntityType.PLAYER && event.getCause() == DamageCause.FALL) { Player p = (Player)event.getEntity(); AnniPlayer pl = AnniPlayer.getPlayer(p.getUniqueId()); if(pl != null && pl.getKit().equals(this)) { event.setDamage(event.getDamage()/2); } } }
Example 13
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 14
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 15
Source File: LoveAtFirstSightListener.java From UhcCore with GNU General Public License v3.0 | 5 votes |
@EventHandler (priority = EventPriority.LOW) public void onPlayerDamage(EntityDamageByEntityEvent e){ if (e.getEntityType() != EntityType.PLAYER || !(e.getDamager() instanceof Player)){ return; } PlayersManager pm = getPlayersManager(); UhcPlayer uhcDamaged = pm.getUhcPlayer((Player) e.getEntity()); UhcPlayer uhcDamager = pm.getUhcPlayer((Player) e.getDamager()); if (getGameManager().getGameState() != GameState.PLAYING){ return; } if (uhcDamaged.getTeam().isFull() || uhcDamager.getTeam().isFull()){ return; // One of the teams is full so no team can be made } if (!uhcDamaged.getTeam().isSolo() && !uhcDamager.getTeam().isSolo()){ return; // Neither of the players are solo so a team can't be created } if (getTeamManager().getPlayingUhcTeams().size() <= 2){ return; // Only 2 teams left, don't team them up but let them first. } boolean result; if (uhcDamaged.getTeam().isSolo()){ // add to damager team result = addPlayerToTeam(uhcDamaged, uhcDamager.getTeam()); }else{ // add damager to damaged result = addPlayerToTeam(uhcDamager, uhcDamaged.getTeam()); } if (result){ e.setCancelled(true); } }
Example 16
Source File: UIListener.java From Shopkeepers with GNU General Public License v3.0 | 4 votes |
@EventHandler(priority = EventPriority.HIGHEST) void onInventoryClick(InventoryClickEvent event) { if (event.getWhoClicked().getType() != EntityType.PLAYER) return; final Player player = (Player) event.getWhoClicked(); UISession session = uiManager.getSession(player); if (session != null) { // inform uiHandler so that it can react to it: Inventory inventory = event.getInventory(); if (session.getUIHandler().isWindow(inventory)) { if (!session.getShopkeeper().isUIActive() || !session.getShopkeeper().isValid()) { // shopkeeper deleted, or the UIs got deactivated: ignore this click Log.debug("Inventory click by " + player.getName() + " ignored, because window is about to get close," + " or shopkeeper got deleted."); event.setCancelled(true); return; } // debug information: Log.debug("Player " + player.getName() + " clicked: raw slot id=" + event.getRawSlot() + ", slot id=" + event.getSlot() + ", slot type=" + event.getSlotType().name() + ", shift=" + event.isShiftClick() + ", left or right=" + (event.isLeftClick() ? "left" : (event.isRightClick() ? "right" : "unknown")) + ", action=" + event.getAction().name()); // let the UIHandler handle the click: session.getUIHandler().onInventoryClick(event, player); } else { // the player probably has some other inventory open, but an active session.. let's close it: Log.debug("Closing inventory for " + player.getName() + ", because different open inventory was expected." + " Open inventory name: " + inventory.getName()); event.setCancelled(true); Bukkit.getScheduler().runTaskLater(ShopkeepersPlugin.getInstance(), new Runnable() { @Override public void run() { uiManager.onInventoryClose(player); // cleanup player.closeInventory(); } }, 1L); } } }
Example 17
Source File: CancellableChunkEvents.java From ClaimChunk with MIT License | 4 votes |
@EventHandler public void onItemFrameBroken(HangingBreakByEntityEvent e) { if (e != null && e.getRemover() != null && e.getRemover().getType() == EntityType.PLAYER) { ChunkEventHelper.handleBlockEvent((Player) e.getRemover(), e.getEntity().getLocation().getChunk(), e); } }
Example 18
Source File: CraftPlayer.java From Thermos with GNU General Public License v3.0 | 4 votes |
@Override public EntityType getType() { return EntityType.PLAYER; }
Example 19
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 20
Source File: CraftPlayer.java From Kettle with GNU General Public License v3.0 | 4 votes |
@Override public EntityType getType() { return EntityType.PLAYER; }