Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify, move variable from 'MapsClient.java' to where it is used #12144

Merged
merged 2 commits into from
Nov 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@
import javax.annotation.Nullable;
import lombok.extern.slf4j.Slf4j;
import org.triplea.game.ApplicationContext;
import org.triplea.http.client.maps.listing.MapsClient;
import org.triplea.io.FileUtils;
import org.triplea.util.Services;

/** Provides methods to work with common file locations in a client installation. */
@Slf4j
public final class ClientFileSystemHelper {
public static final String USER_ROOT_FOLDER_NAME = "triplea";

@VisibleForTesting static final String MAPS_FOLDER_NAME = "downloadedMaps";
private static Path codeSourceLocation;

private ClientFileSystemHelper() {}
Expand Down Expand Up @@ -111,7 +112,7 @@ public static Path getUserMapsFolder() {
@VisibleForTesting
static Path getUserMapsFolder(final Supplier<Path> userHomeRootFolderSupplier) {
final Path defaultDownloadedMapsFolder =
userHomeRootFolderSupplier.get().resolve(MapsClient.MAPS_FOLDER_NAME);
userHomeRootFolderSupplier.get().resolve(MAPS_FOLDER_NAME);

// make sure folder override location is valid, if not notify user and reset it.
final Optional<Path> path = ClientSetting.mapFolderOverride.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import lombok.AccessLevel;
import lombok.Getter;
import lombok.extern.slf4j.Slf4j;
import org.triplea.http.client.maps.listing.MapsClient;
import org.triplea.java.ThreadRunner;

/**
Expand Down Expand Up @@ -149,10 +148,6 @@ public abstract class ClientSetting<T> implements GameSetting<T> {
UnitsDrawer.UnitFlagDrawMode.class,
"UNIT_FLAG_DRAW_MODE",
UnitsDrawer.UnitFlagDrawMode.NONE);
public static final ClientSetting<Path> userMapsFolderPath =
new PathClientSetting(
"USER_MAPS_FOLDER_PATH",
ClientFileSystemHelper.getUserRootFolder().resolve(MapsClient.MAPS_FOLDER_NAME));
public static final ClientSetting<Integer> wheelScrollAmount =
new IntegerClientSetting("WHEEL_SCROLL_AMOUNT", 60);
public static final ClientSetting<String> playerName =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import java.nio.file.Path;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.triplea.http.client.maps.listing.MapsClient;

@SuppressWarnings("InnerClassMayBeStatic")
final class ClientFileSystemHelperTest {
Expand All @@ -18,7 +17,8 @@ void shouldReturnCurrentFolderWhenOverrideFolderNotSet() {
final Path result =
ClientFileSystemHelper.getUserMapsFolder(() -> Path.of("/path/to/current"));

assertThat(result, is(Path.of("/path", "to", "current", MapsClient.MAPS_FOLDER_NAME)));
assertThat(
result, is(Path.of("/path", "to", "current", ClientFileSystemHelper.MAPS_FOLDER_NAME)));
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
public interface MapsClient {
String MAPS_LISTING_PATH = "/maps/listing";
String MAPS_FOLDER_NAME = "downloadedMaps";

static MapsClient newClient(URI mapsServerUri) {
return HttpClient.newClient(
Expand Down