rip pl3xmap

This commit is contained in:
Torrie Fischer 2022-09-18 12:31:20 +02:00
parent 61d0af1a05
commit 221539001e
3 changed files with 0 additions and 155 deletions

View File

@ -11,12 +11,6 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<dependencies>
<dependency>
<groupId>net.pl3x.map</groupId>
<artifactId>pl3xmap-api</artifactId>
<version>1.0.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.bstats</groupId>
<artifactId>bstats-bukkit</artifactId>

View File

@ -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 <http://www.gnu.org/licenses/>.
*
*/
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<MapWorld> opt = m_map.getWorldIfEnabled(world);
opt.ifPresent((MapWorld mapWorld) -> {
Registry<LayerProvider> 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<Marker> getMarkers() {
ArrayList<Marker> markers = new ArrayList<Marker>();
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 = "<h3>" + region.name() + "</h3>";
clickTooltip += "<ul>";
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 += "<li style=\"display: list-item\">" + neighbor.name() + " - Cost: ";
clickTooltip += region.getTravelCost(neighbor);
clickTooltip += " levels</li>";
}
clickTooltip += "</ul>";
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;
}
}
}

View File

@ -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);