Bump Pl3xMap, register layers/icons on map load, Close #409

This commit is contained in:
William278 committed 2023-05-22 12:23:18 +01:00
1 parent f05896c8bb
commit e0961711e7
2 files changed
+18 -18

No files matched your search

+1 -1
View File
@@ -29,7 +29,7 @@ dependencies {
compileOnly 'com.github.plan-player-analytics:Plan:5.5.1923'
compileOnly 'com.github.BlueMap-Minecraft:BlueMapAPI:2.5.0'
compileOnly 'us.dynmap:DynmapCoreAPI:3.4'
compileOnly 'maven.modrinth:pl3xmap:1.19.4-382'
compileOnly 'maven.modrinth:pl3xmap:1.19.4-433'
testImplementation 'com.github.plan-player-analytics:Plan:5.5.1923'
testImplementation 'com.github.yuriy-g:simple-java-plot:5c502c2e98'
@@ -22,7 +22,7 @@ package net.william278.huskhomes.hook;
import net.pl3x.map.core.Pl3xMap;
import net.pl3x.map.core.event.EventHandler;
import net.pl3x.map.core.event.EventListener;
import net.pl3x.map.core.event.server.ServerLoadedEvent;
import net.pl3x.map.core.event.server.Pl3xMapEnabledEvent;
import net.pl3x.map.core.event.world.WorldLoadedEvent;
import net.pl3x.map.core.event.world.WorldUnloadedEvent;
import net.pl3x.map.core.image.IconImage;
@@ -65,18 +65,6 @@ public class Pl3xMapHook extends MapHook implements EventListener {
@Override
public void initialize() {
Pl3xMap.api().getEventRegistry().register(this);
if (plugin.getSettings().doWarpsOnMap()) {
this.registerIcon(WARPS_LAYER, "markers/16x/warp.png");
}
if (plugin.getSettings().doPublicHomesOnMap()) {
this.registerIcon(PUBLIC_HOMES_LAYER, "markers/16x/public-home.png");
}
plugin.runAsync(() -> {
plugin.getDatabase().getLocalPublicHomes(plugin).forEach(this::updateHome);
plugin.getDatabase().getLocalWarps(plugin).forEach(this::updateWarp);
});
}
@Override
@@ -138,19 +126,31 @@ public class Pl3xMapHook extends MapHook implements EventListener {
}
}
@SuppressWarnings("unused")
@EventHandler
public void onServerLoaded(@NotNull ServerLoadedEvent event) {
public void onPl3xMapEnabled(@NotNull Pl3xMapEnabledEvent event) {
// Register icons
if (plugin.getSettings().doWarpsOnMap()) {
this.registerIcon(WARPS_LAYER, "markers/16x/warp.png");
}
if (plugin.getSettings().doPublicHomesOnMap()) {
this.registerIcon(PUBLIC_HOMES_LAYER, "markers/16x/public-home.png");
}
// Register layers for each world
Pl3xMap.api().getWorldRegistry().forEach(this::registerLayers);
// Update home positions
plugin.runAsync(() -> {
plugin.getDatabase().getLocalPublicHomes(plugin).forEach(this::updateHome);
plugin.getDatabase().getLocalWarps(plugin).forEach(this::updateWarp);
});
}
@SuppressWarnings("unused")
@EventHandler
public void onWorldLoaded(@NotNull WorldLoadedEvent event) {
registerLayers(event.getWorld());
}
@SuppressWarnings("unused")
@EventHandler
public void onWorldUnloaded(@NotNull WorldUnloadedEvent event) {
event.getWorld().getLayerRegistry().unregister(WARPS_LAYER);