Advertisement
Guest User

Untitled

a guest
Jan 29th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 34.57 KB | None | 0 0
  1. package de.DurchMachen.BungeeSystem.MySQL;
  2.  
  3. import java.sql.Connection;
  4. import java.sql.DatabaseMetaData;
  5. import java.sql.DriverManager;
  6. import java.sql.PreparedStatement;
  7. import java.sql.ResultSet;
  8. import java.sql.SQLException;
  9. import java.util.UUID;
  10.  
  11. import net.md_5.bungee.api.connection.ProxiedPlayer;
  12. import de.Durchmachen.BungeeSystem.BungeeSystem;
  13.  
  14. public class MySQL {
  15.  
  16. public static String host = BungeeSystem.cfg.getString("MySQL.Host");
  17. public static String port = String.valueOf(BungeeSystem.cfg.getInt("MySQL.Port"));
  18. public static String database = BungeeSystem.cfg.getString("MySQL.Datenbank");
  19. public static String username = BungeeSystem.cfg.getString("MySQL.Benutzername");
  20. public static String password = BungeeSystem.cfg.getString("MySQL.Passwort");
  21.  
  22. public static String host2 = BungeeSystem.cfg.getString("PermissionsEx.Host");
  23. public static String port2 = String.valueOf(BungeeSystem.cfg.getInt("PermissionsEx.Port"));
  24. public static String database2 = BungeeSystem.cfg.getString("PermissionsEx.Datenbank");
  25. public static String username2 = BungeeSystem.cfg.getString("PermissionsEx.Benutzername");
  26. public static String password2 = BungeeSystem.cfg.getString("PermissionsEx.Passwort");
  27.  
  28. public static String host3 = BungeeSystem.cfg.getString("ChatLog.Host");
  29. public static String port3 = String.valueOf(BungeeSystem.cfg.getInt("ChatLog.Port"));
  30. public static String database3 = BungeeSystem.cfg.getString("ChatLog.Datenbank");
  31. public static String username3 = BungeeSystem.cfg.getString("ChatLog.Benutzername");
  32. public static String password3 = BungeeSystem.cfg.getString("ChatLog.Passwort");
  33.  
  34. // public static String host3 = BungeeSystem.cfg.getString("IndividualPrefix.Host");
  35. // public static String port3 = String.valueOf(BungeeSystem.cfg.getInt("IndividualPrefix.Port"));
  36. // public static String database3 = BungeeSystem.cfg.getString("IndividualPrefix.Datenbank");
  37. // public static String username3 = BungeeSystem.cfg.getString("IndividualPrefix.Benutzername");
  38. // public static String password3 = BungeeSystem.cfg.getString("IndividualPrefix.Passwort");
  39.  
  40. public static Connection connection;
  41. public static Connection connection2;
  42. public static Connection connection3;
  43.  
  44. public static Connection getConnection() {
  45. return connection;
  46. }
  47.  
  48. public static Connection getConnection2() {
  49. return connection2;
  50. }
  51.  
  52. public static Connection getConnection3() {
  53. return connection3;
  54. }
  55.  
  56. public static boolean isConnected() {
  57. return (connection == null ? false : true);
  58. }
  59.  
  60. public static boolean isConnected2() {
  61. return (connection2 == null ? false : true);
  62. }
  63.  
  64. public static boolean isConnected3() {
  65. return (connection3 == null ? false : true);
  66. }
  67.  
  68. public static void connect() {
  69. if (!isConnected()) {
  70. try {
  71. connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
  72. } catch (SQLException ex) {
  73. ex.printStackTrace();
  74. }
  75. }
  76. }
  77.  
  78. public static void connect2() {
  79. if (!isConnected2()) {
  80. try {
  81. connection2 = DriverManager.getConnection("jdbc:mysql://" + host2 + ":" + port2 + "/" + database2, username2, password2);
  82. } catch (SQLException ex) {
  83. ex.printStackTrace();
  84. }
  85. }
  86. }
  87.  
  88. public static void connect3() {
  89. if (!isConnected3()) {
  90. try {
  91. connection3 = DriverManager.getConnection("jdbc:mysql://" + host3 + ":" + port3 + "/" + database3, username3, password3);
  92. } catch (SQLException ex) {
  93. ex.printStackTrace();
  94. }
  95. }
  96. }
  97.  
  98. public static void disconnect() {
  99. if (isConnected()) {
  100. try {
  101. connection.close();
  102. } catch (SQLException ex) {
  103. ex.printStackTrace();
  104. }
  105. }
  106. }
  107.  
  108. public static void disconnect2() {
  109. if (isConnected2()) {
  110. try {
  111. connection2.close();
  112. } catch (SQLException ex) {
  113. ex.printStackTrace();
  114. }
  115. }
  116. }
  117.  
  118. public static void disconnect3() {
  119. if (isConnected3()) {
  120. try {
  121. connection3.close();
  122. } catch (SQLException ex) {
  123. ex.printStackTrace();
  124. }
  125. }
  126. }
  127.  
  128. public static void createTableIfNotExists() {
  129. if (isConnected()) {
  130. try {
  131. PreparedStatement ps = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Bans (Spielername VARCHAR(100), UUID VARCHAR(100), Grund VARCHAR(100), Von VARCHAR(100), Bis VARCHAR(100), IP VARCHAR(100))");
  132. ps.executeUpdate();
  133. ps.close();
  134. } catch (SQLException ex) {
  135. ex.printStackTrace();
  136. }
  137. }
  138. }
  139.  
  140. public static void createTableIfNotExists2() {
  141. if (isConnected()) {
  142. try {
  143. PreparedStatement ps = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Mutes (Spielername VARCHAR(100), UUID VARCHAR(100), Grund VARCHAR(100), Von VARCHAR(100), Bis VARCHAR(100), IP VARCHAR(100))");
  144. ps.executeUpdate();
  145. ps.close();
  146. } catch (SQLException ex) {
  147. ex.printStackTrace();
  148. }
  149. }
  150. }
  151.  
  152. public static void createTableIfNotExists3() {
  153. if (isConnected()) {
  154. try {
  155. PreparedStatement ps = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS OnlineTeam (Spielername VARCHAR(100), UUID VARCHAR(100), Rang VARCHAR(100), Reihenfolge INT(100))");
  156. ps.executeUpdate();
  157. ps.close();
  158. } catch (SQLException ex) {
  159. ex.printStackTrace();
  160. }
  161. }
  162. }
  163.  
  164. public static void createTableIfNotExists4() {
  165. if (isConnected()) {
  166. try {
  167. PreparedStatement ps = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS OnlinePlayers (Spielername VARCHAR(100), UUID VARCHAR(100), Server VARCHAR(100))");
  168. ps.executeUpdate();
  169. ps.close();
  170. } catch (SQLException ex) {
  171. ex.printStackTrace();
  172. }
  173. }
  174. }
  175.  
  176. // public static void createTableIfNotExists3() {
  177. // if (isConnected3()) {
  178. // try {
  179. // PreparedStatement ps = getConnection3().prepareStatement("CREATE TABLE IF NOT EXISTS Hostnames (Spielername VARCHAR(100), UUID VARCHAR(100), Hostname VARCHAR(100))");
  180. // ps.executeUpdate();
  181. // ps.close();
  182. // } catch (SQLException ex) {
  183. // ex.printStackTrace();
  184. // }
  185. // }
  186. // }
  187.  
  188. public static boolean isChatLogExisting(String table) {
  189. if (isConnected3()) {
  190. try {
  191. DatabaseMetaData md = connection3.getMetaData();
  192. ResultSet result = md.getTables(null, null, table, null);
  193. if (result.next()) {
  194. result.close();
  195. return true;
  196. }
  197. result.close();
  198. } catch (SQLException ex) {
  199. ex.printStackTrace();
  200. }
  201. }
  202. return false;
  203. }
  204.  
  205. public static boolean isPlayerExisting(ProxiedPlayer p) {
  206. try {
  207. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  208. ps.setString(1, p.getUniqueId().toString());
  209. ResultSet result = ps.executeQuery();
  210. boolean user = result.next();
  211. result.close();
  212. ps.close();
  213. return user;
  214. } catch (Exception ex) {
  215. ex.printStackTrace();
  216. }
  217. return false;
  218. }
  219.  
  220. public static boolean isPlayerExisting2(ProxiedPlayer p) {
  221. try {
  222. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  223. ps.setString(1, p.getUniqueId().toString());
  224. ResultSet result = ps.executeQuery();
  225. boolean user = result.next();
  226. result.close();
  227. ps.close();
  228. return user;
  229. } catch (Exception ex) {
  230. ex.printStackTrace();
  231. }
  232. return false;
  233. }
  234.  
  235. public static boolean isPlayerExisting3(ProxiedPlayer p) {
  236. try {
  237. PreparedStatement ps = connection.prepareStatement("SELECT * FROM OnlineTeam WHERE UUID = ?");
  238. ps.setString(1, p.getUniqueId().toString());
  239. ResultSet result = ps.executeQuery();
  240. boolean user = result.next();
  241. result.close();
  242. ps.close();
  243. return user;
  244. } catch (Exception ex) {
  245. ex.printStackTrace();
  246. }
  247. return false;
  248. }
  249.  
  250. public static boolean isPlayerExisting4(ProxiedPlayer p) {
  251. try {
  252. PreparedStatement ps = connection.prepareStatement("SELECT * FROM OnlinePlayers WHERE UUID = ?");
  253. ps.setString(1, p.getUniqueId().toString());
  254. ResultSet result = ps.executeQuery();
  255. boolean user = result.next();
  256. result.close();
  257. ps.close();
  258. return user;
  259. } catch (Exception ex) {
  260. ex.printStackTrace();
  261. }
  262. return false;
  263. }
  264.  
  265. public static boolean isPlayerExisting(UUID uuid) {
  266. try {
  267. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  268. ps.setString(1, uuid.toString());
  269. ResultSet result = ps.executeQuery();
  270. boolean user = result.next();
  271. result.close();
  272. ps.close();
  273. return user;
  274. } catch (Exception ex) {
  275. ex.printStackTrace();
  276. }
  277. return false;
  278. }
  279.  
  280. public static boolean isPlayerExisting2(UUID uuid) {
  281. try {
  282. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  283. ps.setString(1, uuid.toString());
  284. ResultSet result = ps.executeQuery();
  285. boolean user = result.next();
  286. result.close();
  287. ps.close();
  288. return user;
  289. } catch (Exception ex) {
  290. ex.printStackTrace();
  291. }
  292. return false;
  293. }
  294.  
  295. public static boolean isIPExisting(String ip) {
  296. try {
  297. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE IP = ?");
  298. ps.setString(1, ip);
  299. ResultSet result = ps.executeQuery();
  300. boolean user = result.next();
  301. result.close();
  302. ps.close();
  303. return user;
  304. } catch (Exception ex) {
  305. ex.printStackTrace();
  306. }
  307. return false;
  308. }
  309.  
  310. public static boolean isIPExisting2(String ip) {
  311. try {
  312. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE IP = ?");
  313. ps.setString(1, ip);
  314. ResultSet result = ps.executeQuery();
  315. boolean user = result.next();
  316. result.close();
  317. ps.close();
  318. return user;
  319. } catch (Exception ex) {
  320. ex.printStackTrace();
  321. }
  322. return false;
  323. }
  324.  
  325. public static void registerPlayer(ProxiedPlayer p) {
  326. if (isPlayerExisting(p)) {
  327. return;
  328. }
  329. try {
  330. PreparedStatement ps = connection.prepareStatement("INSERT INTO Bans (Spielername, UUID, Grund, Von, Bis, IP) VALUES (?, ?, ?, ?, ?, ?)");
  331. ps.setString(1, p.getName());
  332. ps.setString(2, p.getUniqueId().toString());
  333. ps.setString(3, "-");
  334. ps.setString(4, "-");
  335. ps.setString(5, "-");
  336. ps.setString(6, "-");
  337. ps.execute();
  338. ps.close();
  339. } catch (Exception ex) {
  340. ex.printStackTrace();
  341. }
  342. }
  343.  
  344. public static void registerPlayer2(ProxiedPlayer p) {
  345. if (isPlayerExisting2(p)) {
  346. return;
  347. }
  348. try {
  349. PreparedStatement ps = connection.prepareStatement("INSERT INTO Mutes (Spielername, UUID, Grund, Von, Bis, IP) VALUES (?, ?, ?, ?, ?, ?)");
  350. ps.setString(1, p.getName());
  351. ps.setString(2, p.getUniqueId().toString());
  352. ps.setString(3, "-");
  353. ps.setString(4, "-");
  354. ps.setString(5, "-");
  355. ps.setString(6, "-");
  356. ps.execute();
  357. ps.close();
  358. } catch (Exception ex) {
  359. ex.printStackTrace();
  360. }
  361. }
  362.  
  363. public static void registerPlayer3(ProxiedPlayer p) {
  364. if (isPlayerExisting3(p)) {
  365. return;
  366. }
  367. try {
  368. PreparedStatement ps = connection.prepareStatement("INSERT INTO OnlineTeam (Spielername, UUID, Rang, Reihenfolge) VALUES (?, ?, ?, ?)");
  369. ps.setString(1, p.getName());
  370. ps.setString(2, p.getUniqueId().toString());
  371. String rank = BungeeSystem.playerGroup.get(p.getUniqueId());
  372. ps.setString(3, rank);
  373. int order = 0;
  374. if (rank.equalsIgnoreCase("Administrator")) {
  375. order = 1;
  376. }
  377. if (rank.equalsIgnoreCase("SrModerator")) {
  378. order = 2;
  379. }
  380. if (rank.equalsIgnoreCase("Moderator")) {
  381. order = 3;
  382. }
  383. if (rank.equalsIgnoreCase("Developer")) {
  384. order = 4;
  385. }
  386. if (rank.equalsIgnoreCase("Builder")) {
  387. order = 5;
  388. }
  389. ps.setString(4, String.valueOf(order));
  390. ps.execute();
  391. ps.close();
  392. } catch (Exception ex) {
  393. ex.printStackTrace();
  394. }
  395. }
  396.  
  397. public static void registerPlayer4(ProxiedPlayer p) {
  398. if (isPlayerExisting4(p)) {
  399. return;
  400. }
  401. try {
  402. PreparedStatement ps = connection.prepareStatement("INSERT INTO OnlinePlayers (Spielername, UUID, Server) VALUES (?, ?, ?)");
  403. ps.setString(1, p.getName());
  404. ps.setString(2, p.getUniqueId().toString());
  405. ps.setString(3, p.getServer().getInfo().getName());
  406. ps.execute();
  407. ps.close();
  408. } catch (Exception ex) {
  409. ex.printStackTrace();
  410. }
  411. }
  412.  
  413. public static void updateServer(ProxiedPlayer p) {
  414. try {
  415. PreparedStatement ps = connection.prepareStatement("UPDATE OnlinePlayers SET Server = ? WHERE UUID = ?");
  416. ps.setString(1, p.getServer().getInfo().getName());
  417. ps.setString(2, p.getUniqueId().toString());
  418. ps.execute();
  419. ps.close();
  420. } catch (Exception ex) {
  421. ex.printStackTrace();
  422. }
  423. }
  424.  
  425. public static void unregisterPlayer(ProxiedPlayer p) {
  426. try {
  427. PreparedStatement ps = connection.prepareStatement("DELETE FROM OnlineTeam WHERE UUID = ?");
  428. ps.setString(1, p.getUniqueId().toString());
  429. ps.execute();
  430. ps.close();
  431. } catch (Exception ex) {
  432. ex.printStackTrace();
  433. }
  434. }
  435.  
  436. public static void unregisterPlayer2(ProxiedPlayer p) {
  437. try {
  438. PreparedStatement ps = connection.prepareStatement("DELETE FROM OnlinePlayers WHERE UUID = ?");
  439. ps.setString(1, p.getUniqueId().toString());
  440. ps.execute();
  441. ps.close();
  442. } catch (Exception ex) {
  443. ex.printStackTrace();
  444. }
  445. }
  446.  
  447. public static void clearTeable() {
  448. try {
  449. PreparedStatement ps = connection.prepareStatement("DELETE FROM OnlineTeam");
  450. ps.execute();
  451. ps.close();
  452. } catch (Exception ex) {
  453. ex.printStackTrace();
  454. }
  455. }
  456.  
  457. public static void clearTeable2() {
  458. try {
  459. PreparedStatement ps = connection.prepareStatement("DELETE FROM OnlinePlayers");
  460. ps.execute();
  461. ps.close();
  462. } catch (Exception ex) {
  463. ex.printStackTrace();
  464. }
  465. }
  466.  
  467. public static void registerPlayer(UUID uuid, String name) {
  468. if (isPlayerExisting(uuid)) {
  469. return;
  470. }
  471. try {
  472. PreparedStatement ps = connection.prepareStatement("INSERT INTO Bans (Spielername, UUID, Grund, Von, Bis, IP) VALUES (?, ?, ?, ?, ?, ?)");
  473. ps.setString(1, name);
  474. ps.setString(2, uuid.toString());
  475. ps.setString(3, "-");
  476. ps.setString(4, "-");
  477. ps.setString(5, "-");
  478. ps.setString(6, "-");
  479. ps.execute();
  480. ps.close();
  481. } catch (Exception ex) {
  482. ex.printStackTrace();
  483. }
  484. }
  485.  
  486. public static void registerPlayer2(UUID uuid, String name) {
  487. if (isPlayerExisting2(uuid)) {
  488. return;
  489. }
  490. try {
  491. PreparedStatement ps = connection.prepareStatement("INSERT INTO Mutes (Spielername, UUID, Grund, Von, Bis, IP) VALUES (?, ?, ?, ?, ?, ?)");
  492. ps.setString(1, name);
  493. ps.setString(2, uuid.toString());
  494. ps.setString(3, "-");
  495. ps.setString(4, "-");
  496. ps.setString(5, "-");
  497. ps.setString(6, "-");
  498. ps.execute();
  499. ps.close();
  500. } catch (Exception ex) {
  501. ex.printStackTrace();
  502. }
  503. }
  504.  
  505. public static void setPlayerName(UUID uuid, String name) {
  506. try {
  507. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Spielername = ? WHERE UUID = ?");
  508. ps.setString(1, name);
  509. ps.setString(2, uuid.toString());
  510. ps.executeUpdate();
  511. ps.close();
  512. } catch (Exception ex) {
  513. ex.printStackTrace();
  514. }
  515. }
  516.  
  517. public static void setPlayerName2(UUID uuid, String name) {
  518. try {
  519. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Spielername = ? WHERE UUID = ?");
  520. ps.setString(1, name);
  521. ps.setString(2, uuid.toString());
  522. ps.executeUpdate();
  523. ps.close();
  524. } catch (Exception ex) {
  525. ex.printStackTrace();
  526. }
  527. }
  528.  
  529. public static void setIP(UUID uuid, String ip) {
  530. try {
  531. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET IP = ? WHERE UUID = ?");
  532. ps.setString(1, ip);
  533. ps.setString(2, uuid.toString());
  534. ps.executeUpdate();
  535. ps.close();
  536. } catch (Exception ex) {
  537. ex.printStackTrace();
  538. }
  539. }
  540.  
  541. public static void setIP2(UUID uuid, String ip) {
  542. try {
  543. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET IP = ? WHERE UUID = ?");
  544. ps.setString(1, ip);
  545. ps.setString(2, uuid.toString());
  546. ps.executeUpdate();
  547. ps.close();
  548. } catch (Exception ex) {
  549. ex.printStackTrace();
  550. }
  551. }
  552.  
  553. public static String getReason(ProxiedPlayer p) {
  554. try {
  555. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  556. ps.setString(1, p.getUniqueId().toString());
  557. ResultSet result = ps.executeQuery();
  558. result.next();
  559. String name = result.getString("Grund");
  560. result.close();
  561. ps.close();
  562. return name;
  563. } catch (Exception ex) {
  564. ex.printStackTrace();
  565. }
  566. return "null";
  567. }
  568.  
  569. public static String getReason2(ProxiedPlayer p) {
  570. try {
  571. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  572. ps.setString(1, p.getUniqueId().toString());
  573. ResultSet result = ps.executeQuery();
  574. result.next();
  575. String name = result.getString("Grund");
  576. result.close();
  577. ps.close();
  578. return name;
  579. } catch (Exception ex) {
  580. ex.printStackTrace();
  581. }
  582. return "null";
  583. }
  584.  
  585. public static String getReason(UUID uuid) {
  586. try {
  587. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  588. ps.setString(1, uuid.toString());
  589. ResultSet result = ps.executeQuery();
  590. result.next();
  591. String name = result.getString("Grund");
  592. result.close();
  593. ps.close();
  594. return name;
  595. } catch (Exception ex) {
  596. ex.printStackTrace();
  597. }
  598. return "null";
  599. }
  600.  
  601. public static String getReason2(UUID uuid) {
  602. try {
  603. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  604. ps.setString(1, uuid.toString());
  605. ResultSet result = ps.executeQuery();
  606. result.next();
  607. String name = result.getString("Grund");
  608. result.close();
  609. ps.close();
  610. return name;
  611. } catch (Exception ex) {
  612. ex.printStackTrace();
  613. }
  614. return "null";
  615. }
  616.  
  617. public static String getBy(ProxiedPlayer p) {
  618. try {
  619. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  620. ps.setString(1, p.getUniqueId().toString());
  621. ResultSet result = ps.executeQuery();
  622. result.next();
  623. String name = result.getString("Von");
  624. result.close();
  625. ps.close();
  626. return name;
  627. } catch (Exception ex) {
  628. ex.printStackTrace();
  629. }
  630. return "null";
  631. }
  632.  
  633. public static String getBy2(ProxiedPlayer p) {
  634. try {
  635. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  636. ps.setString(1, p.getUniqueId().toString());
  637. ResultSet result = ps.executeQuery();
  638. result.next();
  639. String name = result.getString("Von");
  640. result.close();
  641. ps.close();
  642. return name;
  643. } catch (Exception ex) {
  644. ex.printStackTrace();
  645. }
  646. return "null";
  647. }
  648.  
  649. public static String getBy(UUID uuid) {
  650. try {
  651. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  652. ps.setString(1, uuid.toString());
  653. ResultSet result = ps.executeQuery();
  654. result.next();
  655. String name = result.getString("Von");
  656. result.close();
  657. ps.close();
  658. return name;
  659. } catch (Exception ex) {
  660. ex.printStackTrace();
  661. }
  662. return "null";
  663. }
  664.  
  665. public static String getBy2(UUID uuid) {
  666. try {
  667. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  668. ps.setString(1, uuid.toString());
  669. ResultSet result = ps.executeQuery();
  670. result.next();
  671. String name = result.getString("Von");
  672. result.close();
  673. ps.close();
  674. return name;
  675. } catch (Exception ex) {
  676. ex.printStackTrace();
  677. }
  678. return "null";
  679. }
  680.  
  681. public static long getUntil(ProxiedPlayer p) {
  682. try {
  683. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  684. ps.setString(1, p.getUniqueId().toString());
  685. ResultSet result = ps.executeQuery();
  686. result.next();
  687. long until = result.getLong("Bis");
  688. result.close();
  689. ps.close();
  690. return until;
  691. } catch (Exception ex) {
  692. ex.printStackTrace();
  693. }
  694. return -1;
  695. }
  696.  
  697. public static long getUntil2(ProxiedPlayer p) {
  698. try {
  699. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  700. ps.setString(1, p.getUniqueId().toString());
  701. ResultSet result = ps.executeQuery();
  702. result.next();
  703. long until = result.getLong("Bis");
  704. result.close();
  705. ps.close();
  706. return until;
  707. } catch (Exception ex) {
  708. ex.printStackTrace();
  709. }
  710. return -1;
  711. }
  712.  
  713. public static long getUntil(UUID uuid) {
  714. try {
  715. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  716. ps.setString(1, uuid.toString());
  717. ResultSet result = ps.executeQuery();
  718. result.next();
  719. long until = result.getLong("Bis");
  720. result.close();
  721. ps.close();
  722. return until;
  723. } catch (Exception ex) {
  724. ex.printStackTrace();
  725. }
  726. return -1;
  727. }
  728.  
  729. public static long getUntil2(UUID uuid) {
  730. try {
  731. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  732. ps.setString(1, uuid.toString());
  733. ResultSet result = ps.executeQuery();
  734. result.next();
  735. long until = result.getLong("Bis");
  736. result.close();
  737. ps.close();
  738. return until;
  739. } catch (Exception ex) {
  740. ex.printStackTrace();
  741. }
  742. return -1;
  743. }
  744.  
  745. public static String getIP(UUID uuid) {
  746. try {
  747. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
  748. ps.setString(1, uuid.toString());
  749. ResultSet result = ps.executeQuery();
  750. result.next();
  751. String ip = result.getString("IP");
  752. result.close();
  753. ps.close();
  754. return ip;
  755. } catch (Exception ex) {
  756. ex.printStackTrace();
  757. }
  758. return "null";
  759. }
  760.  
  761. public static String getIP2(UUID uuid) {
  762. try {
  763. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
  764. ps.setString(1, uuid.toString());
  765. ResultSet result = ps.executeQuery();
  766. result.next();
  767. String ip = result.getString("IP");
  768. result.close();
  769. ps.close();
  770. return ip;
  771. } catch (Exception ex) {
  772. ex.printStackTrace();
  773. }
  774. return "null";
  775. }
  776.  
  777. public static String getUUIDOfIP(String ip) {
  778. try {
  779. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE IP = ?");
  780. ps.setString(1, ip);
  781. ResultSet result = ps.executeQuery();
  782. result.next();
  783. String uuid = result.getString("UUID");
  784. result.close();
  785. ps.close();
  786. return uuid;
  787. } catch (Exception ex) {
  788. ex.printStackTrace();
  789. }
  790. return "null";
  791. }
  792.  
  793. public static String getUUIDOfIP2(String ip) {
  794. try {
  795. PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE IP = ?");
  796. ps.setString(1, ip);
  797. ResultSet result = ps.executeQuery();
  798. result.next();
  799. String uuid = result.getString("UUID");
  800. result.close();
  801. ps.close();
  802. return uuid;
  803. } catch (Exception ex) {
  804. ex.printStackTrace();
  805. }
  806. return "null";
  807. }
  808.  
  809. public static void setBanned(ProxiedPlayer p, String reason, ProxiedPlayer by, long time, String ip) {
  810. try {
  811. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Grund = ? WHERE UUID = ?");
  812. ps.setString(1, reason);
  813. ps.setString(2, p.getUniqueId().toString());
  814. ps.executeUpdate();
  815. ps.close();
  816. } catch (Exception ex) {
  817. ex.printStackTrace();
  818. }
  819. try {
  820. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Von = ? WHERE UUID = ?");
  821. ps.setString(1, by.getName());
  822. ps.setString(2, p.getUniqueId().toString());
  823. ps.executeUpdate();
  824. ps.close();
  825. } catch (Exception ex) {
  826. ex.printStackTrace();
  827. }
  828. try {
  829. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Bis = ? WHERE UUID = ?");
  830. ps.setLong(1, time);
  831. ps.setString(2, p.getUniqueId().toString());
  832. ps.executeUpdate();
  833. ps.close();
  834. } catch (Exception ex) {
  835. ex.printStackTrace();
  836. }
  837. try {
  838. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET IP = ? WHERE UUID = ?");
  839. ps.setString(1, ip);
  840. ps.setString(2, p.getUniqueId().toString());
  841. ps.executeUpdate();
  842. ps.close();
  843. } catch (Exception ex) {
  844. ex.printStackTrace();
  845. }
  846. }
  847.  
  848. public static void setBanned2(ProxiedPlayer p, String reason, ProxiedPlayer by, long time, String ip) {
  849. try {
  850. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Grund = ? WHERE UUID = ?");
  851. ps.setString(1, reason);
  852. ps.setString(2, p.getUniqueId().toString());
  853. ps.executeUpdate();
  854. ps.close();
  855. } catch (Exception ex) {
  856. ex.printStackTrace();
  857. }
  858. try {
  859. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Von = ? WHERE UUID = ?");
  860. ps.setString(1, by.getName());
  861. ps.setString(2, p.getUniqueId().toString());
  862. ps.executeUpdate();
  863. ps.close();
  864. } catch (Exception ex) {
  865. ex.printStackTrace();
  866. }
  867. try {
  868. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Bis = ? WHERE UUID = ?");
  869. ps.setLong(1, time);
  870. ps.setString(2, p.getUniqueId().toString());
  871. ps.executeUpdate();
  872. ps.close();
  873. } catch (Exception ex) {
  874. ex.printStackTrace();
  875. }
  876. try {
  877. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET IP = ? WHERE UUID = ?");
  878. ps.setString(1, ip);
  879. ps.setString(2, p.getUniqueId().toString());
  880. ps.executeUpdate();
  881. ps.close();
  882. } catch (Exception ex) {
  883. ex.printStackTrace();
  884. }
  885. }
  886.  
  887. public static void setBanned(UUID uuid, String reason, ProxiedPlayer by, long time, String ip) {
  888. try {
  889. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Grund = ? WHERE UUID = ?");
  890. ps.setString(1, reason);
  891. ps.setString(2, uuid.toString());
  892. ps.executeUpdate();
  893. ps.close();
  894. } catch (Exception ex) {
  895. ex.printStackTrace();
  896. }
  897. try {
  898. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Von = ? WHERE UUID = ?");
  899. ps.setString(1, by.getName());
  900. ps.setString(2, uuid.toString());
  901. ps.executeUpdate();
  902. ps.close();
  903. } catch (Exception ex) {
  904. ex.printStackTrace();
  905. }
  906. try {
  907. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Bis = ? WHERE UUID = ?");
  908. ps.setLong(1, time);
  909. ps.setString(2, uuid.toString());
  910. ps.executeUpdate();
  911. ps.close();
  912. } catch (Exception ex) {
  913. ex.printStackTrace();
  914. }
  915. try {
  916. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET IP = ? WHERE UUID = ?");
  917. ps.setString(1, ip);
  918. ps.setString(2, uuid.toString());
  919. ps.executeUpdate();
  920. ps.close();
  921. } catch (Exception ex) {
  922. ex.printStackTrace();
  923. }
  924. }
  925.  
  926. public static void setBanned2(UUID uuid, String reason, ProxiedPlayer by, long time, String ip) {
  927. try {
  928. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Grund = ? WHERE UUID = ?");
  929. ps.setString(1, reason);
  930. ps.setString(2, uuid.toString());
  931. ps.executeUpdate();
  932. ps.close();
  933. } catch (Exception ex) {
  934. ex.printStackTrace();
  935. }
  936. try {
  937. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Von = ? WHERE UUID = ?");
  938. ps.setString(1, by.getName());
  939. ps.setString(2, uuid.toString());
  940. ps.executeUpdate();
  941. ps.close();
  942. } catch (Exception ex) {
  943. ex.printStackTrace();
  944. }
  945. try {
  946. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Bis = ? WHERE UUID = ?");
  947. ps.setLong(1, time);
  948. ps.setString(2, uuid.toString());
  949. ps.executeUpdate();
  950. ps.close();
  951. } catch (Exception ex) {
  952. ex.printStackTrace();
  953. }
  954. try {
  955. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET IP = ? WHERE UUID = ?");
  956. ps.setString(1, ip);
  957. ps.setString(2, uuid.toString());
  958. ps.executeUpdate();
  959. ps.close();
  960. } catch (Exception ex) {
  961. ex.printStackTrace();
  962. }
  963. }
  964.  
  965. public static void setBanned(ProxiedPlayer p, String reason, String by, long time, String ip) {
  966. try {
  967. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Grund = ? WHERE UUID = ?");
  968. ps.setString(1, reason);
  969. ps.setString(2, p.getUniqueId().toString());
  970. ps.executeUpdate();
  971. ps.close();
  972. } catch (Exception ex) {
  973. ex.printStackTrace();
  974. }
  975. try {
  976. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Von = ? WHERE UUID = ?");
  977. ps.setString(1, by);
  978. ps.setString(2, p.getUniqueId().toString());
  979. ps.executeUpdate();
  980. ps.close();
  981. } catch (Exception ex) {
  982. ex.printStackTrace();
  983. }
  984. try {
  985. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Bis = ? WHERE UUID = ?");
  986. ps.setLong(1, time);
  987. ps.setString(2, p.getUniqueId().toString());
  988. ps.executeUpdate();
  989. ps.close();
  990. } catch (Exception ex) {
  991. ex.printStackTrace();
  992. }
  993. try {
  994. PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET IP = ? WHERE UUID = ?");
  995. ps.setString(1, ip);
  996. ps.setString(2, p.getUniqueId().toString());
  997. ps.executeUpdate();
  998. ps.close();
  999. } catch (Exception ex) {
  1000. ex.printStackTrace();
  1001. }
  1002. }
  1003.  
  1004. public static void setBanned2(ProxiedPlayer p, String reason, String by, long time, String ip) {
  1005. try {
  1006. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Grund = ? WHERE UUID = ?");
  1007. ps.setString(1, reason);
  1008. ps.setString(2, p.getUniqueId().toString());
  1009. ps.executeUpdate();
  1010. ps.close();
  1011. } catch (Exception ex) {
  1012. ex.printStackTrace();
  1013. }
  1014. try {
  1015. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Von = ? WHERE UUID = ?");
  1016. ps.setString(1, by);
  1017. ps.setString(2, p.getUniqueId().toString());
  1018. ps.executeUpdate();
  1019. ps.close();
  1020. } catch (Exception ex) {
  1021. ex.printStackTrace();
  1022. }
  1023. try {
  1024. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Bis = ? WHERE UUID = ?");
  1025. ps.setLong(1, time);
  1026. ps.setString(2, p.getUniqueId().toString());
  1027. ps.executeUpdate();
  1028. ps.close();
  1029. } catch (Exception ex) {
  1030. ex.printStackTrace();
  1031. }
  1032. try {
  1033. PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET IP = ? WHERE UUID = ?");
  1034. ps.setString(1, ip);
  1035. ps.setString(2, p.getUniqueId().toString());
  1036. ps.executeUpdate();
  1037. ps.close();
  1038. } catch (Exception ex) {
  1039. ex.printStackTrace();
  1040. }
  1041. }
  1042.  
  1043. public static void setUnBanned(ProxiedPlayer p) {
  1044. try {
  1045. PreparedStatement ps = connection.prepareStatement("DELETE FROM Bans WHERE UUID = ?");
  1046. ps.setString(1, p.getUniqueId().toString());
  1047. ps.executeUpdate();
  1048. ps.close();
  1049. } catch (Exception ex) {
  1050. ex.printStackTrace();
  1051. }
  1052. }
  1053.  
  1054. public static void setUnBanned2(ProxiedPlayer p) {
  1055. try {
  1056. PreparedStatement ps = connection.prepareStatement("DELETE FROM Mutes WHERE UUID = ?");
  1057. ps.setString(1, p.getUniqueId().toString());
  1058. ps.executeUpdate();
  1059. ps.close();
  1060. } catch (Exception ex) {
  1061. ex.printStackTrace();
  1062. }
  1063. }
  1064.  
  1065. public static void setUnBanned(UUID uuid) {
  1066. try {
  1067. PreparedStatement ps = connection.prepareStatement("DELETE FROM Bans WHERE UUID = ?");
  1068. ps.setString(1, uuid.toString());
  1069. ps.executeUpdate();
  1070. ps.close();
  1071. } catch (Exception ex) {
  1072. ex.printStackTrace();
  1073. }
  1074. }
  1075.  
  1076. public static void setUnBanned2(UUID uuid) {
  1077. try {
  1078. PreparedStatement ps = connection.prepareStatement("DELETE FROM Mutes WHERE UUID = ?");
  1079. ps.setString(1, uuid.toString());
  1080. ps.executeUpdate();
  1081. ps.close();
  1082. } catch (Exception ex) {
  1083. ex.printStackTrace();
  1084. }
  1085. }
  1086.  
  1087. public static String getPlayerGroup(UUID uuid) {
  1088. try {
  1089. PreparedStatement ps = connection2.prepareStatement("SELECT * FROM permissions_inheritance WHERE child = ?");
  1090. ps.setString(1, uuid.toString());
  1091. ResultSet result = ps.executeQuery();
  1092. result.next();
  1093. String rank = result.getString("parent");
  1094. result.close();
  1095. ps.close();
  1096. return rank;
  1097. } catch (SQLException ex) {
  1098. // ex.printStackTrace();
  1099. }
  1100. return "Spieler";
  1101. }
  1102.  
  1103. public static String getPlayerGroupUntil(UUID uuid, String group) {
  1104. try {
  1105. PreparedStatement ps = connection2.prepareStatement("SELECT * FROM permissions WHERE name = ? AND permission = ?");
  1106. ps.setString(1, uuid.toString());
  1107. ps.setString(2, "group-" + group + "-until");
  1108. ResultSet result = ps.executeQuery();
  1109. result.next();
  1110. String until = result.getString("value");
  1111. result.close();
  1112. ps.close();
  1113. return until;
  1114. } catch (SQLException ex) {
  1115. // ex.printStackTrace();
  1116. }
  1117. return "-1";
  1118. }
  1119.  
  1120. // public static boolean isPlayerHostnameExisting(UUID uuid) {
  1121. // try {
  1122. // PreparedStatement ps = connection3.prepareStatement("SELECT * FROM Hostnames WHERE UUID = ?");
  1123. // ps.setString(1, uuid.toString());
  1124. // ResultSet result = ps.executeQuery();
  1125. // boolean isExisting = result.next();
  1126. // result.close();
  1127. // ps.close();
  1128. // return isExisting;
  1129. // } catch (Exception ex) {
  1130. // ex.printStackTrace();
  1131. // }
  1132. // return false;
  1133. // }
  1134.  
  1135. // public static void registerPlayerHostname(UUID uuid, String name) {
  1136. // if (isPlayerHostnameExisting(uuid)) {
  1137. // return;
  1138. // }
  1139. // try {
  1140. // PreparedStatement ps = connection3.prepareStatement("INSERT INTO Hostnames (Spielername, UUID, Hostname) VALUES (?, ?, ?)");
  1141. // ps.setString(1, name);
  1142. // ps.setString(2, uuid.toString());
  1143. // ps.setString(3, "-");
  1144. // ps.execute();
  1145. // ps.close();
  1146. // } catch (Exception ex) {
  1147. // ex.printStackTrace();
  1148. // }
  1149. // }
  1150.  
  1151. // public static void setHostname(UUID uuid, String hostname) {
  1152. // try {
  1153. // PreparedStatement ps = connection3.prepareStatement("UPDATE Hostnames SET Hostname = ? WHERE UUID = ?");
  1154. // ps.setString(1, hostname);
  1155. // ps.setString(2, uuid.toString());
  1156. // ps.executeUpdate();
  1157. // ps.close();
  1158. // } catch (Exception ex) {
  1159. // ex.printStackTrace();
  1160. // }
  1161. // }
  1162.  
  1163. // public static void unregisterPlayerHostname(ProxiedPlayer p) {
  1164. // try {
  1165. // PreparedStatement ps = connection3.prepareStatement("DELETE FROM Hostnames WHERE UUID = ?");
  1166. // ps.setString(1, p.getUniqueId().toString());
  1167. // ps.executeUpdate();
  1168. // ps.close();
  1169. // } catch (Exception ex) {
  1170. // ex.printStackTrace();
  1171. // }
  1172. // }
  1173. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement