Solved Placing an iron door

Discussion in 'Plugin Development' started by cfil360, Aug 29, 2013.

Thread Status:
Not open for further replies.
  1. Offline

    cfil360

    I am trying to place an iron door with a command, but i can't get it working. It places the block, but it auto deletes it.
     
  2. Offline

    Trevor1134

    Show the code?
     
  3. Offline

    cfil360

    Trevor1134 here you go
    Code:java
    1. if(args[0].equalsIgnoreCase("door")){
    2. if(p.hasPermission("infirmity.admin")) {
    3. Location l = p.getLocation();
    4. Block bottom = p.getWorld().getBlockAt(l.getBlockX(), l.getBlockY(), l.getBlockZ());
    5. Block top = bottom.getRelative(BlockFace.UP, 1);
    6.  
    7. Byte data1 = (0x8); //not sure on this syntax...
    8. Byte data2 = (0x4); //not sure on this syntax...
    9. top.setTypeIdAndData(64, data1, true);
    10. bottom.setTypeIdAndData(64, data2, true);
    11.  
    12. p.getWorld().getBlockAt(l).setTypeId(71);
    13. p.sendMessage(ChatColor.GREEN + "Door set at " + l.getBlockX() + "," + l.getBlockY() + "," + l.getBlockZ());
    14. return true;
    15. }
    16. else {
    17. p.sendMessage(ChatColor.RED + noPermission);
    18. }
     
  4. Offline

    cfil360

  5. Offline

    lenis0012

    dont need:
    Code:java
    1. p.getWorld().getBlockAt(l).setTypeId(71);


    and replace:
    Code:java
    1. top.setTypeIdAndData(64, data1, true);
    2. bottom.setTypeIdAndData(64, data2, true);


    with:
    Code:java
    1. top.setTypeIdAndData(71, data1, true);
    2. bottom.setTypeIdAndData(71, data2, true);



    Be careful when copying code from threads related to orther subjects ;)
    https://forums.bukkit.org/threads/how-do-i-place-doors-at-given-coords.57921/
     
    cfil360 likes this.
Thread Status:
Not open for further replies.

Share This Page