Close #121 - Migrate to SquareMap

This commit is contained in:
William committed 2021-12-30 23:55:44 +00:00
1 parent 0560bface4
commit 3081a6f91a
5 files changed
+32 -31

No files matched your search

+5 -5
View File
@@ -129,8 +129,8 @@
<url>https://repo.minebench.de/</url> <url>https://repo.minebench.de/</url>
</repository> </repository>
<repository> <repository>
<id>pl3x-repo</id> <id>squaremap-snapshots</id>
<url>https://repo.pl3x.net/</url> <url>https://repo.jpenilla.xyz/snapshots/</url>
</repository> </repository>
</repositories> </repositories>
@@ -154,9 +154,9 @@
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>net.pl3x.map</groupId> <groupId>xyz.jpenilla</groupId>
<artifactId>pl3xmap-api</artifactId> <artifactId>squaremap-api</artifactId>
<version>1.0.0-SNAPSHOT</version> <version>1.1.0-SNAPSHOT</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
@@ -11,7 +11,7 @@ import me.william278.huskhomes2.integrations.map.BlueMap;
import me.william278.huskhomes2.integrations.map.DynMap; import me.william278.huskhomes2.integrations.map.DynMap;
import me.william278.huskhomes2.integrations.map.Map; import me.william278.huskhomes2.integrations.map.Map;
import me.william278.huskhomes2.integrations.VaultIntegration; import me.william278.huskhomes2.integrations.VaultIntegration;
import me.william278.huskhomes2.integrations.map.Pl3xMap; import me.william278.huskhomes2.integrations.map.SquareMap;
import me.william278.huskhomes2.listeners.PlayerListener; import me.william278.huskhomes2.listeners.PlayerListener;
import me.william278.huskhomes2.data.message.pluginmessage.PluginMessageReceiver; import me.william278.huskhomes2.data.message.pluginmessage.PluginMessageReceiver;
import me.william278.huskhomes2.migrators.UpgradeDatabase; import me.william278.huskhomes2.migrators.UpgradeDatabase;
@@ -214,7 +214,7 @@ public final class HuskHomes extends JavaPlugin {
switch (mapPlugin) { switch (mapPlugin) {
case "dynmap" -> map = new DynMap(); case "dynmap" -> map = new DynMap();
case "bluemap" -> map = new BlueMap(); case "bluemap" -> map = new BlueMap();
case "pl3xmap" -> map = new Pl3xMap(); case "pl3xmap" -> map = new SquareMap();
} }
map.initialize(); map.initialize();
} }
@@ -177,7 +177,7 @@ public class Settings {
if (this.doMapIntegration) { if (this.doMapIntegration) {
PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager(); PluginManager pluginManager = HuskHomes.getInstance().getServer().getPluginManager();
switch (mapPlugin.toLowerCase()) { switch (mapPlugin.toLowerCase()) {
case "dynmap", "bluemap", "pl3xmap" -> { case "dynmap", "bluemap", "squaremap" -> {
Plugin mapSpigotPlugin = pluginManager.getPlugin(mapPlugin.toLowerCase()); Plugin mapSpigotPlugin = pluginManager.getPlugin(mapPlugin.toLowerCase());
if (mapSpigotPlugin == null) { if (mapSpigotPlugin == null) {
Bukkit.getLogger().warning(mapPlugin + " integration was enabled in config, but the " + mapPlugin + " plugin could not be found!"); Bukkit.getLogger().warning(mapPlugin + " integration was enabled in config, but the " + mapPlugin + " plugin could not be found!");
@@ -4,24 +4,24 @@ import me.william278.huskhomes2.HuskHomes;
import me.william278.huskhomes2.data.DataManager; import me.william278.huskhomes2.data.DataManager;
import me.william278.huskhomes2.teleport.points.Home; import me.william278.huskhomes2.teleport.points.Home;
import me.william278.huskhomes2.teleport.points.Warp; import me.william278.huskhomes2.teleport.points.Warp;
import net.pl3x.map.api.*;
import net.pl3x.map.api.marker.Icon;
import net.pl3x.map.api.marker.Marker;
import net.pl3x.map.api.marker.MarkerOptions;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.world.WorldLoadEvent; import org.bukkit.event.world.WorldLoadEvent;
import xyz.jpenilla.squaremap.api.*;
import xyz.jpenilla.squaremap.api.marker.Icon;
import xyz.jpenilla.squaremap.api.marker.Marker;
import xyz.jpenilla.squaremap.api.marker.MarkerOptions;
import java.sql.Connection; import java.sql.Connection;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.HashMap; import java.util.HashMap;
import java.util.logging.Level; import java.util.logging.Level;
public class Pl3xMap extends Map { public class SquareMap extends Map {
private final HashMap<String,SimpleLayerProvider> publicHomeProviders = new HashMap<>(); private final HashMap<String, SimpleLayerProvider> publicHomeProviders = new HashMap<>();
private final HashMap<String,SimpleLayerProvider> warpProviders = new HashMap<>(); private final HashMap<String,SimpleLayerProvider> warpProviders = new HashMap<>();
private final static int MARKER_SIZE = 20; private final static int MARKER_SIZE = 20;
private final static HuskHomes plugin = HuskHomes.getInstance(); private final static HuskHomes plugin = HuskHomes.getInstance();
@@ -77,24 +77,24 @@ public class Pl3xMap extends Map {
@Override @Override
public void initialize() { public void initialize() {
net.pl3x.map.api.Pl3xMap mapAPI = Pl3xMapProvider.get(); Squaremap mapAPI = SquaremapProvider.get();
plugin.getServer().getPluginManager().registerEvents(new Pl3xMapWorldLoadListener(), plugin); plugin.getServer().getPluginManager().registerEvents(new SquareMapWorldLoadListener(), plugin);
plugin.getLogger().info("Initializing Pl3xMap integration"); plugin.getLogger().info("Initializing Squaremap integration");
final Key publicHomeMarkerIconKey = Key.of(PUBLIC_HOME_MARKER_IMAGE_NAME); final Key publicHomeMarkerIconKey = Key.of(PUBLIC_HOME_MARKER_IMAGE_NAME);
final Key warpMarkerIconKey = Key.of(WARP_MARKER_IMAGE_NAME); final Key warpMarkerIconKey = Key.of(WARP_MARKER_IMAGE_NAME);
// Make sure markers are unregistered, then register marker icon keys // Make sure markers are unregistered, then register marker icon keys
if (Pl3xMapProvider.get().iconRegistry().hasEntry(publicHomeMarkerIconKey)) { if (SquaremapProvider.get().iconRegistry().hasEntry(publicHomeMarkerIconKey)) {
Pl3xMapProvider.get().iconRegistry().unregister(publicHomeMarkerIconKey); SquaremapProvider.get().iconRegistry().unregister(publicHomeMarkerIconKey);
} }
Pl3xMapProvider.get().iconRegistry().register(publicHomeMarkerIconKey, getPublicHomeIcon()); SquaremapProvider.get().iconRegistry().register(publicHomeMarkerIconKey, getPublicHomeIcon());
if (Pl3xMapProvider.get().iconRegistry().hasEntry(warpMarkerIconKey)) { if (SquaremapProvider.get().iconRegistry().hasEntry(warpMarkerIconKey)) {
Pl3xMapProvider.get().iconRegistry().unregister(warpMarkerIconKey); SquaremapProvider.get().iconRegistry().unregister(warpMarkerIconKey);
} }
Pl3xMapProvider.get().iconRegistry().register(warpMarkerIconKey, getWarpIcon()); SquaremapProvider.get().iconRegistry().register(warpMarkerIconKey, getWarpIcon());
for (net.pl3x.map.api.MapWorld world : mapAPI.mapWorlds()) { for (MapWorld world : mapAPI.mapWorlds()) {
loadWorld(world); loadWorld(world);
} }
@@ -116,12 +116,12 @@ public class Pl3xMap extends Map {
} }
} }
} catch (SQLException e) { } catch (SQLException e) {
plugin.getLogger().log(Level.WARNING, "An SQL exception occurred adding homes and warps to the Pl3xMap"); plugin.getLogger().log(Level.WARNING, "An SQL exception occurred adding homes and warps to the Squaremap");
} }
}); });
} }
// Removes a marker from the Pl3xMap Marker API // Removes a marker from the Squaremap Marker API
private void removeMarker(Key markerKey, HashMap<String, SimpleLayerProvider> layerProviders) { private void removeMarker(Key markerKey, HashMap<String, SimpleLayerProvider> layerProviders) {
String markerWorld = null; String markerWorld = null;
for (String worldName : layerProviders.keySet()) { for (String worldName : layerProviders.keySet()) {
@@ -162,12 +162,13 @@ public class Pl3xMap extends Map {
} }
public class Pl3xMapWorldLoadListener implements Listener { public class SquareMapWorldLoadListener implements Listener {
@EventHandler @EventHandler
public void onWorldLoad(WorldLoadEvent e) { public void onWorldLoad(WorldLoadEvent e) {
net.pl3x.map.api.Pl3xMap mapAPI = Pl3xMapProvider.get(); Squaremap mapAPI = SquaremapProvider.get();
mapAPI.getWorldIfEnabled(e.getWorld()).ifPresent(Pl3xMap.this::loadWorld); mapAPI.getWorldIfEnabled(BukkitAdapter.worldIdentifier(e.getWorld())).ifPresent(SquareMap.this::loadWorld);
// Populate map with markers // Populate map with markers
Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> { Bukkit.getScheduler().runTaskAsynchronously(plugin, () -> {
try (Connection connection = HuskHomes.getConnection()) { try (Connection connection = HuskHomes.getConnection()) {
@@ -190,7 +191,7 @@ public class Pl3xMap extends Map {
} }
} }
} catch (SQLException exception) { } catch (SQLException exception) {
plugin.getLogger().log(Level.WARNING, "An SQL exception occurred adding homes and warps to the Pl3xMap"); plugin.getLogger().log(Level.WARNING, "An SQL exception occurred adding homes and warps to the Squaremap");
} }
}); });
} }
+1 -1
View File
@@ -3,7 +3,7 @@ version: '${project.version}'
main: me.william278.huskhomes2.HuskHomes main: me.william278.huskhomes2.HuskHomes
api-version: 1.16 api-version: 1.16
authors: [William278] authors: [William278]
softdepend: [dynmap, Vault, BlueMap, Pl3xMap] softdepend: [dynmap, Vault, BlueMap, Squaremap]
description: A powerful, intuitive and flexible teleportation suite description: A powerful, intuitive and flexible teleportation suite
libraries: libraries:
- redis.clients:jedis:2.7.2 - redis.clients:jedis:2.7.2