Merge branch 'development'

This commit is contained in:
Brianna 2020-12-10 09:08:57 -06:00
commit b126508f31
20 changed files with 44 additions and 19 deletions

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../</relativePath>
</parent>

View File

@ -53,7 +53,7 @@ public class SongodaCore {
/**
* This has been added as of Rev 6
*/
private final static String coreVersion = "2.4.25";
private final static String coreVersion = "2.4.26";
/**
* This is specific to the website api

View File

@ -4,6 +4,7 @@ import org.bukkit.Bukkit;
import org.bukkit.plugin.Plugin;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
@ -19,6 +20,7 @@ public class DataManagerAbstract {
protected final Plugin plugin;
private static Map<String, LinkedList<Runnable>> queues = new HashMap<>();
private static Map<String, LinkedList<PreparedStatement>> queuedStatements = new HashMap<>();
public DataManagerAbstract(DatabaseConnector databaseConnector, Plugin plugin) {
this.databaseConnector = databaseConnector;
@ -78,6 +80,29 @@ public class DataManagerAbstract {
Bukkit.getScheduler().runTask(this.plugin, runnable);
}
/**
* Queue PreparedStatements to be executed in a single database connection.
*
* @param statement statement to queue.
* @param queueKey the queue key to add the statement to.
* @param delay the delay between each queue execution.
*/
public void queueAsync(PreparedStatement statement, String queueKey, long delay) {
if (queues.get(queueKey) == null || queues.get(queueKey).isEmpty())
Bukkit.getScheduler().runTaskLaterAsynchronously(plugin, () -> {
databaseConnector.connect(connection -> {
List<PreparedStatement> queue = queuedStatements.get(queueKey);
for (PreparedStatement stmt : queue)
stmt.executeBatch();
connection.commit();
queue.clear();
});
}, delay);
List<PreparedStatement> queue = queuedStatements.computeIfAbsent(queueKey, t -> new LinkedList<>());
queue.add(statement);
}
/**
* Queue tasks to be ran asynchronously.
*

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -3,7 +3,7 @@
<parent>
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<relativePath>../../</relativePath>
</parent>

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId>
<artifactId>SongodaCore-Modules</artifactId>
<version>2.4.25</version>
<version>2.4.26</version>
<modelVersion>4.0.0</modelVersion>
<packaging>pom</packaging>