Advertisement
Guest User

Untitled

a guest
Apr 27th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.39 KB | None | 0 0
  1.     private boolean createStructure(Block baseBlock, Material baseMaterial, Player player) {
  2.         if (getWorldGuard().canBuild(player,baseBlock)) {
  3.             Block block1 = baseBlock.getRelative(BlockFace.UP);
  4.             Block block2 = block1.getRelative(BlockFace.UP);
  5.             HashMap<String, ArrayList<Block>> structure = new HashMap<>();
  6.             if (block1.getType().equals(Material.AIR) && block2.getType().equals(Material.AIR)) {
  7.                 baseBlock.setType(baseMaterial);
  8.                 block1.setType(Material.ACACIA_FENCE);
  9.                 block1.getLocation().getWorld().playEffect(block1.getLocation(), Effect.STEP_SOUND, 5);
  10.  
  11.                 Location ploc = player.getLocation();
  12.                 player.sendMessage(ploc.toString());
  13.                 block2.setType(Material.DISPENSER);
  14.                 if (ploc.getYaw() >= 45 && ploc.getYaw() <= 135) {
  15.                     block2.setData((byte) 5); //West
  16.                 } else if (ploc.getYaw() >= 135 && ploc.getYaw() <= 225) {
  17.                     block2.setData((byte) 3); //North
  18.                 } else if (ploc.getYaw() >= 225 && ploc.getYaw() <= 315) {
  19.                     block2.setData((byte) 4); //east
  20.                 } else {
  21.                     block2.setData((byte) 2); //south
  22.                 }
  23.                 block2.getLocation().getWorld().playEffect(block2.getLocation(), Effect.STEP_SOUND, 2);
  24.  
  25.                 ArrayList<Block> blocks = new ArrayList<>();
  26.                 blocks.add(baseBlock);
  27.                 blocks.add(block1);
  28.                 blocks.add(block2);
  29.  
  30.                 structure.put("Building", blocks);
  31.                 player.sendMessage(ChatColor.GREEN + "Structure placed!");
  32.                 if (structures.get(player) == null) {
  33.                     ArrayList<HashMap<String, ArrayList<Block>>> h = new ArrayList<>();
  34.                     h.add(structure);
  35.                     structures.put(player, h);
  36.                     player.sendMessage("new entry added!");
  37.                 } else {
  38.                     ArrayList array = structures.get(player);
  39.                     array.add(structure);
  40.                     structures.put(player, array);
  41.                 }
  42.                 return true;
  43.             } else {
  44.                 player.sendMessage(ChatColor.RED + "You cannot place that here!");
  45.                 return false;
  46.  
  47.             }
  48.         }
  49.         return false;
  50.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement