performance concerns

Discussion in 'Plugin Development' started by ToastHelmi, Mar 28, 2014.

?

Do you think this could be critical

  1. Yes

    0 vote(s)
    0.0%
  2. No

    0 vote(s)
    0.0%
Thread Status:
Not open for further replies.
  1. Offline

    ToastHelmi

    Im writeing a plugin and im I'm worried about performance issus at this peace of code:

    Code:java
    1. Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(GrandTheftMinecart.getInstance(), new Runnable() {
    2.  
    3. @Override
    4. public void run() {
    5. for(Cooldown c: cooldowns.values()){
    6. c.getPlayer().sendMessage(c.getSecondsLeft()+"");
    7. if(c.getSecondsLeft() == 0){
    8. setWantedLevel(c.getPlayer(), 0);
    9. }
    10. else{
    11. c.decrement();
    12. for(Entity e : c.getPlayer().getNearbyEntities(16, 16, 16)){
    13. if(c.getPlayer().hasLineOfSight(e)){
    14. c.resetCooldown();
    15. break;
    16. }
    17.  
    18. }
    19. }
    20. }
    21.  
    22. }


    this is my Countdownclass:
    Code:java
    1. private class Cooldown{
    2.  
    3. private final long lengthInSeconds;
    4. private long secondsLeft;
    5. private final Player p;
    6.  
    7. public Cooldown(Player p, long lengthInSeconds){
    8. this.p = p;
    9. this.lengthInSeconds = lengthInSeconds-1;
    10. secondsLeft = lengthInSeconds;
    11. }
    12.  
    13. public void decrement() {
    14. secondsLeft--;
    15. }
    16. public long getSecondsLeft() {
    17. return secondsLeft;
    18. }
    19. public void resetCooldown(){
    20. secondsLeft = lengthInSeconds;
    21. }
    22. public Player getPlayer() {
    23. return p;
    24. }
    25. }

    What do you think?
     
  2. Offline

    Opacification

    ToastHelmi,
    Like any another Developer, test it for yourself; if their are any issues you encounter feel free to ask for help.
     
  3. Offline

    ToastHelmi

    Opacification
    I'v already tested it by myselfe and it worked fine (with one player)
    but I doesent hafe the operunity to test it with more players (like 20 or so)
     
  4. Offline

    Jalau

    How often do you run the task? And how much ram does your server has?
     
  5. Offline

    RawCode

    what performance issue you hit?

    where are results of your benchmarks?
     
Thread Status:
Not open for further replies.

Share This Page