Skip to content

Commit 9056d69

Browse files
authored
Merge pull request #270 from Querz/config-rework
Config rework
2 parents b0dfdc9 + 89519f0 commit 9056d69

File tree

187 files changed

+11835
-5695
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

187 files changed

+11835
-5695
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -453,15 +453,15 @@ placed in this folder.
453453

454454
---
455455

456-
[**Download Version 1.16.3 (Windows Installer)**](https://github.com/Querz/mcaselector/releases/download/1.16.3/MCA_Selector_Setup.exe)
456+
[**Download Version 1.17 (Windows Installer)**](https://github.com/Querz/mcaselector/releases/download/1.17/MCA_Selector_Setup.exe)
457457

458458
"Requirements":
459459
* Windows 7-10 64bit
460460
* At least 6 GB of RAM
461461

462462
---
463463

464-
[**Download Version 1.16.3 (Universal)**](https://github.com/Querz/mcaselector/releases/download/1.16.3/mcaselector-1.16.3.jar)
464+
[**Download Version 1.17 (Universal)**](https://github.com/Querz/mcaselector/releases/download/1.17/mcaselector-1.17.jar)
465465

466466

467467
"Requirements":
@@ -481,11 +481,11 @@ For Windows:
481481

482482
* Download the JRE-FX-16 from [HERE](https://cdn.azul.com/zulu/bin/zulu16.30.15-ca-fx-jre16.0.1-win_x64.zip) into an
483483
empty folder.
484-
* Move the previously downloaded `mcaselector-1.16.3.jar` into the same folder. Extract the content of the
484+
* Move the previously downloaded `mcaselector-1.17.jar` into the same folder. Extract the content of the
485485
downloaded .zip file into this folder.
486486
* Hold `Shift` and `right-click` an empty spot in this folder, and choose `Open PowerShell window here`. Type `& `
487487
(with a space at the end), go into the previously extracted folder and drag and drop the `bin\java.exe` file into
488-
the PowerShell window. Then complete the command by typing a space and ` -jar mcaselector-1.16.3.jar` and press
488+
the PowerShell window. Then complete the command by typing a space and ` -jar mcaselector-1.17.jar` and press
489489
`Enter`.
490490

491491
For MacOS:
@@ -495,23 +495,23 @@ For MacOS:
495495
* Extract the content of the downloaded .zip file into this folder.
496496
* Press `Cmd+Space`, type `Terminal` and press `Enter`. Go into the previously extracted folder and drag and drop
497497
the `zulu-16.jdk/Contents/Home/bin/java` into the terminal. Continue to type `-jar ` (with a space at the end) and
498-
drag-and drop the `mcaselector-1.16.3.jar` into the terminal as well, the press `Enter`.
498+
drag-and drop the `mcaselector-1.17.jar` into the terminal as well, the press `Enter`.
499499

500500
For Linux:
501501

502502
* Download the JDK-FX-16 from [HERE](https://cdn.azul.com/zulu/bin/zulu16.30.15-ca-fx-jdk16.0.1-linux_x64.tar.gz)
503503
into an empty folder.
504504
* Extract the content of the downloaded .tar.gz file into this folder.
505505
* Open your terminal of choice and navigate in the extracted folder into `bin`, then run `./java -jar
506-
<path-to-mcaselector-1.16.3.jar>`.
506+
<path-to-mcaselector-1.17.jar>`.
507507

508508
To avoid having to go through this process every time to start MCA Selector, the resulting command can be copied
509509
into a `.bat`-file on Windows or `.sh`-file on MacOS and Linux and can then be executed by double-clicking the
510510
`.bat`-file on Windows or running `sh <file>.sh` in the terminal / console on MacOS or Linux where `<file>` must be
511511
replaced by the name of the `.sh`-file.
512512

513513
### When you receive an error from a previously installed version of Java
514-
"When I run `mcaselector-1.16.3.jar`, an error dialog appears that looks like this:"
514+
"When I run `mcaselector-1.17.jar`, an error dialog appears that looks like this:"
515515

516516
<p align="center">
517517
<img src="https://gist.githubusercontent.com/Querz/5e08c4ab863c2ad8b5da146dc4188ecb/raw/1a935464a6d62ce1c73f4651149825ce6a2ecd80/missing_javafx.png" alt="Popup dialog stating a missing JavaFX installation">
@@ -531,35 +531,35 @@ version older than 16, make sure that you have Java 16 installed or proceed with
531531
JavaFX (the simple way)](#using-a-jre-or-jdk-with-pre-packed-javafx-the-simple-way).
532532

533533
For Windows and MacOS:
534-
* Type `java -jar ` (with a space at the end) and drag and drop the `mcaselector-1.16.3.jar` into the console and
534+
* Type `java -jar ` (with a space at the end) and drag and drop the `mcaselector-1.17.jar` into the console and
535535
hit `Enter`.
536536

537537
For Linux:
538-
* Run `java -jar <path to mcaselector-1.16.3.jar` where you replace everything in `<>`.
538+
* Run `java -jar <path to mcaselector-1.17.jar` where you replace everything in `<>`.
539539

540540
For Windows:
541541
* Download "JavaFX Windows SDK" for your Java version from [here](https://gluonhq.com/products/javafx/).
542542
* Unzip the `.zip`-file with your program of choice, then navigate into the unzipped folder.
543543
* Hold `Shift` and Right-click on an empty space in that folder and select `Open PowerShell window here` (`Open
544544
Command window here` on Windows 8 and earlier). Type `java --module-path ` (with a space at the end), then drag
545545
and drop the `lib`-folder into the console. Continue to type ` --add-modules ALL-MODULE-PATH -jar ` (with a space
546-
at the beginning and the end), then drag and drop the `mcaselector-1.16.3.jar` into the console and hit `Enter`.
546+
at the beginning and the end), then drag and drop the `mcaselector-1.17.jar` into the console and hit `Enter`.
547547

548548
For MacOS:
549549
* Download "JavaFX Mac OS X SDK" for your Java version from [here](https://gluonhq.com/products/javafx/).
550550
* Double-click the `.zip`-file to unpack, then navigate into the unzipped folder.
551551
* Press `Cmd+Space`, type `Terminal` and press `Enter`. Type `java --module-path ` (with a space at the end), then
552552
drag and drop the `lib`-folder into the console. Continue to type `--add-modules ALL-MODULE-PATH -jar ` (with a
553-
space at the end), then drag and drop the `mcaselector-1.16.3.jar` into the console and hit `Enter`.
553+
space at the end), then drag and drop the `mcaselector-1.17.jar` into the console and hit `Enter`.
554554

555555
For Linux:
556556
* Download "JavaFX Linux SDK" for your Java version from [here](https://gluonhq.com/products/javafx/).
557557
* Unzip the `.zip`-file with your program of choice.
558558
* Open the command prompt and run `java --module-path <path to unzipped folder>/lib --add-modules ALL-MODULE-PATH
559-
-jar <path to mcaselector-1.16.3.jar>` where you replace everything in `<>` with the appropriate paths.
559+
-jar <path to mcaselector-1.17.jar>` where you replace everything in `<>` with the appropriate paths.
560560
* Some distributions like AdoptOpenJDK (shipped with most Linux distributions) do not ship with JavaFX by default.
561561
On Debian, an open version of JavaFX is contained in the `openjfx` package. This or some other installation of
562-
JavaFX is required to run the `mcaselector-1.16.3.jar`.
562+
JavaFX is required to run the `mcaselector-1.17.jar`.
563563

564564
To avoid having to go through this process every time to start MCA Selector, the resulting command can be copied
565565
into a `.bat`-file on Windows or `.sh`-file on MacOS and Linux and can then be executed by double-clicking the

build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ plugins {
99
}
1010

1111
group 'net.querz.mcaselector'
12-
version '1.16.3'
12+
version '1.17'
1313
def appName = 'MCA Selector'
1414
def appUrl = 'https://github.com/Querz/mcaselector'
1515
def appAuthor = 'Querz'
@@ -36,6 +36,7 @@ dependencies {
3636
implementation 'org.json:json:20201115'
3737
implementation 'ar.com.hjg:pngj:2.1.0'
3838
implementation 'org.xerial:sqlite-jdbc:3.34.0'
39+
implementation 'it.unimi.dsi:fastutil:8.5.6'
3940
testImplementation 'junit:junit:4.12'
4041
testImplementation 'commons-io:commons-io:2.6'
4142
}

src/main/java/net/querz/mcaselector/Config.java

Lines changed: 71 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package net.querz.mcaselector;
22

3+
import net.querz.mcaselector.io.CacheHelper;
34
import net.querz.mcaselector.io.FileHelper;
45
import net.querz.mcaselector.io.WorldDirectories;
56
import net.querz.mcaselector.tiles.Tile;
@@ -108,10 +109,10 @@ private static boolean attemptCreateDirectory(File file) {
108109
return false;
109110
}
110111
try {
111-
Files.createDirectories(parent.toPath());
112+
Files.createDirectories(parent.getCanonicalFile().toPath());
112113
return true;
113114
} catch (IOException ex) {
114-
System.out.println("failed to create directory " + parent + ": " + ex.getMessage());
115+
System.out.println("failed to create directory " + parent + ": " + ex.getMessage() + "(" + ex.getClass().getSimpleName() + ")");
115116
return false;
116117
}
117118
}
@@ -127,7 +128,6 @@ private static String resolveHome(String dir) {
127128
public static final Color DEFAULT_CHUNK_SELECTION_COLOR = new Color(1, 0.45, 0, 0.8);
128129
public static final Color DEFAULT_PASTE_CHUNKS_COLOR = new Color(0, 1, 0, 0.8);
129130
public static final Locale DEFAULT_LOCALE = Locale.UK;
130-
public static final int DEFAULT_LOAD_THREADS = 1;
131131
public static final int DEFAULT_PROCESS_THREADS = Math.max(Runtime.getRuntime().availableProcessors() - 2, 1);
132132
public static final int DEFAULT_WRITE_THREADS = Math.min(Runtime.getRuntime().availableProcessors(), 4);
133133
public static final int DEFAULT_MAX_LOADED_FILES = (int) Math.max(Math.ceil(Runtime.getRuntime().maxMemory() / 1_000_000_000D) * 2, 1);
@@ -142,6 +142,7 @@ private static String resolveHome(String dir) {
142142

143143
public static final int DEFAULT_RENDER_HEIGHT = 319;
144144
public static final boolean DEFAULT_RENDER_LAYER_ONLY = false;
145+
public static final boolean DEFAULT_RENDER_CAVES = false;
145146

146147
private static File worldDir = null;
147148
private static WorldDirectories worldDirs = null;
@@ -154,7 +155,6 @@ private static String resolveHome(String dir) {
154155
private static Color regionSelectionColor = DEFAULT_REGION_SELECTION_COLOR;
155156
private static Color chunkSelectionColor = DEFAULT_CHUNK_SELECTION_COLOR;
156157
private static Color pasteChunksColor = DEFAULT_PASTE_CHUNKS_COLOR;
157-
private static int loadThreads = DEFAULT_LOAD_THREADS;
158158
private static int processThreads = DEFAULT_PROCESS_THREADS;
159159
private static int writeThreads = DEFAULT_WRITE_THREADS;
160160
private static int maxLoadedFiles = DEFAULT_MAX_LOADED_FILES;
@@ -168,6 +168,7 @@ private static String resolveHome(String dir) {
168168

169169
private static int renderHeight = DEFAULT_RENDER_HEIGHT;
170170
private static boolean renderLayerOnly = DEFAULT_RENDER_LAYER_ONLY;
171+
private static boolean renderCaves = DEFAULT_RENDER_CAVES;
171172

172173
private static boolean debug = DEFAULT_DEBUG;
173174

@@ -324,6 +325,14 @@ public static boolean renderLayerOnly() {
324325
return Config.renderLayerOnly;
325326
}
326327

328+
public static void setRenderCaves(boolean renderCaves) {
329+
Config.renderCaves = renderCaves;
330+
}
331+
332+
public static boolean renderCaves() {
333+
return Config.renderCaves;
334+
}
335+
327336
public static void setMCSavesDir(String mcSavesDir) {
328337
Config.mcSavesDir = mcSavesDir;
329338
}
@@ -409,16 +418,9 @@ public static void loadFromIni() {
409418
regionSelectionColor = new Color(config.getOrDefault("RegionSelectionColor", DEFAULT_REGION_SELECTION_COLOR.toString()));
410419
chunkSelectionColor = new Color(config.getOrDefault("ChunkSelectionColor", DEFAULT_CHUNK_SELECTION_COLOR.toString()));
411420
pasteChunksColor = new Color(config.getOrDefault("PasteChunksColor", DEFAULT_PASTE_CHUNKS_COLOR.toString()));
412-
loadThreads = Integer.parseInt(config.getOrDefault("LoadThreads", DEFAULT_LOAD_THREADS + ""));
413421
processThreads = Integer.parseInt(config.getOrDefault("ProcessThreads", DEFAULT_PROCESS_THREADS + ""));
414422
writeThreads = Integer.parseInt(config.getOrDefault("WriteThreads", DEFAULT_WRITE_THREADS + ""));
415423
maxLoadedFiles = Integer.parseInt(config.getOrDefault("MaxLoadedFiles", DEFAULT_MAX_LOADED_FILES + ""));
416-
shade = Boolean.parseBoolean(config.getOrDefault("Shade", DEFAULT_SHADE + ""));
417-
shadeWater = Boolean.parseBoolean(config.getOrDefault("ShadeWater", DEFAULT_SHADE_WATER + ""));
418-
showNonexistentRegions = Boolean.parseBoolean(config.getOrDefault("ShowNonexistentRegions", DEFAULT_SHOW_NONEXISTENT_REGIONS + ""));
419-
smoothRendering = Boolean.parseBoolean(config.getOrDefault("SmoothRendering", DEFAULT_SMOOTH_RENDERING + ""));
420-
smoothOverlays = Boolean.parseBoolean(config.getOrDefault("SmoothOverlays", DEFAULT_SMOOTH_OVERLAYS + ""));
421-
tileMapBackground = config.getOrDefault("TileMapBackground", DEFAULT_TILEMAP_BACKGROUND);
422424
mcSavesDir = config.getOrDefault("MCSavesDir", DEFAULT_MC_SAVES_DIR);
423425
if (!new File(mcSavesDir).exists()) {
424426
mcSavesDir = DEFAULT_MC_SAVES_DIR;
@@ -450,6 +452,8 @@ public static void loadFromIni() {
450452
Config.overlays = overlays;
451453
}
452454
}
455+
456+
System.out.println(asString());
453457
}
454458

455459
public static void exportConfig() {
@@ -467,16 +471,9 @@ public static void exportConfig() {
467471
addSettingsLine("RegionSelectionColor", regionSelectionColor.toString(), DEFAULT_REGION_SELECTION_COLOR.toString(), lines);
468472
addSettingsLine("ChunkSelectionColor", chunkSelectionColor.toString(), DEFAULT_CHUNK_SELECTION_COLOR.toString(), lines);
469473
addSettingsLine("PasteChunksColor", pasteChunksColor.toString(), DEFAULT_PASTE_CHUNKS_COLOR.toString(), lines);
470-
addSettingsLine("LoadThreads", loadThreads, DEFAULT_LOAD_THREADS, lines);
471474
addSettingsLine("ProcessThreads", processThreads, DEFAULT_PROCESS_THREADS, lines);
472475
addSettingsLine("WriteThreads", writeThreads, DEFAULT_WRITE_THREADS, lines);
473476
addSettingsLine("MaxLoadedFiles", maxLoadedFiles, DEFAULT_MAX_LOADED_FILES, lines);
474-
addSettingsLine("Shade", shade, DEFAULT_SHADE, lines);
475-
addSettingsLine("ShadeWater", shadeWater, DEFAULT_SHADE_WATER, lines);
476-
addSettingsLine("ShowNonexistentRegions", showNonexistentRegions, DEFAULT_SHOW_NONEXISTENT_REGIONS, lines);
477-
addSettingsLine("SmoothRendering", smoothRendering, DEFAULT_SMOOTH_RENDERING, lines);
478-
addSettingsLine("SmoothOverlays", smoothOverlays, DEFAULT_SMOOTH_OVERLAYS, lines);
479-
addSettingsLine("TileMapBackground", tileMapBackground, DEFAULT_TILEMAP_BACKGROUND, lines);
480477
addSettingsLine("MCSavesDir", mcSavesDir, DEFAULT_MC_SAVES_DIR, lines);
481478
addSettingsLine("Debug", debug, DEFAULT_DEBUG, lines);
482479
if (lines.size() == 0) {
@@ -531,14 +528,6 @@ public static void setPasteChunksColor(Color pasteChunksColor) {
531528
Config.pasteChunksColor = pasteChunksColor;
532529
}
533530

534-
public static int getLoadThreads() {
535-
return loadThreads;
536-
}
537-
538-
public static void setLoadThreads(int loadThreads) {
539-
Config.loadThreads = loadThreads;
540-
}
541-
542531
public static int getProcessThreads() {
543532
return processThreads;
544533
}
@@ -570,4 +559,60 @@ public static int getMaxZoomLevel() {
570559
public static int getMinZoomLevel() {
571560
return Tile.getZoomLevel(MIN_SCALE);
572561
}
562+
563+
public static String asString() {
564+
final StringBuilder sb = new StringBuilder("Config{\n");
565+
sb.append(" DEFAULT_BASE_DIR=").append(DEFAULT_BASE_DIR);
566+
sb.append(",\n DEFAULT_BASE_CACHE_DIR=").append(DEFAULT_BASE_CACHE_DIR);
567+
sb.append(",\n DEFAULT_BASE_LOG_FILE=").append(DEFAULT_BASE_LOG_FILE);
568+
sb.append(",\n DEFAULT_BASE_CONFIG_FILE=").append(DEFAULT_BASE_CONFIG_FILE);
569+
sb.append(",\n DEFAULT_BASE_OVERLAYS_FILE=").append(DEFAULT_BASE_OVERLAYS_FILE);
570+
sb.append(",\n DEFAULT_REGION_SELECTION_COLOR=").append(DEFAULT_REGION_SELECTION_COLOR);
571+
sb.append(",\n DEFAULT_CHUNK_SELECTION_COLOR=").append(DEFAULT_CHUNK_SELECTION_COLOR);
572+
sb.append(",\n DEFAULT_PASTE_CHUNKS_COLOR=").append(DEFAULT_PASTE_CHUNKS_COLOR);
573+
sb.append(",\n DEFAULT_LOCALE=").append(DEFAULT_LOCALE);
574+
sb.append(",\n DEFAULT_PROCESS_THREADS=").append(DEFAULT_PROCESS_THREADS);
575+
sb.append(",\n DEFAULT_WRITE_THREADS=").append(DEFAULT_WRITE_THREADS);
576+
sb.append(",\n DEFAULT_MAX_LOADED_FILES=").append(DEFAULT_MAX_LOADED_FILES);
577+
sb.append(",\n DEFAULT_SHADE=").append(DEFAULT_SHADE);
578+
sb.append(",\n DEFAULT_SHADE_WATER=").append(DEFAULT_SHADE_WATER);
579+
sb.append(",\n DEFAULT_SHOW_NONEXISTENT_REGIONS=").append(DEFAULT_SHOW_NONEXISTENT_REGIONS);
580+
sb.append(",\n DEFAULT_SMOOTH_RENDERING=").append(DEFAULT_SMOOTH_RENDERING);
581+
sb.append(",\n DEFAULT_SMOOTH_OVERLAYS=").append(DEFAULT_SMOOTH_OVERLAYS);
582+
sb.append(",\n DEFAULT_TILEMAP_BACKGROUND='").append(DEFAULT_TILEMAP_BACKGROUND).append('\'');
583+
sb.append(",\n DEFAULT_DEBUG=").append(DEFAULT_DEBUG);
584+
sb.append(",\n DEFAULT_MC_SAVES_DIR='").append(DEFAULT_MC_SAVES_DIR).append('\'');
585+
sb.append(",\n DEFAULT_RENDER_HEIGHT=").append(DEFAULT_RENDER_HEIGHT);
586+
sb.append(",\n DEFAULT_RENDER_LAYER_ONLY=").append(DEFAULT_RENDER_LAYER_ONLY);
587+
sb.append(",\n DEFAULT_RENDER_CAVES=").append(DEFAULT_RENDER_CAVES);
588+
sb.append(",\n worldDir=").append(worldDir);
589+
sb.append(",\n worldDirs=").append(worldDirs);
590+
sb.append(",\n worldUUID=").append(worldUUID);
591+
sb.append(",\n baseCacheDir=").append(baseCacheDir);
592+
sb.append(",\n logFile=").append(logFile);
593+
sb.append(",\n cacheDir=").append(cacheDir);
594+
sb.append(",\n locale=").append(locale);
595+
sb.append(",\n regionSelectionColor=").append(regionSelectionColor);
596+
sb.append(",\n chunkSelectionColor=").append(chunkSelectionColor);
597+
sb.append(",\n pasteChunksColor=").append(pasteChunksColor);
598+
sb.append(",\n processThreads=").append(processThreads);
599+
sb.append(",\n writeThreads=").append(writeThreads);
600+
sb.append(",\n maxLoadedFiles=").append(maxLoadedFiles);
601+
sb.append(",\n shade=").append(shade);
602+
sb.append(",\n shadeWater=").append(shadeWater);
603+
sb.append(",\n showNonexistentRegions=").append(showNonexistentRegions);
604+
sb.append(",\n smoothRendering=").append(smoothRendering);
605+
sb.append(",\n smoothOverlays=").append(smoothOverlays);
606+
sb.append(",\n tileMapBackground='").append(tileMapBackground).append('\'');
607+
sb.append(",\n mcSavesDir='").append(mcSavesDir).append('\'');
608+
sb.append(",\n renderHeight=").append(renderHeight);
609+
sb.append(",\n renderLayerOnly=").append(renderLayerOnly);
610+
sb.append(",\n renderCaves=").append(renderCaves);
611+
sb.append(",\n debug=").append(debug);
612+
sb.append(",\n MAX_SCALE=").append(MAX_SCALE);
613+
sb.append(",\n MIN_SCALE=").append(MIN_SCALE);
614+
sb.append(",\n IMAGE_POOL_SIZE=").append(IMAGE_POOL_SIZE);
615+
sb.append("\n}");
616+
return sb.toString();
617+
}
573618
}

0 commit comments

Comments
 (0)