Exemplo n.º 1
0
 @EventHandler(priority = EventPriority.NORMAL)
 public void onSplashPotion(PotionSplashEvent event) {
   if (event.isCancelled()) return;
   Entity ent = event.getEntity();
   boolean srcpvp = Residence.getPermsByLoc(ent.getLocation()).has("pvp", true);
   Iterator<LivingEntity> it = event.getAffectedEntities().iterator();
   while (it.hasNext()) {
     LivingEntity target = it.next();
     if (target.getType() == EntityType.PLAYER) {
       Boolean tgtpvp = Residence.getPermsByLoc(target.getLocation()).has("pvp", true);
       if (!srcpvp || !tgtpvp) {
         event.setIntensity(target, 0);
       }
     }
   }
 }
Exemplo n.º 2
0
  @EventHandler(priority = EventPriority.MONITOR)
  public void onPotionSplash(PotionSplashEvent event) {
    if (event.isCancelled() == false && !worlds.contains(event.getPotion().getWorld().getName())) {
      ThrownPotion potion = event.getPotion();

      for (Entity e : event.getAffectedEntities()) {
        if (e instanceof Player) {
          Player p = (Player) e;
          playerStatManager
              .getPlayerBlob(p.getName())
              .getStat("potions", "splashhit")
              .incrementStat(1);
          // added per potion details
          for (PotionEffect potionEffect : potion.getEffects()) {
            String effect = potionEffect.getType().toString().toLowerCase().replaceAll("_", "");
            playerStatManager
                .getPlayerBlob(p.getName())
                .getStat("potions", "splash" + effect)
                .incrementStat(1);
          }
        }
      }
    }
  }