From a2df590fae2dc753bc52012f5bc7d8bd80199948 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Desjardins=20J=C3=A9r=C3=B4me?= <jewome62@gmail.com>
Date: Fri, 12 Nov 2021 15:21:06 +0100
Subject: [PATCH] feat: Add worldedit.schematic.save.global permission (#1406)

---
 .../com/sk89q/worldedit/command/SchematicCommands.java    | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
index 188610af3..6e7f5f4fd 100644
--- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
+++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/SchematicCommands.java
@@ -416,7 +416,7 @@ public class SchematicCommands {
             name = "save",
             desc = "Save your clipboard into a schematic file"
     )
-    @CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other"})
+    @CommandPermissions({"worldedit.clipboard.save", "worldedit.schematic.save", "worldedit.schematic.save.other", "worldedit.schematic.save.global"})
     public void save(
             Actor actor, LocalSession session,
             @Arg(desc = "File name.")
@@ -429,6 +429,12 @@ public class SchematicCommands {
             @Switch(name = 'g', desc = "Bypasses per-player-schematic folders")
                     boolean global
     ) throws WorldEditException {
+
+         if (global && !actor.hasPermission("worldedit.schematic.save.global")) {
+             actor.print(Caption.of("fawe.error.no-perm", "worldedit.schematic.save.global"));
+             return;
+        }
+
         //FAWE end
         if (worldEdit.getPlatformManager().queryCapability(Capability.GAME_HOOKS).getDataVersion() == -1) {
             actor.print(TranslatableComponent.of("worldedit.schematic.unsupported-minecraft-version"));