No idea whats happening

Discussion in 'Plugin Development' started by MoseMister, Sep 24, 2014.

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

    MoseMister

    Ok so im not sure if this is a Java error or Bukkit API error or something I just can not see.
    I have debugged the whole plugin and found out that the error only occurs when i have
    Code:
    block2.setTypeId(id);
    block2.setData(data);
    //or
    block2.setType(material);
    block2.setData(data);
    //or
    block2.setTypeIdAndData(id, data, false);
    however the debug fails before it gets to that stage. Here is my code
    Code:java
    1. @SuppressWarnings("deprecation")
    2. public static void ForceMove(int Speed, String direction, Vessel vessel, List<Block> vesselBlocks, Player player){
    3.  
    4. for (Block block : vesselBlocks){
    5. Bukkit.getLogger().info("BeforeBeforeMove = " + block.getType().toString());
    6. }
    7.  
    8. for (Block block : vesselBlocks){
    9. Bukkit.getLogger().info("BeforeMove = " + block.getType().toString());
    10. if (direction.equalsIgnoreCase("-X")){
    11. double X = block.getLocation().getX() - Speed;
    12. double Y = block.getLocation().getY();
    13. double Z = block.getLocation().getZ();
    14. int id = block.getTypeId();
    15. byte data = block.getData();
    16. Location loc = new Location(block.getWorld(), X, Y, Z);
    17. Block block2 = loc.getBlock();
    18. block2.setTypeId(id);
    19. block2.setData(data);
    20. }
    21. }
    22. }



    now time to tell you the error. The blocks change themselves between the first debug and the 2nd debug (Bukkit.getLogger().info("message") being the debugs) to something that they are not suppose to be.

    This is what it comes up with in the console (3 WALL_SIGNs before then only 2 WALL_SIGNs):
    Code:
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WALL_SIGN
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WALL_SIGN
    [12:43:54 INFO]: BeforeBeforeMove = WOOD
    [12:43:54 INFO]: BeforeBeforeMove = WALL_SIGN
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WALL_SIGN
    [12:43:54 INFO]: BeforeMove = WOOD
    [12:43:54 INFO]: BeforeMove = WALL_SIGN
    

    it replaces the wall sign with wood. I have also found that the block connected to the wall sign also changes to the block that the wall sign clicked is attached to.

    oh and i have also tried using block2.getRelative(-Speed, 0, 0); but the same error occurs

    Any Ideas?
     
  2. Offline

    fireblast709

    MoseMister make sure when you place the wall sign, the block it is supposed to be attached to exists. Also, what most likely causes your bug, is that you move your blocks in the wrong order (for example, if you move to -x, you replace them from +x to -x, which causes you to replace blocks before they move)

    Lastly, don't use Bukkit.getLogger() since this is the same as Logger.getLogger("Minecraft"). Use the Logger you get from JavaPlugin's getLogger() method.
     
  3. Offline

    MoseMister

    I though of that whist writing the code just forgot to put it in. Ill have a go

    Thanks. Just tried it ;)

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 14, 2016
Thread Status:
Not open for further replies.

Share This Page