Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.DurchMachen.BungeeSystem.MySQL;
- import java.sql.Connection;
- import java.sql.DatabaseMetaData;
- import java.sql.DriverManager;
- import java.sql.PreparedStatement;
- import java.sql.ResultSet;
- import java.sql.SQLException;
- import java.util.UUID;
- import net.md_5.bungee.api.connection.ProxiedPlayer;
- import de.Durchmachen.BungeeSystem.BungeeSystem;
- public class MySQL {
- public static String host = BungeeSystem.cfg.getString("MySQL.Host");
- public static String port = String.valueOf(BungeeSystem.cfg.getInt("MySQL.Port"));
- public static String database = BungeeSystem.cfg.getString("MySQL.Datenbank");
- public static String username = BungeeSystem.cfg.getString("MySQL.Benutzername");
- public static String password = BungeeSystem.cfg.getString("MySQL.Passwort");
- public static String host2 = BungeeSystem.cfg.getString("PermissionsEx.Host");
- public static String port2 = String.valueOf(BungeeSystem.cfg.getInt("PermissionsEx.Port"));
- public static String database2 = BungeeSystem.cfg.getString("PermissionsEx.Datenbank");
- public static String username2 = BungeeSystem.cfg.getString("PermissionsEx.Benutzername");
- public static String password2 = BungeeSystem.cfg.getString("PermissionsEx.Passwort");
- public static String host3 = BungeeSystem.cfg.getString("ChatLog.Host");
- public static String port3 = String.valueOf(BungeeSystem.cfg.getInt("ChatLog.Port"));
- public static String database3 = BungeeSystem.cfg.getString("ChatLog.Datenbank");
- public static String username3 = BungeeSystem.cfg.getString("ChatLog.Benutzername");
- public static String password3 = BungeeSystem.cfg.getString("ChatLog.Passwort");
- // public static String host3 = BungeeSystem.cfg.getString("IndividualPrefix.Host");
- // public static String port3 = String.valueOf(BungeeSystem.cfg.getInt("IndividualPrefix.Port"));
- // public static String database3 = BungeeSystem.cfg.getString("IndividualPrefix.Datenbank");
- // public static String username3 = BungeeSystem.cfg.getString("IndividualPrefix.Benutzername");
- // public static String password3 = BungeeSystem.cfg.getString("IndividualPrefix.Passwort");
- public static Connection connection;
- public static Connection connection2;
- public static Connection connection3;
- public static Connection getConnection() {
- return connection;
- }
- public static Connection getConnection2() {
- return connection2;
- }
- public static Connection getConnection3() {
- return connection3;
- }
- public static boolean isConnected() {
- return (connection == null ? false : true);
- }
- public static boolean isConnected2() {
- return (connection2 == null ? false : true);
- }
- public static boolean isConnected3() {
- return (connection3 == null ? false : true);
- }
- public static void connect() {
- if (!isConnected()) {
- try {
- connection = DriverManager.getConnection("jdbc:mysql://" + host + ":" + port + "/" + database, username, password);
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void connect2() {
- if (!isConnected2()) {
- try {
- connection2 = DriverManager.getConnection("jdbc:mysql://" + host2 + ":" + port2 + "/" + database2, username2, password2);
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void connect3() {
- if (!isConnected3()) {
- try {
- connection3 = DriverManager.getConnection("jdbc:mysql://" + host3 + ":" + port3 + "/" + database3, username3, password3);
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void disconnect() {
- if (isConnected()) {
- try {
- connection.close();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void disconnect2() {
- if (isConnected2()) {
- try {
- connection2.close();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void disconnect3() {
- if (isConnected3()) {
- try {
- connection3.close();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void createTableIfNotExists() {
- if (isConnected()) {
- try {
- 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))");
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void createTableIfNotExists2() {
- if (isConnected()) {
- try {
- 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))");
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void createTableIfNotExists3() {
- if (isConnected()) {
- try {
- PreparedStatement ps = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS OnlineTeam (Spielername VARCHAR(100), UUID VARCHAR(100), Rang VARCHAR(100), Reihenfolge INT(100))");
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- public static void createTableIfNotExists4() {
- if (isConnected()) {
- try {
- PreparedStatement ps = getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS OnlinePlayers (Spielername VARCHAR(100), UUID VARCHAR(100), Server VARCHAR(100))");
- ps.executeUpdate();
- ps.close();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- }
- // public static void createTableIfNotExists3() {
- // if (isConnected3()) {
- // try {
- // PreparedStatement ps = getConnection3().prepareStatement("CREATE TABLE IF NOT EXISTS Hostnames (Spielername VARCHAR(100), UUID VARCHAR(100), Hostname VARCHAR(100))");
- // ps.executeUpdate();
- // ps.close();
- // } catch (SQLException ex) {
- // ex.printStackTrace();
- // }
- // }
- // }
- public static boolean isChatLogExisting(String table) {
- if (isConnected3()) {
- try {
- DatabaseMetaData md = connection3.getMetaData();
- ResultSet result = md.getTables(null, null, table, null);
- if (result.next()) {
- result.close();
- return true;
- }
- result.close();
- } catch (SQLException ex) {
- ex.printStackTrace();
- }
- }
- return false;
- }
- public static boolean isPlayerExisting(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- boolean user = result.next();
- result.close();
- ps.close();
- return user;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
- public static boolean isPlayerExisting2(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- boolean user = result.next();
- result.close();
- ps.close();
- return user;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
- public static boolean isPlayerExisting3(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM OnlineTeam WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- boolean user = result.next();
- result.close();
- ps.close();
- return user;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
- public static boolean isPlayerExisting4(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM OnlinePlayers WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- boolean user = result.next();
- result.close();
- ps.close();
- return user;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
- public static boolean isPlayerExisting(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- boolean user = result.next();
- result.close();
- ps.close();
- return user;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
- public static boolean isPlayerExisting2(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- boolean user = result.next();
- result.close();
- ps.close();
- return user;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
- public static boolean isIPExisting(String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE IP = ?");
- ps.setString(1, ip);
- ResultSet result = ps.executeQuery();
- boolean user = result.next();
- result.close();
- ps.close();
- return user;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
- public static boolean isIPExisting2(String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE IP = ?");
- ps.setString(1, ip);
- ResultSet result = ps.executeQuery();
- boolean user = result.next();
- result.close();
- ps.close();
- return user;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return false;
- }
- public static void registerPlayer(ProxiedPlayer p) {
- if (isPlayerExisting(p)) {
- return;
- }
- try {
- PreparedStatement ps = connection.prepareStatement("INSERT INTO Bans (Spielername, UUID, Grund, Von, Bis, IP) VALUES (?, ?, ?, ?, ?, ?)");
- ps.setString(1, p.getName());
- ps.setString(2, p.getUniqueId().toString());
- ps.setString(3, "-");
- ps.setString(4, "-");
- ps.setString(5, "-");
- ps.setString(6, "-");
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void registerPlayer2(ProxiedPlayer p) {
- if (isPlayerExisting2(p)) {
- return;
- }
- try {
- PreparedStatement ps = connection.prepareStatement("INSERT INTO Mutes (Spielername, UUID, Grund, Von, Bis, IP) VALUES (?, ?, ?, ?, ?, ?)");
- ps.setString(1, p.getName());
- ps.setString(2, p.getUniqueId().toString());
- ps.setString(3, "-");
- ps.setString(4, "-");
- ps.setString(5, "-");
- ps.setString(6, "-");
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void registerPlayer3(ProxiedPlayer p) {
- if (isPlayerExisting3(p)) {
- return;
- }
- try {
- PreparedStatement ps = connection.prepareStatement("INSERT INTO OnlineTeam (Spielername, UUID, Rang, Reihenfolge) VALUES (?, ?, ?, ?)");
- ps.setString(1, p.getName());
- ps.setString(2, p.getUniqueId().toString());
- String rank = BungeeSystem.playerGroup.get(p.getUniqueId());
- ps.setString(3, rank);
- int order = 0;
- if (rank.equalsIgnoreCase("Administrator")) {
- order = 1;
- }
- if (rank.equalsIgnoreCase("SrModerator")) {
- order = 2;
- }
- if (rank.equalsIgnoreCase("Moderator")) {
- order = 3;
- }
- if (rank.equalsIgnoreCase("Developer")) {
- order = 4;
- }
- if (rank.equalsIgnoreCase("Builder")) {
- order = 5;
- }
- ps.setString(4, String.valueOf(order));
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void registerPlayer4(ProxiedPlayer p) {
- if (isPlayerExisting4(p)) {
- return;
- }
- try {
- PreparedStatement ps = connection.prepareStatement("INSERT INTO OnlinePlayers (Spielername, UUID, Server) VALUES (?, ?, ?)");
- ps.setString(1, p.getName());
- ps.setString(2, p.getUniqueId().toString());
- ps.setString(3, p.getServer().getInfo().getName());
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void updateServer(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE OnlinePlayers SET Server = ? WHERE UUID = ?");
- ps.setString(1, p.getServer().getInfo().getName());
- ps.setString(2, p.getUniqueId().toString());
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void unregisterPlayer(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("DELETE FROM OnlineTeam WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void unregisterPlayer2(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("DELETE FROM OnlinePlayers WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void clearTeable() {
- try {
- PreparedStatement ps = connection.prepareStatement("DELETE FROM OnlineTeam");
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void clearTeable2() {
- try {
- PreparedStatement ps = connection.prepareStatement("DELETE FROM OnlinePlayers");
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void registerPlayer(UUID uuid, String name) {
- if (isPlayerExisting(uuid)) {
- return;
- }
- try {
- PreparedStatement ps = connection.prepareStatement("INSERT INTO Bans (Spielername, UUID, Grund, Von, Bis, IP) VALUES (?, ?, ?, ?, ?, ?)");
- ps.setString(1, name);
- ps.setString(2, uuid.toString());
- ps.setString(3, "-");
- ps.setString(4, "-");
- ps.setString(5, "-");
- ps.setString(6, "-");
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void registerPlayer2(UUID uuid, String name) {
- if (isPlayerExisting2(uuid)) {
- return;
- }
- try {
- PreparedStatement ps = connection.prepareStatement("INSERT INTO Mutes (Spielername, UUID, Grund, Von, Bis, IP) VALUES (?, ?, ?, ?, ?, ?)");
- ps.setString(1, name);
- ps.setString(2, uuid.toString());
- ps.setString(3, "-");
- ps.setString(4, "-");
- ps.setString(5, "-");
- ps.setString(6, "-");
- ps.execute();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setPlayerName(UUID uuid, String name) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Spielername = ? WHERE UUID = ?");
- ps.setString(1, name);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setPlayerName2(UUID uuid, String name) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Spielername = ? WHERE UUID = ?");
- ps.setString(1, name);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setIP(UUID uuid, String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET IP = ? WHERE UUID = ?");
- ps.setString(1, ip);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setIP2(UUID uuid, String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET IP = ? WHERE UUID = ?");
- ps.setString(1, ip);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static String getReason(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String name = result.getString("Grund");
- result.close();
- ps.close();
- return name;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getReason2(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String name = result.getString("Grund");
- result.close();
- ps.close();
- return name;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getReason(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String name = result.getString("Grund");
- result.close();
- ps.close();
- return name;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getReason2(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String name = result.getString("Grund");
- result.close();
- ps.close();
- return name;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getBy(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String name = result.getString("Von");
- result.close();
- ps.close();
- return name;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getBy2(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String name = result.getString("Von");
- result.close();
- ps.close();
- return name;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getBy(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String name = result.getString("Von");
- result.close();
- ps.close();
- return name;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getBy2(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String name = result.getString("Von");
- result.close();
- ps.close();
- return name;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static long getUntil(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- result.next();
- long until = result.getLong("Bis");
- result.close();
- ps.close();
- return until;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return -1;
- }
- public static long getUntil2(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ResultSet result = ps.executeQuery();
- result.next();
- long until = result.getLong("Bis");
- result.close();
- ps.close();
- return until;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return -1;
- }
- public static long getUntil(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- long until = result.getLong("Bis");
- result.close();
- ps.close();
- return until;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return -1;
- }
- public static long getUntil2(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- long until = result.getLong("Bis");
- result.close();
- ps.close();
- return until;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return -1;
- }
- public static String getIP(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String ip = result.getString("IP");
- result.close();
- ps.close();
- return ip;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getIP2(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String ip = result.getString("IP");
- result.close();
- ps.close();
- return ip;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getUUIDOfIP(String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Bans WHERE IP = ?");
- ps.setString(1, ip);
- ResultSet result = ps.executeQuery();
- result.next();
- String uuid = result.getString("UUID");
- result.close();
- ps.close();
- return uuid;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static String getUUIDOfIP2(String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("SELECT * FROM Mutes WHERE IP = ?");
- ps.setString(1, ip);
- ResultSet result = ps.executeQuery();
- result.next();
- String uuid = result.getString("UUID");
- result.close();
- ps.close();
- return uuid;
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- return "null";
- }
- public static void setBanned(ProxiedPlayer p, String reason, ProxiedPlayer by, long time, String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Grund = ? WHERE UUID = ?");
- ps.setString(1, reason);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Von = ? WHERE UUID = ?");
- ps.setString(1, by.getName());
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Bis = ? WHERE UUID = ?");
- ps.setLong(1, time);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET IP = ? WHERE UUID = ?");
- ps.setString(1, ip);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setBanned2(ProxiedPlayer p, String reason, ProxiedPlayer by, long time, String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Grund = ? WHERE UUID = ?");
- ps.setString(1, reason);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Von = ? WHERE UUID = ?");
- ps.setString(1, by.getName());
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Bis = ? WHERE UUID = ?");
- ps.setLong(1, time);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET IP = ? WHERE UUID = ?");
- ps.setString(1, ip);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setBanned(UUID uuid, String reason, ProxiedPlayer by, long time, String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Grund = ? WHERE UUID = ?");
- ps.setString(1, reason);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Von = ? WHERE UUID = ?");
- ps.setString(1, by.getName());
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Bis = ? WHERE UUID = ?");
- ps.setLong(1, time);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET IP = ? WHERE UUID = ?");
- ps.setString(1, ip);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setBanned2(UUID uuid, String reason, ProxiedPlayer by, long time, String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Grund = ? WHERE UUID = ?");
- ps.setString(1, reason);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Von = ? WHERE UUID = ?");
- ps.setString(1, by.getName());
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Bis = ? WHERE UUID = ?");
- ps.setLong(1, time);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET IP = ? WHERE UUID = ?");
- ps.setString(1, ip);
- ps.setString(2, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setBanned(ProxiedPlayer p, String reason, String by, long time, String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Grund = ? WHERE UUID = ?");
- ps.setString(1, reason);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Von = ? WHERE UUID = ?");
- ps.setString(1, by);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET Bis = ? WHERE UUID = ?");
- ps.setLong(1, time);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Bans SET IP = ? WHERE UUID = ?");
- ps.setString(1, ip);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setBanned2(ProxiedPlayer p, String reason, String by, long time, String ip) {
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Grund = ? WHERE UUID = ?");
- ps.setString(1, reason);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Von = ? WHERE UUID = ?");
- ps.setString(1, by);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET Bis = ? WHERE UUID = ?");
- ps.setLong(1, time);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- try {
- PreparedStatement ps = connection.prepareStatement("UPDATE Mutes SET IP = ? WHERE UUID = ?");
- ps.setString(1, ip);
- ps.setString(2, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setUnBanned(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("DELETE FROM Bans WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setUnBanned2(ProxiedPlayer p) {
- try {
- PreparedStatement ps = connection.prepareStatement("DELETE FROM Mutes WHERE UUID = ?");
- ps.setString(1, p.getUniqueId().toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setUnBanned(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("DELETE FROM Bans WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static void setUnBanned2(UUID uuid) {
- try {
- PreparedStatement ps = connection.prepareStatement("DELETE FROM Mutes WHERE UUID = ?");
- ps.setString(1, uuid.toString());
- ps.executeUpdate();
- ps.close();
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
- public static String getPlayerGroup(UUID uuid) {
- try {
- PreparedStatement ps = connection2.prepareStatement("SELECT * FROM permissions_inheritance WHERE child = ?");
- ps.setString(1, uuid.toString());
- ResultSet result = ps.executeQuery();
- result.next();
- String rank = result.getString("parent");
- result.close();
- ps.close();
- return rank;
- } catch (SQLException ex) {
- // ex.printStackTrace();
- }
- return "Spieler";
- }
- public static String getPlayerGroupUntil(UUID uuid, String group) {
- try {
- PreparedStatement ps = connection2.prepareStatement("SELECT * FROM permissions WHERE name = ? AND permission = ?");
- ps.setString(1, uuid.toString());
- ps.setString(2, "group-" + group + "-until");
- ResultSet result = ps.executeQuery();
- result.next();
- String until = result.getString("value");
- result.close();
- ps.close();
- return until;
- } catch (SQLException ex) {
- // ex.printStackTrace();
- }
- return "-1";
- }
- // public static boolean isPlayerHostnameExisting(UUID uuid) {
- // try {
- // PreparedStatement ps = connection3.prepareStatement("SELECT * FROM Hostnames WHERE UUID = ?");
- // ps.setString(1, uuid.toString());
- // ResultSet result = ps.executeQuery();
- // boolean isExisting = result.next();
- // result.close();
- // ps.close();
- // return isExisting;
- // } catch (Exception ex) {
- // ex.printStackTrace();
- // }
- // return false;
- // }
- // public static void registerPlayerHostname(UUID uuid, String name) {
- // if (isPlayerHostnameExisting(uuid)) {
- // return;
- // }
- // try {
- // PreparedStatement ps = connection3.prepareStatement("INSERT INTO Hostnames (Spielername, UUID, Hostname) VALUES (?, ?, ?)");
- // ps.setString(1, name);
- // ps.setString(2, uuid.toString());
- // ps.setString(3, "-");
- // ps.execute();
- // ps.close();
- // } catch (Exception ex) {
- // ex.printStackTrace();
- // }
- // }
- // public static void setHostname(UUID uuid, String hostname) {
- // try {
- // PreparedStatement ps = connection3.prepareStatement("UPDATE Hostnames SET Hostname = ? WHERE UUID = ?");
- // ps.setString(1, hostname);
- // ps.setString(2, uuid.toString());
- // ps.executeUpdate();
- // ps.close();
- // } catch (Exception ex) {
- // ex.printStackTrace();
- // }
- // }
- // public static void unregisterPlayerHostname(ProxiedPlayer p) {
- // try {
- // PreparedStatement ps = connection3.prepareStatement("DELETE FROM Hostnames WHERE UUID = ?");
- // ps.setString(1, p.getUniqueId().toString());
- // ps.executeUpdate();
- // ps.close();
- // } catch (Exception ex) {
- // ex.printStackTrace();
- // }
- // }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement