From 09db088a1be4cc05d932022d49a6f307ac3dc9e5 Mon Sep 17 00:00:00 2001 From: Lukas Planz Date: Sun, 12 Dec 2021 00:17:38 +0100 Subject: [PATCH] Allow changing the permission of an existing permission waypoint --- .../waypoints/gui/pages/WaypointPage.kt | 18 +++++++++++++++++- .../de/md5lukas/waypoints/lang/Translations.kt | 1 + waypoints/src/main/resources/config.yml | 1 + waypoints/src/main/resources/lang/de.yml | 3 +++ waypoints/src/main/resources/lang/en.yml | 3 +++ 5 files changed, 25 insertions(+), 1 deletion(-) diff --git a/waypoints/src/main/kotlin/de/md5lukas/waypoints/gui/pages/WaypointPage.kt b/waypoints/src/main/kotlin/de/md5lukas/waypoints/gui/pages/WaypointPage.kt index 359a5617..3e8ea2c7 100644 --- a/waypoints/src/main/kotlin/de/md5lukas/waypoints/gui/pages/WaypointPage.kt +++ b/waypoints/src/main/kotlin/de/md5lukas/waypoints/gui/pages/WaypointPage.kt @@ -20,6 +20,7 @@ class WaypointPage(wpGUI: WaypointsGUI, private val waypoint: Waypoint) : BasePa * i = Get UUID (Global waypoints only) * u = Move to public folder * e = Move to permission folder + * p = Change permission * s = Select * c = Select beacon color * f = Move to folder @@ -32,7 +33,7 @@ class WaypointPage(wpGUI: WaypointsGUI, private val waypoint: Waypoint) : BasePa "____w____", "_________", "i_u_s___c", - "_f_e___r_", + "_f_e_p_r_", "d___t___b", ) } @@ -161,6 +162,21 @@ class WaypointPage(wpGUI: WaypointsGUI, private val waypoint: Waypoint) : BasePa } else { background }, + 'p' to if (waypoint.type === Type.PERMISSION && canModifyWaypoint) { + GUIItem(wpGUI.translations.WAYPOINT_EDIT_PERMISSION.getItem(Collections.singletonMap("permission", waypoint.permission ?: ""))) { + AnvilGUI.Builder().plugin(wpGUI.plugin).text(waypoint.permission).onComplete { _, permission -> + waypoint.permission = permission + return@onComplete AnvilGUI.Response.close() + }.onClose { + updatePage() + wpGUI.plugin.runTask { + wpGUI.gui.open() + } + }.open(wpGUI.viewer) + } + } else { + background + }, 's' to GUIItem(wpGUI.translations.WAYPOINT_SELECT.item) { wpGUI.viewer.closeInventory() wpGUI.plugin.pointerManager.enable(wpGUI.viewer, waypoint) diff --git a/waypoints/src/main/kotlin/de/md5lukas/waypoints/lang/Translations.kt b/waypoints/src/main/kotlin/de/md5lukas/waypoints/lang/Translations.kt index 3e0067c1..ffb4c9d0 100644 --- a/waypoints/src/main/kotlin/de/md5lukas/waypoints/lang/Translations.kt +++ b/waypoints/src/main/kotlin/de/md5lukas/waypoints/lang/Translations.kt @@ -151,6 +151,7 @@ class Translations( val WAYPOINT_TELEPORT_BALANCE = Translation(tl, "inventory.waypoint.teleport.balance") val WAYPOINT_SELECT_BEACON_COLOR = ItemTranslation(tl, "inventory.waypoint.selectBeaconColor") val WAYPOINT_GET_UUID = ItemTranslation(tl, "inventory.waypoint.getUuid") + val WAYPOINT_EDIT_PERMISSION = ItemTranslation(tl, "inventory.waypoint.editPermission") val WAYPOINT_MAKE_PUBLIC = ItemTranslation(tl, "inventory.waypoint.make.public", true) val WAYPOINT_MAKE_PUBLIC_CONFIRM_QUESTION = ItemTranslation(tl, "inventory.waypoint.make.public.question") val WAYPOINT_MAKE_PUBLIC_CONFIRM_TRUE = ItemTranslation(tl, "inventory.waypoint.make.public.confirm") diff --git a/waypoints/src/main/resources/config.yml b/waypoints/src/main/resources/config.yml index 703d4110..70b1ddfe 100644 --- a/waypoints/src/main/resources/config.yml +++ b/waypoints/src/main/resources/config.yml @@ -210,6 +210,7 @@ inventory: teleport: ENDER_PEARL selectBeaconColor: LIME_STAINED_GLASS getUuid: PAPER + editPermission: IRON_BARS make: public: item: ENCHANTED_BOOK diff --git a/waypoints/src/main/resources/lang/de.yml b/waypoints/src/main/resources/lang/de.yml index ab51aa65..d9dd6aad 100644 --- a/waypoints/src/main/resources/lang/de.yml +++ b/waypoints/src/main/resources/lang/de.yml @@ -359,6 +359,9 @@ inventory: getUuid: displayName: "&eUUID vom Wegpunkt erhalten" description: "&7Schickt eine klickbare Nachricht die die UUID in das Textfeld kopiert" + editPermission: + displayName: "&eBenötigte Berechtigung ändern" + description: "&7Aktuell benötigte Berechtigung ist &e${permission}" make: public: displayName: "&4Wegpunkt öffentlich machen" diff --git a/waypoints/src/main/resources/lang/en.yml b/waypoints/src/main/resources/lang/en.yml index 25153ef7..49415494 100644 --- a/waypoints/src/main/resources/lang/en.yml +++ b/waypoints/src/main/resources/lang/en.yml @@ -359,6 +359,9 @@ inventory: getUuid: displayName: "&eGet the UUID of the waypoint" description: "&7Sends a clickable message that enters the UUID into the chat" + editPermission: + displayName: "&eChange required permission" + description: "&7Current permission is &e${permission}" make: public: displayName: "&eMake waypoint public"