Initial Development
- /cab list complete.
This commit is contained in:
1 parent
3566555893
commit
c31ec9b8a8
8 files changed
+119
-29
No files matched your search
@@ -8,6 +8,8 @@ import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public final class StopManager {
|
||||
|
||||
@@ -17,6 +19,9 @@ public final class StopManager {
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public record StopEntry(String name, String icon) {
|
||||
}
|
||||
|
||||
public boolean exists(String name) throws SQLException {
|
||||
String sql = "SELECT 1 FROM stops WHERE name = ?";
|
||||
|
||||
@@ -61,6 +66,30 @@ public final class StopManager {
|
||||
}
|
||||
}
|
||||
|
||||
public List<StopEntry> getAllStops() throws SQLException {
|
||||
String sql = """
|
||||
SELECT name, icon
|
||||
FROM stops
|
||||
ORDER BY name COLLATE NOCASE
|
||||
""";
|
||||
|
||||
List<StopEntry> stops = new ArrayList<>();
|
||||
|
||||
try (PreparedStatement statement = connection()
|
||||
.prepareStatement(sql);
|
||||
ResultSet results = statement.executeQuery()) {
|
||||
|
||||
while (results.next()) {
|
||||
stops.add(new StopEntry(
|
||||
results.getString("name"),
|
||||
results.getString("icon")
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
return stops;
|
||||
}
|
||||
|
||||
private Connection connection() {
|
||||
return plugin.getDatabaseManager().getConnection();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user