Exemplo n.º 1
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onEntityDamageByEntity(final EntityDamageByEntityEvent e) {
   Entity ent = e.getEntity();
   Entity entDamager = e.getDamager();
   if ((ent instanceof Player) && (entDamager instanceof Player)) {
     GamePlayer rmp = GamePlayer.getPlayerByName(((Player) ent).getName());
     GamePlayer rmpDamager = GamePlayer.getPlayerByName(((Player) entDamager).getName());
     if ((rmp != null) && (rmpDamager != null)) {
       if ((rmp.isIngame()) && (rmpDamager.isIngame())) {
         GameConfig config = rmp.getGame().getGameConfig();
         Timer pvpTimer = config.getPvpTimer();
         if (!config.getSettingBool(Setting.allowpvp)) {
           e.setCancelled(true);
         } else if (rmp.getTeam() == rmpDamager.getTeam()) {
           if (!config.getSettingBool(Setting.friendlyfire)) {
             e.setCancelled(true);
           }
         } else if ((rmp.isSafe()) || (rmpDamager.isSafe())) {
           e.setCancelled(true);
           rmpDamager.sendMessage(Text.getLabel("game.safezone.pvp"));
         } else if ((pvpTimer.isSet()) && (pvpTimer.isTicking())) {
           e.setCancelled(true);
           // rmpDamager.sendMessage(RMText.getLabelArgs("game.pvp.delay",
           // pvpTimer.getTextTimeRemaining()));
           rmpDamager.sendMessage(Text.getLabelArgs("game.pvp.disabled"));
         }
       }
     }
   }
 }
Exemplo n.º 2
0
 public static void parryCheck(EntityDamageByEntityEvent event, Player defender) {
   Entity y = event.getDamager();
   PlayerProfile PPd = Users.getProfile(defender);
   if (defender != null
       && Utils.isSword(defender.getItemInHand())
       && mcPermissions.skillPermission(SkillType.SWORDS, defender)) {
     if (PPd.getSkillLevel(SkillType.SWORDS) >= 900) {
       if (Math.random() * 3000 <= 900) {
         event.setCancelled(true);
         defender.sendMessage(ChatColor.GREEN + "**PARRIED**");
         defender
             .getItemInHand()
             .setDurability((short) (defender.getItemInHand().getDurability() + 1));
         if (y instanceof Player) {
           Player attacker = (Player) y;
           attacker.sendMessage(ChatColor.GREEN + "**PARRIED**");
         }
       }
     } else {
       if (Math.random() * 3000 <= PPd.getSkillLevel(SkillType.SWORDS)) {
         event.setCancelled(true);
         defender.sendMessage(ChatColor.YELLOW + "*CLANG* SUCCESSFUL PARRY *CLANG*");
         defender
             .getItemInHand()
             .setDurability((short) (defender.getItemInHand().getDurability() + 1));
         if (y instanceof Player) {
           Player attacker = (Player) y;
           attacker.sendMessage(ChatColor.DARK_RED + "**TARGET HAS PARRIED THAT ATTACK**");
         }
       }
     }
   }
 }
Exemplo n.º 3
0
 @EventHandler
 public void slendernoattack(EntityDamageByEntityEvent e) {
   if (e.getDamager() == slender.slenderman && e.getEntity() instanceof Player) {
     e.setCancelled(true);
   }
   if (e.getEntity() == slender.slenderman) {
     e.setCancelled(true);
   }
 }
  public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    Entity attacker = event.getDamager();
    Entity defender = event.getEntity();

    if (defender instanceof Player) {
      Player player = (Player) defender;

      GlobalConfiguration cfg = plugin.getGlobalConfiguration();
      WorldConfiguration wcfg = cfg.getWorldConfig(player.getWorld().getName());

      if (cfg.isInvinciblePlayer(player.getName())) {
        event.setCancelled(true);
        return;
      }

      if (attacker != null && attacker instanceof Player) {
        if (wcfg.useRegions) {
          Vector pt = toVector(defender.getLocation());
          RegionManager mgr =
              plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());

          if (!mgr.getApplicableRegions(pt).isStateFlagAllowed(Flags.PVP)) {
            ((Player) attacker).sendMessage(ChatColor.DARK_RED + "You are in a no-PvP area.");
            event.setCancelled(true);
            return;
          }
        }
      }

      if (attacker != null && attacker instanceof Monster) {
        if (attacker instanceof Creeper && wcfg.blockCreeperExplosions) {
          event.setCancelled(true);
          return;
        }

        if (wcfg.useRegions) {
          Vector pt = toVector(defender.getLocation());
          RegionManager mgr =
              plugin.getGlobalRegionManager().getRegionManager(player.getWorld().getName());
          ApplicableRegionSet set = mgr.getApplicableRegions(pt);

          if (!set.isStateFlagAllowed(Flags.MOB_DAMAGE)) {
            event.setCancelled(true);
            return;
          }

          if (attacker instanceof Creeper) {
            if (!set.isStateFlagAllowed(Flags.CREEPER_EXPLOSION)) {
              event.setCancelled(true);
              return;
            }
          }
        }
      }
    }
  }
 @EventHandler
 public final void onEntityDamage(final EntityDamageByEntityEvent event) {
   final Entity entity = event.getEntity();
   Entity damager = EntityUtils.getTopLevel(event.getDamager());
   if (damager instanceof Player) {
     if (entity instanceof Player) {
       event.setCancelled(pvp((Player) damager, (Player) entity));
     } else {
       event.setCancelled(pve((Player) damager, entity));
     }
   }
 }
  /**
   * Entity damaged by another entity event. Cancels the event and sends damager a message if either
   * damager or attacked player have not enabled PvP
   *
   * @param event event being handled
   */
  @EventHandler(priority = EventPriority.LOWEST, ignoreCancelled = true)
  public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
    if (event.getEntity() instanceof Player) {
      final Player attackedPlayer = (Player) event.getEntity();
      final Player attacker;

      if (event.getDamager() instanceof Player) {
        attacker = (Player) event.getDamager();
      } else if (event.getDamager() instanceof Projectile) {
        if (((Projectile) event.getDamager()).getShooter() instanceof Player) {
          attacker = (Player) ((Projectile) event.getDamager()).getShooter();
        } else {
          return;
        }
      } else {
        return;
      }

      final World world = attacker.getWorld();
      final Localisation localisation = plugin.getLocalisation();
      if (PVPConfigUtils.getPlayerStatus(attacker, world, plugin)) {
        if (PVPConfigUtils.getPlayerStatus(attackedPlayer, world, plugin)) {
          LastPVPActionTimeConfigUtils.update(attacker, world, plugin);
          if (DebugConfigUtils.getDebugEnabled(plugin)) {
            attacker.sendMessage(
                localisation.get(
                    LocalisationEntry.DEBUG_ATTACKED_PLAYER,
                    new Object[] {attackedPlayer.getDisplayName(), event.getDamage()}));
            attackedPlayer.sendMessage(
                localisation.get(
                    LocalisationEntry.DEBUG_ATTACKED_BY_PLAYER,
                    new Object[] {attacker.getDisplayName(), event.getDamage()}));
          }
        } else {
          event.setCancelled(true);
          attacker.sendMessage(
              localisation.get(
                  LocalisationEntry.MSG_ATTACK_CANCELLED_PLAYER_DOES_NOT_HAVE_PVP_ENABLED,
                  new Object[] {attackedPlayer.getDisplayName()}));
        }
      } else {
        event.setCancelled(true);
        attacker.sendMessage(
            localisation.get(LocalisationEntry.MSG_ATTACK_CANCELLED_PVP_NOT_ENABLED));
      }

      // Stop arrows bouncing back, possibly hitting you.
      if ((event.isCancelled()) && (event.getDamager() instanceof Projectile)) {
        ((Projectile) event.getDamager()).setBounce(false);
      }
    }
  }
Exemplo n.º 7
0
  // prevent damage from frozen players / prevent friendly fire / prevent killing frozen players
  @EventHandler
  public void onPlayerDamage_frozen_damage(EntityDamageByEntityEvent event) {
    Entity victim_entity = event.getEntity();
    Entity damager_entity = event.getDamager();
    if (victim_entity instanceof Player) {
      if (damager_entity instanceof Player) {
        Player victim = (Player) victim_entity;
        Player damager = (Player) damager_entity;
        if (plugin.frozen.contains(victim.getName())) {
          event.setCancelled(true);
        }

        // disable FF for red team
        if (plugin.wsred.containsValue(victim.getName())) {
          if (plugin.frozenred.contains(victim.getName())) {
            if (plugin.wsred.containsValue(damager.getName())) {
              // do nothing - unfreezeing process
            } else {
              event.setCancelled(true);
              // disables other people to harm frozen people
            }
          } else {
            if (plugin.wsred.containsValue(damager.getName())) {
              event.setCancelled(true);
              // disables friendly fire
            }
          }
        }

        // disable FF for green team
        else if (plugin.wsgreen.containsValue(victim.getName())) {
          if (plugin.frozengreen.contains(victim.getName())) {
            if (plugin.wsgreen.containsValue(damager.getName())) {
              // do nothing - unfreezeing process
            } else {
              event.setCancelled(true);
              // disables other people to harm frozen people
            }
          } else {
            if (plugin.wsgreen.containsValue(damager.getName())) {
              event.setCancelled(true);
              // disables friendly fire
            }
          }
        }
      } else {
        return;
      }
    }
  }
Exemplo n.º 8
0
 @EventHandler
 public void SpectatorPvP(EntityDamageByEntityEvent event) {
   Entity offense = event.getDamager();
   if (offense instanceof Player) {
     Player Attacker = (Player) event.getDamager();
     String attackerName = Attacker.getName();
     for (i = 0; i < plugin.Watching.size(); i++) {
       if (plugin.Watching.get(i) != null) {
         if (plugin.Watching.get(i).contains(attackerName)) {
           event.setCancelled(true);
           Attacker.sendMessage(
               ChatColor.RED + "You are spectating, you can't interfere with the game!");
           return;
         }
       }
     }
     for (i = 0; i < plugin.Playing.size(); i++) {
       if (plugin.Playing.get(i) != null) {
         if (plugin.Playing.get(i).contains(attackerName)) {
           event.setCancelled(true);
         }
       }
     }
   } else if (event.getDamager() instanceof Projectile) {
     Projectile arrow = (Projectile) offense;
     if (arrow.getShooter() instanceof Player) {
       Player BowMan = (Player) arrow.getShooter();
       String bowManName = BowMan.getName();
       for (i = 0; i < plugin.Watching.size(); i++) {
         if (plugin.Watching.get(i) != null) {
           if (plugin.Watching.get(i).contains(bowManName)) {
             event.setCancelled(true);
             BowMan.sendMessage(
                 ChatColor.RED + "You are spectating, you can't interfere with the game!");
             return;
           }
         }
       }
       for (i = 0; i < plugin.Playing.size(); i++) {
         if (plugin.Playing.get(i) != null) {
           if (plugin.Playing.get(i).contains(bowManName)) {
             event.setCancelled(true);
           }
         }
       }
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent ede) {
    List<EntityType> canDamageTypes = new ArrayList<EntityType>();
    canDamageTypes.add(EntityType.PLAYER);

    if (Main.getInstance().getServer().getPluginManager().isPluginEnabled("AntiAura")) {
      canDamageTypes.add(EntityType.SQUID);
    }

    if (canDamageTypes.contains(ede.getEntityType())) {
      return;
    }

    Game game =
        Main.getInstance().getGameManager().getGameByLocation(ede.getEntity().getLocation());
    if (game == null) {
      return;
    }

    if (game.getState() == GameState.STOPPED) {
      return;
    }

    ede.setCancelled(true);
  }
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (!(event.getEntity() instanceof Player && event.getDamager() instanceof Player))
     return; // We only want to check this if players hit each other
   final Player attacker = (Player) event.getDamager();
   if (attacker.getInventory().getHeldItemSlot() != 8) return;
   final Player victim = (Player) event.getEntity();
   if (AbilityManager.getInstance().getCurrentSpell(attacker) instanceof AbilityHealing) {
     event.setCancelled(true);
     victim.setHealth(victim.getMaxHealth());
     ParticleEffect.HEART.display(
         Vector.getRandom(), 1, victim.getEyeLocation().add(0, 0, .25), Bukkit.getOnlinePlayers());
   }
   if (!(AbilityManager.getInstance().getCurrentSpell(attacker) instanceof AbilityHeartripping))
     return; // Make sure the person punching has heartripping active
   if (!AbilityManager.getInstance().getCurrentSpell(attacker).canUse(attacker)) return;
   if (victim.hasPermission("heart.block")) {
     ChatManager.messageBad(attacker, "That player is too powerful!");
     ChatManager.messageGood(
         victim, attacker.getName() + " attempted to rip out your heart but was too weak!");
     return;
   }
   if (!spellSelection.containsKey(attacker) || !spellSelection.get(attacker).equals(victim)) {
     ChatManager.messageGood(
         attacker, "You ripped " + victim.getName() + "'s heart out of their body!");
     ChatManager.messageBad(
         victim, attacker.getName() + " has ripped your heart out of your body!");
     spellSelection.put(attacker, victim);
   }
   attacker.getInventory().setItemInMainHand(getValidBook(attacker));
 }
Exemplo n.º 11
0
 @EventHandler
 public void onPlayerAttack(EntityDamageByEntityEvent e) {
   if (e.getDamager() instanceof Player) {
     Player p = (Player) e.getDamager();
     if (ArenaManager.getInstance().getArena(p) != null) e.setCancelled(true);
   }
 }
Exemplo n.º 12
0
  /**
   * Monitor EntityDamageByEntity events.
   *
   * @param event The event to monitor
   */
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (event instanceof FakeEntityDamageByEntityEvent) {
      return;
    }

    Entity defender = event.getEntity();
    Entity attacker = event.getDamager();

    if (attacker instanceof Player && defender instanceof Player) {
      if (!defender.getWorld().getPVP()) {
        return;
      }

      if (Party.getInstance().inSameParty((Player) defender, (Player) attacker)) {
        event.setCancelled(true);
        return;
      }
    }

    /* Check for invincibility */
    if (defender instanceof LivingEntity) {
      LivingEntity livingDefender = (LivingEntity) defender;

      if (!m.isInvincible(livingDefender, event)) {
        // Make sure event isn't cancelled before trying to proc?
        if (!event.isCancelled()) Combat.combatChecks(event, plugin);
      }
    }
  }
Exemplo n.º 13
0
 @EventHandler
 public void onDammange(EntityDamageByEntityEvent event) {
   Entity dammage = event.getEntity();
   if (dammage.getType() == EntityType.ENDER_CRYSTAL) {
     event.setCancelled(true);
   }
 }
Exemplo n.º 14
0
  @EventHandler
  public void onEntityDamageByEntity(EntityDamageByEntityEvent e) {
    if (e.getEntity() instanceof org.bukkit.entity.Player) {
      Player entity = Arcade.getServer().getPlayer(e.getEntity().getUniqueId());
      if (!entity.getTeam().isFrendlyFire()) {
        return;
      }
      Player damager = null;
      Projectile projectile = null;

      if (e.getDamager() instanceof org.bukkit.entity.Player) { // Player vs player direct
        damager = Arcade.getServer().getPlayer(e.getDamager().getUniqueId());
      } else if (e.getDamager() instanceof Projectile
          && ((Projectile) e.getDamager()).getShooter()
              instanceof org.bukkit.entity.Player) { // Arrows, snowballs, etc...
        projectile = (Projectile) e.getDamager();
        damager =
            Arcade.getServer()
                .getPlayer(((org.bukkit.entity.Player) projectile.getShooter()).getUniqueId());
      }

      if (damager != null && entity.getTeam().equals(damager.getTeam())) {
        e.setCancelled(true);
      }
      if (projectile != null) {
        projectile.setBounce(true);
      }
    }
  }
Exemplo n.º 15
0
  @Override
  public boolean onDamageOther(EntityDamageByEntityEvent e, Player p, int level) {
    if (e.getEntity() instanceof LivingEntity) {
      LivingEntity le = (LivingEntity) e.getEntity();

      try {
        fireworks.playFirework(
            le.getWorld(),
            le.getLocation(),
            FireworkEffect.builder().with(Type.BURST).withColor(Color.WHITE).build());
      } catch (Exception ex) {
        Logger.getLogger(Burst.class.getName()).log(Level.SEVERE, null, ex);
      }

      Vector unitVector =
          le.getLocation().toVector().subtract(e.getDamager().getLocation().toVector()).normalize();

      unitVector.setY(0.55 / level);

      le.setVelocity(unitVector.multiply(level * 2));

      e.setCancelled(true);

      return true;
    }
    return false;
  }
Exemplo n.º 16
0
 @EventHandler(ignoreCancelled = true)
 public void CreatureExplosion(final EntityDamageByEntityEvent event) {
   if (plugin.isMonsterExplosionDamageEnabled()
       || event.getCause() != DamageCause.ENTITY_EXPLOSION) return;
   if (!(event.getEntity() instanceof Monster)) return;
   if (event.getDamager() instanceof TNTPrimed) return;
   event.setCancelled(true);
 }
 @EventHandler
 public void combatEvent(EntityDamageByEntityEvent e) {
   if (PlayerOnlineListener.min_players_yet == false) {
     e.setCancelled(true);
   } else {
     return;
   }
 }
Exemplo n.º 18
0
  @EventHandler(priority = EventPriority.HIGHEST)
  private void onPlayerDamage(EntityDamageByEntityEvent evt) {
    if (evt.getEntity() instanceof Player && evt.getDamager() instanceof Player) {
      Player player = (Player) evt.getEntity();
      PlayerDataClass playerData = plugin.getPlayerHandler().findPlayer(player.getDisplayName());
      Player attacker = (Player) evt.getDamager();
      PlayerDataClass attackerData =
          plugin.getPlayerHandler().findPlayer(attacker.getDisplayName());

      if (attackerData != null && playerData != null) {
        if (attackerData.getTeam() == playerData.getTeam()) {
          evt.setCancelled(true);
          return;
        }

        if (attackerData.getType().equals("spy")) {
          plugin.getLogger().info("Logged knife stab");
          if (plugin
              .getUtilities()
              .checkPlayerInCone(
                  player, attacker.getLocation(), 4, 80, (int) attacker.getLocation().getYaw())) {
            plugin.getLogger().info(attackerData.getName() + " behind " + playerData.getName());
          }
        }
      } else {
        evt.setCancelled(true);
      }
    }

    if (evt.getDamager() instanceof Arrow) {
      Arrow arrow = (Arrow) evt.getDamager();
      Player attacker = (Player) arrow.getShooter();
      PlayerDataClass attackerData =
          plugin.getPlayerHandler().findPlayer(attacker.getDisplayName());

      Player player = (Player) evt.getEntity();
      PlayerDataClass playerData = plugin.getPlayerHandler().findPlayer(player.getDisplayName());

      if (attackerData != null && playerData != null) {
        if (attackerData.getTeam() == playerData.getTeam()) {
          evt.setCancelled(true);
        }
      }
    }
  }
Exemplo n.º 19
0
  @EventHandler
  public void onPlayerAttack(EntityDamageByEntityEvent event) {
    Entity att = event.getDamager();
    Entity ent = event.getEntity();

    if (ent instanceof Player && att instanceof Player)
      if (plugin.spectators.contains(((Player) att).getName()) || Main.lobbyBoolean)
        event.setCancelled(true);
  }
Exemplo n.º 20
0
 @EventHandler
 public void onDamage(EntityDamageByEntityEvent event) {
   if (event.getDamager() instanceof Player && hasAbility((Player) event.getDamager())) {
     Player p = (Player) event.getDamager();
     if (p.isSneaking() && (!needToBlock || p.isBlocking())) {
       event.setCancelled(true);
     }
   }
 }
Exemplo n.º 21
0
  @EventHandler(priority = EventPriority.HIGH)
  public void removeItemFromFrame(EntityDamageByEntityEvent event) {
    Entity victim = event.getEntity();

    if (!victim.getType().equals(EntityType.ITEM_FRAME)) {
      return;
    }
    Player p;
    Entity attacker = event.getDamager();
    // System.out.println("Attacker: "+attacker.getType().toString());
    if (attacker.getType().toString().equals("PLAYER")) {
      p = (Player) attacker;

      OwnedLand land = OwnedLand.getApplicableLand(victim.getLocation());
      if (land == null) {
        return;
      }
      if (!land.hasPermTo(p, this)) {
        p.sendMessage(
            ChatColor.RED
                + getPlugin().getMessageConfig().getString("event.build.itemFrameRemoveWithMelee"));
        event.setCancelled(true);
      }

    } else if (attacker.getType().toString().equals("ARROW")) {
      Arrow a = (Arrow) attacker;
      if (a.getShooter() instanceof Player) {
        p = (Player) a.getShooter();
      } else {
        return;
      }

      OwnedLand land = OwnedLand.getApplicableLand(victim.getLocation());
      if (land == null) {
        return;
      }
      if (!land.hasPermTo(p, this)) {
        p.sendMessage(
            ChatColor.RED
                + getPlugin().getMessageConfig().getString("event.build.itemFrameRemoveWithArrow"));
        event.setCancelled(true);
      }
    }
  }
 @EventHandler
 public void onPlayerDamage(EntityDamageByEntityEvent event) {
   if (VAR.config.getBoolean("enableRules")) {
     if (event.getDamager() instanceof Player) {
       String name = getPlayerByID(event.getDamager().getEntityId());
       if (!VAR.pLog
           .getString("players." + name + ".Has accepted rules")
           .equalsIgnoreCase("true")) {
         if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("damageothers")) {
           String msg = VAR.config.getString("RulesNotAcceptedMsg");
           msg = ip.replace(msg, Bukkit.getServer().getPlayer(name));
           Bukkit.getServer().getPlayer(name).sendMessage(msg);
           event.setCancelled(true);
           return;
         }
       }
       if (event.getEntity() instanceof Player) {
         String damagedName = getPlayerByID(event.getEntity().getEntityId());
         if (!VAR.pLog
             .getString("players." + damagedName + ".Has accepted rules")
             .equalsIgnoreCase("true")) {
           if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("damageself")) {
             String msg = VAR.config.getString("RulesNotAcceptedDmgSelfMsg");
             msg = ip.replace(msg, Bukkit.getServer().getPlayer(name));
             Bukkit.getServer().getPlayer(name).sendMessage(msg);
             event.setCancelled(true);
             return;
           }
         }
       }
     }
     if (event.getEntity() instanceof Player) {
       String name = getPlayerByID(event.getEntity().getEntityId());
       if (!VAR.pLog
           .getString("players." + name + ".Has accepted rules")
           .equalsIgnoreCase("true")) {
         if (VAR.config.getString("PreventNotAccepted").toLowerCase().contains("damageself")) {
           event.setCancelled(true);
           return;
         }
       }
     }
   }
 }
Exemplo n.º 23
0
 @EventHandler(ignoreCancelled = true)
 public void damage(EntityDamageByEntityEvent event) {
   if (!event.getEntity().getWorld().getName().equals(getName())) return;
   if (event.getEntity() instanceof Player && event.getDamager() instanceof Player) {
     Player p = (Player) event.getEntity();
     if (!p1.equals(p.getName())
         && !p2.equals(p.getName())
         && !p3.equals(p.getName())
         && !p4.equals(p.getName())) {
       event.setCancelled(true);
       ((Player) event.getDamager())
           .sendMessage(ChatColor.RED + "Please wait until you are selected before fighting!");
     } else if (acc) {
       event.setCancelled(true);
       ((Player) event.getDamager())
           .sendMessage(ChatColor.RED + "Please wait until you are selected before fighting!");
     }
   }
 }
  @EventHandler(priority = EventPriority.HIGHEST)
  public void onEntityDamageByEntity(EntityDamageByEntityEvent event) {
    if (event.isCancelled()) return;

    final Entity target = event.getEntity();

    Player attacker = null;
    if (event.getDamager() instanceof Player) {
      attacker = (Player) event.getDamager();
    } else if (event.getDamager() instanceof Projectile) {
      if (((Projectile) event.getDamager()).getShooter() instanceof Player)
        attacker = (Player) ((Projectile) event.getDamager()).getShooter();
    }

    if (target != null && attacker != null) {
      plugin.debug("Attacker: " + attacker + ", Target: " + target + "");

      if (attacker.getWorld() != plugin.getIslandWorld()) return;
      if (attacker.isOp()) return;
      if (attacker.hasPermission("islandworld.bypass.damage")) return;

      if (target instanceof Player) {
        if (!Config.FLAG_PVP) event.setCancelled(true);
      } else {
        if (target instanceof ItemFrame) {
          if (!plugin.canBuildOnLocation(attacker, target.getLocation())) event.setCancelled(true);
        } else if (target instanceof Monster || target instanceof WaterMob) {
          if (plugin.canBuildOnLocation(attacker, target.getLocation())
              || plugin.getConfig().getBoolean("flags.kill-monster", false)) {
          } else {
            event.setCancelled(true);
          }
        } else if (target instanceof Animals || target instanceof NPC) {
          if (plugin.canBuildOnLocation(attacker, target.getLocation())
              || plugin.getConfig().getBoolean("flags.kill-animals", false)) {
          } else {
            event.setCancelled(true);
          }
        }
      }
    }
    plugin.debug("Event :" + event.getEventName() + ", cancelled:" + event.isCancelled());
  }
Exemplo n.º 25
0
  @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
  public void onEntityDamageByEntityHighest(EntityDamageByEntityEvent event) {
    Player attacker = getPlayer(event.getDamager());
    if (attacker == null) return;

    Player defender = getPlayer(event.getEntity());
    if (defender == null) return;

    ArenaPlayer ap = plugin.getArenaPlayer(attacker);
    if (ap != null) {
      ArenaPlayer dp = plugin.getArenaPlayer(defender);
      if (dp != null) {
        Arena arena = ap.getArena();
        if (arena.isInLobby()) {
          // Prevent lobby PvP
          ap.sendMessage("&cYou cannot PvP in the lobby!");
          event.setCancelled(true);
          return;
        }

        // Prevent team killing
        if (!arena.isAllowTeamKilling()) {
          if (dp.getTeam() == ap.getTeam()) {
            ap.sendMessage("&cYou cannot hurt your team mate!");
            event.setCancelled(true);
            return;
          }
        }
      } else {
        ap.sendMessage("&cYou cannot hurt players not in the arena!");
        event.setCancelled(true);
        return;
      }
    } else {
      if (plugin.isInArena(defender)) {
        attacker.sendMessage(
            plugin.getPrefix()
                + FormatUtil.format("&cYou cannot hurt players while they are in an arena!"));
        event.setCancelled(true);
        return;
      }
    }
  }
Exemplo n.º 26
0
 @EventHandler
 private void preventDamage(EntityDamageByEntityEvent event) {
   if (checkRules(event.getEntity().getWorld())) {
     if (event.getEntity() instanceof Horse) {
       if (playerDamage(event)) {
         event.setCancelled(true);
       }
     }
   }
 }
  @EventHandler
  public void onEntityDamageByEntityEvent(EntityDamageByEntityEvent event) {
    if (!isEnabled()) return;

    if ((event.getEntity() instanceof Player)
        && event.getDamager().getType().getName() == null
        && !getProtectionManager().CanDamage((Player) event.getEntity())) {
      event.setCancelled(true);
    }
  }
Exemplo n.º 28
0
  @Override
  public void spellEvent(EntityDamageByEntityEvent event, Player target) {
    Player player = (Player) event.getDamager();
    SuperNPlayer snplayer = SuperNManager.get(player);
    Material itemMaterial = player.getItemInHand().getType();

    boolean cancelled = false;

    if (player.getItemInHand() == null) {
      return;
    }

    if (itemMaterial != null) {
      if (SNConfigHandler.priestSpellMaterials.contains(itemMaterial)) {
        if (itemMaterial.equals(SNConfigHandler.priestSpellMaterials.get(0))) {
          banish(player, target);
          cancelled = true;
        } else if (itemMaterial.equals(SNConfigHandler.priestSpellMaterials.get(1))) {
          exorcise(player, target);
          cancelled = true;
        } else if (itemMaterial.equals(SNConfigHandler.priestSpellMaterials.get(2))) {
          cancelled = cure(player, target, itemMaterial);
        } else if (itemMaterial.equals(SNConfigHandler.priestSpellMaterials.get(3))) {
          cancelled = heal(player, target);
        } else if (itemMaterial.equals(SNConfigHandler.priestSpellMaterials.get(4))) {
          drainPower(player, target);
          cancelled = true;
        }
        if (!event.isCancelled()) {
          event.setCancelled(cancelled);
        }
      } else if (itemMaterial
          .toString()
          .equalsIgnoreCase(SNConfigHandler.priestSpellGuardianAngel)) {
        cancelled = guardianAngel(player, target);
        if (!event.isCancelled()) {
          event.setCancelled(cancelled);
        }
      } else if (itemMaterial.equals(Material.BOWL)) {
        remoteDonations(player);
      }
    }
  }
Exemplo n.º 29
0
 // Think i fixed
 @EventHandler
 public void onJump(EntityDamageByEntityEvent e) {
   Entity ev = e.getEntity();
   if (ev instanceof Player) {
     Player player = (Player) e.getEntity();
     if (player.getLocation().getBlock().getRelative(0, -1, 0).isEmpty()) {
       e.setCancelled(true);
     }
   }
 }
Exemplo n.º 30
0
 @Override
 public void onEntityDamage(EntityDamageEvent event) {
   if (!(event instanceof EntityDamageByEntityEvent)) return;
   EntityDamageByEntityEvent e = (EntityDamageByEntityEvent) event;
   if (e.getEntity() instanceof Player
       && e.getDamager() instanceof Player
       && NPCManager.getNPC(e.getEntity()) != null) {
     e.setCancelled(true);
   }
 }