pl3xmap: use lantern icons for region posts
This commit is contained in:
parent
ff70dd255b
commit
51fdc80542
@ -33,6 +33,10 @@ 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;
|
||||
@ -53,6 +57,20 @@ public class Pl3xMapRelay implements Listener {
|
||||
}
|
||||
|
||||
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) -> {
|
||||
@ -95,28 +113,25 @@ public class Pl3xMapRelay implements Listener {
|
||||
int size = 32;
|
||||
String clickTooltip = "<h3>" + region.name() + "</h3>";
|
||||
clickTooltip += "<ul>";
|
||||
Key imageKey = Key.of("sign_oak");
|
||||
Marker marker = Marker.icon(point, imageKey, size);
|
||||
|
||||
for(Region neighbor : geom.neighbors(region)) {
|
||||
marker = Marker.polyline(Point.of(region.location().getX(), region.location().getZ()), Point.of(neighbor.location().getX(), neighbor.location().getZ()));
|
||||
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>" + neighbor.name() + " - Cost: ";
|
||||
clickTooltip += "<li style=\"display: list-item\">" + neighbor.name() + " - Cost: ";
|
||||
clickTooltip += region.getTravelCost(neighbor);
|
||||
clickTooltip += " levels</li>";
|
||||
}
|
||||
clickTooltip += "</ul>";
|
||||
|
||||
marker = Marker.circle(point, size);
|
||||
Key imageKey = Key.of("lantern");
|
||||
Marker marker = Marker.icon(point, imageKey, size);
|
||||
marker.markerOptions(MarkerOptions.builder()
|
||||
.hoverTooltip(region.name())
|
||||
.clickTooltip(clickTooltip)
|
||||
.strokeColor(awtColor)
|
||||
.strokeOpacity(0.8));
|
||||
.clickTooltip(clickTooltip));
|
||||
markers.add(marker);
|
||||
}
|
||||
|
||||
|
BIN
src/main/resources/lantern.png
Normal file
BIN
src/main/resources/lantern.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in New Issue
Block a user