mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
Add Dynmap support, revert to requiring Java 17
This commit is contained in:
1 parent
c22276908a
commit
a3cf54e776
10 files changed
+337
-15
No files matched your search
@@ -0,0 +1,75 @@
|
||||
package net.william278.huskhomes.hook;
|
||||
|
||||
import net.william278.huskhomes.HuskHomes;
|
||||
import net.william278.huskhomes.position.Home;
|
||||
import net.william278.huskhomes.position.Warp;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
/**
|
||||
* A hook for a mapping plugin, such as Dynmap
|
||||
*/
|
||||
public abstract class MapHook extends PluginHook {
|
||||
|
||||
protected static final String PUBLIC_HOMES_MARKER_SET_ID = "huskhomes:public_homes";
|
||||
protected static final String WARPS_MARKER_SET_ID = "huskhomes:warps";
|
||||
|
||||
protected MapHook(@NotNull HuskHomes implementor, @NotNull String hookName) {
|
||||
super(implementor, hookName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean initialize() {
|
||||
initializeMap().thenRun(() -> {
|
||||
if (plugin.getSettings().publicHomesOnMap) {
|
||||
plugin.getDatabase().getPublicHomes().thenAccept(homes -> homes.stream()
|
||||
.filter(home -> plugin.getWorlds().stream().anyMatch(world -> world.uuid.equals(home.world.uuid)))
|
||||
.forEach(this::updateHome));
|
||||
}
|
||||
if (plugin.getSettings().warpsOnMap) {
|
||||
plugin.getDatabase().getWarps().thenAccept(warps -> warps
|
||||
.stream()
|
||||
.filter(warp -> plugin.getWorlds().stream().anyMatch(world -> world.uuid.equals(warp.world.uuid)))
|
||||
.forEach(this::updateWarp));
|
||||
}
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare the map plugin for adding homes to
|
||||
*
|
||||
* @return a {@link CompletableFuture} that completes when the map plugin is ready
|
||||
*/
|
||||
protected abstract CompletableFuture<Void> initializeMap();
|
||||
|
||||
/**
|
||||
* Update a home, adding it to the map if it exists, or updating it on the map if it doesn't
|
||||
*
|
||||
* @param home the home to update
|
||||
*/
|
||||
public abstract void updateHome(@NotNull Home home);
|
||||
|
||||
/**
|
||||
* Removes a home from the map
|
||||
*
|
||||
* @param home the home to remove
|
||||
*/
|
||||
public abstract void removeHome(@NotNull Home home);
|
||||
|
||||
/**
|
||||
* Update a warp, adding it to the map if it exists, or updating it on the map if it doesn't
|
||||
*
|
||||
* @param warp the warp to update
|
||||
*/
|
||||
public abstract void updateWarp(@NotNull Warp warp);
|
||||
|
||||
/**
|
||||
* Removes a warp from the map
|
||||
*
|
||||
* @param warp the warp to remove
|
||||
*/
|
||||
public abstract void removeWarp(@NotNull Warp warp);
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user