Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onJoin(PostLoginEvent e){
- ProxiedPlayer p = e.getPlayer();
- //Avant qu'il se connecte au serveur de base
- System.out.println("PostLoginEvent");
- //MySQl
- PreparedStatement sts;
- if(exist(p)){
- //S'il existe
- }else{
- //S'il n'existe pas
- try {
- sts = MySQL.getConnection().prepareStatement("INSERT INTO players (uuid) VALUES(?)");
- sts.setString(1, p.getUniqueId().toString());
- sts.executeUpdate();
- sts.close();
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- }
- }
- private boolean exist(ProxiedPlayer p){
- PreparedStatement sts;
- String retour = null;
- try {
- sts = MySQL.getConnection().prepareStatement("SELECT count(*) FROM players WHERE uuid = ?");
- sts.setString(1, p.getUniqueId().toString());
- retour = MySQL.getResult(sts.executeQuery(), 1).toString().replaceAll("[\\[\\]]", "");
- sts.close();
- } catch (SQLException e1) {
- e1.printStackTrace();
- }
- Integer infos = Integer.parseInt(retour);
- if(infos == 0){
- return false;
- }else{
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment