mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-03 22:16:34 +00:00
Add support for BlueMap
This commit is contained in:
1 parent
36703c55f5
commit
25d90530d3
13 files changed
+148
-8
No files matched your search
+1
-1
@@ -48,7 +48,7 @@ allprojects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
processResources {
|
processResources {
|
||||||
filesNotMatching('**/*.png') {
|
filesNotMatching(['**/*.png', '**/*.svg']) {
|
||||||
filter ReplaceTokens as Class, beginToken: '${', endToken: '}',
|
filter ReplaceTokens as Class, beginToken: '${', endToken: '}',
|
||||||
tokens: rootProject.ext.properties
|
tokens: rootProject.ext.properties
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -5,12 +5,12 @@ dependencies {
|
|||||||
implementation 'io.papermc:paperlib:1.0.7'
|
implementation 'io.papermc:paperlib:1.0.7'
|
||||||
implementation 'me.lucko:commodore:2.2'
|
implementation 'me.lucko:commodore:2.2'
|
||||||
|
|
||||||
|
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||||
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT'
|
||||||
compileOnly 'redis.clients:jedis:' + jedis_version
|
compileOnly 'redis.clients:jedis:' + jedis_version
|
||||||
compileOnly 'commons-io:commons-io:2.11.0'
|
compileOnly 'commons-io:commons-io:2.11.0'
|
||||||
compileOnly 'com.google.guava:guava:31.1-jre'
|
compileOnly 'com.google.guava:guava:31.1-jre'
|
||||||
compileOnly 'de.themoep:minedown:1.7.1-SNAPSHOT'
|
compileOnly 'de.themoep:minedown:1.7.1-SNAPSHOT'
|
||||||
compileOnly 'org.jetbrains:annotations:23.0.0'
|
|
||||||
compileOnly 'net.william278:Annotaml:1.0.2'
|
compileOnly 'net.william278:Annotaml:1.0.2'
|
||||||
compileOnly 'net.william278:DesertWell:1.0'
|
compileOnly 'net.william278:DesertWell:1.0'
|
||||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
|
compileOnly 'com.github.MilkBowl:VaultAPI:1.7.1'
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import net.william278.huskhomes.config.Spawn;
|
|||||||
import net.william278.huskhomes.database.Database;
|
import net.william278.huskhomes.database.Database;
|
||||||
import net.william278.huskhomes.database.MySqlDatabase;
|
import net.william278.huskhomes.database.MySqlDatabase;
|
||||||
import net.william278.huskhomes.database.SqLiteDatabase;
|
import net.william278.huskhomes.database.SqLiteDatabase;
|
||||||
|
import net.william278.huskhomes.hook.BlueMapHook;
|
||||||
import net.william278.huskhomes.hook.DynMapHook;
|
import net.william278.huskhomes.hook.DynMapHook;
|
||||||
import net.william278.huskhomes.hook.PluginHook;
|
import net.william278.huskhomes.hook.PluginHook;
|
||||||
import net.william278.huskhomes.hook.VaultEconomyHook;
|
import net.william278.huskhomes.hook.VaultEconomyHook;
|
||||||
@@ -168,6 +169,11 @@ public class BukkitHuskHomes extends JavaPlugin implements HuskHomes {
|
|||||||
pluginHooks.add(new DynMapHook(this, dynmapPlugin));
|
pluginHooks.add(new DynMapHook(this, dynmapPlugin));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
case BLUEMAP -> {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("BlueMap") != null) {
|
||||||
|
pluginHooks.add(new BlueMapHook(this));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
getMapHook().ifPresent(mapHook -> savedPositionManager.setMapHook(mapHook));
|
getMapHook().ifPresent(mapHook -> savedPositionManager.setMapHook(mapHook));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,9 +24,6 @@ import java.util.logging.Level;
|
|||||||
*/
|
*/
|
||||||
public class DynMapHook extends MapHook {
|
public class DynMapHook extends MapHook {
|
||||||
|
|
||||||
private static final String WARP_MARKER_IMAGE_NAME = "warp";
|
|
||||||
private static final String PUBLIC_HOME_MARKER_IMAGE_NAME = "public-home";
|
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
private final DynmapAPI dynmapAPI;
|
private final DynmapAPI dynmapAPI;
|
||||||
|
|
||||||
@@ -45,7 +42,7 @@ public class DynMapHook extends MapHook {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(markerIcon -> markerAPI.getMarkerIcons().remove(markerIcon));
|
.ifPresent(markerIcon -> markerAPI.getMarkerIcons().remove(markerIcon));
|
||||||
markerAPI.createMarkerIcon(PUBLIC_HOME_MARKER_IMAGE_NAME, "Public Home",
|
markerAPI.createMarkerIcon(PUBLIC_HOME_MARKER_IMAGE_NAME, "Public Home",
|
||||||
((BukkitHuskHomes) plugin).getResource("markers/" + PUBLIC_HOME_MARKER_IMAGE_NAME + ".png"));
|
((BukkitHuskHomes) plugin).getResource("markers/16x/" + PUBLIC_HOME_MARKER_IMAGE_NAME + ".png"));
|
||||||
markerAPI.createMarkerSet(PUBLIC_HOMES_MARKER_SET_ID,
|
markerAPI.createMarkerSet(PUBLIC_HOMES_MARKER_SET_ID,
|
||||||
"Public Homes", dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
"Public Homes", dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||||
}
|
}
|
||||||
@@ -55,7 +52,7 @@ public class DynMapHook extends MapHook {
|
|||||||
.findFirst()
|
.findFirst()
|
||||||
.ifPresent(markerIcon -> markerAPI.getMarkerIcons().remove(markerIcon));
|
.ifPresent(markerIcon -> markerAPI.getMarkerIcons().remove(markerIcon));
|
||||||
markerAPI.createMarkerIcon(WARP_MARKER_IMAGE_NAME, "Warp",
|
markerAPI.createMarkerIcon(WARP_MARKER_IMAGE_NAME, "Warp",
|
||||||
((BukkitHuskHomes) plugin).getResource("markers/" + WARP_MARKER_IMAGE_NAME + ".png"));
|
((BukkitHuskHomes) plugin).getResource("markers/16x/" + WARP_MARKER_IMAGE_NAME + ".png"));
|
||||||
markerAPI.createMarkerSet(WARPS_MARKER_SET_ID,
|
markerAPI.createMarkerSet(WARPS_MARKER_SET_ID,
|
||||||
"Warps", dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
"Warps", dynmapAPI.getMarkerAPI().getMarkerIcons(), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ api-version: 1.16
|
|||||||
softdepend:
|
softdepend:
|
||||||
- Vault
|
- Vault
|
||||||
- dynmap
|
- dynmap
|
||||||
|
- BlueMap
|
||||||
libraries:
|
libraries:
|
||||||
- 'redis.clients:jedis:${jedis_version}'
|
- 'redis.clients:jedis:${jedis_version}'
|
||||||
- 'mysql:mysql-connector-java:${mysql_driver_version}'
|
- 'mysql:mysql-connector-java:${mysql_driver_version}'
|
||||||
|
|||||||
+3
-1
@@ -9,12 +9,14 @@ dependencies {
|
|||||||
exclude module: 'slf4j-api'
|
exclude module: 'slf4j-api'
|
||||||
}
|
}
|
||||||
|
|
||||||
|
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||||
compileOnly 'com.google.guava:guava:31.1-jre'
|
compileOnly 'com.google.guava:guava:31.1-jre'
|
||||||
compileOnly 'redis.clients:jedis:' + jedis_version
|
compileOnly 'redis.clients:jedis:' + jedis_version
|
||||||
compileOnly 'org.xerial:sqlite-jdbc:' + sqlite_driver_version
|
compileOnly 'org.xerial:sqlite-jdbc:' + sqlite_driver_version
|
||||||
compileOnly 'mysql:mysql-connector-java:' + mysql_driver_version
|
compileOnly 'mysql:mysql-connector-java:' + mysql_driver_version
|
||||||
compileOnly 'org.apache.commons:commons-text:' + commons_text_version
|
compileOnly 'org.apache.commons:commons-text:' + commons_text_version
|
||||||
compileOnly 'org.jetbrains:annotations:23.0.0'
|
|
||||||
|
compileOnly 'com.github.BlueMap-Minecraft:BlueMapAPI:v2.1.0'
|
||||||
|
|
||||||
testImplementation 'com.github.yuriy-g:simple-java-plot:5c502c2e98'
|
testImplementation 'com.github.yuriy-g:simple-java-plot:5c502c2e98'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import net.william278.huskhomes.util.Permission;
|
|||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
|
import java.io.InputStream;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -251,6 +252,15 @@ public interface HuskHomes {
|
|||||||
@NotNull
|
@NotNull
|
||||||
Server getServer(@NotNull OnlineUser requester);
|
Server getServer(@NotNull OnlineUser requester);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a resource read from the plugin resources folder
|
||||||
|
*
|
||||||
|
* @param name the name of the resource
|
||||||
|
* @return the resource read as an {@link InputStream}
|
||||||
|
*/
|
||||||
|
@Nullable
|
||||||
|
InputStream getResource(@NotNull String name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a list of worlds on the server
|
* Returns a list of worlds on the server
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -0,0 +1,122 @@
|
|||||||
|
package net.william278.huskhomes.hook;
|
||||||
|
|
||||||
|
import com.flowpowered.math.vector.Vector2i;
|
||||||
|
import de.bluecolored.bluemap.api.BlueMapAPI;
|
||||||
|
import de.bluecolored.bluemap.api.markers.MarkerSet;
|
||||||
|
import de.bluecolored.bluemap.api.markers.POIMarker;
|
||||||
|
import net.william278.huskhomes.HuskHomes;
|
||||||
|
import net.william278.huskhomes.position.Home;
|
||||||
|
import net.william278.huskhomes.position.Warp;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import javax.imageio.ImageIO;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook to display warps and public homes on <a href="https://github.com/BlueMap-Minecraft/BlueMap">BlueMap</a> maps
|
||||||
|
*/
|
||||||
|
public class BlueMapHook extends MapHook {
|
||||||
|
|
||||||
|
private String publicHomeMarkerIconPath;
|
||||||
|
private String warpMarkerIconPath;
|
||||||
|
|
||||||
|
public BlueMapHook(@NotNull HuskHomes implementor) {
|
||||||
|
super(implementor, "BlueMap");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected CompletableFuture<Void> initializeMap() {
|
||||||
|
final CompletableFuture<Void> initializedFuture = new CompletableFuture<>();
|
||||||
|
CompletableFuture.runAsync(() -> BlueMapAPI.onEnable(blueMapAPI -> {
|
||||||
|
// Create marker sets
|
||||||
|
plugin.getWorlds().forEach(world -> blueMapAPI.getWorld(world.uuid)
|
||||||
|
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(map -> {
|
||||||
|
if (plugin.getSettings().publicHomesOnMap) {
|
||||||
|
map.getMarkerSets().put(world.uuid + ":" + PUBLIC_HOMES_MARKER_SET_ID,
|
||||||
|
MarkerSet.builder().label("Public Homes").build());
|
||||||
|
}
|
||||||
|
if (plugin.getSettings().warpsOnMap) {
|
||||||
|
map.getMarkerSets().put(world.uuid + ":" + WARPS_MARKER_SET_ID,
|
||||||
|
MarkerSet.builder().label("Warps").build());
|
||||||
|
}
|
||||||
|
})));
|
||||||
|
|
||||||
|
// Create marker icons
|
||||||
|
try {
|
||||||
|
publicHomeMarkerIconPath = blueMapAPI.getWebApp().createImage(
|
||||||
|
ImageIO.read(Objects.requireNonNull(plugin.getResource("markers/50x/" + PUBLIC_HOME_MARKER_IMAGE_NAME + ".png"))),
|
||||||
|
"huskhomes/" + PUBLIC_HOMES_MARKER_SET_ID + ".png");
|
||||||
|
warpMarkerIconPath = blueMapAPI.getWebApp().createImage(
|
||||||
|
ImageIO.read(Objects.requireNonNull(plugin.getResource("markers/50x/" + WARP_MARKER_IMAGE_NAME + ".png"))),
|
||||||
|
"huskhomes/" + WARP_MARKER_IMAGE_NAME + ".png");
|
||||||
|
} catch (IOException e) {
|
||||||
|
plugin.getLoggingAdapter().log(Level.SEVERE, "Failed to create warp marker image", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
initializedFuture.complete(null);
|
||||||
|
}));
|
||||||
|
return initializedFuture;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> updateHome(@NotNull Home home) {
|
||||||
|
if (!plugin.getSettings().publicHomesOnMap) return CompletableFuture.completedFuture(null);
|
||||||
|
return removeHome(home).thenRun(() -> BlueMapAPI.getInstance().flatMap(
|
||||||
|
blueMapAPI -> blueMapAPI.getWorld(home.world.uuid)).ifPresent(blueMapWorld -> blueMapWorld.getMaps()
|
||||||
|
.forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||||
|
.computeIfPresent(home.world.uuid + ":" + PUBLIC_HOMES_MARKER_SET_ID, (s, markerSet) -> {
|
||||||
|
markerSet.getMarkers().put(home.uuid.toString(),
|
||||||
|
POIMarker.toBuilder()
|
||||||
|
.label(home.meta.name)
|
||||||
|
.position((int) home.x, (int) home.y, (int) home.z)
|
||||||
|
.icon(publicHomeMarkerIconPath, Vector2i.from(25, 25))
|
||||||
|
.maxDistance(5000)
|
||||||
|
.build());
|
||||||
|
return markerSet;
|
||||||
|
}))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> removeHome(@NotNull Home home) {
|
||||||
|
if (!plugin.getSettings().publicHomesOnMap) return CompletableFuture.completedFuture(null);
|
||||||
|
BlueMapAPI.getInstance().flatMap(blueMapAPI -> blueMapAPI.getWorld(home.world.uuid))
|
||||||
|
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||||
|
.computeIfPresent(home.world.uuid + ":" + PUBLIC_HOMES_MARKER_SET_ID, (s, markerSet) -> {
|
||||||
|
markerSet.getMarkers().remove(home.uuid.toString());
|
||||||
|
return markerSet;
|
||||||
|
})));
|
||||||
|
return CompletableFuture.completedFuture(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> updateWarp(@NotNull Warp warp) {
|
||||||
|
if (!plugin.getSettings().warpsOnMap) return CompletableFuture.completedFuture(null);
|
||||||
|
return removeWarp(warp).thenRun(() -> BlueMapAPI.getInstance().flatMap(blueMapAPI -> blueMapAPI.getWorld(warp.world.uuid))
|
||||||
|
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||||
|
.computeIfPresent(warp.world.uuid + ":" + WARPS_MARKER_SET_ID, (s, markerSet) -> {
|
||||||
|
markerSet.getMarkers().put(warp.uuid.toString(),
|
||||||
|
POIMarker.toBuilder()
|
||||||
|
.label(warp.meta.name)
|
||||||
|
.position((int) warp.x, (int) warp.y, (int) warp.z)
|
||||||
|
.icon(warpMarkerIconPath, Vector2i.from(25, 25))
|
||||||
|
.maxDistance(10000)
|
||||||
|
.build());
|
||||||
|
return markerSet;
|
||||||
|
}))));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CompletableFuture<Void> removeWarp(@NotNull Warp warp) {
|
||||||
|
if (!plugin.getSettings().warpsOnMap) return CompletableFuture.completedFuture(null);
|
||||||
|
BlueMapAPI.getInstance().flatMap(blueMapAPI -> blueMapAPI.getWorld(warp.world.uuid))
|
||||||
|
.ifPresent(blueMapWorld -> blueMapWorld.getMaps().forEach(blueMapMap -> blueMapMap.getMarkerSets()
|
||||||
|
.computeIfPresent(warp.world.uuid + ":" + WARPS_MARKER_SET_ID, (s, markerSet) -> {
|
||||||
|
markerSet.getMarkers().remove(warp.uuid.toString());
|
||||||
|
return markerSet;
|
||||||
|
})));
|
||||||
|
return CompletableFuture.completedFuture(null);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,8 @@ public abstract class MapHook extends PluginHook {
|
|||||||
|
|
||||||
protected static final String PUBLIC_HOMES_MARKER_SET_ID = "huskhomes-public-homes";
|
protected static final String PUBLIC_HOMES_MARKER_SET_ID = "huskhomes-public-homes";
|
||||||
protected static final String WARPS_MARKER_SET_ID = "huskhomes-warps";
|
protected static final String WARPS_MARKER_SET_ID = "huskhomes-warps";
|
||||||
|
protected static final String WARP_MARKER_IMAGE_NAME = "warp";
|
||||||
|
protected static final String PUBLIC_HOME_MARKER_IMAGE_NAME = "public-home";
|
||||||
|
|
||||||
protected MapHook(@NotNull HuskHomes implementor, @NotNull String hookName) {
|
protected MapHook(@NotNull HuskHomes implementor, @NotNull String hookName) {
|
||||||
super(implementor, hookName);
|
super(implementor, hookName);
|
||||||
|
|||||||
File renamed without changes.
|
Before Width: | Height: | Size: 856 B After Width: | Height: | Size: 856 B |
File renamed without changes.
|
Before Width: | Height: | Size: 785 B After Width: | Height: | Size: 785 B |
Binary file not shown.
|
After Width: | Height: | Size: 2.3 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
Reference in new issue
Block a user