SHARE
TWEET

Untitled

a guest Dec 16th, 2018 47 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.     public static void setFriendAndOnline(ProxiedPlayer p) {
  2.        
  3.         Integer onlineI = 0;
  4.        
  5.         List<String> freunde = Files.yFriends.getStringList("Freunde von " + PlayerUtil.getUUID(p.getName()));
  6.        
  7.         for(String online : freunde) {
  8.             if(BungeeCord.getInstance().getPlayer(online) != null) {
  9.                 onlineI++;
  10.             }
  11.         }
  12.        
  13.         Main.mysql.update("DELETE FROM Freunde WHERE Name= '" + p.getName() + "'");
  14.        
  15.         Main.mysql.update("INSERT INTO Freunde(Name, Online, Freunde) VALUES ('" + p.getName() + "', '" + onlineI + "', '" + freunde.size() + "');");
  16.        
  17.     public static Integer getFriends(String name) {
  18.         String i = "0";
  19.        
  20.         if(PlayerExists(name)) {
  21.             try {
  22.                
  23.                 ResultSet rs = Main.mysqlf.query("SELECT * FROM Freunde WHERE Name= '" + name + "'");
  24.                 if((!rs.next()) || (String.valueOf(rs.getString("Freunde")) == null));
  25.                    
  26.                 i = rs.getString("Freunde");
  27.             } catch (SQLException e) {
  28.                 e.printStackTrace();
  29.             }
  30.         }
  31.            
  32.         return Integer.valueOf(i);
  33.     }
  34.    
  35.     public static Integer getOnline(String name) {
  36.         String i = "0";
  37.        
  38.         if(PlayerExists(name)) {
  39.             try {
  40.                
  41.                 ResultSet rs = Main.mysqlf.query("SELECT * FROM Freunde WHERE Name= '" + name + "'");
  42.                 if((!rs.next()) || (String.valueOf(rs.getString("Online")) == null));
  43.                    
  44.                 i = rs.getString("Online");
  45.             } catch (SQLException e) {
  46.                 e.printStackTrace();
  47.             }
  48.         }
  49.        
  50.         return Integer.valueOf(i);
  51.     }
  52.    
  53.     public static boolean PlayerExists(String name) {
  54.         try {
  55.            
  56.             ResultSet rs = Main.mysqlf.query("SELECT * FROM Freunde WHERE Name= '" + name + "'");
  57.            
  58.         if(rs.next()) {
  59.             return rs.getString("Freunde") != null;
  60.         }
  61.         return false;
  62.         } catch (SQLException e) {
  63.             e.printStackTrace();
  64.         }
  65.     return false;
  66.     }
  67.  
  68.     }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top