Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onPlayerDammage(EntityDamageEvent e){
- if(e.getCause().equals(DamageCause.FALL) || e.getCause().equals(DamageCause.FALLING_BLOCK)){
- Block a = e.getEntity().getLocation().add(0, -1, 0).getBlock();
- Block b = e.getEntity().getLocation().add(0, -2, 0).getBlock();
- if(a.getType().equals(Material.HAY_BLOCK) || b.getType().equals(Material.HAY_BLOCK)){
- e.setDamage(0D);
- }else{
- if(e.getEntity() instanceof Player){
- Player pl = (Player)e.getEntity();
- if(pl.isSneaking()){
- pl.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, Refrence.random.nextInt((int)(e.getDamage()*40+1)), 0, false));
- e.setDamage(e.getDamage() /2);
- }
- }
- }
- }else if( e.getEntity() instanceof Player
- && (e.getCause().equals(DamageCause.ENTITY_ATTACK) || e.getCause().equals(DamageCause.PROJECTILE))
- && !PlayerStats.getPlayerStats((Player)e.getEntity()).isInMission){
- e.setCancelled(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement