Database: Rename setHome and setWarp methods to "save" for consistency

This commit is contained in:
William278 committed 2022-09-04 23:48:39 +03:00
1 parent a0c34743ef
commit 7a63e8c173
4 files changed
+13 -13

No files matched your search

@@ -382,7 +382,7 @@ public abstract class Database {
* @param home The {@link Home} to set - or update - in the database. * @param home The {@link Home} to set - or update - in the database.
* @return A future returning void when complete * @return A future returning void when complete
*/ */
public abstract CompletableFuture<Void> setHome(@NotNull Home home); public abstract CompletableFuture<Void> saveHome(@NotNull Home home);
/** /**
* Sets or updates a {@link Warp} into the warp data table on the database. * Sets or updates a {@link Warp} into the warp data table on the database.
@@ -390,7 +390,7 @@ public abstract class Database {
* @param warp The {@link Warp} to set - or update - in the database. * @param warp The {@link Warp} to set - or update - in the database.
* @return A future returning void when complete * @return A future returning void when complete
*/ */
public abstract CompletableFuture<Void> setWarp(@NotNull Warp warp); public abstract CompletableFuture<Void> saveWarp(@NotNull Warp warp);
/** /**
* Deletes a {@link Home} by the given unique id from the home table on the database. * Deletes a {@link Home} by the given unique id from the home table on the database.
@@ -886,7 +886,7 @@ public class MySqlDatabase extends Database {
} }
@Override @Override
public CompletableFuture<Void> setHome(@NotNull Home home) { public CompletableFuture<Void> saveHome(@NotNull Home home) {
return CompletableFuture.runAsync(() -> getHome(home.uuid) return CompletableFuture.runAsync(() -> getHome(home.uuid)
.thenAccept(existingHome -> existingHome.ifPresentOrElse(presentHome -> { .thenAccept(existingHome -> existingHome.ifPresentOrElse(presentHome -> {
try (Connection connection = getConnection()) { try (Connection connection = getConnection()) {
@@ -935,7 +935,7 @@ public class MySqlDatabase extends Database {
} }
@Override @Override
public CompletableFuture<Void> setWarp(@NotNull Warp warp) { public CompletableFuture<Void> saveWarp(@NotNull Warp warp) {
return CompletableFuture.runAsync(() -> getWarp(warp.uuid) return CompletableFuture.runAsync(() -> getWarp(warp.uuid)
.thenAccept(existingHome -> existingHome.ifPresentOrElse(presentWarp -> { .thenAccept(existingHome -> existingHome.ifPresentOrElse(presentWarp -> {
try (Connection connection = getConnection()) { try (Connection connection = getConnection()) {
@@ -901,7 +901,7 @@ public class SqLiteDatabase extends Database {
} }
@Override @Override
public CompletableFuture<Void> setHome(@NotNull Home home) { public CompletableFuture<Void> saveHome(@NotNull Home home) {
return CompletableFuture.runAsync(() -> getHome(home.uuid) return CompletableFuture.runAsync(() -> getHome(home.uuid)
.thenAccept(existingHome -> existingHome.ifPresentOrElse(presentHome -> { .thenAccept(existingHome -> existingHome.ifPresentOrElse(presentHome -> {
try { try {
@@ -940,7 +940,7 @@ public class SqLiteDatabase extends Database {
} }
@Override @Override
public CompletableFuture<Void> setWarp(@NotNull Warp warp) { public CompletableFuture<Void> saveWarp(@NotNull Warp warp) {
return CompletableFuture.runAsync(() -> getWarp(warp.uuid) return CompletableFuture.runAsync(() -> getWarp(warp.uuid)
.thenAccept(existingHome -> existingHome.ifPresentOrElse(presentWarp -> { .thenAccept(existingHome -> existingHome.ifPresentOrElse(presentWarp -> {
try { try {
@@ -89,7 +89,7 @@ public class SavedPositionManager {
cache.homes.putIfAbsent(home.owner.uuid, new ArrayList<>()); cache.homes.putIfAbsent(home.owner.uuid, new ArrayList<>());
cache.homes.get(home.owner.uuid).add(home.meta.name); cache.homes.get(home.owner.uuid).add(home.meta.name);
cache.privateHomeLists.remove(home.owner.uuid); cache.privateHomeLists.remove(home.owner.uuid);
return database.setHome(home).thenApply(value -> return database.saveHome(home).thenApply(value ->
new SaveResult(SaveResult.ResultType.SUCCESS, Optional.of(home))).join(); new SaveResult(SaveResult.ResultType.SUCCESS, Optional.of(home))).join();
}).join(); }).join();
} }
@@ -178,7 +178,7 @@ public class SavedPositionManager {
if (home.isPublic && mapHook != null) { if (home.isPublic && mapHook != null) {
mapHook.updateHome(home); mapHook.updateHome(home);
} }
return database.setHome(home).thenApply(value -> return database.saveHome(home).thenApply(value ->
new SaveResult(SaveResult.ResultType.SUCCESS, Optional.of(home))).join(); new SaveResult(SaveResult.ResultType.SUCCESS, Optional.of(home))).join();
}).join(); }).join();
}); });
@@ -226,7 +226,7 @@ public class SavedPositionManager {
if (home.isPublic && mapHook != null) { if (home.isPublic && mapHook != null) {
mapHook.updateHome(home); mapHook.updateHome(home);
} }
return database.setHome(home).thenApply(ignored -> true).join(); return database.saveHome(home).thenApply(ignored -> true).join();
}); });
} }
@@ -263,7 +263,7 @@ public class SavedPositionManager {
return false; return false;
} }
return database.setHome(home).thenApply(ignored -> { return database.saveHome(home).thenApply(ignored -> {
if (isHomePublic) { if (isHomePublic) {
cache.publicHomes.putIfAbsent(home.owner.username, new ArrayList<>()); cache.publicHomes.putIfAbsent(home.owner.username, new ArrayList<>());
cache.publicHomes.get(home.owner.username).add(home.meta.name); cache.publicHomes.get(home.owner.username).add(home.meta.name);
@@ -307,7 +307,7 @@ public class SavedPositionManager {
if (mapHook != null) { if (mapHook != null) {
mapHook.updateWarp(warp); mapHook.updateWarp(warp);
} }
return database.setWarp(warp).thenApply(ignored -> return database.saveWarp(warp).thenApply(ignored ->
new SaveResult(SaveResult.ResultType.SUCCESS, Optional.of(warp))).join(); new SaveResult(SaveResult.ResultType.SUCCESS, Optional.of(warp))).join();
}).join(); }).join();
} }
@@ -389,7 +389,7 @@ public class SavedPositionManager {
if (mapHook != null) { if (mapHook != null) {
mapHook.updateWarp(warp); mapHook.updateWarp(warp);
} }
return database.setWarp(warp).thenApply(value -> return database.saveWarp(warp).thenApply(value ->
new SaveResult(SaveResult.ResultType.SUCCESS, Optional.of(warp))).join(); new SaveResult(SaveResult.ResultType.SUCCESS, Optional.of(warp))).join();
}).join(); }).join();
}); });
@@ -436,7 +436,7 @@ public class SavedPositionManager {
if (mapHook != null) { if (mapHook != null) {
mapHook.updateWarp(warp); mapHook.updateWarp(warp);
} }
return database.setWarp(warp).thenApply(ignored -> true).join(); return database.saveWarp(warp).thenApply(ignored -> true).join();
}); });
} }