Exemplo n.º 1
0
 @Override
 public boolean standsOnEntity(
     final Entity entity,
     final double minX,
     final double minY,
     final double minZ,
     final double maxX,
     final double maxY,
     final double maxZ) {
   try {
     // TODO: Probably check other ids too before doing this ?
     for (final Entity other : entity.getNearbyEntities(2.0, 2.0, 2.0)) {
       final EntityType type = other.getType();
       if (type != EntityType.BOAT) { //  && !(other instanceof Minecart))
         continue;
       }
       final double locY = entity.getLocation(useLoc).getY();
       useLoc.setWorld(null);
       if (Math.abs(locY - minY) < 0.7) {
         // TODO: A "better" estimate is possible, though some more tolerance would be good.
         return true;
       } else return false;
     }
   } catch (Throwable t) {
     // Ignore exceptions (Context: DisguiseCraft).
   }
   return false;
 }
Exemplo n.º 2
0
  public List<MCEntity> getNearbyEntities(double x, double y, double z) {
    List<Entity> lst = e.getNearbyEntities(x, y, z);
    List<MCEntity> retn = new ArrayList<MCEntity>();

    for (Entity e : lst) {
      retn.add(BukkitConvertor.BukkitGetCorrectEntity(e));
    }

    return retn;
  }
Exemplo n.º 3
0
 @Override
 public void doPickupAnimation(Entity entity, Entity target) {
   for (Entity p : target.getNearbyEntities(10, 10, 10)) {
     if (p instanceof Player) {
       ((CraftPlayer) p)
           .getHandle()
           .playerConnection
           .sendPacket(new PacketPlayOutCollect(target.getEntityId(), entity.getEntityId()));
     }
   }
 }
  private void aoe(Entity projectile, ProjectileInfo info) {
    playSpellEffects(EffectPosition.SPECIAL, projectile.getLocation());
    List<Entity> entities = projectile.getNearbyEntities(aoeRadius, aoeRadius, aoeRadius);
    for (Entity entity : entities) {
      if (entity instanceof LivingEntity
          && (targetPlayers || !(entity instanceof Player))
          && !entity.equals(info.player)) {
        LivingEntity target = (LivingEntity) entity;
        float power = info.power;

        // call target event
        SpellTargetEvent evt = new SpellTargetEvent(this, info.player, target, power);
        Bukkit.getPluginManager().callEvent(evt);
        if (evt.isCancelled()) {
          continue;
        } else if (allowTargetChange) {
          target = evt.getTarget();
        }
        power = evt.getPower();

        // run spells
        for (Subspell spell : spells) {
          if (spell.isTargetedEntitySpell()) {
            spell.castAtEntity(info.player, target, power);
            playSpellEffects(EffectPosition.TARGET, target);
          } else if (spell.isTargetedLocationSpell()) {
            spell.castAtLocation(info.player, target.getLocation(), power);
            playSpellEffects(EffectPosition.TARGET, target.getLocation());
          }
        }

        // send message if player
        if (target instanceof Player) {
          sendMessage(
              formatMessage(strHitTarget, "%a", info.player.getDisplayName()),
              (Player) target,
              MagicSpells.NULL_ARGS);
        }
      }
    }
    sendMessage(strHitCaster, info.player, MagicSpells.NULL_ARGS);
  }
Exemplo n.º 5
0
 /** Checks the creeper is there and spawns in a new one if not. */
 private void checkCreepers() {
   ResultSetTardis rs = new ResultSetTardis(plugin, null, "", true);
   if (rs.resultSet()) {
     ArrayList<HashMap<String, String>> data = rs.getData();
     for (HashMap<String, String> map : data) {
       // only if there is a saved creeper location
       if (!map.get("creeper").isEmpty()) {
         // only if the TARDIS has been initialised
         if (map.get("tardis_init").equals("1")) {
           String[] creeperData = map.get("creeper").split(":");
           World w = plugin.getServer().getWorld(creeperData[0]);
           if (w != null) {
             float cx = 0, cy = 0, cz = 0;
             try {
               cx = plugin.utils.parseFloat(creeperData[1]);
               cy = plugin.utils.parseFloat(creeperData[2]) + 1;
               cz = plugin.utils.parseFloat(creeperData[3]);
             } catch (NumberFormatException nfe) {
               plugin.debug("Couldn't convert to a float! " + nfe.getMessage());
             }
             Location l = new Location(w, cx, cy, cz);
             plugin.myspawn = true;
             Entity e = w.spawnEntity(l, EntityType.CREEPER);
             // if there is a creeper there already get rid of it!
             for (Entity k : e.getNearbyEntities(1d, 1d, 1d)) {
               if (k.getType().equals(EntityType.CREEPER)) {
                 e.remove();
                 break;
               }
             }
             Creeper c = (Creeper) e;
             c.setPowered(true);
           }
         }
       }
     }
   }
 }
Exemplo n.º 6
0
  @EventHandler
  public void onDrop(EntityDamageEvent event) {
    if (!event.getEntity().getWorld().getName().equals(name)) return;
    if (event.getEntity() instanceof Player) return;

    final Entity e = event.getEntity();
    EntityType et = e.getType();
    final Location loc = e.getLocation();
    if (event.getCause() == EntityDamageEvent.DamageCause.FALL) {
      if (et == EntityType.CREEPER) {
        Bukkit.getScheduler()
            .runTaskLater(
                MapsPlugin.getInstance(),
                new Runnable() {
                  public void run() {
                    loc.getWorld().createExplosion(loc, (float) 4);
                  }
                },
                30);
      } else if (et == EntityType.COW) {
        Random rdom = new Random();

        for (int i = 0; i <= 3; i++) {
          loc.getWorld()
              .spawnEntity(loc, EntityType.PRIMED_TNT)
              .setVelocity(new Vector(rdom.nextDouble() - 0.5, 1.5, rdom.nextDouble() - 0.5));
        }

      } else if (et == EntityType.PIG) {
        Random rdom = new Random();
        loc.getWorld()
            .spawnEntity(loc, EntityType.PIG_ZOMBIE)
            .setVelocity(new Vector(rdom.nextDouble(), 3, rdom.nextDouble()));
      } else if (et == EntityType.PIG_ZOMBIE) {
        Bukkit.getScheduler()
            .runTaskLater(
                MapsPlugin.getInstance(),
                new Runnable() {
                  public void run() {
                    loc.getWorld().createExplosion(loc, (float) 6);
                  }
                },
                30);
      } else if (et == EntityType.SHEEP) {
        Random rdom = new Random();

        for (int i = 0; i <= 10; i++) {
          loc.getWorld()
              .spawnFallingBlock(loc, Material.WOOL, (byte) 0)
              .setVelocity(new Vector(rdom.nextDouble() - 0.5, 2, rdom.nextDouble() - 0.5));
        }

      } else if (et == EntityType.SQUID) {
        Random rdom = new Random();
        loc.getWorld()
            .spawnFallingBlock(loc, Material.WATER, (byte) 0)
            .setVelocity(new Vector(rdom.nextDouble() - 0.5, 1, rdom.nextDouble() - 0.5));
      } else if (et == EntityType.WOLF) {
        Random rdom = new Random();
        List<Entity> l = e.getNearbyEntities(3, 3, 3);

        for (Entity ee : l) {
          if (ee instanceof Player) {
            Player p = (Player) ee;
            p.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, 5, 1));
          }
        }
      } else if (et == EntityType.OCELOT) {
        Random rdom = new Random();
        List<Entity> l = e.getNearbyEntities(3, 3, 3);
        for (Entity ee : l) {
          if (ee instanceof Player) {
            Player p = (Player) ee;
            p.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 5, 1));
          }
        }
      } else if (et == EntityType.SPIDER) {
        Random rdom = new Random();

        for (int i = 0; i <= 4; i++) {
          loc.getWorld()
              .spawnFallingBlock(loc, Material.WEB, (byte) 0)
              .setVelocity(new Vector(rdom.nextDouble() - 0.5, 1, rdom.nextDouble() - 0.5));
        }
      } else if (et == EntityType.HORSE) {
        Random rdom = new Random();
        List<Entity> l = e.getNearbyEntities(10, 10, 10);
        for (Entity ee : l) {
          if (ee instanceof Player) {
            Player p = (Player) ee;
            p.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 5, 2));
            p.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 20, 2));
          }
        }
      } else if (et == EntityType.SKELETON) {
        Random rdom = new Random();

        for (int i = 0; i <= 4; i++) {
          loc.getWorld()
              .spawnEntity(loc, EntityType.ZOMBIE)
              .setVelocity(new Vector(rdom.nextDouble() - 0.5, 3, rdom.nextDouble() - 0.5));
        }

      } else if (et == EntityType.SILVERFISH) {
        Random rdom = new Random();
        loc.getWorld()
            .spawnFallingBlock(loc, Material.MONSTER_EGGS, (byte) 0)
            .setVelocity(new Vector(rdom.nextDouble() - 0.5, 3, rdom.nextDouble() - 0.5));
        Bukkit.getScheduler()
            .runTaskLater(
                MapsPlugin.getInstance(),
                new Runnable() {
                  public void run() {
                    loc.getWorld().createExplosion(loc, (float) 2);
                  }
                },
                30);
      } else if (et == EntityType.CAVE_SPIDER) {
        Random rdom = new Random();
        for (int i = 0; i <= 3; i++) {
          loc.getWorld()
              .spawnEntity(loc, EntityType.SPIDER)
              .setVelocity(new Vector(rdom.nextDouble() - 0.5, 3, rdom.nextDouble() - 0.5));
        }
      } else if (et == EntityType.WITHER_SKULL) {
        Random rdom = new Random();
      }
      if (et == EntityType.ZOMBIE) {
        Bukkit.getScheduler()
            .runTaskLater(
                MapsPlugin.getInstance(),
                new Runnable() {
                  public void run() {
                    loc.getWorld().strikeLightning(loc);
                  }
                },
                30);
      } else if (et == EntityType.IRON_GOLEM) {
        Random rdom = new Random();
        for (int i = 0; i <= 3; i++) {
          loc.getWorld()
              .spawnEntity(loc, EntityType.VILLAGER)
              .setVelocity(new Vector(rdom.nextDouble() - 0.5, 3, rdom.nextDouble() - 0.5));
        }
      } else if (et == EntityType.VILLAGER) {
        Random rdom = new Random();

        for (int i = 0; i <= 3; i++) {
          loc.getWorld()
              .spawnFallingBlock(loc, Material.ANVIL, (byte) 0)
              .setVelocity(new Vector(rdom.nextDouble() - 0.5, 1.5, rdom.nextDouble() - 0.5));
        }
      } else if (et == EntityType.MUSHROOM_COW) {
        Random rdom = new Random();
        for (int i = 0; i <= 5; i++) {
          loc.getWorld()
              .spawnEntity(loc, EntityType.PRIMED_TNT)
              .setVelocity(new Vector(rdom.nextDouble() - 0.5, 1.5, rdom.nextDouble() - 0.5));
        }
      }
      if (et == EntityType.SLIME) {
        Bukkit.getScheduler()
            .runTaskLater(
                MapsPlugin.getInstance(),
                new Runnable() {
                  public void run() {
                    loc.getWorld().createExplosion(loc, (float) 6);
                  }
                },
                30);
      } else if (et == EntityType.SKELETON) {
        Random rdom = new Random();
        loc.getWorld()
            .spawnFallingBlock(loc, Material.LAVA, (byte) 0)
            .setVelocity(new Vector(rdom.nextDouble() - 0.5, 1, rdom.nextDouble() - 0.5));
      }
    }
  }