Skip to content

Commit e6f18ad

Browse files
1.7.3 // LiteBans Fix, Fixes, MariaDB added for the rest Instances.
1 parent 3f444da commit e6f18ad

82 files changed

Lines changed: 1137 additions & 677 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Logger - BungeeCord/pom.xml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<modelVersion>4.0.0</modelVersion>
66

77
<artifactId>Logger-Bungeecord</artifactId>
8-
<version>1.7.2</version>
8+
<version>1.7.3</version>
99
<packaging>jar</packaging>
1010

1111
<name>Logger-BungeeCord</name>
@@ -19,7 +19,7 @@
1919
<parent>
2020
<artifactId>Logger</artifactId>
2121
<groupId>com.carpour</groupId>
22-
<version>1.7.2</version>
22+
<version>1.7.3</version>
2323
</parent>
2424

2525
<build>
@@ -104,5 +104,10 @@
104104
<version>LATEST</version>
105105
<scope>provided</scope>
106106
</dependency>
107+
<dependency>
108+
<groupId>org.mariadb.jdbc</groupId>
109+
<artifactId>mariadb-java-client</artifactId>
110+
<version>3.0.2-rc</version>
111+
</dependency>
107112
</dependencies>
108113
</project>
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
package com.carpour.loggerbungeecord.Database.External;
2+
3+
import com.carpour.loggerbungeecord.Main;
4+
5+
import java.sql.Connection;
6+
import java.sql.DriverManager;
7+
import java.sql.SQLException;
8+
import java.util.Objects;
9+
10+
public class External {
11+
12+
private final Main main = Main.getInstance();
13+
14+
private String jdbc;
15+
private final String dataType = Objects.requireNonNull(main.getConfig().getString("Database.Type")).toLowerCase();
16+
private final String host = main.getConfig().getString("Database.Host");
17+
private final int port = main.getConfig().getInt("Database.Port");
18+
private final String username = main.getConfig().getString("Database.Username");
19+
private final String password = main.getConfig().getString("Database.Password");
20+
private final String database = main.getConfig().getString("Database.Database");
21+
private Connection connection;
22+
23+
public boolean isConnected(){ return connection != null; }
24+
25+
public void connect() {
26+
27+
String jdbcDriver;
28+
final String mySQL = "MySQL";
29+
final String mySQLDriver = "com.mysql.cj.jdbc.Driver";
30+
final String mariaDB = "MariaDB";
31+
final String mariaDBDriver = "org.mariadb.jdbc.Driver";
32+
33+
switch (dataType){
34+
35+
case "mysql":
36+
jdbc = mySQL;
37+
jdbcDriver = mySQLDriver;
38+
break;
39+
40+
case "mariadb":
41+
jdbc = mariaDB;
42+
jdbcDriver = mariaDBDriver;
43+
main.getLogger().warning(jdbc + " Type is still in Development. Report any issues on Discord or Github!");
44+
break;
45+
46+
default:
47+
main.getLogger().severe("Unknown Database Type. Available ones are: MySQL and MariaDB.");
48+
return;
49+
50+
}
51+
52+
if (!isConnected()) {
53+
54+
try {
55+
56+
Class.forName(jdbcDriver);
57+
connection = DriverManager.getConnection("jdbc:" + jdbc + "://" + host + ":" + port + "/" + database + "?AllowPublicKeyRetrieval=true?useSSL=false&jdbcCompliantTruncation=false", username, password);
58+
main.getLogger().info(jdbc + " Connection has been established!");
59+
60+
} catch (SQLException | ClassNotFoundException e) {
61+
62+
main.getLogger().severe("Could not connect to " + jdbc + " Database!");
63+
64+
}
65+
}
66+
}
67+
68+
public void disconnect() {
69+
70+
if (isConnected()) {
71+
72+
try {
73+
74+
connection.close();
75+
Main.getInstance().getLogger().info(jdbc + " Connection has been closed!");
76+
77+
} catch (SQLException e) {
78+
79+
Main.getInstance().getLogger().severe(jdbc + " Database couldn't be closed safely, if the issue persists contact the Authors!");
80+
81+
}
82+
}
83+
}
84+
public Connection getConnection(){ return connection; }
85+
}

Logger - BungeeCord/src/main/java/com/carpour/loggerbungeecord/Database/MySQL/MySQLData.java renamed to Logger - BungeeCord/src/main/java/com/carpour/loggerbungeecord/Database/External/ExternalData.java

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
package com.carpour.loggerbungeecord.Database.MySQL;
1+
package com.carpour.loggerbungeecord.Database.External;
22

33
import com.carpour.loggerbungeecord.Main;
44

55
import java.net.InetSocketAddress;
66
import java.sql.PreparedStatement;
77
import java.sql.SQLException;
88

9-
public class MySQLData {
9+
public class ExternalData {
1010

1111
private static Main plugin = Main.getInstance();
1212

13-
public MySQLData(Main plugin){
14-
MySQLData.plugin = plugin;
13+
public ExternalData(Main plugin){
14+
ExternalData.plugin = plugin;
1515
}
1616

1717
public void createTable(){
@@ -21,33 +21,33 @@ public void createTable(){
2121

2222
try {
2323

24-
playerChat = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Player_Chat_Proxy "
24+
playerChat = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Player_Chat_Proxy "
2525
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),Playername VARCHAR(100),Message VARCHAR(200),Is_Staff TINYINT,PRIMARY KEY (Date))");
2626

27-
playerCommand = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Player_Commands_Proxy "
27+
playerCommand = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Player_Commands_Proxy "
2828
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),Playername VARCHAR(100),Command VARCHAR(200),Is_Staff TINYINT,PRIMARY KEY (Date))");
2929

30-
playerLogin = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Player_Login_Proxy "
30+
playerLogin = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Player_Login_Proxy "
3131
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),Playername VARCHAR(100),IP INT UNSIGNED,Is_Staff TINYINT,PRIMARY KEY (Date))");
3232

33-
playerLeave = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Player_Leave_Proxy "
33+
playerLeave = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Player_Leave_Proxy "
3434
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),Playername VARCHAR(100),Is_Staff TINYINT,PRIMARY KEY (Date))");
3535

3636
// Server Side Part
37-
serverReload = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Server_Reload_Proxy "
37+
serverReload = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Server_Reload_Proxy "
3838
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),Playername VARCHAR(100),Is_Staff TINYINT,PRIMARY KEY (Date))");
3939

40-
serverStart = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Server_Start_Proxy "
40+
serverStart = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Server_Start_Proxy "
4141
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),PRIMARY KEY (Date))");
4242

43-
serverStop = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Server_Stop_Proxy "
43+
serverStop = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS Server_Stop_Proxy "
4444
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),PRIMARY KEY (Date))");
4545

46-
ram = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS RAM_Proxy "
46+
ram = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS RAM_Proxy "
4747
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),Total_Memory INT,Used_Memory INT,Free_Memory INT,PRIMARY KEY (Date))");
4848

4949
// Extra Side Part
50-
liteBans = plugin.mySQL.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS LiteBans_Proxy "
50+
liteBans = plugin.external.getConnection().prepareStatement("CREATE TABLE IF NOT EXISTS LiteBans_Proxy "
5151
+ "(Server_Name VARCHAR(30),Date DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP(),Sender VARCHAR(100),Command VARCHAR(20),OnWho VARCHAR(100)," +
5252
"Reason VARCHAR(200),Duration VARCHAR(30), Is_Silent TINYINT,PRIMARY KEY (Date))");
5353

@@ -73,7 +73,7 @@ public void createTable(){
7373
public static void playerChat(String serverName, String playerName, String message, boolean staff){
7474
try {
7575
String database = "Player_Chat_Proxy";
76-
PreparedStatement playerChat = plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,Message,Is_Staff) VALUES(?,?,?,?)");
76+
PreparedStatement playerChat = plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,Message,Is_Staff) VALUES(?,?,?,?)");
7777
playerChat.setString(1, serverName);
7878
playerChat.setString(2, playerName);
7979
playerChat.setString(3, message);
@@ -86,7 +86,7 @@ public static void playerChat(String serverName, String playerName, String messa
8686
public static void playerCommands(String serverName, String playerName, String command, boolean staff){
8787
try {
8888
String database = "Player_Commands_Proxy";
89-
PreparedStatement playerCommand = plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,Command,Is_Staff) VALUES(?,?,?,?)");
89+
PreparedStatement playerCommand = plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,Command,Is_Staff) VALUES(?,?,?,?)");
9090
playerCommand.setString(1, serverName);
9191
playerCommand.setString(2, playerName);
9292
playerCommand.setString(3, command);
@@ -99,7 +99,7 @@ public static void playerCommands(String serverName, String playerName, String c
9999
public static void playerLogin(String serverName, String playerName, InetSocketAddress IP, boolean staff){
100100
try {
101101
String database = "Player_Login_Proxy";
102-
PreparedStatement playerLogin = plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,IP,Is_Staff) VALUES(?,?,?,?)");
102+
PreparedStatement playerLogin = plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,IP,Is_Staff) VALUES(?,?,?,?)");
103103
playerLogin.setString(1, serverName);
104104
playerLogin.setString(2, playerName);
105105
if (plugin.getConfig().getBoolean("Player-Login.Player-IP")) {
@@ -119,7 +119,7 @@ public static void playerLogin(String serverName, String playerName, InetSocketA
119119
public static void playerLeave(String serverName, String playerName, boolean staff){
120120
try {
121121
String database = "Player_Leave_Proxy";
122-
PreparedStatement playerLeave = plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,Is_Staff) VALUES(?,?,?)");
122+
PreparedStatement playerLeave = plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,Is_Staff) VALUES(?,?,?)");
123123
playerLeave.setString(1, serverName);
124124
playerLeave.setString(2, playerName);
125125
playerLeave.setBoolean(3, staff);
@@ -131,7 +131,7 @@ public static void playerLeave(String serverName, String playerName, boolean sta
131131
public static void serverReload(String serverName, String playerName, boolean staff){
132132
try {
133133
String database = "Server_Reload_Proxy";
134-
PreparedStatement serverReload= plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,Is_Staff) VALUES(?,?,?)");
134+
PreparedStatement serverReload= plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Playername,Is_Staff) VALUES(?,?,?)");
135135
serverReload.setString(1, serverName);
136136
serverReload.setString(2, playerName);
137137
serverReload.setBoolean(3, staff);
@@ -143,7 +143,7 @@ public static void serverReload(String serverName, String playerName, boolean st
143143
public static void serverStart(String serverName){
144144
try {
145145
String database = "Server_Start_Proxy";
146-
PreparedStatement serverStart = plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name) VALUES(?)");
146+
PreparedStatement serverStart = plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name) VALUES(?)");
147147
serverStart.setString(1, serverName);
148148
serverStart.executeUpdate();
149149

@@ -153,7 +153,7 @@ public static void serverStart(String serverName){
153153
public static void serverStop(String serverName){
154154
try {
155155
String database = "Server_Stop_Proxy";
156-
PreparedStatement serverStop = plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name) VALUES(?)");
156+
PreparedStatement serverStop = plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name) VALUES(?)");
157157
serverStop.setString(1, serverName);
158158
serverStop.executeUpdate();
159159

@@ -163,7 +163,7 @@ public static void serverStop(String serverName){
163163
public static void RAM(String serverName, long TM, long UM, long FM){
164164
try {
165165
String database = "RAM_Proxy";
166-
PreparedStatement RAM = plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Total_Memory,Used_Memory,Free_Memory) VALUES(?,?,?,?)");
166+
PreparedStatement RAM = plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Total_Memory,Used_Memory,Free_Memory) VALUES(?,?,?,?)");
167167
RAM.setString(1, serverName);
168168
RAM.setLong(2, TM);
169169
RAM.setLong(3, UM);
@@ -176,7 +176,7 @@ public static void RAM(String serverName, long TM, long UM, long FM){
176176
public static void liteBans(String serverName, String executor, String command, String onWho, String duration, String reason, boolean isSilent){
177177
try {
178178
String database = "LiteBans_Proxy";
179-
PreparedStatement liteBans = plugin.mySQL.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Sender,Command,OnWho,Reason,Duration,Is_Silent) VALUES(?,?,?,?,?,?,?)");
179+
PreparedStatement liteBans = plugin.external.getConnection().prepareStatement("INSERT IGNORE INTO " + database + "(Server_Name,Sender,Command,OnWho,Reason,Duration,Is_Silent) VALUES(?,?,?,?,?,?,?)");
180180
liteBans.setString(1, serverName);
181181
liteBans.setString(2, executor);
182182
liteBans.setString(3, command);
@@ -197,23 +197,23 @@ public void emptyTable(){
197197

198198
try{
199199

200-
PreparedStatement player_Chat = plugin.mySQL.getConnection().prepareStatement("DELETE FROM Player_Chat_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
200+
PreparedStatement player_Chat = plugin.external.getConnection().prepareStatement("DELETE FROM Player_Chat_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
201201

202-
PreparedStatement player_Command = plugin.mySQL.getConnection().prepareStatement("DELETE FROM Player_Commands_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
202+
PreparedStatement player_Command = plugin.external.getConnection().prepareStatement("DELETE FROM Player_Commands_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
203203

204-
PreparedStatement player_Login = plugin.mySQL.getConnection().prepareStatement("DELETE FROM Player_Login_Proxy WHERE Date < NOW() - INTERVAL " + when + " DAY");
204+
PreparedStatement player_Login = plugin.external.getConnection().prepareStatement("DELETE FROM Player_Login_Proxy WHERE Date < NOW() - INTERVAL " + when + " DAY");
205205

206-
PreparedStatement player_Leave = plugin.mySQL.getConnection().prepareStatement("DELETE FROM Player_Leave_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
206+
PreparedStatement player_Leave = plugin.external.getConnection().prepareStatement("DELETE FROM Player_Leave_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
207207

208-
PreparedStatement server_Reload = plugin.mySQL.getConnection().prepareStatement("DELETE FROM Server_Reload_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
208+
PreparedStatement server_Reload = plugin.external.getConnection().prepareStatement("DELETE FROM Server_Reload_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
209209

210-
PreparedStatement server_Start = plugin.mySQL.getConnection().prepareStatement("DELETE FROM Server_Start_Proxy WHERE Date < NOW() - INTERVAL " + when + " DAY");
210+
PreparedStatement server_Start = plugin.external.getConnection().prepareStatement("DELETE FROM Server_Start_Proxy WHERE Date < NOW() - INTERVAL " + when + " DAY");
211211

212-
PreparedStatement server_Stop = plugin.mySQL.getConnection().prepareStatement("DELETE FROM Server_Stop_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
212+
PreparedStatement server_Stop = plugin.external.getConnection().prepareStatement("DELETE FROM Server_Stop_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
213213

214-
PreparedStatement ram = plugin.mySQL.getConnection().prepareStatement("DELETE FROM RAM_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
214+
PreparedStatement ram = plugin.external.getConnection().prepareStatement("DELETE FROM RAM_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
215215

216-
PreparedStatement liteBans = plugin.mySQL.getConnection().prepareStatement("DELETE FROM LiteBans_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
216+
PreparedStatement liteBans = plugin.external.getConnection().prepareStatement("DELETE FROM LiteBans_Proxy WHERE DATE < NOW() - INTERVAL " + when + " DAY");
217217

218218
player_Chat.executeUpdate();
219219
player_Login.executeUpdate();

Logger - BungeeCord/src/main/java/com/carpour/loggerbungeecord/Database/MySQL/MySQL.java

Lines changed: 0 additions & 59 deletions
This file was deleted.

0 commit comments

Comments
 (0)