Solved Ping acting weird?

Discussion in 'Plugin Development' started by KarimAKL, Jul 1, 2018.

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

    KarimAKL

    I've been trying to work with ping and i wanted to start off by doing some testing but the ping seems to be acting weird.
    Here is some examples:
    Ping only going down:
    2018-07-02_05.07.23.png
    Ping repeating itself:
    2018-07-02_05.11.27.png
    The first one i don't understand but the second one is probably just because of my coding. :p
    Here is the code i've been using to test:
    Code:Java
    1.  
    2. public class Test implements CommandExecutor {
    3.  
    4. private Main plugin;
    5.  
    6. public Test(Main plugin) {
    7. this.plugin = plugin;
    8. plugin.getCommand("test").setExecutor(this);
    9. }
    10.  
    11. String ping = String.valueOf(0);
    12. String oldping = ping;
    13.  
    14. @Override
    15. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    16. if (cmd.getName().equalsIgnoreCase("test")) {
    17. if (sender instanceof Player) {
    18. Player p = (Player) sender;
    19. ping = String.valueOf(((CraftPlayer) p).getHandle().ping);
    20. oldping = ping;
    21. p.sendMessage("Ping "+ping);
    22. new BukkitRunnable() {
    23. public void run() {
    24. ping = String.valueOf(((CraftPlayer) p).getHandle().ping);
    25. if (!oldping.equals(ping)) {
    26. oldping = ping;
    27. p.sendMessage("Ping "+ping);
    28. }
    29. }
    30. }.runTaskTimer(plugin, 20*2, 20*2);
    31. return true;
    32. } else {
    33. sender.sendMessage("nope");
    34. return true;
    35. }
    36. }
    37. return false;
    38. }
    39. }
    40.  

    Did i do something wrong? Btw the oldping is to check if it's the same, if it is then don't spam the chat with the same ping, if it's not the same then send a new message.
     
  2. Offline

    Zombie_Striker

    @KarimAKL
    How long have you let your code run? If you let it run long enough, it should reach a minimum. Does it stay at that minimum, or does it then increase (and if it does, by how much)?
     
  3. Offline

    KarimAKL

    @Zombie_Striker With the one where it only went down i think i let it stay around 10-15 minutes. Max 15 minutes but still, it should've at least went up a little. :/
    EDIT: It wouldn't be a problem if my ping really didn't go up tho. :p (I wasn't experiencing lag or anything, tho it was only on a test server with like 4 small plugins)
    EDIT2: I think i'll try letting it go for minimum 1 hour and see if it went up aswell as down. I'll get back here when it goes up or i give up on it going up.
    EDIT3: After around 35 minutes it seems it went up by 1! :p
    2018-07-02_06.38.44.png
    Seems kinda weird how it goes down in pretty large chunks and when it gets to around 60 and down it's very slow and only by like 1 and it rarely goes up. (doesn't seem like a normal ping to me)
    Btw around the 50 it can take like 5 minutes for it to update, any idea why it does this and if there is a way to get a more accurate ping? (this doesn't seem accurate)
    EDIT4: (I know this is alot of edits and i'm sorry about that. :/) Just wanted to give you an update, since it went from 47 to 48 it has been going like this:
    49
    48
    50
    49
    I just thought i would let you know that it seems like it only goes up and down around 50. (could it be my ping on this test server is just staying around 50 and has been going down to the correct number since testing? If so then it's weird how it can take 30 minutes for that. :/)

    EDIT: From what i've heard it seems this is as accurate as it'll get, marking as solved.
     
    Last edited: Jul 9, 2018
Thread Status:
Not open for further replies.

Share This Page