コード例 #1
0
  public void bombs() {
    new BukkitRunnable() {
      public void run() {

        if (!getArena().equals(name)) {
          bombs.clear();
          this.cancel();
          return;
        }

        Random rdom = new Random();
        Location loc = getBlocks().get(rdom.nextInt(getBlocks().size())).getLocation();

        bombs.add(1);

        List<Class> type = new ArrayList<Class>();

        type.add(Creeper.class);
        if (bombs.size() > 20) type.add(Cow.class);
        if (bombs.size() > 30) type.add(Pig.class);
        if (bombs.size() > 40) type.add(Sheep.class);
        if (bombs.size() > 50) type.add(Wolf.class);
        if (bombs.size() > 55) {
          type.add(Spider.class);
        }
        if (bombs.size() > 60) {
          type.add(Silverfish.class);
          type.add(CaveSpider.class);
        }
        if (bombs.size() > 65) {

          type.add(Villager.class);
        }
        if (bombs.size() > 70) {
          type.add(MushroomCow.class);
          type.add(Slime.class);
        }
        if (bombs.size() > 80) type.add(Skeleton.class);

        Class T = type.get(rdom.nextInt(type.size()));

        loc.getWorld().spawn(loc, T);
      }
    }.runTaskTimer(MapsPlugin.getInstance(), 20, 20);
  }
コード例 #2
0
  public void applyInventory(final BattlePlayer p) {
    final Player pl = (Player) p;
    Inventory i = pl.getInventory();

    ItemStack SNOW_BALL = new ItemStack(Material.SNOW_BALL, 200);
    ItemStack STEAK = new ItemStack(Material.COOKED_BEEF, 10);

    i.setItem(0, SNOW_BALL);
    i.setItem(1, STEAK);

    Bukkit.getScheduler()
        .runTask(
            MapsPlugin.getInstance(),
            new Runnable() {
              public void run() {
                pl.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 1000 * 20, 2));
              }
            });
  }
コード例 #3
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));
      }
    }
  }