From 6a746d57027c798833898467d03d9b2a00e1a8fd Mon Sep 17 00:00:00 2001 From: ZeroHD Date: Sun, 13 Oct 2019 02:45:53 +0200 Subject: [PATCH] Added `/marker remove` and made the icon a config option (#43) --- docs/source/commands.rst | 2 +- docs/source/misc.rst | 6 +++++- src/main/java/xyz/etztech/qol/QoL.java | 4 +++- .../etztech/qol/commands/MarkerCommand.java | 19 +++++++++++++++++-- src/main/resources/config.yml | 1 + 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/docs/source/commands.rst b/docs/source/commands.rst index a7e8c34..4ce2631 100644 --- a/docs/source/commands.rst +++ b/docs/source/commands.rst @@ -45,4 +45,4 @@ Alias ``/names`` and ``/name`` ``/dynmaplink [] []`` Get a link to Dynmap with your current location. Optionally choose the map (flat, surface, etc.) and zoom level. -``/marker`` Creates a marker on the dynmap at the players current location. +``/marker `` Creates or removes a marker on the dynmap at the players current location. diff --git a/docs/source/misc.rst b/docs/source/misc.rst index 3e84c98..a7c49d2 100644 --- a/docs/source/misc.rst +++ b/docs/source/misc.rst @@ -59,4 +59,8 @@ World View Distance Override .. note:: Paper has removed this feature in ``1.14.x`` and so it has been disabled in QoL until it is re-implemented by Paper. -Each world can have its own view distance. View distances of each world can be set in the config file. If no view distance is set, the view distance defaults to the one in server.properties. \ No newline at end of file +Each world can have its own view distance. View distances of each world can be set in the config file. If no view distance is set, the view distance defaults to the one in server.properties. + +QoL Dynmap Markers +------------------ +QoL Markers are placed on their own layer hidden by default. A player with permission can have one marker. When a player loses the `qol.marker` permission, their marker is removed. The icon of the marker can be set in the `dynmap.marker_icon` config option \ No newline at end of file diff --git a/src/main/java/xyz/etztech/qol/QoL.java b/src/main/java/xyz/etztech/qol/QoL.java index 4f6b5bc..4dfc95e 100644 --- a/src/main/java/xyz/etztech/qol/QoL.java +++ b/src/main/java/xyz/etztech/qol/QoL.java @@ -26,7 +26,7 @@ public class QoL extends JavaPlugin { static private final String qolMarkerSetName = "qolMarkerSet"; static private final String qolMarkerSetLabel = "QoL Markers"; - static private final String qolMarkerIcon = "blueflag"; + private String qolMarkerIcon = null; private static QoL instance; private IEssentials essentials = null; @@ -230,6 +230,8 @@ public class QoL extends JavaPlugin { viewDistances.put(worldName, viewDistance); } + + qolMarkerIcon = config.getString("dynmap.marker_icon", "blueflag"); } diff --git a/src/main/java/xyz/etztech/qol/commands/MarkerCommand.java b/src/main/java/xyz/etztech/qol/commands/MarkerCommand.java index 34bfd9d..42af86d 100644 --- a/src/main/java/xyz/etztech/qol/commands/MarkerCommand.java +++ b/src/main/java/xyz/etztech/qol/commands/MarkerCommand.java @@ -1,6 +1,7 @@ package xyz.etztech.qol.commands; +import org.bukkit.ChatColor; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -29,9 +30,23 @@ public class MarkerCommand implements CommandExecutor { return true; } - plugin.createMarkerAtPlayer((Player) commandSender); + if (args.length < 1) { + EtzTechUtil.sms(commandSender, ChatColor.RED + "/marker set"); + EtzTechUtil.sms(commandSender, ChatColor.RED + "/marker remove"); + return true; + } + else { + String action = args[0].toLowerCase(); + if (action.equals("set")) { + plugin.createMarkerAtPlayer((Player) commandSender); + EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Location Marker Created!"); + } + else if (action.equals("remove")) { + plugin.getPlayerMarker((Player)commandSender).deleteMarker(); + EtzTechUtil.sms(commandSender, ChatColor.GREEN + "Location Marker Removed!"); + } + } - EtzTechUtil.sms(commandSender, "Location Marker Created!"); return true; } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 16d55d5..cf2229b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -103,6 +103,7 @@ spec-confirm: # Dynmap link # Leave url blank to disable dynmap: + marker_icon: "blueflag" url: "" defaults: map: "surface"