Solved Safest way to check a block's data without lagging the server?

Discussion in 'Plugin Development' started by fireboyev, Dec 9, 2016.

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

    fireboyev

    Hey all, I was wondering what the safest way to go for checking a block's data.
    The block I want to recheck/update is the beacon to see the tier and the players in range and then I want to do something to those players in range. Is it safe to use a bukkit runnable or what should I use?
     
  2. Offline

    Zombie_Striker

    @fireboyev
    Use a bukkit runnable.

    BTW: If you are worries about performance (which you should not)
    • Run every second or every half-a-second. You don't need to be that precise.
    • When there are no players online/in that world, return; so you don't need to loop through unnecessarily entities.
     
  3. Offline

    fireboyev

    Thanks it worked. I'm also wondering: How would I be able to test if the player is within a certain radius of a location?
     
  4. Offline

    Zombie_Striker

    @fireboyev
    1. Get the beacons location.
    2. For loop through all the players in a world (World#getPlayers)
    3. get the player's location and check if the distance between that location and the beacon's location is less than __ (BeaconsLoc#distance( player's loc) < ___ ) If this returns true, then the player is close to the beacon.
     
  5. Offline

    fireboyev

    Thanks! It worked perfectly
    -SOLVED-
     
Thread Status:
Not open for further replies.

Share This Page