From 85382ad109fdf3e1932ca363d9dd8d7671a74145 Mon Sep 17 00:00:00 2001 From: Jesse Boyd Date: Fri, 22 Nov 2019 15:30:45 +0000 Subject: [PATCH] Fix permissions --- .../com/sk89q/worldedit/bukkit/BukkitPlayer.java | 4 +++- .../sk89q/worldedit/command/RegionCommands.java | 10 ++++------ .../platform/PlatformCommandManager.java | 15 +++++---------- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java index 10236f5f6..751d915c5 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitPlayer.java @@ -210,7 +210,9 @@ public class BukkitPlayer extends AbstractPlayerActor { @Override public boolean hasPermission(String perm) { - return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp()); + return (!plugin.getLocalConfiguration().noOpPermissions && player.isOp()) + || plugin.getPermissionsResolver().hasPermission( + player.getWorld().getName(), player, perm); } @Override diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java index 036ddb454..cc773f9bb 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/RegionCommands.java @@ -74,6 +74,7 @@ import org.enginehub.piston.annotation.param.ArgFlag; import org.enginehub.piston.annotation.param.Switch; import org.jetbrains.annotations.Range; +import java.io.File; import java.util.ArrayList; import java.util.Iterator; import java.util.List; @@ -137,12 +138,9 @@ public class RegionCommands { ) @CommandPermissions("worldedit.region.test") @Logging(REGION) - public void test(Player player, EditSession editSession, @Arg(desc = "test") @Confirm(RADIUS) BlockVector3 radius) throws WorldEditException { -// editSession.addProcessor(new ChunkSendProcessor(editSession.getWorld(), () -> Collections.singleton(player))); -// editSession.addProcessor(NullProcessor.INSTANCE); -// FlatRegionFunction replace = new BiomeReplace(editSession, biome); -// FlatRegionVisitor visitor = new FlatRegionVisitor(Regions.asFlatRegion(region), replace); -// Operations.completeLegacy(visitor); + public void test(Player player, EditSession editSession, @Arg(desc = "test") String world, BlockVector2 mcaFile) throws WorldEditException { + file = new File(world, "region" + File.separator) + } @Command( diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java index 0e893c58e..48937a972 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/extension/platform/PlatformCommandManager.java @@ -24,6 +24,7 @@ import com.boydti.fawe.command.AnvilCommands; import com.boydti.fawe.command.AnvilCommandsRegistration; import com.boydti.fawe.command.CFICommands; import com.boydti.fawe.command.CFICommandsRegistration; +import com.boydti.fawe.util.StringMan; import com.sk89q.worldedit.util.formatting.text.TranslatableComponent; import com.boydti.fawe.config.Settings; import com.boydti.fawe.object.brush.visualization.cfi.HeightMapMCAGenerator; @@ -729,24 +730,18 @@ public final class PlatformCommandManager { } } catch (ConditionFailedException e) { if (e.getCondition() instanceof PermissionCondition) { - actor.printError("You are not permitted to do that. Are you in the right mode?"); + actor.printError(TranslatableComponent.of("fawe.error.no.perm", StringMan.getString(((PermissionCondition) e.getCondition()).getPermissions()))); } else { actor.print(e.getRichMessage()); } } catch (FaweException e) { - actor.printError(TextComponent.builder().append("Edit cancelled: ").append(e.getComponent()).build()); + actor.printError(TranslatableComponent.of("fawe.cancel.worldedit.cancel.reason", e.getComponent())); } catch (UsageException e) { ImmutableList cmd = e.getCommands(); if (!cmd.isEmpty()) { - actor.print(TextComponent.builder("Usage: ") - .color(TextColor.RED) - .append(HelpGenerator.create(e.getCommandParseResult()).getUsage()) - .build()); + actor.printError(TranslatableComponent.of("fawe.error.command.syntax", HelpGenerator.create(e.getCommandParseResult()).getUsage())); } - actor.print(TextComponent.builder("") - .color(TextColor.RED) - .append(e.getRichMessage()) - .build()); + actor.printError(e.getRichMessage()); } catch (CommandExecutionException e) { handleUnknownException(actor, e.getCause()); } catch (CommandException e) {