mirror of
https://github.com/songoda/SongodaCore.git
synced 2024-11-23 18:45:34 +01:00
Merge branch 'development'
This commit is contained in:
commit
b126508f31
@ -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>
|
||||
|
||||
|
@ -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
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user