Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MySQL {
- public static Connection con;
- public static void connect(){
- if(!isConnected()){
- try {
- con = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/Server?autoReconnect=true", "root", "DasPasswortIstFürHacker");
- BungeeCord.getInstance().broadcast("§aDie MySQL Verbindung wurde auf gebaut!");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- public static void disconnect() {
- if(isConnected()){
- try {
- con.close();
- BungeeCord.getInstance().broadcast("§cDie MySQL Verbindung wurde getrennt!");
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
- public static boolean isConnected() {
- return (con != null);
- }
- public static boolean playerExists(ProxiedPlayer p , UUID uuid){
- try {
- PreparedStatement ps = MySQL.con.prepareStatement("SELECT * from Verify Where UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet rs = ps.executeQuery();
- if(rs.next()){
- return rs.getString("UUID") != null;
- }
- rs.close();
- return false;
- } catch (SQLException e) {
- e.printStackTrace();
- }
- return false;
- }
- public static void update(String qry){
- if(isConnected()){
- try {
- con.createStatement().executeUpdate(qry);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- }
- public static void CheckUser(ProxiedPlayer p, UUID uuid) {
- try {
- if(!playerExists(p, uuid)){
- if(p.hasPermission("*")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','Admin');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.mod")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','Moderator');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.sup")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','Supporter');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.srsup")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','SrSupporter');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.jrsup")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','JrSupporter');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.builder")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','Builder');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.yt")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','Youtube');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.vip")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','VIP');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.srmod")){
- PreparedStatement ps = MySQL.con.prepareStatement("INSERT INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','SrModerator');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.srmod")){
- PreparedStatement ps = MySQL.con.prepareStatement("INSERT INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','SrModerator');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.testsup")){
- PreparedStatement ps = MySQL.con.prepareStatement("INSERT INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','Test-Supporter');");
- ps.executeUpdate();
- }else{
- PreparedStatement ps = MySQL.con.prepareStatement("INSERT INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' ','Spieler');");
- ps.executeUpdate();
- }
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public static void UpdateUser(ProxiedPlayer p, UUID uuid, String tsid) {
- try {
- if(!playerExists(p, uuid)){
- if(p.hasPermission("*")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"','" + tsid + "','Admin');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.mod")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"','" + tsid +"','Moderator');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.sup")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' " + tsid +" ','Supporter');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.srsup")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' " + tsid + " ','SrSupporter');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.jrsup")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' " + tsid +" ','JrSupporter');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.builder")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' " + tsid + " ','Builder');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.yt")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' " + tsid +" ','Youtube');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.vip")){
- PreparedStatement ps = MySQL.con.prepareStatement("Insert INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' "+ tsid +" ','VIP');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.srmod")){
- PreparedStatement ps = MySQL.con.prepareStatement("INSERT INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' " + tsid + " ','SrModerator');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.srmod")){
- PreparedStatement ps = MySQL.con.prepareStatement("INSERT INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' " + tsid +" ','SrModerator');");
- ps.executeUpdate();
- }else if(p.hasPermission("system.prefix.testsup")){
- PreparedStatement ps = MySQL.con.prepareStatement("INSERT INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"','" +tsid+"','Test-Supporter');");
- ps.executeUpdate();
- }else{
- PreparedStatement ps = MySQL.con.prepareStatement("INSERT INTO Verify (UUID,tsid,Rang) VALUES ('"+uuid+"',' " + tsid +" ','Spieler');");
- ps.executeUpdate();
- }
- }
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- public static ResultSet getResult(String qry){
- if(isConnected()){
- try {
- return con.createStatement().executeQuery(qry);
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- return null;
- }
- public static void removeID(ProxiedPlayer p, UUID uuid){
- try {
- if(playerExists(p, p.getUniqueId())){
- PreparedStatement ps = MySQL.con.prepareStatement("DELETE FROM Verify WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ps.executeUpdate();
- p.sendMessage(Main.pr + "Du hast erfolgreich deinen Minecraft Account von deinem Teamspeak Account getrennt.");
- }else if(!playerExists(p, p.getUniqueId())){
- p.sendMessage(Main.pr + "Du bist nicht verifiziert.");
- }
- } catch (SQLException e) {
- e.printStackTrace();
- }
- }
- public static void setID(ProxiedPlayer p, String id){
- try {
- PreparedStatement ps = MySQL.con.prepareStatement("UPDATE Verify SET tsid = '"+id+"' WHERE UUID = '"+p.getUniqueId()+"'");
- ps.executeUpdate();
- } catch (SQLException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement