Restructure connection interfacing system

This commit is contained in:
William committed 2021-10-02 23:07:45 +01:00
1 parent 894b50ad0d
commit 7ef9159daf
33 files changed
+200 -256

No files matched your search

@@ -35,9 +35,8 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter {
// Updates the public home cache
public static void updatePublicHomeTabCache() {
publicHomeTabCache.clear();
Connection connection = HuskHomes.getConnection();
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
try (Connection connection = HuskHomes.getConnection()) {
for (Home home : DataManager.getPublicHomes(connection)) {
publicHomeTabCache.put(home.getName(), home.getOwnerUsername());
}
@@ -48,9 +47,8 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter {
}
public static void queueHomeTeleport(Player p, String publicHome) {
Connection connection = HuskHomes.getConnection();
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
try (Connection connection = HuskHomes.getConnection()) {
String[] split = publicHome.split("\\.");
String ownerName = split[0];
String homeName = split[1];
@@ -102,9 +100,8 @@ public class PublicHomeCommand extends CommandBase implements TabCompleter {
String[] split = publicHomeName.split("\\.");
String ownerName = split[0];
String homeName = split[1];
Connection connection = HuskHomes.getConnection();
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try {
try (Connection connection = HuskHomes.getConnection()) {
if (DataManager.homeExists(ownerName, homeName, connection)) {
Home home = DataManager.getHome(ownerName, homeName, connection);
assert home != null;