Skip to content

Commit

Permalink
fix: inconsistencies with Pl3xMap loading, close #570
Browse files Browse the repository at this point in the history
  • Loading branch information
WiIIiam278 committed Mar 31, 2024
1 parent e2a7fec commit 9d2a73f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 10 deletions.
2 changes: 1 addition & 1 deletion common/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ dependencies {
compileOnly 'com.github.plan-player-analytics:Plan:5.5.2391'
compileOnly 'com.github.BlueMap-Minecraft:BlueMapAPI:2.6.0'
compileOnly 'us.dynmap:DynmapCoreAPI:3.4'
compileOnly 'maven.modrinth:pl3xmap:1.20.2-475'
compileOnly 'maven.modrinth:pl3xmap:1.20.4-489'
compileOnly 'org.projectlombok:lombok:1.18.32'

testImplementation 'com.github.plan-player-analytics:Plan:5.5.2391'
Expand Down
24 changes: 15 additions & 9 deletions common/src/main/java/net/william278/huskhomes/hook/MapHook.java
Original file line number Diff line number Diff line change
Expand Up @@ -176,37 +176,43 @@ private MarkerInformationPopup(@NotNull String title) {
}

@NotNull
protected static DynmapHook.MarkerInformationPopup warp(@NotNull Warp warp, @NotNull String thumbnail) {
return MarkerInformationPopup.create(warp.getName())
protected static MarkerInformationPopup warp(@NotNull Warp warp, @NotNull String thumbnail) {
final MarkerInformationPopup popup = MarkerInformationPopup.create(warp.getName())
.thumbnail(thumbnail)
.field("Description", warp.getMeta().getDescription())
.field("Location", warp.toString())
.field("Command", "/warp " + warp.getSafeIdentifier());
if (!warp.getMeta().getDescription().isBlank()) {
popup.field("Description", warp.getMeta().getDescription());
}
return popup;
}

@NotNull
protected static DynmapHook.MarkerInformationPopup publicHome(@NotNull Home home, @NotNull String thumbnail) {
return MarkerInformationPopup.create(home.getName())
protected static MarkerInformationPopup publicHome(@NotNull Home home, @NotNull String thumbnail) {
final MarkerInformationPopup popup = MarkerInformationPopup.create(home.getName())
.thumbnail(thumbnail)
.field("Owner", home.getOwner().getUsername())
.field("Description", home.getMeta().getDescription())
.field("Location", home.toString())
.field("Command", "/phome " + home.getSafeIdentifier());
if (!home.getMeta().getDescription().isBlank()) {
popup.field("Description", home.getMeta().getDescription());
}
return popup;
}

@NotNull
protected static DynmapHook.MarkerInformationPopup create(@NotNull String title) {
protected static MarkerInformationPopup create(@NotNull String title) {
return new MarkerInformationPopup(title);
}

@NotNull
protected DynmapHook.MarkerInformationPopup thumbnail(@NotNull String thumbnail) {
protected MarkerInformationPopup thumbnail(@NotNull String thumbnail) {
this.thumbnail = thumbnail;
return this;
}

@NotNull
protected DynmapHook.MarkerInformationPopup field(@NotNull String key, @NotNull String value) {
protected MarkerInformationPopup field(@NotNull String key, @NotNull String value) {
fields.put(key, value);
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
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.Pl3xMapDisabledEvent;
import net.pl3x.map.core.event.server.Pl3xMapEnabledEvent;
import net.pl3x.map.core.event.world.WorldLoadedEvent;
import net.pl3x.map.core.event.world.WorldUnloadedEvent;
Expand Down Expand Up @@ -51,6 +52,7 @@
import java.util.logging.Level;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
public class Pl3xMapHook extends MapHook implements EventListener {

private static final String ICON_PATH = "/images/icon/registered/";
Expand All @@ -66,6 +68,9 @@ public Pl3xMapHook(@NotNull HuskHomes plugin) {
@Override
public void initialize() {
Pl3xMap.api().getEventRegistry().register(this);
if (Pl3xMap.api().isEnabled()) {
onPl3xMapEnabled(new Pl3xMapEnabledEvent());
}
}

@Override
Expand Down Expand Up @@ -159,6 +164,14 @@ public void onPl3xMapEnabled(@NotNull Pl3xMapEnabledEvent event) {
});
}

@EventHandler
public void onPl3xMapDisabled(@NotNull Pl3xMapDisabledEvent event) {
Pl3xMap.api().getWorldRegistry().forEach(world -> {
world.getLayerRegistry().unregister(WARPS_LAYER);
world.getLayerRegistry().unregister(PUBLIC_HOMES_LAYER);
});
}

@EventHandler
public void onWorldLoaded(@NotNull WorldLoadedEvent event) {
registerLayers(event.getWorld());
Expand Down
10 changes: 10 additions & 0 deletions paper/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,15 @@ shadowJar {
tasks {
runServer {
minecraftVersion('1.20.4')

downloadPlugins {
url("https://download.luckperms.net/1526/bukkit/loader/LuckPerms-Bukkit-5.4.113.jar")
url("https://ci.lucko.me/job/spark/399/artifact/spark-bukkit/build/libs/spark-1.10.58-bukkit.jar")
hangar("Plan-Player-Analytics", "5.6+build.2614")

// modrinth("dynmap", "5F9fwzR1")
modrinth("pl3xmap", "1.20.4-489")
// modrinth("bluemap", "3.20-paper")
}
}
}

0 comments on commit 9d2a73f

Please sign in to comment.