Signs not being written to

Discussion in 'Plugin Development' started by Gopaintman, Sep 26, 2013.

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

    Gopaintman

    So I'm trying to have this plugin write to signs that have been created using a cuboid.
    Basically the program gets the selection, creates a List<Block> of the blocks within the cuboid. Then a for loop goes through and sets all the selected blocks to a sign in which it then writes a test statement on them. For some reason the signs are being generated fine, however they are not getting any message written to them.

    Code:java
    1. List<Block> signs = Main.blocksFromTwoPoints(selection.getPoint1(),
    2. selection.getPoint2());
    3. sender.sendMessage(ChatColor.YELLOW + "Selection found");
    4. Block block;
    5.  
    6. for(int i = 0; i< signs.size();i++){
    7. block = signs.get(i);
    8.  
    9.  
    10. block.setType(Material.SIGN_POST);
    11. Sign sign = (Sign) block.getState();
    12. for(int a = 0; a<4; a++){
    13. sign.setLine(a, "sign");
    14. }
    15.  
    16.  
    17. }


    blocksFromTwoPoints Method:
    Code:java
    1. public static List<Block> blocksFromTwoPoints(Location loc1, Location loc2) {
    2. List<Block> blocks = new ArrayList<Block>();
    3.  
    4. int topBlockX = (loc1.getBlockX() < loc2.getBlockX() ? loc2.getBlockX()
    5. : loc1.getBlockX());
    6. int bottomBlockX = (loc1.getBlockX() > loc2.getBlockX() ? loc2
    7. .getBlockX() : loc1.getBlockX());
    8.  
    9. int topBlockY = (loc1.getBlockY() < loc2.getBlockY() ? loc2.getBlockY()
    10. : loc1.getBlockY());
    11. int bottomBlockY = (loc1.getBlockY() > loc2.getBlockY() ? loc2
    12. .getBlockY() : loc1.getBlockY());
    13.  
    14. int topBlockZ = (loc1.getBlockZ() < loc2.getBlockZ() ? loc2.getBlockZ()
    15. : loc1.getBlockZ());
    16. int bottomBlockZ = (loc1.getBlockZ() > loc2.getBlockZ() ? loc2
    17. .getBlockZ() : loc1.getBlockZ());
    18.  
    19. for (int x = bottomBlockX; x <= topBlockX; x++) {
    20. for (int z = bottomBlockZ; z <= topBlockZ; z++) {
    21. for (int y = bottomBlockY; y <= topBlockY; y++) {
    22. Block block = loc1.getWorld().getBlockAt(x, y, z);
    23.  
    24. blocks.add(block);
    25. }
    26. }
    27. }
    28.  
    29. return blocks;
    30. }
     
  2. Offline

    The_Doctor_123

    Code:java
    1. sign.update();
     
  3. Offline

    Gopaintman


    hmm, doesn't seem to work.

    Placed correctly?
    Code:java
    1. for(int i = 0; i< signs.size();i++){
    2. block = signs.get(i);
    3.  
    4.  
    5. block.setType(Material.SIGN_POST);
    6. Sign sign = (Sign) block.getState();
    7.  
    8.  
    9. sign.setLine(1, "sign");
    10. sign.update();
    11.  
    12.  
    13.  
    14. }
     
  4. Offline

    The_Doctor_123

    Gopaintman
    Maybe you have to do
    Code:java
    1. sign.update(true);
     
    Gopaintman likes this.
  5. Offline

    Gopaintman

Thread Status:
Not open for further replies.

Share This Page