Skip to content

Commit 78bd894

Browse files
committed
Merge branch 'master' into mc1.21.1
2 parents 54101c0 + 0189c77 commit 78bd894

File tree

41 files changed

+398
-294
lines changed

Some content is hidden

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

41 files changed

+398
-294
lines changed

common/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ node {
3131
version = "20.14.0"
3232
download = true
3333
nodeProjectDir = file("webapp/")
34+
npmInstallCommand = "ci"
3435
}
3536

3637
tasks.register("buildWebapp", type = NpmTask::class) {

common/src/main/java/de/bluecolored/bluemap/common/api/BlueMapAPIImpl.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
*/
2525
package de.bluecolored.bluemap.common.api;
2626

27-
import com.github.benmanes.caffeine.cache.Caffeine;
2827
import com.github.benmanes.caffeine.cache.LoadingCache;
2928
import de.bluecolored.bluemap.api.BlueMapAPI;
3029
import de.bluecolored.bluemap.api.BlueMapMap;
@@ -35,6 +34,7 @@
3534
import de.bluecolored.bluemap.core.BlueMap;
3635
import de.bluecolored.bluemap.core.logger.Logger;
3736
import de.bluecolored.bluemap.core.map.BmMap;
37+
import de.bluecolored.bluemap.core.util.Caches;
3838
import de.bluecolored.bluemap.core.world.World;
3939
import lombok.NonNull;
4040
import org.jetbrains.annotations.Nullable;
@@ -68,12 +68,10 @@ public BlueMapAPIImpl(BlueMapService blueMapService, @Nullable Plugin plugin) {
6868
this.webAppImpl = new WebAppImpl(blueMapService, plugin);
6969
this.pluginImpl = plugin != null ? new PluginImpl(plugin) : null;
7070

71-
this.worldCache = Caffeine.newBuilder()
72-
.executor(BlueMap.THREAD_POOL)
71+
this.worldCache = Caches.with()
7372
.weakKeys()
7473
.build(this::getWorldUncached);
75-
this.mapCache = Caffeine.newBuilder()
76-
.executor(BlueMap.THREAD_POOL)
74+
this.mapCache = Caches.with()
7775
.weakKeys()
7876
.build(this::getMapUncached);
7977
}

common/src/main/java/de/bluecolored/bluemap/common/commands/Commands.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626

2727
import com.flowpowered.math.vector.Vector3d;
2828
import com.github.benmanes.caffeine.cache.Cache;
29-
import com.github.benmanes.caffeine.cache.Caffeine;
3029
import com.github.benmanes.caffeine.cache.LoadingCache;
3130
import de.bluecolored.bluecommands.*;
3231
import de.bluecolored.bluemap.common.commands.arguments.MapBackedArgumentParser;
@@ -39,8 +38,8 @@
3938
import de.bluecolored.bluemap.common.serverinterface.CommandSource;
4039
import de.bluecolored.bluemap.common.serverinterface.ServerWorld;
4140
import de.bluecolored.bluemap.core.map.BmMap;
41+
import de.bluecolored.bluemap.core.util.Caches;
4242
import de.bluecolored.bluemap.core.world.World;
43-
import net.kyori.adventure.text.event.ClickEvent;
4443
import org.jetbrains.annotations.Nullable;
4544

4645
import java.util.Map;
@@ -53,10 +52,10 @@
5352

5453
public class Commands {
5554

56-
private static final Cache<String, RenderTask> REF_TO_RENDERTASK = Caffeine.newBuilder()
55+
private static final Cache<String, RenderTask> REF_TO_RENDERTASK = Caches.with()
5756
.weakValues()
5857
.build();
59-
private static final LoadingCache<RenderTask, String> RENDERTASK_TO_REF = Caffeine.newBuilder()
58+
private static final LoadingCache<RenderTask, String> RENDERTASK_TO_REF = Caches.with()
6059
.weakKeys()
6160
.build(Commands::safeRandomRef);
6261

common/src/main/java/de/bluecolored/bluemap/common/commands/commands/DebugCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public int dump(CommandSource source) {
7373
text(BlueMapConfigManager.formatPath(file)).color(HIGHLIGHT_COLOR)
7474
).color(POSITIVE_COLOR));
7575
return 1;
76-
} catch (IOException ex) {
76+
} catch (Exception ex) {
7777
Logger.global.logError("Failed to create dump!", ex);
7878
source.sendMessage(text("Exception trying to create debug-dump! See console for details.").color(NEGATIVE_COLOR));
7979
return 0;

common/src/main/java/de/bluecolored/bluemap/common/debug/StateDumper.java

Lines changed: 62 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
package de.bluecolored.bluemap.common.debug;
2626

27+
import com.github.benmanes.caffeine.cache.Cache;
28+
import com.github.benmanes.caffeine.cache.stats.CacheStats;
2729
import com.google.gson.stream.JsonWriter;
2830
import de.bluecolored.bluemap.core.BlueMap;
2931
import de.bluecolored.bluemap.core.util.Key;
@@ -117,7 +119,57 @@ private void dumpInstance(Object instance, JsonWriter writer, Set<Object> alread
117119
String identityString = toIdentityString(instance);
118120
writer.name("#identity").value(identityString);
119121

122+
if (instance instanceof Cache<?,?> cache) {
123+
writer.name("stats");
124+
dumpInstance(cache.stats(), writer, alreadyDumped);
125+
126+
writer.name("estimated-size").value(cache.estimatedSize());
127+
128+
writer.name("entries").beginArray();
129+
int count = 0;
130+
for (Map.Entry<?, ?> entry : cache.asMap().entrySet()) {
131+
if (++count > 10) {
132+
writer.value("<<more elements>>");
133+
break;
134+
}
135+
136+
writer.beginObject();
137+
try {
138+
139+
writer.name("key");
140+
dumpInstance(entry.getKey(), writer, alreadyDumped);
141+
142+
writer.name("value");
143+
dumpInstance(entry.getValue(), writer, alreadyDumped);
144+
145+
} finally {
146+
writer.endObject();
147+
}
148+
149+
}
150+
writer.endArray();
151+
return;
152+
}
153+
154+
if (instance instanceof CacheStats cacheStats) {
155+
writer.name("request-count").value(cacheStats.requestCount());
156+
writer.name("hit-count").value(cacheStats.hitCount());
157+
writer.name("hit-rate").value(cacheStats.hitRate());
158+
writer.name("miss-count").value(cacheStats.missCount());
159+
writer.name("miss-rate").value(cacheStats.missRate());
160+
writer.name("load-count").value(cacheStats.loadCount());
161+
writer.name("load-success-count").value(cacheStats.loadSuccessCount());
162+
writer.name("load-failure-count").value(cacheStats.loadFailureCount());
163+
writer.name("load-failure-rate").value(cacheStats.loadFailureRate());
164+
writer.name("total-load-time").value(cacheStats.totalLoadTime());
165+
writer.name("average-load-penalty").value(cacheStats.averageLoadPenalty());
166+
writer.name("eviction-count").value(cacheStats.evictionCount());
167+
writer.name("eviction-weight").value(cacheStats.evictionWeight());
168+
return;
169+
}
170+
120171
if (instance instanceof Map<?, ?> map) {
172+
writer.name("size").value(map.size());
121173
writer.name("entries").beginArray();
122174

123175
int count = 0;
@@ -128,21 +180,25 @@ private void dumpInstance(Object instance, JsonWriter writer, Set<Object> alread
128180
}
129181

130182
writer.beginObject();
183+
try {
131184

132-
writer.name("key");
133-
dumpInstance(entry.getKey(), writer, alreadyDumped);
185+
writer.name("key");
186+
dumpInstance(entry.getKey(), writer, alreadyDumped);
134187

135-
writer.name("value");
136-
dumpInstance(entry.getValue(), writer, alreadyDumped);
188+
writer.name("value");
189+
dumpInstance(entry.getValue(), writer, alreadyDumped);
137190

138-
writer.endObject();
191+
} finally {
192+
writer.endObject();
193+
}
139194
}
140195

141196
writer.endArray();
142197
return;
143198
}
144199

145200
if (instance instanceof Collection<?> collection) {
201+
writer.name("size").value(collection.size());
146202
writer.name("entries").beginArray();
147203

148204
int count = 0;
@@ -160,6 +216,7 @@ private void dumpInstance(Object instance, JsonWriter writer, Set<Object> alread
160216
}
161217

162218
if (instance instanceof Object[] array) {
219+
writer.name("length").value(array.length);
163220
writer.name("entries").beginArray();
164221

165222
int count = 0;

common/src/main/java/de/bluecolored/bluemap/common/plugin/MapUpdateService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@
2626

2727
import com.flowpowered.math.vector.Vector2i;
2828
import com.github.benmanes.caffeine.cache.Cache;
29-
import com.github.benmanes.caffeine.cache.Caffeine;
3029
import de.bluecolored.bluemap.common.rendermanager.RenderManager;
3130
import de.bluecolored.bluemap.common.rendermanager.WorldRegionRenderTask;
3231
import de.bluecolored.bluemap.core.logger.Logger;
3332
import de.bluecolored.bluemap.core.map.BmMap;
33+
import de.bluecolored.bluemap.core.util.Caches;
3434
import de.bluecolored.bluemap.core.util.WatchService;
3535

3636
import java.io.IOException;
@@ -60,7 +60,7 @@ public MapUpdateService(RenderManager renderManager, BmMap map, Duration regionU
6060
this.regionUpdateCooldown = regionUpdateCooldown;
6161
this.closed = false;
6262
this.scheduledUpdates = new HashMap<>();
63-
this.lastUpdateTimes = Caffeine.newBuilder()
63+
this.lastUpdateTimes = Caches.with()
6464
.expireAfterWrite(regionUpdateCooldown)
6565
.build();
6666
this.watchService = map.getWorld().createRegionWatchService();

common/src/main/java/de/bluecolored/bluemap/common/serverinterface/Server.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,8 @@
2525
package de.bluecolored.bluemap.common.serverinterface;
2626

2727
import com.github.benmanes.caffeine.cache.Cache;
28-
import com.github.benmanes.caffeine.cache.Caffeine;
29-
import com.github.benmanes.caffeine.cache.LoadingCache;
3028
import de.bluecolored.bluemap.common.debug.DebugDump;
29+
import de.bluecolored.bluemap.core.util.Caches;
3130
import de.bluecolored.bluemap.core.util.Tristate;
3231
import de.bluecolored.bluemap.core.world.World;
3332
import de.bluecolored.bluemap.core.world.mca.MCAWorld;
@@ -36,12 +35,10 @@
3635
import java.nio.file.Path;
3736
import java.util.Collection;
3837
import java.util.Optional;
39-
import java.util.concurrent.TimeUnit;
4038

4139
public interface Server {
4240

43-
Cache<World, Optional<ServerWorld>> SERVER_WORLD_CACHE = Caffeine.newBuilder()
44-
.expireAfterWrite(10, TimeUnit.SECONDS)
41+
Cache<World, Optional<ServerWorld>> SERVER_WORLD_CACHE = Caches.with()
4542
.weakKeys()
4643
.weakValues()
4744
.build();

common/src/main/resources/de/bluecolored/bluemap/config/core.conf

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,46 +3,47 @@
33
## Core-Config ##
44
## ##
55

6-
# By changing the setting (accept-download) below to TRUE you are indicating that you have accepted mojang's EULA (https://account.mojang.com/documents/minecraft_eula),
7-
# you confirm that you own a license to Minecraft (Java Edition)
8-
# and you agree that BlueMap will download and use a minecraft-client file (depending on the minecraft-version) from mojangs servers (https://piston-meta.mojang.com/) for you.
9-
# This file contains resources that belong to mojang and you must not redistribute it or do anything else that is not compliant with mojang's EULA.
10-
# BlueMap uses resources in this file to generate the 3D-Models used for the map and texture them. (BlueMap will not work without those resources.)
6+
# By changing the setting (accept-download) below to TRUE you are indicating that you have accepted Mojang's EULA (https://account.mojang.com/documents/minecraft_eula),
7+
# you confirm that you own a license to Minecraft (Java Edition),
8+
# and you agree that BlueMap will download and use a Minecraft client file (depending on the Minecraft version) from Mojang's servers (https://piston-meta.mojang.com/) for you.
9+
# This file contains resources that belong to Mojang and you must not redistribute it or do anything else that is not compliant with Mojang's EULA.
10+
# BlueMap uses resources in this file to generate the 3D models used for the map and texture them. Without these, BlueMap will not work.
1111
# ${timestamp}
1212
accept-download: false
1313

14-
# The folder where bluemap saves data-files it needs during runtime or to save e.g. the render-progress to resume it later.
14+
# The folder where BlueMap saves data files it needs during runtime.
15+
# For example, the render progress file, which is used to resume the render across restarts.
1516
# Default is "bluemap"
1617
data: "${data}"
1718

1819
# This changes the amount of threads that BlueMap will use to render the maps.
19-
# A higher value can improve render-speed but could impact performance on the host machine.
20-
# This should be always below or equal to the number of available processor-cores.
21-
# Zero or a negative value means the amount of available processor-cores subtracted by the value.
22-
# (So a value of -2 with 6 cores results in 4 render-processes)
20+
# A higher value can improve the render speed, but could impact performance on the host machine.
21+
# This should be always below or equal to the number of available processor cores.
22+
# Zero or a negative value means the amount of available processor cores subtracted by the value.
23+
# For example, on a machine with 6 cores, a value of -2 would result in 4 render threads.
2324
# Default is 1
2425
render-thread-count: ${render-thread-count}
2526

26-
# Controls whether BlueMap should try to find and load mod-resources and datapacks from the server/world-directories.
27+
# Controls whether BlueMap should try to find and load mod resources and datapacks from the server/world directories.
2728
# Default is true
2829
scan-for-mod-resources: true
2930
${metrics<<
30-
# If this is true, BlueMap might send really basic metrics reports containing only the implementation-type and the version that is being used to https://metrics.bluecolored.de/bluemap/
31+
# If this is true, BlueMap might send really basic metric reports containing only the implementation type and the version that is being used to https://metrics.bluecolored.de/bluemap/
3132
# This allows me to track the basic usage of BlueMap and helps me stay motivated to further develop this tool! Please leave it on :)
3233
# An example report looks like this: {"implementation":"${implementation}","version":"${version}","mcVersion":"${mcVersion}"}
3334
# Default is true
3435
metrics: true
3536
>>}
36-
# Config-section for debug-logging
37+
# Config-section for debug logging:
3738
log: {
38-
# The file where the debug-log will be written to.
39-
# Comment out to disable debug-logging completely.
40-
# Java String formatting syntax can be used to add time, see: https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html
41-
# Default is no logging
39+
# The file where the debug log will be written to.
40+
# Comment out to disable debug logging completely.
41+
# Java String formatting syntax can be used to add timestamps, see: https://docs.oracle.com/javase/8/docs/api/java/util/Formatter.html
42+
# Default is no logging.
4243
file: "${logfile}"
4344
#file: "${logfile-with-time}"
4445

45-
# Whether the logger should append to an existing file, or overwrite it
46-
# Default is false
46+
# Whether the logger should append to an existing file, or overwrite it.
47+
# Default is false (overwrite the file).
4748
append: false
4849
}

0 commit comments

Comments
 (0)