Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.36 KB | None | 0 0
  1.  @EventHandler
  2.          public void ChestMap(BlockPlaceEvent event){
  3.              final Player p = event.getPlayer();
  4.                      if(event.getBlock().getType().equals(Material.CHEST)){
  5.                          Block base = event.getBlock().getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN);
  6.                          event.getPlayer().getWorld().playSound(event.getBlock().getLocation(), Sound.AMBIENCE_THUNDER, 1.0F, 1.0F);
  7.                          Bukkit.broadcastMessage(ChatColor.BLUE + "" + getConfig().getString("prefix") + " " + ChatColor.AQUA + p.getDisplayName() + ChatColor.GRAY + " has opened " + ChatColor.GOLD + "Treasure Chest" + ChatColor.GRAY + "!");
  8.                          Location ori = base.getRelative(BlockFace.UP).getLocation();
  9.                          int layloc;
  10.                          for (int y = 0; y < 3; y++){
  11.                              int by = ori.getBlock().getY() + y;
  12.                              layloc = 0;
  13.                              for (int x = 0; x < 3; x++){
  14.                                  int bx = ori.getBlock().getX() + x;
  15.                                  for (int z = 0; z < 3; z++){
  16.                                      int bz = ori.getBlock().getZ() + z;
  17.                                      Location block = new Location(event.getBlock().getWorld(), bx, by, bz);
  18.                                      block.getBlock().setType(Material.matchMaterial(layers(y, layloc)));
  19.                                      layloc++;
  20.                                  }
  21.                              }
  22.                          }                      
  23.                      }
  24.                  }
  25.  
  26.      public String layers(int y, int layloc){
  27.          String[] layer1 = {
  28.                  "GRASS", "GRASS", "GRASS",
  29.                  "GRASS", "GRASS", "GRASS",
  30.                  "GRASS", "GRASS", "GRASS"
  31.          };
  32.  
  33.          String[] layer2 = {
  34.                  "LEAVES", "FENCE", "LEAVES",
  35.                  "FENCE", "CHEST", "FENCE",
  36.                  "LEAVES", "FENCE", "LEAVES"
  37.          };
  38.  
  39.          String[] layer3 = {
  40.                  "AIR", "AIR", "AIR",
  41.                  "AIR", "AIR", "AIR",
  42.                  "AIR", "AIR", "AIR"
  43.          };
  44.          if (y == 0){return layer1[layloc];}
  45.          if (y == 1){return layer2[layloc];}
  46.          if (y == 2){return layer3[layloc];}
  47.          return null;
  48.      }
  49.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement