diff --git a/pom.xml b/pom.xml index d3d0e9f..98fe73b 100644 --- a/pom.xml +++ b/pom.xml @@ -11,12 +11,6 @@ UTF-8 - - net.pl3x.map - pl3xmap-api - 1.0.0-SNAPSHOT - provided - org.bstats bstats-bukkit diff --git a/src/main/java/us/camin/regions/Pl3xMapRelay.java b/src/main/java/us/camin/regions/Pl3xMapRelay.java deleted file mode 100644 index 02b67e9..0000000 --- a/src/main/java/us/camin/regions/Pl3xMapRelay.java +++ /dev/null @@ -1,141 +0,0 @@ -package us.camin.regions; - -/** - * This file is part of Regions - * - * Regions is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * Regions is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with Regions. If not, see . - * - */ - -import org.bukkit.event.Listener; -import net.pl3x.map.api.Pl3xMap; -import net.pl3x.map.api.Pl3xMapProvider; -import net.pl3x.map.api.LayerProvider; -import net.pl3x.map.api.MapWorld; -import net.pl3x.map.api.Registry; -import net.pl3x.map.api.Key; -import net.pl3x.map.api.Point; -import net.pl3x.map.api.marker.Marker; -import net.pl3x.map.api.marker.MarkerOptions; -import net.pl3x.map.api.marker.Icon; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Optional; -import java.io.File; -import java.awt.image.BufferedImage; -import javax.imageio.ImageIO; -import java.io.IOException; - -import org.bukkit.World; -import org.bukkit.Color; - -import us.camin.regions.geometry.RegionSet; -import us.camin.regions.geometry.BorderMesh; - -public class Pl3xMapRelay implements Listener { - private Plugin m_plugin; - private Pl3xMap m_map; - - public Pl3xMapRelay(Plugin p) { - m_plugin = p; - m_map = null; - try { - m_map = Pl3xMapProvider.get(); - } catch (Exception e) { - } - - if (isEnabled()) { - - File file = new File(m_plugin.getDataFolder(), "lantern.png"); - if (!file.exists()) { - m_plugin.saveResource("lantern.png", false); - } - - Key key = Key.of("lantern"); - try { - BufferedImage image = ImageIO.read(file); - Pl3xMapProvider.get().iconRegistry().register(key, image); - } catch (IOException e) { - //Logger.log().log(Level.WARNING, "Failed to register signs icon", e); - } - - for(World world : m_plugin.getServer().getWorlds()) { - Optional opt = m_map.getWorldIfEnabled(world); - opt.ifPresent((MapWorld mapWorld) -> { - Registry layers = mapWorld.layerRegistry(); - layers.register(Key.of("regions_" + mapWorld.uuid()), new RegionMarkerProvider(this, world)); - }); - } - } - } - - public boolean isEnabled() { - return m_map != null; - } - - private class RegionMarkerProvider implements LayerProvider { - private Pl3xMapRelay m_relay; - private World m_world; - - public RegionMarkerProvider(Pl3xMapRelay relay, World world) { - m_relay = relay; - m_world = world; - } - - public String getLabel() { - return "Regions"; - } - - public int layerPriority() { - return 0; - } - - public Collection getMarkers() { - ArrayList markers = new ArrayList(); - RegionSet regions = m_relay.m_plugin.regionManager().regionsForWorld(m_world); - BorderMesh geom = regions.borders(); - for(Region region : regions) { - Color lineColor = region.color().getColor(); - java.awt.Color awtColor = new java.awt.Color(lineColor.getRed(), lineColor.getGreen(), lineColor.getBlue()); - Point point = Point.of(region.location().getX(), region.location().getZ()); - int size = 32; - String clickTooltip = "

" + region.name() + "

"; - clickTooltip += "
    "; - - for(Region neighbor : geom.neighbors(region)) { - Marker marker = Marker.polyline(Point.of(region.location().getX(), region.location().getZ()), Point.of(neighbor.location().getX(), neighbor.location().getZ())); - marker.markerOptions(MarkerOptions.builder() - .hoverTooltip(region.name() + " / " + neighbor.name()) - .strokeColor(awtColor) - .strokeOpacity(0.8)); - markers.add(marker); - clickTooltip += "
  • " + neighbor.name() + " - Cost: "; - clickTooltip += region.getTravelCost(neighbor); - clickTooltip += " levels
  • "; - } - clickTooltip += "
"; - - Key imageKey = Key.of("lantern"); - Marker marker = Marker.icon(point, imageKey, size); - marker.markerOptions(MarkerOptions.builder() - .hoverTooltip(region.name()) - .clickTooltip(clickTooltip)); - markers.add(marker); - } - - return markers; - } - } -} diff --git a/src/main/java/us/camin/regions/Plugin.java b/src/main/java/us/camin/regions/Plugin.java index 95ad99c..a47c45a 100644 --- a/src/main/java/us/camin/regions/Plugin.java +++ b/src/main/java/us/camin/regions/Plugin.java @@ -86,14 +86,6 @@ public class Plugin extends JavaPlugin { log.info("Dynmap not found. Disabling map support."); } - Pl3xMapRelay plexMapper = new Pl3xMapRelay(this); - if (plexMapper.isEnabled()) { - getServer().getPluginManager().registerEvents(plexMapper, this); - log.info("Pl3xmap support enabled."); - } else { - log.info("Pl3xmap not found. Disabling map support."); - } - // Install the event handler after things are loaded so players aren't spammed with text getServer().getPluginManager().registerEvents(m_playerWatcher, this); getServer().getPluginManager().registerEvents(new PlayerNotifier(this, m_regions), this);