Example #1
0
  private void runPhaseTwo(final Beacon beacon, final int repeat) {
    final Location loc = beacon.getLocation().add(0.0D, 1.0D, 0.0D);
    final Block aboveBlock = loc.getWorld().getBlockAt(loc);
    final Random rnd = new Random();

    loc.getWorld().playSound(loc, Sound.EXPLODE, 1.0F, 1.0F);
    aboveBlock.setType(Material.WATER);
    spawnPressurePlates(beacon);

    final int itemDropTask =
        this.plugin
            .getServer()
            .getScheduler()
            .scheduleSyncRepeatingTask(
                this.plugin,
                new Runnable() {
                  @SuppressWarnings("deprecation")
                  public void run() {
                    beacon
                        .getWorld()
                        .dropItemNaturally(
                            loc,
                            new ItemStack(
                                BeaconDrops.this.config.getItemId(), rnd.nextInt(64) + 1));
                  }
                },
                10L,
                10L);

    this.plugin
        .getServer()
        .getScheduler()
        .scheduleSyncDelayedTask(
            this.plugin,
            new Runnable() {
              public void run() {
                BeaconDrops.this.plugin.getServer().getScheduler().cancelTask(itemDropTask);
                aboveBlock.setType(Material.AIR);

                BeaconDrops.this
                    .plugin
                    .getServer()
                    .getScheduler()
                    .scheduleSyncDelayedTask(
                        BeaconDrops.this.plugin,
                        new Runnable() {
                          public void run() {
                            BeaconDrops.this.removePressurePlates(beacon);
                            BeaconDrops.this.runPhaseOne(beacon, repeat + 1);
                          }
                        },
                        60L);
              }
            },
            this.config.getPhaseTwo() * 20L);
  }
Example #2
0
 private void removePressurePlates(Beacon beacon) {
   for (int x = -2; x <= 2; x++) {
     Block block = beacon.getWorld().getBlockAt(beacon.getLocation().add(x, -1.0D, 3.0D));
     if (block.getType() == Material.WOOD_PLATE) {
       block.setType(Material.AIR);
     }
     block = beacon.getWorld().getBlockAt(beacon.getLocation().add(x, -1.0D, -3.0D));
     if (block.getType() == Material.WOOD_PLATE) {
       block.setType(Material.AIR);
     }
   }
   for (int z = -2; z <= 2; z++) {
     Block block = beacon.getWorld().getBlockAt(beacon.getLocation().add(3.0D, -1.0D, z));
     if (block.getType() == Material.WOOD_PLATE) {
       block.setType(Material.AIR);
     }
     block = beacon.getWorld().getBlockAt(beacon.getLocation().add(-3.0D, -1.0D, z));
     if (block.getType() == Material.WOOD_PLATE) {
       block.setType(Material.AIR);
     }
   }
 }
Example #3
0
  private void runPhaseOne(final Beacon beacon, final int repeat) {
    if (repeat > this.config.getRepeat()) {
      this.plugin
          .getServer()
          .getScheduler()
          .runTaskLaterAsynchronously(
              this.plugin,
              new Runnable() {
                public void run() {
                  BeaconDrops.this
                      .plugin
                      .getServer()
                      .broadcastMessage(BeaconDrops.this.config.getMessage("charged"));
                  BeaconDrops.this.canRun = true;
                }
              },
              this.config.getWaitTime() * 20L * 60L);

      return;
    }
    final Block belowBlock =
        beacon.getWorld().getBlockAt(beacon.getLocation().add(0.0D, -1.0D, 0.0D));
    final Random rnd = new Random();

    final int blockSwitchTask =
        this.plugin
            .getServer()
            .getScheduler()
            .scheduleSyncRepeatingTask(
                this.plugin,
                new Runnable() {
                  @SuppressWarnings("deprecation")
                  public void run() {
                    switch (belowBlock.getType()) {
                      case COOKED_CHICKEN:
                        belowBlock.setType(Material.GOLD_BLOCK);
                        break;
                      default:
                        belowBlock.setType(Material.DIAMOND_BLOCK);
                    }
                    beacon
                        .getWorld()
                        .dropItemNaturally(
                            beacon.getLocation().add(0.0D, 1.0D, 0.0D),
                            new ItemStack(
                                BeaconDrops.this.config.getItemId(), rnd.nextInt(64) + 1));
                  }
                },
                10L,
                10L);

    this.plugin
        .getServer()
        .getScheduler()
        .scheduleSyncDelayedTask(
            this.plugin,
            new Runnable() {
              public void run() {
                BeaconDrops.this.plugin.getServer().getScheduler().cancelTask(blockSwitchTask);
                belowBlock.setType(Material.DIAMOND_BLOCK);

                BeaconDrops.this
                    .plugin
                    .getServer()
                    .getScheduler()
                    .scheduleSyncDelayedTask(
                        BeaconDrops.this.plugin,
                        new Runnable() {
                          public void run() {
                            runPhaseTwo(beacon, repeat);
                          }
                        },
                        60L);
              }
            },
            this.config.getPhaseOne() * 20L);
  }