SHARE
TWEET

Untitled

a guest May 26th, 2019 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Player Disconnect:
  2.  
  3.     @EventHandler
  4.     public void handlePlayerDisconnect(PlayerDisconnectEvent event) {
  5.         final ProxiedPlayer player = event.getPlayer();
  6.         final FriendsData friendsPlayer = this.ventoxyCord.getFriendsManager().getCachedFriendsData().get(player.getName());
  7.  
  8.         for (String allFriendsUUIDs : friendsPlayer.getFriends()) {
  9.             ProxiedPlayer allFriendsAsPlayer = ProxyServer.getInstance().getPlayer(UUID.fromString(allFriendsUUIDs));
  10.             friendsPlayer.getFriends().stream().filter(s -> allFriendsAsPlayer != null).forEach(onlinePlayer -> ProxyServer.getInstance().getPlayer(UUID.fromString(onlinePlayer)).sendMessage(TextComponent.fromLegacyText(Prefix.getFriendsPrefix() + "§e" + player.getName() + " §7ist nun §c§loffline§8.")));
  11.         }
  12.  
  13.         System.out.println(player.getUniqueId().toString());
  14.  
  15.         this.ventoxyCord.getBackendManager().getBungeePlayer(player.getUniqueId().toString(), bungeePlayer -> {
  16.             final long onlineTime = System.currentTimeMillis() - this.ventoxyCord.getOnlineTimeManager().getOnlineTimeCache().get(player.getUniqueId().toString());
  17.  
  18.             Gson gson = new GsonBuilder().setPrettyPrinting().create();
  19.             System.out.println(gson.toJson(friendsPlayer));
  20.  
  21.             bungeePlayer.setFriendsData(friendsPlayer);
  22.             bungeePlayer.setPlaytime(bungeePlayer.getPlaytime() + onlineTime);
  23.  
  24.             System.out.println(gson.toJson(bungeePlayer.getFriendsData()));
  25.  
  26.             System.out.println(gson.toJson(bungeePlayer));
  27.  
  28.             this.ventoxyCord.getBackendManager().updatePlayer(bungeePlayer, (updateResult, throwable) -> ProxyServer.getInstance().getConsole().sendMessage("success"));
  29.         });
  30.     }
  31.  
  32. Update Methode:
  33.  
  34.     public void updatePlayer(final VentoxyPlayer ventoxyPlayer, final SingleResultCallback<UpdateResult> callback) {
  35.         if (ventoxyPlayer == null)
  36.             throw new NullPointerException("null");
  37.  
  38.         this.mongoDB.getPlayerCollection().replaceOne(Filters.eq("uuid", ventoxyPlayer.getUuid()),
  39.                 gson.fromJson(gson.toJson(ventoxyPlayer), Document.class), callback);
  40.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top