Skip to content

Commit b8abf79

Browse files
committed
Add map-freeze, tile-filters and new task-scheduling methods
1 parent 7774935 commit b8abf79

File tree

2 files changed

+78
-5
lines changed

2 files changed

+78
-5
lines changed

src/main/java/de/bluecolored/bluemap/api/BlueMapMap.java

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
import com.flowpowered.math.vector.Vector3d;
2929
import com.flowpowered.math.vector.Vector3i;
3030

31+
import java.util.Optional;
32+
import java.util.function.Predicate;
33+
3134
/**
3235
* This class represents a map that is rendered by BlueMap of a specific world ({@link BlueMapWorld}).
3336
* Each map belongs to a map configured in BlueMap's configuration file (in the <code>maps: []</code> list).
@@ -64,7 +67,34 @@ public interface BlueMapMap {
6467
* @return the tile-offset in blocks
6568
*/
6669
Vector2i getTileOffset();
67-
70+
71+
/**
72+
* <p></p>Sets a filter that determines if a specific (hires) tile of this map should be updated or not.
73+
* If this filter returns false for a tile, the "render"-process of this tile will be cancelled and the tile will be left untouched.</p>
74+
* <p><b>Warning:</b> Using this method will harm the integrity of the map! Since BlueMap will still assume that the tile got updated properly.</p>
75+
* <p>Any previously set filters will get overwritten with the new one. You can get the current filter using {@link #getTileFilter()} and combine them if you wish.</p>
76+
* @param filter The filter that will be used from now on.
77+
*/
78+
void setTileFilter(Predicate<Vector2i> filter);
79+
80+
/**
81+
* Freezes or unfreezes the map in the same way the `/bluemap freeze` command does.
82+
* BlueMap will no longer attempt to update this map if it is frozen.
83+
* @param frozen Whether the map will be frozen or not
84+
*/
85+
void setFrozen(boolean frozen);
86+
87+
/**
88+
* Checks if the map is currently frozen
89+
* @return true if the map is frozen, false otherwise
90+
*/
91+
boolean isFrozen();
92+
93+
/**
94+
* Returns the currently set TileFilter. The default TileFilter is equivalent to <code>t -> true</code>.
95+
*/
96+
Predicate<Vector2i> getTileFilter();
97+
6898
/**
6999
* Converts a block-position to a map-tile-coordinate for this map
70100
*

src/main/java/de/bluecolored/bluemap/api/renderer/RenderAPI.java

Lines changed: 47 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,15 @@
2424
*/
2525
package de.bluecolored.bluemap.api.renderer;
2626

27-
import java.util.UUID;
28-
2927
import com.flowpowered.math.vector.Vector2i;
3028
import com.flowpowered.math.vector.Vector3i;
31-
3229
import de.bluecolored.bluemap.api.BlueMapMap;
3330
import de.bluecolored.bluemap.api.BlueMapWorld;
3431

32+
import java.io.IOException;
33+
import java.util.Collection;
34+
import java.util.UUID;
35+
3536
/**
3637
* The {@link RenderAPI} is used to schedule tile-renders and process them on a number of different threads.
3738
*/
@@ -46,6 +47,7 @@ public interface RenderAPI {
4647
*
4748
* @throws IllegalArgumentException if there is no world loaded with the provided {@link UUID}
4849
*/
50+
@Deprecated
4951
void render(UUID world, Vector3i blockPosition);
5052

5153
/**
@@ -55,6 +57,7 @@ public interface RenderAPI {
5557
* @param world the {@link BlueMapWorld} to render
5658
* @param blockPosition a {@link Vector3i} for the block-position to render (the whole map-tiles will be rendered not only that block)
5759
*/
60+
@Deprecated
5861
default void render(BlueMapWorld world, Vector3i blockPosition) {
5962
for (BlueMapMap map : world.getMaps()) {
6063
render(map, blockPosition);
@@ -70,6 +73,7 @@ default void render(BlueMapWorld world, Vector3i blockPosition) {
7073
*
7174
* @throws IllegalArgumentException if there is no map loaded with the provided mapId
7275
*/
76+
@Deprecated
7377
void render(String mapId, Vector3i blockPosition);
7478

7579
/**
@@ -79,6 +83,7 @@ default void render(BlueMapWorld world, Vector3i blockPosition) {
7983
* @param map the {@link BlueMapMap}
8084
* @param blockPosition a {@link Vector3i} for the block-position to render (the whole map-tile will be rendered not only that block)
8185
*/
86+
@Deprecated
8287
default void render(BlueMapMap map, Vector3i blockPosition) {
8388
render(map, map.posToTile(blockPosition));
8489
}
@@ -92,6 +97,7 @@ default void render(BlueMapMap map, Vector3i blockPosition) {
9297
*
9398
* @throws IllegalArgumentException if there is no map loaded with the provided mapId
9499
*/
100+
@Deprecated
95101
void render(String mapId, Vector2i tile);
96102

97103
/**
@@ -101,8 +107,45 @@ default void render(BlueMapMap map, Vector3i blockPosition) {
101107
* @param map the {@link BlueMapMap}
102108
* @param tile a {@link Vector2i} for the tile-position to render
103109
*/
110+
@Deprecated
104111
void render(BlueMapMap map, Vector2i tile);
105-
112+
113+
/**
114+
* Schedules a task to update the given map.
115+
* @param map the map to be updated
116+
* @return true if a new task has been scheduled, false if not (usually because there is already an update-task for this map scheduled)
117+
*/
118+
default boolean scheduleMapUpdateTask(BlueMapMap map) {
119+
return scheduleMapUpdateTask(map, false);
120+
}
121+
122+
/**
123+
* Schedules a task to update the given map.
124+
* @param map the map to be updated
125+
* @param force it this is true, the task will forcefully re-render all tiles, even if there are no changes since the last map-update.
126+
* @return true if a new task has been scheduled, false if not (usually because there is already an update-task for this map scheduled)
127+
*/
128+
boolean scheduleMapUpdateTask(BlueMapMap map, boolean force);
129+
130+
/**
131+
* Schedules a task to update the given map.
132+
* @param map the map to be updated
133+
* @param regions The regions that should be updated ("region" refers to the coordinates of a minecraft region-file (32x32 chunks, 512x512 blocks))<br>
134+
* BlueMaps updating-system works based on region-files. For this reason you can always only update a whole region-file at once.
135+
* @param force it this is true, the task will forcefully re-render all tiles, even if there are no changes since the last map-update.
136+
* @return true if a new task has been scheduled, false if not (usually because there is already an update-task for this map scheduled)
137+
*/
138+
boolean scheduleMapUpdateTask(BlueMapMap map, Collection<Vector2i> regions, boolean force);
139+
140+
/**
141+
* Schedules a task to purge the given map.
142+
* An update-task will be scheduled right after the purge, to get the map up-to-date again.
143+
* @param map the map to be purged
144+
* @return true if a new task has been scheduled, false if not (usually because there is already an update-task for this map scheduled)
145+
* @throws IOException if an IOException occurs while trying to create the task.
146+
*/
147+
boolean scheduleMapPurgeTask(BlueMapMap map) throws IOException;
148+
106149
/**
107150
* Getter for the current size of the render-queue.
108151
* @return the current size of the render-queue

0 commit comments

Comments
 (0)