Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void ChestMap(BlockPlaceEvent event){
- final Player p = event.getPlayer();
- if(event.getBlock().getType().equals(Material.CHEST)){
- Block base = event.getBlock().getRelative(BlockFace.DOWN).getRelative(BlockFace.DOWN);
- event.getPlayer().getWorld().playSound(event.getBlock().getLocation(), Sound.AMBIENCE_THUNDER, 1.0F, 1.0F);
- Bukkit.broadcastMessage(ChatColor.BLUE + "" + getConfig().getString("prefix") + " " + ChatColor.AQUA + p.getDisplayName() + ChatColor.GRAY + " has opened " + ChatColor.GOLD + "Treasure Chest" + ChatColor.GRAY + "!");
- Location ori = base.getRelative(BlockFace.UP).getLocation();
- int layloc;
- for (int y = 0; y < 3; y++){
- int by = ori.getBlock().getY() + y;
- layloc = 0;
- for (int x = 0; x < 3; x++){
- int bx = ori.getBlock().getX() + x;
- for (int z = 0; z < 3; z++){
- int bz = ori.getBlock().getZ() + z;
- Location block = new Location(event.getBlock().getWorld(), bx, by, bz);
- block.getBlock().setType(Material.matchMaterial(layers(y, layloc)));
- layloc++;
- }
- }
- }
- }
- }
- public String layers(int y, int layloc){
- String[] layer1 = {
- "GRASS", "GRASS", "GRASS",
- "GRASS", "GRASS", "GRASS",
- "GRASS", "GRASS", "GRASS"
- };
- String[] layer2 = {
- "LEAVES", "FENCE", "LEAVES",
- "FENCE", "CHEST", "FENCE",
- "LEAVES", "FENCE", "LEAVES"
- };
- String[] layer3 = {
- "AIR", "AIR", "AIR",
- "AIR", "AIR", "AIR",
- "AIR", "AIR", "AIR"
- };
- if (y == 0){return layer1[layloc];}
- if (y == 1){return layer2[layloc];}
- if (y == 2){return layer3[layloc];}
- return null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement