Advertisement
XploreLP

Untitled

Oct 9th, 2015
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. package de.xplore.bansystembungee;
  2.  
  3. import java.io.IOException;
  4. import java.sql.ResultSet;
  5. import java.sql.SQLException;
  6. import java.util.Date;
  7. import java.util.UUID;
  8.  
  9. import net.md_5.bungee.api.event.PreLoginEvent;
  10. import net.md_5.bungee.api.plugin.Listener;
  11. import net.md_5.bungee.api.plugin.Plugin;
  12. import net.md_5.bungee.event.EventHandler;
  13.  
  14. public class Main extends Plugin implements Listener{
  15.  
  16. public void onEnable(){
  17. try {
  18. PropertyMethod.load();
  19. } catch (IOException e) {
  20. e.printStackTrace();
  21. }
  22. MySQLMethod.open();
  23. getProxy().getPluginManager().registerListener(this, this);
  24. }
  25.  
  26. @EventHandler
  27. public void onPreLogin(PreLoginEvent ev){
  28. UUID connectionUUID = ev.getConnection().getUniqueId();
  29. ResultSet resultSet = MySQLMethod.select("SELECT banid, banreason, date, enddate FROM x_ban WHERE banneduuid = '" + connectionUUID.toString() + "'");
  30. try {
  31. if(resultSet.next()){
  32. if(new Date().before(resultSet.getDate("enddate"))){
  33. ev.setCancelled(true);
  34. ev.setCancelReason(resultSet.getString("banreason"));
  35. }
  36. else{
  37. MySQLMethod.insert("DELETE FROM x_ban WHERE banid = " + resultSet.getInt("banid"));
  38. }
  39. }
  40. } catch (SQLException e) {
  41. e.printStackTrace();
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement