Added MariaDB driver support
This commit is contained in:
parent
0785e82284
commit
291db3fe4a
|
@ -3,7 +3,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>FPChat</artifactId>
|
<artifactId>FPChat</artifactId>
|
||||||
<version>1.1.7</version>
|
<version>1.1.8</version>
|
||||||
<build>
|
<build>
|
||||||
<sourceDirectory>src/main/java</sourceDirectory>
|
<sourceDirectory>src/main/java</sourceDirectory>
|
||||||
<resources>
|
<resources>
|
||||||
|
@ -24,7 +24,7 @@
|
||||||
</plugin>
|
</plugin>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>3.0.0</version>
|
<version>3.2.4</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
|
@ -57,43 +57,14 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.16.5-R0.1-SNAPSHOT</version>
|
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>commons-lang</artifactId>
|
|
||||||
<groupId>commons-lang</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>guava</artifactId>
|
|
||||||
<groupId>com.google.guava</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>gson</artifactId>
|
|
||||||
<groupId>com.google.code.gson</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>bungeecord-chat</artifactId>
|
|
||||||
<groupId>net.md-5</groupId>
|
|
||||||
</exclusion>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>snakeyaml</artifactId>
|
|
||||||
<groupId>org.yaml</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.MilkBowl</groupId>
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<artifactId>bukkit</artifactId>
|
|
||||||
<groupId>org.bukkit</groupId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
34
pom.xml
34
pom.xml
|
@ -4,7 +4,7 @@
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.fpghoti</groupId>
|
<groupId>com.fpghoti</groupId>
|
||||||
<artifactId>FPChat</artifactId>
|
<artifactId>FPChat</artifactId>
|
||||||
<version>1.1.7</version>
|
<version>1.1.8</version>
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
|
@ -57,28 +57,38 @@
|
||||||
</build>
|
</build>
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.mariadb.jdbc</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>mariadb-java-client</artifactId>
|
||||||
<version>3.0</version>
|
<version>3.1.4</version>
|
||||||
<scope>compile</scope>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.mysql</groupId>
|
||||||
|
<artifactId>mysql-connector-j</artifactId>
|
||||||
|
<version>8.1.0</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.18.1-R0.1-SNAPSHOT</version>
|
<version>1.20.1-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.zaxxer</groupId>
|
||||||
|
<artifactId>HikariCP</artifactId>
|
||||||
|
<version>5.0.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.MilkBowl</groupId>
|
<groupId>com.github.MilkBowl</groupId>
|
||||||
<artifactId>VaultAPI</artifactId>
|
<artifactId>VaultAPI</artifactId>
|
||||||
<version>1.7</version>
|
<version>1.7</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>com.zaxxer</groupId>
|
|
||||||
<artifactId>HikariCP</artifactId>
|
|
||||||
<version>4.0.3</version>
|
|
||||||
<scope>compile</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
|
@ -74,7 +74,7 @@ public class FPChat extends JavaPlugin {
|
||||||
vault.setupPermissions();
|
vault.setupPermissions();
|
||||||
config = new MainConfig(this);
|
config = new MainConfig(this);
|
||||||
pluginTag = config.getPluginTag();
|
pluginTag = config.getPluginTag();
|
||||||
if(config.mySQLEnabled()) {
|
if(config.isSQLEnabled()) {
|
||||||
sql = new MySQLConnection(this);
|
sql = new MySQLConnection(this);
|
||||||
sql.generate();
|
sql.generate();
|
||||||
startTimers();
|
startTimers();
|
||||||
|
@ -100,7 +100,7 @@ public class FPChat extends JavaPlugin {
|
||||||
for(FPlayer p : FPlayer.getPlayers()) {
|
for(FPlayer p : FPlayer.getPlayers()) {
|
||||||
p.cleanup();
|
p.cleanup();
|
||||||
}
|
}
|
||||||
if(config.mySQLEnabled()) {
|
if(config.isSQLEnabled()) {
|
||||||
sql.disconnect();
|
sql.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -114,7 +114,7 @@ public class FPChat extends JavaPlugin {
|
||||||
refresh.cancel();
|
refresh.cancel();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(config.mySQLEnabled()) {
|
if(config.isSQLEnabled()) {
|
||||||
sql.disconnect();
|
sql.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ public class FPChat extends JavaPlugin {
|
||||||
FPlayer.purge();
|
FPlayer.purge();
|
||||||
config = new MainConfig(this);
|
config = new MainConfig(this);
|
||||||
pluginTag = config.getPluginTag();
|
pluginTag = config.getPluginTag();
|
||||||
if(config.mySQLEnabled()) {
|
if(config.isSQLEnabled()) {
|
||||||
sql = new MySQLConnection(this);
|
sql = new MySQLConnection(this);
|
||||||
sql.generate();
|
sql.generate();
|
||||||
startTimers();
|
startTimers();
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class BadgeData {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Badge getBadge(int slot) {
|
public Badge getBadge(int slot) {
|
||||||
if(slot <= 0 || !FPChat.getPlugin().getMainConfig().mySQLEnabled() || slot > FPChat.getPlugin().getMainConfig().getMaxBadgeSlots()) {
|
if(slot <= 0 || !FPChat.getPlugin().getMainConfig().isSQLEnabled() || slot > FPChat.getPlugin().getMainConfig().getMaxBadgeSlots()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return slots.get(slot);
|
return slots.get(slot);
|
||||||
|
@ -56,7 +56,7 @@ public class BadgeData {
|
||||||
|
|
||||||
/**Will equip the badge regardless of the user's permissions.**/
|
/**Will equip the badge regardless of the user's permissions.**/
|
||||||
public BadgeEquipResult setBadge(int slot, Badge badge) {
|
public BadgeEquipResult setBadge(int slot, Badge badge) {
|
||||||
if(!FPChat.getPlugin().getMainConfig().mySQLEnabled()) {
|
if(!FPChat.getPlugin().getMainConfig().isSQLEnabled()) {
|
||||||
return BadgeEquipResult.NO_SQL;
|
return BadgeEquipResult.NO_SQL;
|
||||||
}
|
}
|
||||||
if(slot <= 0 || slot > FPChat.getPlugin().getMainConfig().getMaxBadgeSlots()) {
|
if(slot <= 0 || slot > FPChat.getPlugin().getMainConfig().getMaxBadgeSlots()) {
|
||||||
|
|
|
@ -299,7 +299,7 @@ public abstract class ChatChannel {
|
||||||
if(Permission.isStaff(p)){
|
if(Permission.isStaff(p)){
|
||||||
stf = FPChat.getPlugin().getMainConfig().getStaffBadge();
|
stf = FPChat.getPlugin().getMainConfig().getStaffBadge();
|
||||||
}
|
}
|
||||||
if(plugin.getMainConfig().mySQLEnabled()){
|
if(plugin.getMainConfig().isSQLEnabled()){
|
||||||
badges = p.getBadgeData().getAppearanceString();
|
badges = p.getBadgeData().getAppearanceString();
|
||||||
}
|
}
|
||||||
if(plugin.getMainConfig().chatFilterEnabled()){
|
if(plugin.getMainConfig().chatFilterEnabled()){
|
||||||
|
|
|
@ -32,7 +32,7 @@ public class BadgeClearCommand extends Commands {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if(!plugin.getMainConfig().mySQLEnabled()) {
|
if(!plugin.getMainConfig().isSQLEnabled()) {
|
||||||
FPlayer.errMsg(null, "MySQL is not enabled.");
|
FPlayer.errMsg(null, "MySQL is not enabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public class BadgeEquipCommand extends Commands {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!plugin.getMainConfig().mySQLEnabled()) {
|
if(!plugin.getMainConfig().isSQLEnabled()) {
|
||||||
FPlayer.errMsg(null, "MySQL is not enabled.");
|
FPlayer.errMsg(null, "MySQL is not enabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@ public class BadgeListCommand extends Commands {
|
||||||
p = FPlayer.getPlayer((Player)sender);
|
p = FPlayer.getPlayer((Player)sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!plugin.getMainConfig().mySQLEnabled()) {
|
if(!plugin.getMainConfig().isSQLEnabled()) {
|
||||||
FPlayer.errMsg(null, "MySQL is not enabled.");
|
FPlayer.errMsg(null, "MySQL is not enabled.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,9 +25,13 @@ public class MainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generate(){
|
private void generate(){
|
||||||
if (config.get("MySQL")==null) {
|
if (config.get("SQL")==null) {
|
||||||
config.createSection("MySQL");
|
config.createSection("SQL");
|
||||||
config.set("MySQL", false);
|
config.set("SQL", false);
|
||||||
|
}
|
||||||
|
if (config.get("UseMariaDBDriver")==null){
|
||||||
|
config.createSection("UseMariaDBDriver");
|
||||||
|
config.set("UseMariaDBDriver", true);
|
||||||
}
|
}
|
||||||
if (config.get("Host")==null) {
|
if (config.get("Host")==null) {
|
||||||
config.createSection("Host");
|
config.createSection("Host");
|
||||||
|
@ -133,12 +137,16 @@ public class MainConfig {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean mySQLEnabled() {
|
public boolean isSQLEnabled() {
|
||||||
return config.getBoolean("MySQL");
|
return config.getBoolean("SQL");
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean useMariaDBDriver() {
|
||||||
|
return config.getBoolean("UseMariaDBDriver");
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getHost() {
|
public String getHost() {
|
||||||
if(mySQLEnabled()) {
|
if(isSQLEnabled()) {
|
||||||
return config.getString("Host");
|
return config.getString("Host");
|
||||||
}else {
|
}else {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Null SQL host. Is MySQL disabled?");
|
plugin.getLogger().log(Level.SEVERE, "Null SQL host. Is MySQL disabled?");
|
||||||
|
@ -147,7 +155,7 @@ public class MainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPort() {
|
public String getPort() {
|
||||||
if(mySQLEnabled()) {
|
if(isSQLEnabled()) {
|
||||||
return config.getString("Port");
|
return config.getString("Port");
|
||||||
}else {
|
}else {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Null SQL port. Is MySQL disabled?");
|
plugin.getLogger().log(Level.SEVERE, "Null SQL port. Is MySQL disabled?");
|
||||||
|
@ -156,7 +164,7 @@ public class MainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUser() {
|
public String getUser() {
|
||||||
if(mySQLEnabled()) {
|
if(isSQLEnabled()) {
|
||||||
return config.getString("User");
|
return config.getString("User");
|
||||||
}else {
|
}else {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Null SQL user. Is MySQL disabled?");
|
plugin.getLogger().log(Level.SEVERE, "Null SQL user. Is MySQL disabled?");
|
||||||
|
@ -165,7 +173,7 @@ public class MainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPassword() {
|
public String getPassword() {
|
||||||
if(mySQLEnabled()) {
|
if(isSQLEnabled()) {
|
||||||
return config.getString("Password");
|
return config.getString("Password");
|
||||||
}else {
|
}else {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Null SQL password. Is MySQL disabled?");
|
plugin.getLogger().log(Level.SEVERE, "Null SQL password. Is MySQL disabled?");
|
||||||
|
@ -174,7 +182,7 @@ public class MainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDatabase() {
|
public String getDatabase() {
|
||||||
if(mySQLEnabled()) {
|
if(isSQLEnabled()) {
|
||||||
return config.getString("Database");
|
return config.getString("Database");
|
||||||
}else {
|
}else {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Null SQL database. Is MySQL disabled?");
|
plugin.getLogger().log(Level.SEVERE, "Null SQL database. Is MySQL disabled?");
|
||||||
|
@ -183,7 +191,7 @@ public class MainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getChatFeatureTable() {
|
public String getChatFeatureTable() {
|
||||||
if(mySQLEnabled()) {
|
if(isSQLEnabled()) {
|
||||||
return config.getString("Chat-Feature-Table");
|
return config.getString("Chat-Feature-Table");
|
||||||
}else {
|
}else {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Null SQL chat feature table. Is MySQL disabled?");
|
plugin.getLogger().log(Level.SEVERE, "Null SQL chat feature table. Is MySQL disabled?");
|
||||||
|
@ -192,7 +200,7 @@ public class MainConfig {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPermSyncTable() {
|
public String getPermSyncTable() {
|
||||||
if(mySQLEnabled()) {
|
if(isSQLEnabled()) {
|
||||||
return config.getString("PermSync-Table");
|
return config.getString("PermSync-Table");
|
||||||
}else {
|
}else {
|
||||||
plugin.getLogger().log(Level.SEVERE, "Null SQL perm sync table. Is MySQL disabled?");
|
plugin.getLogger().log(Level.SEVERE, "Null SQL perm sync table. Is MySQL disabled?");
|
||||||
|
|
|
@ -29,16 +29,21 @@ public class MySQLConnection{
|
||||||
port = config.getPort();
|
port = config.getPort();
|
||||||
hikari = new HikariDataSource();
|
hikari = new HikariDataSource();
|
||||||
hikari.setMaximumPoolSize(10);
|
hikari.setMaximumPoolSize(10);
|
||||||
hikari.setDataSourceClassName("com.mysql.cj.jdbc.MysqlDataSource");
|
|
||||||
hikari.addDataSourceProperty("serverName", host);
|
|
||||||
hikari.addDataSourceProperty("user", user);
|
hikari.addDataSourceProperty("user", user);
|
||||||
hikari.addDataSourceProperty("password", password);
|
hikari.addDataSourceProperty("password", password);
|
||||||
hikari.addDataSourceProperty("databaseName", database);
|
if(config.useMariaDBDriver()) {
|
||||||
hikari.addDataSourceProperty("port", port);
|
hikari.setDataSourceClassName("org.mariadb.jdbc.MariaDbDataSource");
|
||||||
|
hikari.addDataSourceProperty("url", "jdbc:mariadb://"+ host + ":" + port + "/" + database);
|
||||||
|
}else {
|
||||||
|
hikari.setDataSourceClassName("com.mysql.cj.jdbc.MysqlDataSource");
|
||||||
|
hikari.addDataSourceProperty("serverName", host);
|
||||||
|
hikari.addDataSourceProperty("databaseName", database);
|
||||||
|
hikari.addDataSourceProperty("port", port);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generate() {
|
public void generate() {
|
||||||
if(config.mySQLEnabled()){
|
if(config.isSQLEnabled()){
|
||||||
plugin.log(Level.INFO, "Connecting to MySQL...");
|
plugin.log(Level.INFO, "Connecting to MySQL...");
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
try {
|
try {
|
||||||
|
@ -91,24 +96,24 @@ public class MySQLConnection{
|
||||||
if (input == null){
|
if (input == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Statement statement;
|
Statement statement;
|
||||||
Connection connection = null;
|
Connection connection = null;
|
||||||
|
try {
|
||||||
|
connection = hikari.getConnection();
|
||||||
|
statement = connection.createStatement();
|
||||||
|
statement.executeUpdate(input);
|
||||||
|
statement.close();
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}finally {
|
||||||
try {
|
try {
|
||||||
connection = hikari.getConnection();
|
connection.close();
|
||||||
statement = connection.createStatement();
|
|
||||||
statement.executeUpdate(input);
|
|
||||||
statement.close();
|
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}finally {
|
|
||||||
try {
|
|
||||||
connection.close();
|
|
||||||
} catch (SQLException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void asyncUpdate(String input){
|
public void asyncUpdate(String input){
|
||||||
CompletableFuture.runAsync(() -> {
|
CompletableFuture.runAsync(() -> {
|
||||||
update(input);
|
update(input);
|
||||||
|
|
|
@ -165,7 +165,7 @@ public class FPlayer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(FPChat.getPlugin().getMainConfig().mySQLEnabled()) {
|
if(FPChat.getPlugin().getMainConfig().isSQLEnabled()) {
|
||||||
this.badgeData = new BadgeData(this);
|
this.badgeData = new BadgeData(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue