From 48c7a3e94ec015675606b1c9092ccbbc9085d302 Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 2 Nov 2021 14:32:04 +0100 Subject: [PATCH] refactor: Use player friendly done message on restricted building (#3309) --- .../plotsquared/bukkit/listener/BlockEventListener.java | 6 ++---- .../plotsquared/bukkit/listener/PlayerEventListener.java | 9 +++------ .../com/plotsquared/bukkit/util/BukkitEntityUtil.java | 3 +-- Core/src/main/resources/lang/messages_en.json | 1 + 4 files changed, 7 insertions(+), 12 deletions(-) diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java index f3cd52005..2a87b383e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/BlockEventListener.java @@ -318,8 +318,7 @@ public class BlockEventListener implements Listener { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) + TranslatableCaption.of("done.building_restricted") ); event.setCancelled(true); return; @@ -401,8 +400,7 @@ public class BlockEventListener implements Listener { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { plotPlayer.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_DESTROY_OTHER)) + TranslatableCaption.of("done.building_restricted") ); event.setCancelled(true); return; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java index 40912ef7d..ee9a6d56d 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEventListener.java @@ -985,8 +985,7 @@ public class PlayerEventListener extends PlotListener implements Listener { if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) + TranslatableCaption.of("done.building_restricted") ); e.setCancelled(true); return; @@ -1258,8 +1257,7 @@ public class PlayerEventListener extends PlotListener implements Listener { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(pp, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { pp.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) + TranslatableCaption.of("done.building_restricted") ); event.setCancelled(true); } @@ -1332,8 +1330,7 @@ public class PlayerEventListener extends PlotListener implements Listener { } else if (Settings.Done.RESTRICT_BUILDING && DoneFlag.isDone(plot)) { if (!Permissions.hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { plotPlayer.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) + TranslatableCaption.of("done.building_restricted") ); event.setCancelled(true); } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java index baa29bc59..32efe985e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitEntityUtil.java @@ -178,8 +178,7 @@ public class BukkitEntityUtil { if (!Permissions .hasPermission(plotPlayer, Permission.PERMISSION_ADMIN_BUILD_OTHER)) { plotPlayer.sendMessage( - TranslatableCaption.of("permission.no_permission_event"), - Template.of("node", String.valueOf(Permission.PERMISSION_ADMIN_BUILD_OTHER)) + TranslatableCaption.of("done.building_restricted") ); return false; } diff --git a/Core/src/main/resources/lang/messages_en.json b/Core/src/main/resources/lang/messages_en.json index 420f1b71d..9a0726c90 100644 --- a/Core/src/main/resources/lang/messages_en.json +++ b/Core/src/main/resources/lang/messages_en.json @@ -94,6 +94,7 @@ "done.done_insufficient_complexity": "This plot is too simple. Please add more detail before using this command.", "done.done_success": "Successfully marked this plot as done.", "done.done_removed": "You may now continue building in this plot.", + "done.building_restricted": "You can't build on plots marked as done.", "ratings.ratings_purged": "Purged ratings for this plot.", "ratings.rating_not_valid": "You need to specify a number between 1 and 10.", "ratings.rating_already_exists": "You have already rated plot .",