This commit is contained in:
AlphaAE
2019-05-02 19:42:43 +08:00
parent b36c37b5ab
commit 01333107f7
5 changed files with 60 additions and 27 deletions

View File

@ -24,21 +24,26 @@ public class DisplayInfoBlock implements JoinQuitEventBlock {
public void onPlayerJoin(PlayerJoinEvent event) {
final Player player = event.getPlayer();
final UUID uuid = player.getUniqueId();
final String name = player.getDisplayName();
try {
infoHandler = MainPlugin.getPlugin().getServer().getScheduler().scheduleDelayedRepeatingTask(new Task() {
@Override
public void onRun(int i) {
String name = player.getDisplayName();
int ping = player.getPing();
RePlayer rePlayer = StaticData.rePlayerMap.get(uuid);
int coin = rePlayer.getCoin();
try {
int ping = player.getPing();
RePlayer rePlayer = StaticData.rePlayerMap.get(uuid);
int coin = rePlayer.getCoin();
player.sendActionBar(TextFormat.colorize("" + name + " &f延迟: " + ping + "ms 硬币: " + coin));
player.sendActionBar(TextFormat.colorize("" + name + " &f延迟: " + ping + "ms 硬币: " + coin));
} catch (Exception e) {
cancel();
}
}
}, Config.JOIN_WAITING_TIME, 36);
} catch (Exception e) {
infoHandler.cancel();
if (infoHandler != null)
infoHandler.cancel();
e.printStackTrace();
}