mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-01 22:16:08 +00:00
Further refactoring, move away from using future thread pool
This commit is contained in:
1 parent
4c90e5498c
commit
39e0b25d46
56 files changed
+737
-1713
No files matched your search
@@ -6,7 +6,6 @@ import net.william278.huskhomes.user.User;
|
||||
import net.william278.huskhomes.user.UserData;
|
||||
import net.william278.huskhomes.position.*;
|
||||
import net.william278.huskhomes.teleport.Teleport;
|
||||
import net.william278.huskhomes.teleport.TeleportType;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.sqlite.SQLiteConfig;
|
||||
@@ -144,7 +143,7 @@ public class SqLiteDatabase extends Database {
|
||||
statement.setFloat(5, position.getPitch());
|
||||
statement.setString(6, position.getWorld().getName());
|
||||
statement.setString(7, position.getWorld().getUuid().toString());
|
||||
statement.setString(8, position.getServer().getName());
|
||||
statement.setString(8, position.getServer());
|
||||
statement.executeUpdate();
|
||||
|
||||
// Return the ID of the newly inserted row
|
||||
@@ -177,7 +176,7 @@ public class SqLiteDatabase extends Database {
|
||||
statement.setFloat(5, position.getPitch());
|
||||
statement.setString(6, position.getWorld().getUuid().toString());
|
||||
statement.setString(7, position.getWorld().getName());
|
||||
statement.setString(8, position.getServer().getName());
|
||||
statement.setString(8, position.getServer());
|
||||
statement.setDouble(9, positionId);
|
||||
statement.executeUpdate();
|
||||
}
|
||||
@@ -596,20 +595,20 @@ public class SqLiteDatabase extends Database {
|
||||
|
||||
final ResultSet resultSet = statement.executeQuery();
|
||||
if (resultSet.next()) {
|
||||
return Optional.of(Teleport.builder(plugin, onlineUser)
|
||||
.setTarget(new Position(resultSet.getDouble("x"),
|
||||
return Optional.of(Teleport.builder(plugin)
|
||||
.teleporter(onlineUser)
|
||||
.target(new Position(resultSet.getDouble("x"),
|
||||
resultSet.getDouble("y"),
|
||||
resultSet.getDouble("z"),
|
||||
resultSet.getFloat("yaw"),
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
new Server(resultSet.getString("server_name"))))
|
||||
.setType(TeleportType.getTeleportType(resultSet.getInt("type"))
|
||||
.orElse(TeleportType.TELEPORT))
|
||||
.doUpdateLastPosition(false)
|
||||
.toTeleport()
|
||||
.join());
|
||||
resultSet.getString("server_name")))
|
||||
.type(Teleport.Type.getTeleportType(resultSet.getInt("type"))
|
||||
.orElse(Teleport.Type.TELEPORT))
|
||||
.updateLastPosition(false)
|
||||
.toTeleport());
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
@@ -654,13 +653,13 @@ public class SqLiteDatabase extends Database {
|
||||
}
|
||||
|
||||
// Set the user's teleport into the database (if it's not null)
|
||||
if (teleport != null && teleport.target != null) {
|
||||
if (teleport != null) {
|
||||
try (PreparedStatement statement = getConnection().prepareStatement(formatStatementTables("""
|
||||
INSERT INTO `%teleports_table%` (`player_uuid`, `destination_id`, `type`)
|
||||
VALUES (?,?,?);"""))) {
|
||||
statement.setString(1, user.getUuid().toString());
|
||||
statement.setInt(2, setPosition(teleport.target, connection));
|
||||
statement.setInt(3, teleport.type.typeId);
|
||||
statement.setInt(2, setPosition((Position) teleport.getTarget(), connection));
|
||||
statement.setInt(3, teleport.getType().getTypeId());
|
||||
|
||||
statement.executeUpdate();
|
||||
|
||||
@@ -688,7 +687,7 @@ public class SqLiteDatabase extends Database {
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
new Server(resultSet.getString("server_name"))));
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
getLogger().log(Level.SEVERE, "Failed to query the last teleport position of " + user.getUsername(), e);
|
||||
@@ -745,7 +744,7 @@ public class SqLiteDatabase extends Database {
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
new Server(resultSet.getString("server_name"))));
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
|
||||
} catch (SQLException e) {
|
||||
@@ -800,7 +799,7 @@ public class SqLiteDatabase extends Database {
|
||||
resultSet.getFloat("pitch"),
|
||||
new World(resultSet.getString("world_name"),
|
||||
UUID.fromString(resultSet.getString("world_uuid"))),
|
||||
new Server(resultSet.getString("server_name"))));
|
||||
resultSet.getString("server_name")));
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
getLogger().log(Level.SEVERE, "Failed to query the respawn position of " + user.getUsername(), e);
|
||||
|
||||
Reference in new issue
Block a user