Compare commits
1
Commits
dev/update
...
bbd4610fbe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbd4610fbe |
@@ -137,7 +137,7 @@ public class SQLStorageProvider extends StorageProvider {
|
|||||||
.uuid(uuid)
|
.uuid(uuid)
|
||||||
.backLocation(locationStringToLocation(resultSet.getString("BackLocation")))
|
.backLocation(locationStringToLocation(resultSet.getString("BackLocation")))
|
||||||
.deathLocation(locationStringToLocation(resultSet.getString("DeathLocation")))
|
.deathLocation(locationStringToLocation(resultSet.getString("DeathLocation")))
|
||||||
.homes(locationMapStringToLocationMap(resultSet.getString("locationMapToString")))
|
.homes(loadHomes(uuid))
|
||||||
.userSettings(new EssentiaUserSettings
|
.userSettings(new EssentiaUserSettings
|
||||||
.Builder()
|
.Builder()
|
||||||
//.allowTeleports(resultSet.getBoolean("TeleportToggled")) // FIXME
|
//.allowTeleports(resultSet.getBoolean("TeleportToggled")) // FIXME
|
||||||
@@ -150,6 +150,30 @@ public class SQLStorageProvider extends StorageProvider {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Map<String, Home> loadHomes(UUID uuid) {
|
||||||
|
String sql = "SELECT * FROM homes WHERE uuid = ?";
|
||||||
|
Map<String, Home> locationMap = new HashMap<>();
|
||||||
|
DatabaseQuery databaseQuery = new DatabaseQuery(sql, ps -> ps.setString(1, uuid.toString()));
|
||||||
|
try (ResultSet resultSet = databaseQuery.executeQuery(getDatabaseConnection().get())) {
|
||||||
|
if (!resultSet.next()) {
|
||||||
|
return locationMap;
|
||||||
|
}
|
||||||
|
String homeName = resultSet.getString("Name");
|
||||||
|
while (resultSet.next()) {
|
||||||
|
locationMap.put(
|
||||||
|
homeName,
|
||||||
|
new EssentiaHome(
|
||||||
|
homeName,
|
||||||
|
locationStringToLocation(resultSet.getString("HomeLocation"))
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
} catch (SQLException e) {
|
||||||
|
// catch this nicely
|
||||||
|
}
|
||||||
|
return locationMap;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void save(@NotNull EssentiaUser user) throws Exception {
|
public void save(@NotNull EssentiaUser user) throws Exception {
|
||||||
// Todo - use reflection to go over the fields to save?
|
// Todo - use reflection to go over the fields to save?
|
||||||
@@ -224,13 +248,4 @@ public class SQLStorageProvider extends StorageProvider {
|
|||||||
return stringBuilder.toString();
|
return stringBuilder.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, Home> locationMapStringToLocationMap(String locationMapString) {
|
|
||||||
Map<String, Home> locationMap = new HashMap<>();
|
|
||||||
String[] entries = locationMapString.split(";");
|
|
||||||
for (String entry : entries) {
|
|
||||||
String[] data = entry.split("%");
|
|
||||||
locationMap.put(data[0], new EssentiaHome(data[0], locationStringToLocation(data[1])));
|
|
||||||
}
|
|
||||||
return locationMap;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user