Guest User

Untitled

a guest
Apr 17th, 2020
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1.         HashMap<String, Boolean> isOnline = new HashMap<String, Boolean>();
  2.         BungeeCord.getInstance().getScheduler().schedule(this, new Runnable() {
  3.             public void run() {
  4.                 for(String key : BungeeCord.getInstance().getServers().keySet()) {
  5.                     BungeeCord.getInstance().getServerInfo(key).ping(new Callback<ServerPing>() {
  6.                        
  7.                         @Override
  8.                         public void done(ServerPing result, Throwable error) {
  9.                             Object oldState = isOnline.get(key);
  10.                             boolean newState = true;;
  11.                             if(error == null) {
  12.                                 isOnline.put(key, true);
  13.                             } else {
  14.                                 isOnline.put(key, false);
  15.                                 newState = false;
  16.                             }
  17.                             BaseComponent message = new TextComponent(Utils.chat("&5ERROR-S || REPORT TO SKRUMP"));
  18.                             if(oldState == null || (boolean) oldState != newState) {
  19.                                 if(newState) {
  20.                                     message = new TextComponent(Utils.chat("&4&l[STAFF] &a" + key + " &2is now online!"));
  21.                                 } else {
  22.                                     message = new TextComponent(Utils.chat("&4&l[STAFF] &c" + key + " &4is now offline!"));
  23.                                 }
  24.                                 for(ProxiedPlayer player : BungeeCord.getInstance().getPlayers()) {
  25.                                     if(player.hasPermission("arcadia.staffchat")) {
  26.                                         player.sendMessage(message);
  27.                                     }
  28.                                 }
  29.                             }
  30.                         }
  31.                     });
  32.                 }
  33.             }
  34.         }, 10, 5, TimeUnit.SECONDS);
Advertisement
Add Comment
Please, Sign In to add comment