Questions

Discussion in 'Plugin Development' started by Heroiik, May 12, 2014.

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

    Heroiik

    Hi, hi everyone, i have an question :

    In the code, this line is execute how many times in one second ?

    world.getBlockAt(new Location(world, x, y, z)).setType(Material.ICE);

    Once or until the loop isn't finished ?

    Code:java
    1. public void Timer(final Location pos1, final Location pos2)
    2. {
    3. final double blockToDeplace = 0;
    4.  
    5. getServer().getScheduler().scheduleSyncRepeatingTask(this, new Runnable()
    6. {
    7. @Override
    8. public void run()
    9. {
    10. World world = pos1.getWorld();
    11. double counter = blockToDeplace;
    12.  
    13. if(pos1.getY() < pos2.getY())
    14. counter = (pos1.getY() - pos2.getY());
    15. elsee
    16. counter = (pos2.getY() - pos1.getY());
    17.  
    18.  
    19. if(pos1.getX() < pos2.getX())
    20. {
    21. if(pos1.getZ() < pos2.getZ())
    22. {
    23. for(int x = (int) (pos1.getX()); x < pos2.getX() + 1; x++)
    24. {
    25. for(int y = (int) (pos1.getY()); y < pos2.getY() + 1; y++)
    26. {
    27. for(int z = (int) (pos1.getZ()); z < pos2.getZ() + 1; z++)
    28. {
    29. world.getBlockAt(new Location(world, x, y, z)).setType(Material.ICE);
    30. }
    31. }
    32. }
    33. }
    34. }
    35. }, 0, 20L);
    36. }


    Thanks
     
  2. Offline

    thecrystalflame

    that depens soly on the processing power and memory allocation of the server running the plugin. there is no set speed, you could easily measure it by simple adding a counter variable that increments every time it is called. then printing that value to the console by using a tasktimer every second.
     
Thread Status:
Not open for further replies.

Share This Page