Advertisement
Guest User

Untitled

a guest
Nov 2nd, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.46 KB | None | 0 0
  1. package de.rexlNico.GameClient.Api;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DriverManager;
  5. import java.sql.PreparedStatement;
  6. import java.sql.ResultSet;
  7. import java.sql.SQLException;
  8. import java.util.Random;
  9. import java.util.Timer;
  10. import java.util.TimerTask;
  11.  
  12. import javax.swing.JOptionPane;
  13.  
  14. public class MySQLConnection{
  15. private static Connection con = null;
  16. private String dbHost = "****"; // Hostname
  17. private String dbPort = "****"; // Port -- Standard: 3306
  18. private String dbName = "****"; // Datenbankname
  19. private String dbUser = "****"; // Datenbankuser
  20. private String dbPass = "****"; // Datenbankpasswort
  21.  
  22. public MySQLConnection(){
  23. try {
  24. Class.forName("com.mysql.jdbc.Driver"); // Datenbanktreiber für JDBC Schnittstellen laden.
  25.  
  26. // Verbindung zur JDBC-Datenbank herstellen.
  27. con = DriverManager.getConnection("jdbc:mysql://"+dbHost+":"+ dbPort+"/"+dbName+"?"+"user="+dbUser+"&"+"password="+dbPass);
  28. } catch (ClassNotFoundException e) {
  29. System.out.println("Treiber nicht gefunden");
  30. } catch (SQLException e) {
  31. System.out.println("Verbindung nicht moglich");
  32. System.out.println("SQLException: " + e.getMessage());
  33. System.out.println("SQLState: " + e.getSQLState());
  34. System.out.println("VendorError: " + e.getErrorCode());
  35. }
  36. }
  37.  
  38. private static Connection getInstance(){
  39. if(con == null)
  40. new MySQLConnection();
  41. return con;
  42. }
  43.  
  44.  
  45.  
  46. public static boolean hasOwnServer(int userID){
  47. PreparedStatement ps;
  48. try {
  49. ps = con.prepareStatement("Select userID from OwnServers where userID = '"+userID+"'");
  50. ResultSet res = ps.executeQuery();
  51. if(res.next()){
  52. return true;
  53. }
  54.  
  55. } catch (SQLException e) {
  56. // TODO Auto-generated catch block
  57.  
  58. }
  59.  
  60. return false;
  61.  
  62. }
  63. public static boolean loginUser(String username, String pw){
  64. if(username == null || username.equals("")){
  65. return false;
  66. }
  67. PreparedStatement ps;
  68. try {
  69. ps = con.prepareStatement("Select username, password from clientSaveUsers where username = '"+username+"' and password = '"+pw+"'");
  70. ResultSet res = ps.executeQuery();
  71. if(res.next()){
  72. if(res.getString("username") != null){
  73. if(res.getString("password") != null){
  74. return true;
  75. }
  76. }
  77. return false;
  78. }
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85. } catch (SQLException e) {
  86. // TODO Auto-generated catch block
  87.  
  88. }
  89.  
  90. return false;
  91.  
  92. }
  93. public static boolean getClientVersion(){
  94. PreparedStatement ps;
  95. try {
  96. ps = con.prepareStatement("Select version from Clientversion where version = '"+Var.VERSION+"'");
  97. ResultSet res = ps.executeQuery();
  98. if(res.next()){
  99. if(res.getString("version") != null){
  100. return false;
  101. }else{
  102. new update();
  103. return true;
  104. }
  105. }
  106.  
  107.  
  108.  
  109.  
  110.  
  111.  
  112. } catch (SQLException e) {
  113. // TODO Auto-generated catch block
  114.  
  115. }
  116.  
  117. return false;
  118.  
  119. }
  120. public static int getUserID(String username){
  121. if(username == null || username.equals("")){
  122. return 0;
  123. }
  124. PreparedStatement ps;
  125. try {
  126. ps = con.prepareStatement("Select username, userID from clientSaveUsers where username = '"+username+"'");
  127. ResultSet res = ps.executeQuery();
  128. if(res.next()){
  129. return res.getInt("userID");
  130. }
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137. } catch (SQLException e) {
  138. // TODO Auto-generated catch block
  139.  
  140. }
  141.  
  142. return -1;
  143.  
  144. }
  145. public static int getServerOnlinePlayers(int userID){
  146.  
  147. String OvM = "";
  148. PreparedStatement ps;
  149. try {
  150. ps = con.prepareStatement("Select players from OwnServers where userID = '"+userID+"'");
  151. ResultSet res = ps.executeQuery();
  152. if(res.next()){
  153. return res.getInt("players");
  154. }
  155. } catch (SQLException e) {
  156. // TODO Auto-generated catch block
  157.  
  158. }
  159.  
  160. return 0;
  161.  
  162. }
  163. public static int getServerMaxPlayers(int userID){
  164. String OvM = "";
  165. PreparedStatement ps;
  166. try {
  167. ps = con.prepareStatement("Select slots from OwnServers where userID = '"+userID+"'");
  168. ResultSet res = ps.executeQuery();
  169. if(res.next()){
  170. return res.getInt("slots");
  171. }
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178. } catch (SQLException e) {
  179. // TODO Auto-generated catch block
  180.  
  181. }
  182.  
  183. return 0;
  184.  
  185. }
  186. public static int getServerStatus(int userID){
  187. PreparedStatement ps;
  188. try {
  189. ps = con.prepareStatement("Select status from OwnServers where userID = '"+userID+"'");
  190. ResultSet res = ps.executeQuery();
  191. if(res.next()){
  192. return res.getInt("status");
  193. }
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200. } catch (SQLException e) {
  201. // TODO Auto-generated catch block
  202.  
  203. }
  204.  
  205. return 0;
  206.  
  207. }
  208. public static boolean canServerUpdateStatus(int userID){
  209. PreparedStatement ps;
  210. try {
  211. ps = con.prepareStatement("Select ready from OwnServers where userID = '"+userID+"'");
  212. ResultSet res = ps.executeQuery();
  213. if(res.next()){
  214. if(res.getInt("ready") == 1){
  215. return true;
  216. }else{
  217. return false;
  218. }
  219. }
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226. } catch (SQLException e) {
  227. // TODO Auto-generated catch block
  228.  
  229. }
  230.  
  231. return false;
  232.  
  233. }
  234. public static boolean isUserIDUsed(int userID){
  235. PreparedStatement ps;
  236. try {
  237. ps = con.prepareStatement("Select userID from clientSaveUsers where userID = '"+userID+"'");
  238. ResultSet res = ps.executeQuery();
  239. if(res.next()){
  240. return true;
  241. }
  242.  
  243. } catch (SQLException e) {
  244. // TODO Auto-generated catch block
  245.  
  246. }
  247.  
  248. return false;
  249.  
  250. }
  251. public static boolean isServerPortUsed(int port){
  252. PreparedStatement ps;
  253. try {
  254. ps = con.prepareStatement("Select port from OwnServers where port = '"+port+"'");
  255. ResultSet res = ps.executeQuery();
  256. if(res.next()){
  257. return true;
  258. }
  259.  
  260. } catch (SQLException e) {
  261. // TODO Auto-generated catch block
  262.  
  263. }
  264.  
  265. return false;
  266.  
  267. }
  268. public static boolean isSaveLogin(String username){
  269. if(username == null || username.equals("")){
  270. return false;
  271. }
  272. PreparedStatement ps;
  273. try {
  274. ps = con.prepareStatement("Select username, isenable from clientSaveUsers where username = '"+username+"'");
  275. ResultSet res = ps.executeQuery();
  276. if(res.next()){
  277. if(res.getString("username") != null){
  278. if(res.getString("isenable") != null){
  279. if(res.getInt("isenable") == 0){
  280. return false;
  281. }else{
  282. return true;
  283. }
  284. }
  285. }
  286. return false;
  287. }
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294. } catch (SQLException e) {
  295. // TODO Auto-generated catch block
  296.  
  297. }
  298.  
  299. return false;
  300.  
  301. }
  302. public static boolean isUserRegistered(String username){
  303. if(username == null || username.equals("")){
  304. return false;
  305. }
  306. PreparedStatement ps;
  307. try {
  308. ps = con.prepareStatement("Select username from clientSaveUsers where username = '"+username+"'");
  309. ResultSet res = ps.executeQuery();
  310. if(res.next()){
  311. if(res.getString("username") != null){
  312. return true;
  313. }else{
  314. return false;
  315. }
  316. }
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323. } catch (SQLException e) {
  324. // TODO Auto-generated catch block
  325.  
  326. }
  327.  
  328. return false;
  329.  
  330. }
  331. public static boolean isServernameUsed(String servername){
  332. PreparedStatement ps;
  333. try {
  334. ps = con.prepareStatement("Select servername from OwnServers where servername = '"+servername+"'");
  335. ResultSet res = ps.executeQuery();
  336. if(res.next()){
  337. if(res.getString("username") != null){
  338. return true;
  339. }else{
  340. return false;
  341. }
  342. }
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349. } catch (SQLException e) {
  350. // TODO Auto-generated catch block
  351.  
  352. }
  353.  
  354. return false;
  355.  
  356. }
  357. public static boolean isMailUsed(String mail){
  358. if(mail == null || mail.equals("")){
  359. return false;
  360. }
  361. PreparedStatement ps;
  362. try {
  363. ps = con.prepareStatement("Select mail from clientMails where mail = '"+mail+"'");
  364. ResultSet res = ps.executeQuery();
  365. if(res.next()){
  366. if(res.getString("mail") != null){
  367. return true;
  368. }else{
  369. return false;
  370. }
  371. }
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378. } catch (SQLException e) {
  379. // TODO Auto-generated catch block
  380.  
  381. }
  382.  
  383. return false;
  384.  
  385. }
  386. public static boolean isServerInBeta(int userID){
  387. PreparedStatement ps;
  388. try {
  389. ps = con.prepareStatement("Select beta from OwnServers where userID = '"+userID+"'");
  390. ResultSet res = ps.executeQuery();
  391. if(res.next()){
  392. if(res.getInt("beta") == 1){
  393. return true;
  394. }else{
  395. return false;
  396. }
  397. }
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404. } catch (SQLException e) {
  405. // TODO Auto-generated catch block
  406.  
  407. }
  408.  
  409. return true;
  410.  
  411. }
  412. public static boolean isServerInWartung(int userID){
  413. PreparedStatement ps;
  414. try {
  415. ps = con.prepareStatement("Select wartung from OwnServers where userID = '"+userID+"'");
  416. ResultSet res = ps.executeQuery();
  417. if(res.next()){
  418. if(res.getInt("wartung") == 1){
  419. return true;
  420. }else{
  421. return false;
  422. }
  423. }
  424. } catch (SQLException e) {
  425. // TODO Auto-generated catch block
  426.  
  427. }
  428.  
  429. return true;
  430.  
  431. }
  432. public static boolean isServerPremium(int userID){
  433. PreparedStatement ps;
  434. try {
  435. ps = con.prepareStatement("Select premium from OwnServers where userID = '"+userID+"'");
  436. ResultSet res = ps.executeQuery();
  437. if(res.next()){
  438. if(res.getInt("premium") == 1){
  439. return true;
  440. }else{
  441. return false;
  442. }
  443. }
  444. } catch (SQLException e) {
  445. // TODO Auto-generated catch block
  446. }
  447.  
  448. return false;
  449.  
  450. }
  451. public static boolean createAccount(String username, String password, String mail){
  452. if(username == null || username.equals("") || password == null || password.equals("") || mail == null || mail.equals("")){
  453. return false;
  454. }
  455. boolean b = true;
  456. String ids = "";
  457. int id = 0;
  458.  
  459. while(b == true){
  460. id = new Random().nextInt(9);
  461. ids = id+"";
  462. id = new Random().nextInt(9);
  463. ids += id;
  464. id = new Random().nextInt(9);
  465. ids += id;
  466. id = new Random().nextInt(9);
  467. ids += id;
  468. id = new Random().nextInt(9);
  469. ids += id;
  470. id = new Random().nextInt(9);
  471. ids += id;
  472. id = new Random().nextInt(9);
  473. ids += id;
  474. id = new Random().nextInt(9);
  475. ids += id;
  476.  
  477. System.out.println(ids);
  478. if(!isUserIDUsed(Integer.parseInt(ids))){
  479. b = false;
  480. }
  481.  
  482. }
  483.  
  484. PreparedStatement ps;
  485. try {
  486. ps = con.prepareStatement("INSERT INTO clientMails (mail) VALUES ('"+mail+"')");
  487. ps.execute();
  488.  
  489. ps = con.prepareStatement("INSERT INTO clientSaveUsers (username, isenable, mail, password, userID, changes, premium) VALUES ('"+username+"', '0', '"+mail+"', '"+password+"', '"+Integer.parseInt(ids)+"', '1', '0')");
  490. ps.execute();
  491.  
  492.  
  493.  
  494.  
  495.  
  496.  
  497. } catch (SQLException e) {
  498. // TODO Auto-generated catch block
  499.  
  500. }
  501.  
  502. return false;
  503.  
  504. }
  505. public static boolean createServer(int userID, String username, String Servername, String motd, boolean PvP, boolean PvE){
  506.  
  507. boolean b = true;
  508. String port = "";
  509. int id = 0;
  510.  
  511. while(b == true){
  512. id = new Random().nextInt(9);
  513. port = id+"";
  514. id = new Random().nextInt(9);
  515. port += id;
  516. id = new Random().nextInt(9);
  517. port += id;
  518. id = new Random().nextInt(9);
  519. port += id;
  520. id = new Random().nextInt(9);
  521. port += id;
  522.  
  523. if(!isServerPortUsed(Integer.parseInt(port))){
  524. b = false;
  525. }
  526.  
  527. }
  528. int pvp = 0;
  529. int pve = 0;
  530. if(PvP) pvp = 1;
  531. if(PvE) pve = 1;
  532.  
  533.  
  534. PreparedStatement ps;
  535. try {
  536. ps = con.prepareStatement("INSERT INTO OwnServers (userID, username, servername, port, motd, slots, status, PvP, PvE, players, premium, wartung, beta, ready) VALUES ('"+userID+"', '"+username+"', '"+Servername+"', '"+Integer.parseInt(port)+"', '"+motd+"', '60', '0', '"+pvp+"', '"+pve+"', '0', '0', '1', '0', '0')");
  537. ps.execute();
  538.  
  539. ps = con.prepareStatement("CREATE TABLE IF NOT EXISTS `Server-"+username+"` (userID int(10), username varchar(15), owner int(1), headadmin int(1), admin int(1), premium int(1))");
  540. ps.execute();
  541.  
  542. ps = con.prepareStatement("INSERT INTO `Server-"+username+"` (userID, username, owner, headadmin, admin, premium) VALUES ('"+userID+"', '"+username+"', '1', '0', '0', '0')");
  543. ps.execute();
  544.  
  545. ps = con.prepareStatement("INSERT INTO `Server-"+username+"` (userID, username, owner, headadmin, admin, premium) VALUES ('"+getUserID("rexlNico")+"', 'rexlNico', '0', '1', '0', '0')");
  546. ps.execute();
  547.  
  548.  
  549.  
  550.  
  551.  
  552.  
  553. } catch (SQLException e) {
  554. // TODO Auto-generated catch block
  555.  
  556. }
  557.  
  558. return false;
  559.  
  560. }
  561. public static String getPassword(String username){
  562. if(username == null || username.equals("")){
  563. return "ERROR >> Kein Username";
  564. }
  565. PreparedStatement ps;
  566. try {
  567. ps = con.prepareStatement("Select username, password from clientSaveUsers where username = '"+username+"'");
  568. ResultSet res = ps.executeQuery();
  569. if(res.next()){
  570. return res.getString("password");
  571. }
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578. } catch (SQLException e) {
  579. // TODO Auto-generated catch block
  580.  
  581. }
  582.  
  583. return "ERROR >> MYSQL";
  584.  
  585. }
  586. public static int getNameChanges(String username){
  587. if(username == null || username.equals("")){
  588. return 0;
  589. }
  590. PreparedStatement ps;
  591. try {
  592. ps = con.prepareStatement("Select username, changes from clientSaveUsers where username = '"+username+"'");
  593. ResultSet res = ps.executeQuery();
  594. if(res.next()){
  595. return res.getInt("changes");
  596. }
  597.  
  598.  
  599.  
  600.  
  601.  
  602.  
  603. } catch (SQLException e) {
  604. // TODO Auto-generated catch block
  605.  
  606. }
  607.  
  608. return 0;
  609.  
  610. }
  611. public static String getMail(String username){
  612.  
  613. if(username == null || username.equals("")){
  614. return "ERROR >> Kein Username";
  615. }
  616. PreparedStatement ps;
  617. try {
  618. ps = con.prepareStatement("Select username, mail from clientSaveUsers where username = '"+username+"'");
  619. ResultSet res = ps.executeQuery();
  620. if(res.next()){
  621. return res.getString("mail");
  622. }
  623.  
  624.  
  625.  
  626.  
  627.  
  628.  
  629. } catch (SQLException e) {
  630. // TODO Auto-generated catch block
  631.  
  632. }
  633.  
  634. return "ERROR >> MYSQL";
  635.  
  636. }
  637. public static String getServerMotd(int userID){
  638. PreparedStatement ps;
  639. try {
  640. ps = con.prepareStatement("Select motd from OwnServers where userID = '"+userID+"'");
  641. ResultSet res = ps.executeQuery();
  642. if(res.next()){
  643. return res.getString("motd");
  644. }
  645.  
  646.  
  647.  
  648.  
  649.  
  650.  
  651. } catch (SQLException e) {
  652. // TODO Auto-generated catch block
  653.  
  654. }
  655.  
  656. return "ERROR >> MYSQL";
  657.  
  658. }
  659. public static void setSaveLogin(String username, boolean trueoderfalse){
  660. if(username == null || username.equals("")){
  661. return;
  662. }
  663. PreparedStatement ps;
  664. try {
  665. if(trueoderfalse){
  666. ps = con.prepareStatement("UPDATE clientSaveUsers SET isenable = '1' where username = '"+username+"'");
  667. ps.execute();
  668. }else{
  669. ps = con.prepareStatement("UPDATE clientSaveUsers SET isenable = '0' where username = '"+username+"'");
  670. ps.execute();
  671. }
  672. } catch (SQLException e) {
  673.  
  674. }
  675. }
  676. public static void updateServerStatus(int userID, boolean online, boolean restart){
  677. PreparedStatement ps;
  678. try {
  679. if(restart){
  680. ps = con.prepareStatement("UPDATE OwnServers SET status = '-1' where userID = '"+userID+"'");
  681. ps.execute();
  682. }else if(online){
  683. ps = con.prepareStatement("UPDATE OwnServers SET status = '1' where userID = '"+userID+"'");
  684. ps.execute();
  685. }else{
  686. ps = con.prepareStatement("UPDATE OwnServers SET status = '0' where userID = '"+userID+"'");
  687. ps.execute();
  688. }
  689. ps = con.prepareStatement("UPDATE OwnServers SET ready = '0' where userID = '"+userID+"'");
  690. ps.execute();
  691. } catch (SQLException e) {
  692.  
  693. }
  694. }
  695. public static void setUsername(String usernameOld, String usernameNew){
  696. if(usernameOld == null || usernameOld.equals("") || usernameNew == null || usernameNew.equals("")){
  697. return;
  698. }
  699. PreparedStatement ps;
  700. try {
  701.  
  702. if(!isUserRegistered(usernameNew)){
  703. ps = con.prepareStatement("UPDATE clientSaveUsers SET username = '"+usernameNew+"' where username = '"+usernameOld+"'");
  704. ps.execute();
  705. Var.USERNAME = usernameNew;
  706. }
  707.  
  708. } catch (SQLException e) {
  709.  
  710. }
  711. }
  712. @SuppressWarnings("resource")
  713. public static void updateServerBetaAndWartung(int userID, boolean beta, boolean wartung){
  714. PreparedStatement ps;
  715. try {
  716. if(beta){
  717. ps = con.prepareStatement("UPDATE OwnServers SET beta = '1' where userID = '"+userID+"'");
  718. ps.execute();
  719. }else{
  720. ps = con.prepareStatement("UPDATE OwnServers SET beta = '0' where userID = '"+userID+"'");
  721. ps.execute();
  722. }
  723. if(wartung){
  724. ps = con.prepareStatement("UPDATE OwnServers SET wartung = '1' where userID = '"+userID+"'");
  725. ps.execute();
  726. }else{
  727. ps = con.prepareStatement("UPDATE OwnServers SET wartung = '0' where userID = '"+userID+"'");
  728. ps.execute();
  729. }
  730. } catch (SQLException e) {
  731.  
  732. }
  733. }
  734. public static void setPassword(String username, String password){
  735. PreparedStatement ps;
  736. try {
  737. ps = con.prepareStatement("UPDATE clientSaveUsers SET password = '"+password+"' where username = '"+username+"'");
  738. ps.execute();
  739. Var.PASSWORD = password;
  740. }catch (Exception e) {
  741. System.out.println(e);
  742. }
  743.  
  744.  
  745. }
  746. public static void updateServerMotd(int userID, String motd){
  747. PreparedStatement ps;
  748. try {
  749. ps = con.prepareStatement("UPDATE OwnServers SET motd = '"+motd+"' where userID = '"+userID+"'");
  750. ps.execute();
  751. }catch (Exception e) {
  752. System.out.println(e);
  753. }
  754.  
  755.  
  756. }
  757. public static void setMail(String username, String mail){
  758. PreparedStatement ps;
  759. try {
  760. if(isMailUsed(mail)){
  761. return;
  762. }
  763.  
  764. ps = con.prepareStatement("UPDATE clientSaveUsers SET mail = '"+mail+"' where username = '"+username+"'");
  765. ps.execute();
  766.  
  767. ps = con.prepareStatement("DELETE FROM clientMails where mail = '"+mail+"'");
  768. ps.execute();
  769.  
  770. ps = con.prepareStatement("INSERT INTO clientMails (mail) VALUES ('"+mail+"')");
  771. ps.execute();
  772. }catch (Exception e) {
  773. System.out.println(e);
  774. }
  775.  
  776.  
  777. }
  778. public static void updateServerAdmin(String username, String playerName, boolean trueorefalse){
  779. PreparedStatement ps;
  780. if(username.equals(playerName)) return;
  781. if(trueorefalse){
  782. try {
  783. ps = con.prepareStatement("Select userID from `Server-"+username+"` where userID = '"+getUserID(playerName)+"'");
  784. ResultSet res = ps.executeQuery();
  785. if(!res.next()){
  786. return;
  787. }
  788. ps = con.prepareStatement("INSERT INTO `Server-"+username+"` (userID, username, owner, headadmin, admin, premium) VALUES ('"+getUserID(playerName)+"', '"+playerName+"', '0', '0', '1', '0')");
  789. ps.execute();
  790. }catch (Exception e) {
  791. System.out.println(e);
  792. }
  793. }else{
  794. try {
  795. ps = con.prepareStatement("Select userID from `Server-"+username+"` where userID = '"+getUserID(playerName)+"'");
  796. ResultSet res = ps.executeQuery();
  797. if(res.next()){
  798. return;
  799. }
  800. ps = con.prepareStatement("INSERT INTO `Server-"+username+"` (userID, username, owner, headadmin, admin, premium) VALUES ('"+getUserID(playerName)+"', '"+playerName+"', '0', '0', '0', '0')");
  801. ps.execute();
  802. }catch (Exception e) {
  803. System.out.println(e);
  804. }
  805. }
  806.  
  807.  
  808. }
  809. public static void updateServerPremium(String username, String playerName, boolean trueorefalse){
  810. PreparedStatement ps;
  811. if(username.equals(playerName)) return;
  812. if(trueorefalse){
  813. try {
  814. ps = con.prepareStatement("Select userID from `Server-"+username+"` where userID = '"+getUserID(playerName)+"'");
  815. ResultSet res = ps.executeQuery();
  816. if(!res.next()){
  817. return;
  818. }
  819. ps = con.prepareStatement("INSERT INTO `Server-"+username+"` (userID, username, owner, headadmin, admin, premium) VALUES ('"+getUserID(playerName)+"', '"+playerName+"', '0', '0', '0', '1')");
  820. ps.execute();
  821. }catch (Exception e) {
  822. System.out.println(e);
  823. }
  824. }else{
  825. try {
  826. ps = con.prepareStatement("Select userID from `Server-"+username+"` where userID = '"+getUserID(playerName)+"'");
  827. ResultSet res = ps.executeQuery();
  828. if(res.next()){
  829. return;
  830. }
  831. ps = con.prepareStatement("INSERT INTO `Server-"+username+"` (userID, username, owner, headadmin, admin, premium) VALUES ('"+getUserID(playerName)+"', '"+playerName+"', '0', '0', '0', '0')");
  832. ps.execute();
  833. }catch (Exception e) {
  834. System.out.println(e);
  835. }
  836. }
  837.  
  838.  
  839. }
  840. public static void setNameChanges(String username, int changes){
  841. PreparedStatement ps;
  842. try {
  843. ps = con.prepareStatement("UPDATE clientSaveUsers SET changes = '"+changes+"' where username = '"+username+"'");
  844. ps.execute();
  845. }catch (Exception e) {
  846. System.out.println(e);
  847. }
  848.  
  849.  
  850. }
  851.  
  852. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement