-
-
Save silverwolfg11/f16efd2d36f1bebb482e81c6cb06804e to your computer and use it in GitHub Desktop.
MapTowny Layer Priority Test Plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.silverwolfg11.maptownytestplugin; | |
import me.silverwolfg11.cmdprocessor.annotations.CommandClass; | |
import me.silverwolfg11.cmdprocessor.annotations.DepInject; | |
import me.silverwolfg11.cmdprocessor.annotations.Name; | |
import me.silverwolfg11.cmdprocessor.annotations.NoArgs; | |
import me.silverwolfg11.cmdprocessor.annotations.SubCommand; | |
import org.bukkit.ChatColor; | |
import org.bukkit.command.CommandSender; | |
@CommandClass("maptownytest") | |
public class MapTownyTestCmd { | |
@DepInject | |
private MapTownyTestPlugin plugin; | |
@NoArgs | |
public void help(CommandSender sender) { | |
sender.sendMessage(ChatColor.GOLD + "=== MapTownyTestPlugin Help ==="); | |
sender.sendMessage(ChatColor.AQUA + "/maptownytest draw " + ChatColor.WHITE + " : Draw marker!"); | |
sender.sendMessage(ChatColor.AQUA + "/maptownytest removelayer " + ChatColor.WHITE + " : Remove marker layer!"); | |
} | |
@SubCommand("draw") | |
public void drawMarker(CommandSender sender, int layerPriority, int zIndex) { | |
plugin.drawMarker(layerPriority, zIndex); | |
sender.sendMessage(ChatColor.GREEN + String.format( | |
"Drew marker square at around x: -623 with layer priority '%d' and z-index '%d'", | |
layerPriority, zIndex | |
)); | |
} | |
@SubCommand("removelayer") | |
public void removeLayer(CommandSender sender) { | |
plugin.removeLayer(); | |
sender.sendMessage(ChatColor.GREEN + "Removed marker and marker layer!"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.silverwolfg11.maptownytestplugin; | |
import me.silverwolfg11.maptowny.MapTownyPlugin; | |
import me.silverwolfg11.maptowny.objects.LayerOptions; | |
import me.silverwolfg11.maptowny.objects.MarkerOptions; | |
import me.silverwolfg11.maptowny.objects.Point2D; | |
import me.silverwolfg11.maptowny.objects.Polygon; | |
import me.silverwolfg11.maptowny.platform.MapWorld; | |
import org.bukkit.Bukkit; | |
import org.bukkit.plugin.java.JavaPlugin; | |
import java.awt.Color; | |
import java.util.Arrays; | |
import java.util.Collections; | |
public final class MapTownyTestPlugin extends JavaPlugin { | |
private MapTownyPlugin mapTowny; | |
@Override | |
public void onEnable() { | |
// Plugin startup logic | |
if (Bukkit.getPluginManager().isPluginEnabled("MapTowny")) { | |
mapTowny = (MapTownyPlugin) Bukkit.getPluginManager().getPlugin("MapTowny"); | |
mapTowny.getPlatform().onFirstInitialize(() -> this.drawMarker(6, 4)); | |
} | |
} | |
private static String LAYER_NAME = "MapTownyTest"; | |
private static String MARKER_KEY = "TestMarker"; | |
public void drawMarker(int layerPriority, int zIndex) { | |
var platform = mapTowny.getPlatform(); | |
MapWorld world = platform.getWorld(Bukkit.getWorld("world")); | |
world.unregisterLayer(LAYER_NAME); | |
var testLayer = world.registerLayer(LAYER_NAME, | |
new LayerOptions(LAYER_NAME, true, false, layerPriority, zIndex) | |
); | |
Polygon polygon = new Polygon(Arrays.asList( | |
Point2D.of(-623, -250), | |
Point2D.of(-571, -250), | |
Point2D.of(-571, -205), | |
Point2D.of(-623, -205) | |
), Collections.emptyList()); | |
testLayer.addMultiPolyMarker(MARKER_KEY, Collections.singletonList(polygon), | |
MarkerOptions.builder() | |
.name(MARKER_KEY) | |
.fillColor(Color.MAGENTA) | |
.clickTooltip("This is a test marker!") | |
.build()); | |
} | |
public void removeLayer() { | |
var platform = mapTowny.getPlatform(); | |
MapWorld world = platform.getWorld(Bukkit.getWorld("world")); | |
world.unregisterLayer(LAYER_NAME); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment