Initial Development

- /cab list complete.
This commit is contained in:
BigPappa committed 2026-10-11 11:37:17 -05:00
1 parent 54f22aebbb
commit 9611dacc96
15 files changed
+356 -4

No files matched your search

@@ -90,6 +90,94 @@ public final class StopManager {
return stops;
}
public List<StopEntry> searchByName(String name)
throws SQLException {
String sql = """
SELECT name, icon
FROM stops
WHERE name LIKE ? ESCAPE '\\'
ORDER BY name COLLATE NOCASE
""";
List<StopEntry> stops = new ArrayList<>();
String escapedName = name
.replace("\\", "\\\\")
.replace("%", "\\%")
.replace("_", "\\_");
try (PreparedStatement statement = connection()
.prepareStatement(sql)) {
statement.setString(1, "%" + escapedName + "%");
try (ResultSet results = statement.executeQuery()) {
while (results.next()) {
stops.add(new StopEntry(
results.getString("name"),
results.getString("icon")
));
}
}
}
return stops;
}
public List<StopEntry> searchByIcon(String icon)
throws SQLException {
String sql = """
SELECT name, icon
FROM stops
WHERE icon = ?
ORDER BY name COLLATE NOCASE
""";
List<StopEntry> stops = new ArrayList<>();
try (PreparedStatement statement = connection()
.prepareStatement(sql)) {
statement.setString(1, icon);
try (ResultSet results = statement.executeQuery()) {
while (results.next()) {
stops.add(new StopEntry(
results.getString("name"),
results.getString("icon")
));
}
}
}
return stops;
}
public List<String> getUsedIcons() throws SQLException {
String sql = """
SELECT DISTINCT icon
FROM stops
ORDER BY icon COLLATE NOCASE
""";
List<String> icons = new ArrayList<>();
try (PreparedStatement statement = connection()
.prepareStatement(sql);
ResultSet results = statement.executeQuery()) {
while (results.next()) {
icons.add(results.getString("icon"));
}
}
return icons;
}
private Connection connection() {
return plugin.getDatabaseManager().getConnection();
}