i've made a ping plugin , and i want when i write /ping it shows to messages and wait for 4500 M.s and give him real ping like big servers , i made this sender.sendMessage("§8§l┃ §a§lBlocks§e§lMC §8┃ §aCalculating your ping, please wait..."); try { Thread.sleep(4500L); } catch (InterruptedException ex) { Thread.currentThread().interrupt(); } sender.sendMessage("§8§l┃ §a§lBlocks§e§lMC §8┃ §aYour latency (ping) is: §a" + RealPing.getPing((Player)sender)); -------- but when i do that it stop the server for 4500L , i want to send the first to messages after that the realpingmessages , thx.
Well I really didn't understand what you are trying to tell, just step your grammar up a bit. But one thing is more than clear: NEVER NEVER use the the Thread#sleep() Method in one of your plugins! Switch it out with this Codesnippet Code:java // Put your first Message here Bukkit.getScheduler.runTaskLater(this, new Runnable() { @Override public void run() { // Put your second Message here } }, 4.5 * 20L);
i meant that in big servers like HiveMc , when i type /ping it gives me ! Pong ! Calculating your ping and no thing happen for 4 seconds after that it tells me my ping ! your ping is : .. that i meant i want to wait for 4 seconds after that i want it to tell me the ping ,, i don't want to use Runnable :/ @InstanceofDeath
@tvtad202020 Unless you have a terrible connection, it should not take four seconds to calculate the ping. Instead, just use this: Code: int ping = ((CraftPlayer) player).getHandle().ping; Note, this is version dependent, but this should work if you are building this plugin for only your server.
I mean send the 2 messages after that send the ping message like !Pong !Calculate your ping Nand here i want not to do anything after 4 seconds without doing thing send this msg !your ping is ** And i have the code to calculate i just dont now how to make the plugin wait 4 seconds and send the last msg *ping msg* @Zombie_Striker
For the thing you want to do, you HAVE to use BukkitRunnable, because if you don't, it's going to block your server from functioning while it's gonna wait for those 4 seconds. If you put it in a runnable, it's not going to block your server and it's still going to reply in 4500ms if you set it to. If you have any more questions, tag me. Sent from my Xperia M4 Aqua using Tapatalk
Lol you need to describe this "better". Do you want to add a Team Scoreboard and add players to it? Or do you want that every player in a team has a scoreboard on a sidebar with the display name of that team?