SHARE
TWEET

Untitled

a guest Apr 27th, 2018 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package fr.happytony.overplugin;
  2.  
  3. import java.sql.PreparedStatement;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.util.HashMap;
  7. import java.util.Map;
  8. import java.util.UUID;
  9.  
  10. import fr.happytony.overplugin.cache.BanPlayerData;
  11. import fr.happytony.overplugin.commands.CmdBan;
  12. import fr.happytony.overplugin.commands.CommandCoin;
  13. import fr.happytony.overplugin.commands.CommandDiscord;
  14. import fr.happytony.overplugin.commands.CommandSpawn;
  15. import fr.happytony.overplugin.commands.CommandTest;
  16. import fr.happytony.overplugin.sql.SQL;
  17.  
  18. public class Main extends org.bukkit.plugin.java.JavaPlugin
  19. {
  20.  
  21.  
  22.   public SQL sql;
  23.  
  24.   public Map<UUID, BanPlayerData> bannis = new HashMap<>();
  25.  
  26.   public CmdBan cmdBan = new CmdBan(this);
  27.   public CommandCoin cmdCoin = new CommandCoin(sql);
  28.  
  29.   public void onEnable()
  30.   {
  31.     //recup les commandes
  32.     getCommand("gtempban").setExecutor(cmdBan);
  33.     getCommand("pay").setExecutor(cmdCoin);
  34.     getCommand("balance").setExecutor(cmdCoin);
  35.     getCommand("gban").setExecutor(cmdBan);
  36.     getCommand("unban").setExecutor(cmdBan);
  37.     getCommand("test").setExecutor(new CommandTest());
  38.     getCommand("spawn").setExecutor(new CommandSpawn());
  39.     getCommand("discord").setExecutor(new CommandDiscord());
  40.     //mettre le listener en event
  41.    getServer().getPluginManager().registerEvents(new Listerners(this, sql), this);
  42.     //connecté le serveur MySQL
  43.     sql = new SQL("jdbc:mysql://","localhost","serveur","root","");
  44.     sql.connection();
  45.  
  46.     //charger les joueur ban
  47.     loadBannedPlayers();
  48.   }
  49.  
  50.   private void loadBannedPlayers() {
  51.      
  52.       try {
  53.           PreparedStatement q = sql.getConnection().prepareStatement("SELECT uuid, reason, expiredate FROM bannis WHERE CURDATE() < expiredate");
  54.      
  55.           ResultSet resultat = q.executeQuery();
  56.          
  57.           while(resultat.next()){
  58.              
  59.               UUID uuid = UUID.fromString(resultat.getString("uuid"));
  60.               String reason = resultat.getString("reason");
  61.              
  62.               BanPlayerData ban = new BanPlayerData();
  63.               ban.setReason(reason);
  64.               ban.setUuid(uuid);
  65.              
  66.               bannis.put(uuid, ban);
  67.              
  68.           }
  69.          
  70.           q.execute();
  71.           q.close();
  72.       } catch (SQLException e) {
  73.           e.printStackTrace();
  74.       }
  75.      
  76.       System.out.println(bannis.size() + " joueurs ont été bannis sur le serveur !");
  77.      
  78.   }
  79.  
  80.   public void onDisable(){
  81.       sql.disconnect();
  82.   }
  83.  
  84.  
  85.  
  86.  
  87. }
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