Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private boolean createStructure(Block baseBlock, Material baseMaterial, Player player) {
- if (getWorldGuard().canBuild(player,baseBlock)) {
- Block block1 = baseBlock.getRelative(BlockFace.UP);
- Block block2 = block1.getRelative(BlockFace.UP);
- HashMap<String, ArrayList<Block>> structure = new HashMap<>();
- if (block1.getType().equals(Material.AIR) && block2.getType().equals(Material.AIR)) {
- baseBlock.setType(baseMaterial);
- block1.setType(Material.ACACIA_FENCE);
- block1.getLocation().getWorld().playEffect(block1.getLocation(), Effect.STEP_SOUND, 5);
- Location ploc = player.getLocation();
- player.sendMessage(ploc.toString());
- block2.setType(Material.DISPENSER);
- if (ploc.getYaw() >= 45 && ploc.getYaw() <= 135) {
- block2.setData((byte) 5); //West
- } else if (ploc.getYaw() >= 135 && ploc.getYaw() <= 225) {
- block2.setData((byte) 3); //North
- } else if (ploc.getYaw() >= 225 && ploc.getYaw() <= 315) {
- block2.setData((byte) 4); //east
- } else {
- block2.setData((byte) 2); //south
- }
- block2.getLocation().getWorld().playEffect(block2.getLocation(), Effect.STEP_SOUND, 2);
- ArrayList<Block> blocks = new ArrayList<>();
- blocks.add(baseBlock);
- blocks.add(block1);
- blocks.add(block2);
- structure.put("Building", blocks);
- player.sendMessage(ChatColor.GREEN + "Structure placed!");
- if (structures.get(player) == null) {
- ArrayList<HashMap<String, ArrayList<Block>>> h = new ArrayList<>();
- h.add(structure);
- structures.put(player, h);
- player.sendMessage("new entry added!");
- } else {
- ArrayList array = structures.get(player);
- array.add(structure);
- structures.put(player, array);
- }
- return true;
- } else {
- player.sendMessage(ChatColor.RED + "You cannot place that here!");
- return false;
- }
- }
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement