コード例 #1
0
  public void storeNonSolidBlocks() {
    sensitiveBlocks = new LinkedList<Location>();
    Iterator<Entry<Location, StructureBlock>> i = blocks.entrySet().iterator();
    while (i.hasNext()) {
      StructureBlock current = i.next().getValue();

      if (Structure.annoyingBlocks.contains(current.originalBlock.getType())) {
        sensitiveBlocks.add(current.location);
        if (current.originalBlock.getType() == Material.IRON_DOOR_BLOCK
            || current.originalBlock.getType() == Material.WOODEN_DOOR) {
          Block above = current.originalBlock.getBlock().getRelative(BlockFace.UP);
          Block below = current.originalBlock.getBlock().getRelative(BlockFace.DOWN);
          if (above.getType() == Material.IRON_DOOR_BLOCK
              || above.getType() == Material.WOODEN_DOOR) {
            current.originalBlock.getBlock().setType(Material.AIR);
            above.setType(Material.AIR);
            continue;
          } else if (below.getType() == Material.IRON_DOOR_BLOCK
              || below.getType() == Material.WOODEN_DOOR) {
            below.setType(Material.AIR);
            current.originalBlock.getBlock().setType(Material.AIR);
            continue;
          }
        }
        current.originalBlock.getBlock().setType(Material.AIR);
      }
    }
  }
コード例 #2
0
 public void destroyFlag() {
   flagLightBlock.setType(Material.AIR);
   flagBlock.setType(Material.AIR);
   flagBaseBlock.setType(Material.AIR);
   for (Block block : beaconFlagBlocks) block.setType(Material.AIR);
   for (Block block : beaconWireframeBlocks) block.setType(Material.AIR);
 }
コード例 #3
0
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onPlayerMove(PlayerMoveEvent event) {
    Player p = event.getPlayer();
    Block b = p.getTargetBlock((Set<Material>) null, p.getGameMode() == GameMode.CREATIVE ? 5 : 4);
    PumpkinCheck check =
        new PumpkinCheck(p.getWorld().getBlockAt(b.getLocation()).getType(), b.getLocation());

    if (targetBlocks.containsKey(p) && targetBlocks.get(p).isPumpkin() && !check.isPumpkin()) {
      Block newBlock = p.getWorld().getBlockAt(targetBlocks.get(p).getLocation());
      byte data = newBlock.getData();

      newBlock.setType(Material.PUMPKIN);
      newBlock.setData(data);
    }

    targetBlocks.put(p, check);

    if (targetBlocks.get(p).isPumpkin()) {
      Block newBlock = p.getWorld().getBlockAt(targetBlocks.get(p).getLocation());
      byte data = newBlock.getData();

      newBlock.setType(Material.JACK_O_LANTERN);
      newBlock.setData(data);
    }
  }
コード例 #4
0
ファイル: RainbowClay.java プロジェクト: JoniMega/Minicat
 @Override
 protected void onBlockHitByProjectile(ProjectileHitEvent evt, Block b, Projectile proj) {
   // TODO Auto-generated method stub
   super.onBlockHitByProjectile(evt, b, proj);
   // sendGlobalMessage("Pilotassa");
   Material t = b.getType();
   if (t == Material.GLASS
       || t == Material.STAINED_GLASS
       || t == Material.STAINED_GLASS_PANE
       || t == Material.THIN_GLASS
       || t == Material.GLOWSTONE) {
     b.setType(Material.AIR);
     getWorld().playSound(b.getLocation(), Sound.GLASS, 15F, 1.2F);
     proj.remove();
     for (BlockFace f : BlockFace.values()) {
       if (GUtils.Possibilitat(58)) continue;
       Block relative = b.getRelative(f);
       t = relative.getType();
       if (t == Material.GLASS
           || t == Material.STAINED_GLASS
           || t == Material.STAINED_GLASS_PANE
           || t == Material.THIN_GLASS
           || t == Material.GLOWSTONE) {
         relative.setType(Material.AIR);
       }
     }
   }
 }
コード例 #5
0
 public void run() {
   for (String s : lifewalkers.toArray(strArr)) {
     Player player = Bukkit.getServer().getPlayer(s);
     if (player != null) {
       if (isExpired(player)) {
         turnOff(player);
         continue;
       }
       Block feet = player.getLocation().getBlock();
       Block ground = feet.getRelative(BlockFace.DOWN);
       if (feet.getType() == Material.AIR
           && (ground.getType() == Material.DIRT || ground.getType() == Material.GRASS)) {
         if (ground.getType() == Material.DIRT) {
           ground.setType(Material.GRASS);
         }
         int rand = random.nextInt(100);
         if (rand < redFlowerChance) {
           feet.setType(Material.RED_ROSE);
           addUse(player);
           chargeUseCost(player);
         } else {
           rand -= redFlowerChance;
           if (rand < yellowFlowerChance) {
             feet.setType(Material.YELLOW_FLOWER);
             addUse(player);
             chargeUseCost(player);
           } else {
             rand -= yellowFlowerChance;
             if (rand < saplingChance) {
               feet.setType(Material.SAPLING);
               addUse(player);
               chargeUseCost(player);
             } else {
               rand -= saplingChance;
               if (rand < tallgrassChance) {
                 BlockState state = feet.getState();
                 state.setType(Material.LONG_GRASS);
                 state.setData(new LongGrass(GrassSpecies.NORMAL));
                 state.update(true);
                 addUse(player);
                 chargeUseCost(player);
               } else {
                 rand -= tallgrassChance;
                 if (rand < fernChance) {
                   BlockState state = feet.getState();
                   state.setType(Material.LONG_GRASS);
                   state.setData(new LongGrass(GrassSpecies.FERN_LIKE));
                   state.update(true);
                   addUse(player);
                   chargeUseCost(player);
                 }
               }
             }
           }
         }
       }
     }
   }
 }
コード例 #6
0
 public void restore() {
   final Block block = Bukkit.getWorld(worldName).getBlockAt(x, y, z);
   if (isBreak) {
     block.setType(getMaterial());
     TFM_DepreciationAggregator.setData_Block(block, data);
   } else {
     block.setType(Material.AIR);
   }
 }
コード例 #7
0
  public void drawFlag() {
    loadBeacon();

    flagBaseBlock.setType(TownyWarConfig.getFlagBaseMaterial());
    updateFlag();
    flagLightBlock.setType(TownyWarConfig.getFlagLightMaterial());
    for (Block block : beaconWireframeBlocks)
      block.setType(TownyWarConfig.getBeaconWireFrameMaterial());
  }
コード例 #8
0
  public static void setSellSign(final World world, final AthionPlot plot) {
    removeSellSign(world, plot.id);

    if (plot.forsale || plot.auctionned) {
      final Location pillar =
          new Location(
              world,
              bottomX(plot.id, world) - 1,
              getMap(world).RoadHeight + 1,
              bottomZ(plot.id, world) - 1);

      Block bsign = pillar.clone().add(-1, 0, 0).getBlock();
      bsign.setType(Material.AIR);
      bsign.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 4, false);

      Sign sign = (Sign) bsign.getState();

      if (plot.forsale) {
        sign.setLine(0, AthionPlots.caption("SignForSale"));
        sign.setLine(1, AthionPlots.caption("SignPrice"));
        if ((plot.customprice % 1) == 0) {
          sign.setLine(2, AthionPlots.caption("SignPriceColor") + Math.round(plot.customprice));
        } else {
          sign.setLine(2, AthionPlots.caption("SignPriceColor") + plot.customprice);
        }
        sign.setLine(3, "/ap " + AthionPlots.caption("CommandBuy"));

        sign.update(true);
      }

      if (plot.auctionned) {
        if (plot.forsale) {
          bsign = pillar.clone().add(-1, 0, 1).getBlock();
          bsign.setType(Material.AIR);
          bsign.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 4, false);

          sign = (Sign) bsign.getState();
        }

        sign.setLine(0, "" + AthionPlots.caption("SignOnAuction"));
        if (plot.currentbidder.equals("")) {
          sign.setLine(1, AthionPlots.caption("SignMinimumBid"));
        } else {
          sign.setLine(1, AthionPlots.caption("SignCurrentBid"));
        }
        if ((plot.currentbid % 1) == 0) {
          sign.setLine(2, AthionPlots.caption("SignCurrentBidColor") + Math.round(plot.currentbid));
        } else {
          sign.setLine(2, AthionPlots.caption("SignCurrentBidColor") + plot.currentbid);
        }
        sign.setLine(3, "/ap " + AthionPlots.caption("CommandBid") + " <x>");

        sign.update(true);
      }
    }
  }
コード例 #9
0
ファイル: OctopusForm.java プロジェクト: N4m/MinecraftTLA
 private void form() {
   incrementStep();
   if (Tools.isPlant(sourceblock)) {
     new Plantbending(sourceblock);
     sourceblock.setType(Material.AIR);
   } else if (!Tools.adjacentToThreeOrMoreSources(sourceblock)) {
     sourceblock.setType(Material.AIR);
   }
   source = new TempBlock(sourceblock, Material.WATER, full);
 }
コード例 #10
0
  public static void removeOwnerSign(final World world, final String id) {
    final Location bottom = getPlotBottomLoc(world, id);

    final Location pillar =
        new Location(world, bottom.getX() - 1, getMap(world).RoadHeight + 1, bottom.getZ() - 1);

    final Block bsign = pillar.add(0, 0, -1).getBlock();
    final Block redlight = pillar.add(0, -1, 0).getBlock();
    bsign.setType(Material.AIR);
    redlight.setType(Material.WOOD);
  }
コード例 #11
0
  public static void removeSellSign(final World world, final String id) {
    final Location bottom = getPlotBottomLoc(world, id);

    final Location pillar =
        new Location(world, bottom.getX() - 1, getMap(world).RoadHeight + 1, bottom.getZ() - 1);

    Block bsign = pillar.clone().add(-1, 0, 0).getBlock();
    bsign.setType(Material.AIR);

    bsign = pillar.clone().add(-1, 0, 1).getBlock();
    bsign.setType(Material.AIR);
  }
コード例 #12
0
ファイル: SuperHeat.java プロジェクト: riking/Zephyrus
  @Override
  public void run(Player player, String[] args) {
    try {
      Material block = player.getTargetBlock(null, 7).getType();
      if (block == Material.COBBLESTONE) {
        player.getTargetBlock(null, 7).setType(Material.STONE);
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        Location loc = player.getTargetBlock(null, 7).getLocation();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        loc.setY(loc.getY() + 0.5);
        ParticleEffects.sendToLocation(ParticleEffects.FLAME, loc, 1, 1, 1, 0, 10);
      } else if (block == Material.SAND) {
        player.getTargetBlock(null, 7).setType(Material.GLASS);
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        Location loc = player.getTargetBlock(null, 7).getLocation();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        loc.setY(loc.getY() + 0.5);
        ParticleEffects.sendToLocation(ParticleEffects.FLAME, loc, 1, 1, 1, 0, 10);
      } else if (block == Material.IRON_ORE) {
        Block b = player.getTargetBlock(null, 7);
        b.setType(Material.AIR);
        b.getWorld().dropItem(b.getLocation(), new ItemStack(Material.IRON_INGOT));
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        Location loc = player.getTargetBlock(null, 7).getLocation();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        loc.setY(loc.getY() + 0.5);
        ParticleEffects.sendToLocation(ParticleEffects.FLAME, loc, 1, 1, 1, 0, 10);
      } else if (block == Material.GOLD_ORE) {
        Block b = player.getTargetBlock(null, 7);
        b.setType(Material.AIR);
        b.getWorld().dropItem(b.getLocation(), new ItemStack(Material.GOLD_INGOT));
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        Location loc = player.getTargetBlock(null, 7).getLocation();
        loc.setX(loc.getX() + 0.5);
        loc.setZ(loc.getZ() + 0.5);
        loc.setY(loc.getY() + 0.5);
        ParticleEffects.sendToLocation(ParticleEffects.FLAME, loc, 1, 1, 1, 0, 30);
      } else {
        LivingEntity en = (LivingEntity) getTarget(player);
        player.getWorld().playSound(player.getLocation(), Sound.FIRE_IGNITE, 1, 1);
        en.setFireTicks(160);
      }
    } catch (Exception e) {

    }
  }
コード例 #13
0
    // Hits a netherrack block
    public void onPlayerInteract(PlayerInteractEvent event) {
      // Do not run if cancelled
      if (event.isCancelled()) {
        return;
      }

      // Only run if netherrack ignition is enabled
      if (igniteNetherrack) {
        // Check to see if player clicked a netherrack block
        if (event.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
          if (event.getClickedBlock().getType() == Material.NETHERRACK) {
            // Ignite this block if Firetouch enabled
            Player player = event.getPlayer();
            PotionEntry buff = getPlugin().BuffList.get(player);

            if (buff != null) {
              if (buff.HasBuff.get(Name) != null && buff.HasBuff.get(Name)) {
                // Ignite block
                BlockIgniteEvent ignite =
                    new BlockIgniteEvent(
                        event.getClickedBlock(), IgniteCause.FLINT_AND_STEEL, player);
                getPlugin().getServer().getPluginManager().callEvent(ignite);
                if (!ignite.isCancelled()) {
                  Block above = event.getClickedBlock().getRelative(0, 1, 0);
                  if (above.isEmpty()) {
                    above.setType(Material.FIRE);
                  }
                }
              }
            }
          }
        }
      }
    }
コード例 #14
0
	@EventHandler(priority = EventPriority.HIGHEST)
	public void onPlayerInteract(PlayerInteractEvent e) {
		SpleefPlayer player = HeavySpleef.getInstance().getSpleefPlayer(e.getPlayer());
		Block block = e.getClickedBlock();

		if (player == null)
			return;
		if (block == null)
			return;
		if (!player.isActive())
			return;
		if (e.getAction() != Action.LEFT_CLICK_BLOCK)
			return;

		Game game = player.getGame();
		if (!game.canSpleef(player, block.getLocation()))
			return;

		if (game.getFlag(FlagType.BOWSPLEEF) || game.getFlag(FlagType.SPLEGG))
			return;

		if (game.getFlag(FlagType.BLOCKBREAKEFFECT)) {
			block.getWorld().playEffect(block.getLocation(), Effect.STEP_SOUND, block.getType());
		}

		block.setType(Material.AIR);
		player.addBrokenBlock(block);
	}
コード例 #15
0
ファイル: FeastGen.java プロジェクト: TheButlah/HungerGames
  public static void generateFeast() {
    FeastUtils.clearCyl(FeastLoc.getLocation(), radius, 25, Material.GRASS);

    FeastLoc.setType(Material.ENCHANTMENT_TABLE);

    for (int x = -2; x <= 2; x++) {
      for (int z = -2; z <= 2; z++) {
        int worldx = (x + FeastLoc.getX());
        int worldz = (z + FeastLoc.getZ());
        if ((Math.abs(x) == Math.abs(z) && x != 0)
            || (Math.abs(x) == 2 && z == 0)
            || (Math.abs(z) == 2 && x == 0)) {
          generateFeastChest(
              new Location(FeastLoc.getLocation().getWorld(), worldx, FeastLoc.getY(), worldz));
        }
      }
    }

    Bukkit.broadcastMessage(
        ChatColor.GOLD
            + "Spawned feast at "
            + FeastLoc.getX()
            + ", "
            + FeastLoc.getY()
            + ", "
            + FeastLoc.getZ()
            + "!");
  }
コード例 #16
0
 /**
  * Remove a island from SkyBlock.
  *
  * @param l given location
  */
 public void removeIsland(Location l) {
   if (l != null) {
     int px = l.getBlockX();
     int py = l.getBlockY();
     int pz = l.getBlockZ();
     for (int x = -15; x <= 15; x++) {
       for (int y = -15; y <= 15; y++) {
         for (int z = -15; z <= 15; z++) {
           Block b = new Location(l.getWorld(), px + x, py + y, pz + z).getBlock();
           if (b.getType() != Material.AIR) {
             if (b.getType() == Material.CHEST) {
               Chest c = (Chest) b.getState();
               ItemStack[] items = new ItemStack[c.getInventory().getContents().length];
               c.getInventory().setContents(items);
             } else if (b.getType() == Material.FURNACE) {
               Furnace f = (Furnace) b.getState();
               ItemStack[] items = new ItemStack[f.getInventory().getContents().length];
               f.getInventory().setContents(items);
             } else if (b.getType() == Material.DISPENSER) {
               Dispenser d = (Dispenser) b.getState();
               ItemStack[] items = new ItemStack[d.getInventory().getContents().length];
               d.getInventory().setContents(items);
             }
             b.setType(Material.AIR);
           }
         }
       }
     }
   }
 }
コード例 #17
0
ファイル: FireJet.java プロジェクト: N4m/MinecraftTLA
 public FireJet(Player player) {
   if (instances.containsKey(player)) {
     // player.setAllowFlight(canfly);
     instances.remove(player);
     return;
   }
   if (timers.containsKey(player)) {
     if (System.currentTimeMillis()
         < timers.get(player)
             + (long) ((double) cooldown / Tools.getFirebendingDayAugment(player.getWorld()))) {
       return;
     }
   }
   factor = Tools.firebendingDayAugment(defaultfactor, player.getWorld());
   Block block = player.getLocation().getBlock();
   if (FireStream.isIgnitable(player, block)
       || block.getType() == Material.AIR
       || AvatarState.isAvatarState(player)) {
     player.setVelocity(
         player.getEyeLocation().getDirection().clone().normalize().multiply(factor));
     block.setType(Material.FIRE);
     this.player = player;
     // canfly = player.getAllowFlight();
     player.setAllowFlight(true);
     time = System.currentTimeMillis();
     timers.put(player, time);
     instances.put(player, this);
   }
 }
コード例 #18
0
  public void addChunkLoader(ChunkLoader chunkLoader) {
    Block block =
        getServer()
            .getWorld(chunkLoader.getWorld())
            .getBlockAt(chunkLoader.getX(), chunkLoader.getY(), chunkLoader.getZ());

    ChunkLoader existing =
        chunkLoaders.stream().filter(c -> c.getBlock().equals(block)).findFirst().orElse(null);

    if (existing != null) existing.delete();

    chunkLoader.setBlock(block);

    block.setType(getChunkLoaderMaterial(chunkLoader.getChunkType()));

    getChunkLoaders().add(chunkLoader);

    chunkLoader.load();

    data.saveChunkLoader(chunkLoader);

    Player player = getServer().getPlayer(chunkLoader.getOwner());
    if (player != null && player.isOnline())
      player.sendMessage(
          String.format(
              "%sSuccessfully placed %s chunk loader with and ID of %s and %s chunks",
              ChatColor.GOLD,
              chunkLoader.getChunkType(),
              chunkLoader.getId(),
              chunkLoader.getSize()));
  }
コード例 #19
0
  private void placeShrubs(World world, int rx, int rz, Random random) {
    for (int i = 0; i < random.nextInt(32); i++) {
      int x = random.nextInt(15);
      int z = random.nextInt(15);

      int ran = 0;

      Biome biome = world.getBiome(rx + x, rz + z);

      if (biome.equals(Biome.EXTREME_HILLS)) {
        ran = random.nextInt(16);
      } else if (biome.equals(Biome.FOREST) || biome.equals(Biome.FOREST_HILLS)) {
        ran = random.nextInt(6);
      } else if (biome.equals(Biome.PLAINS)) {
        ran = random.nextInt(20);
      } else if (biome.equals(Biome.JUNGLE) || biome.equals(Biome.JUNGLE_HILLS)) {
        ran = random.nextInt(3);
      } else if (biome.equals(Biome.SWAMPLAND)) {
        ran = random.nextInt(14);
      } else if (biome.equals(Biome.TAIGA) || biome.equals(Biome.TAIGA_HILLS)) {
        ran = random.nextInt(12);
      } else if (biome.equals(Biome.ROOFED_FOREST) || biome.equals(Biome.MUTATED_ROOFED_FOREST)) {
        ran = random.nextInt(7);
      } else if (biome.equals(Biome.DESERT)) {
        ran = random.nextInt(3);
      } else {
        ran = random.nextInt(5);
      }

      if (ran == 1) {
        Block block = world.getHighestBlockAt(rx + x, rz + z);
        block.setType(Material.DEAD_BUSH);
      }
    }
  }
コード例 #20
0
ファイル: Filler.java プロジェクト: pokecolemon/Bytecraft
  @Override
  public void changeBlock(Block block) {
    currentJob.addBlock(block.getState());

    block.setType(item.getItemType());
    block.setData(item.getData());
  }
コード例 #21
0
  @Override
  public void populate(World world, Random rand, Chunk chunk) {
    int x, y, z;
    Block block;

    for (x = 0; x < 16; ++x) {
      for (z = 0; z < 16; ++z) {
        for (y = 80; chunk.getBlock(x, y, z).getType() == Material.AIR; --y) ;
        block = chunk.getBlock(x, y, z);
        if (block != null) {
          // snow on snow biomes
          if ((block.getBiome() == Biome.FROZEN_OCEAN)
              || (block.getBiome() == Biome.FROZEN_RIVER)
              || (block.getBiome() == Biome.ICE_DESERT)
              || (block.getBiome() == Biome.ICE_MOUNTAINS)
              || (block.getBiome() == Biome.ICE_PLAINS)
              || (block.getBiome() == Biome.TUNDRA)
              || (block.getBiome() == Biome.EXTREME_HILLS)) {
            if ((block.getType() == Material.RED_ROSE)
                || (block.getType() == Material.YELLOW_FLOWER)
                || (block.getType() == Material.LONG_GRASS)
                || (block.getType() == Material.CACTUS)
                || (block.getType() == Material.SUGAR_CANE_BLOCK)) {
            } else if ((block.getType() == Material.STATIONARY_WATER)
                || (block.getType() == Material.WATER)) {
              block.setType(Material.ICE);
            } else {
              block.getRelative(0, 1, 0).setTypeId(Material.SNOW.getId());
            }
          }
        }
      }
    }
  }
コード例 #22
0
  @SuppressWarnings("deprecation")
  @Command(
      value = "myplanet",
      desc = "Erzeugt einen Testplaneten",
      perm = "craftoplugin.galaxywar.generate",
      onlyplayers = true)
  public void generatePlanet(final CommandSender cs, final String command, final String[] args) {
    final Player p = (Player) cs;
    p.sendMessage("Aktiv!");
    final int r = 6;
    PlanetType type = PlanetType.SUN;
    if (args.length > 0) {
      try {
        type = PlanetType.valueOf(args[0].toUpperCase());
      } catch (final IllegalArgumentException e) {
      }
    }
    final World world = p.getWorld();

    final Planet planet = new Planet(new Position(p.getLocation()), r, type);
    final ArrayList<MaterialBlockPoint> blocks = planet.getMaterialBlockPoints();

    Block block;
    for (final MaterialBlockPoint b : blocks) {
      block = world.getBlockAt(b.getX(), b.getY(), b.getZ());
      block.setType(b.getMaterial());
      block.setData((byte) 0);
    }
  }
コード例 #23
0
ファイル: IceSpike.java プロジェクト: GyozaGuy/ProjectKorra
  private boolean moveEarth() {
    progress++;
    Block affectedblock = location.clone().add(direction).getBlock();
    location = location.add(direction);
    if (GeneralMethods.isRegionProtectedFromBuild(player, "IceSpike", location)) return false;
    for (Entity en : GeneralMethods.getEntitiesAroundPoint(location, 1.4)) {
      if (en instanceof LivingEntity && en != player && !damaged.contains(((LivingEntity) en))) {
        LivingEntity le = (LivingEntity) en;
        affect(le);
        // le.setVelocity(thrown);
        // le.damage(damage);
        // damaged.add(le);
        // Methods.verbose(damage + " Hp:" + le.getHealth());
      }
    }
    affectedblock.setType(Material.ICE);
    WaterMethods.playIcebendingSound(block.getLocation());
    loadAffectedBlocks();

    if (location.distance(origin) >= height) {
      return false;
    }

    return true;
  }
コード例 #24
0
  @SuppressWarnings("deprecation")
  @EventHandler
  public void onInventoryClick(InventoryClickEvent e) {
    Player player = (Player) e.getWhoClicked();
    Inventory inventory = e.getInventory();
    ItemStack currentItem = e.getCurrentItem();

    if (ArenaManager.getInstance().getArena(player) == null) {
      return;
    }

    Plot plot = ArenaManager.getInstance().getArena(player).getPlot(player);

    if (!inventory.getName().equals(ChatColor.GREEN + "Options menu")) {
      return;
    }
    if (currentItem.getType() != Material.HARD_CLAY) {
      return;
    }
    if (!currentItem.hasItemMeta()) {
      return;
    }
    if (!currentItem.getItemMeta().getDisplayName().equals(ChatColor.GREEN + "Floor block")) {
      return;
    }

    for (Block block : plot.getFloor().getAllBlocks()) {
      block.setType(e.getCursor().getType());
      block.setData(e.getCursor().getData().getData());
    }

    e.setCancelled(true);
  }
コード例 #25
0
ファイル: Methods.java プロジェクト: dragonfly190/LootCrate
  public static void drop(Player p) {
    Location loc = new Location(Bukkit.getWorld("world"), 0, 0, 0);
    Random rand = new Random();
    loc.setX(rand.nextInt(8000));
    loc.setY(100);
    loc.setZ(rand.nextInt(8000));
    loc.setY(Bukkit.getWorld("world").getHighestBlockAt(loc.getBlockX(), loc.getBlockZ()).getY());
    loc.getBlock().setType(Material.CHEST);
    Block bb = loc.getBlock();
    bb.setType(Material.CHEST);
    Chest chest = (Chest) bb.getState();

    Inventory inv = chest.getInventory();

    for (ItemStack stack : items) {
      inv.addItem(stack);
    }

    Bukkit.broadcastMessage(
        ChatColor.RED + "A tornado has appeared in the world, and left valuble supplies!");
    Bukkit.broadcastMessage(
        ChatColor.translateAlternateColorCodes(
            '&',
            "&7Coords: X: &c"
                + loc.getBlockX()
                + "&7 Y:&c "
                + loc.getBlockY()
                + "&7 Z: &c"
                + loc.getBlockZ()));
  }
コード例 #26
0
 private void write_block(boolean overwrite, int x, int y, int z, Material _cmpnt) {
   Block _bk = this.ev.getPlayer().getWorld().getBlockAt(x, y, z);
   Material type = _bk.getType();
   if ((type == Material.AIR) || ((overwrite) && (type != Material.BEDROCK))) {
     _bk.setType(_cmpnt);
     _bk.getWorld().playEffect(_bk.getLocation(), Effect.SMOKE, 1);
   }
 }
コード例 #27
0
 private void unfocusBlock() {
   if (destination != null) {
     breakBlock();
     return;
   }
   if (sourceblock.getType() == Material.SAND) {
     if (sourceblock.getData() == (byte) 0x1) {
       sourceblock.setType(sourcetype);
       sourceblock.setData((byte) 0x1);
     } else {
       sourceblock.setType(sourcetype);
     }
   } else {
     sourceblock.setType(sourcetype);
   }
   instances.remove(id);
 }
コード例 #28
0
ファイル: SimulateBatch.java プロジェクト: S-Toad/MagicPlugin
 protected void killBlock(Block block) {
   if (concurrent) {
     registerForUndo(block);
     block.setType(deathMaterial);
   } else {
     deadBlocks.add(block);
   }
 }
コード例 #29
0
ファイル: FeastGen.java プロジェクト: TheButlah/HungerGames
 public static void generateFeastChest(Location loc) {
   Block b = Main.hgworld.getBlockAt(loc);
   b.setType(Material.CHEST);
   ((Chest) b.getState()).getInventory().setContents(Config.getNewFeastChest());
   // System.out.println("Feast chest generated at " + loc.getBlockX() + ", " + loc.getBlockY() +
   // ", " + loc.getBlockZ());
   // world.getPlayers().get(0).teleport(loc);
 }
コード例 #30
0
ファイル: FreezeMelt.java プロジェクト: GyozaGuy/ProjectKorra
 @SuppressWarnings("deprecation")
 public static void thaw(Block block) {
   if (frozenblocks.containsKey(block)) {
     byte data = frozenblocks.get(block);
     frozenblocks.remove(block);
     block.setType(Material.WATER);
     block.setData(data);
   }
 }