From 88764d8d468427d9cadad313cd43f65627ca63ac Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sat, 10 Apr 2021 11:15:41 +0200 Subject: [PATCH] Update Upstream 98adde2 Allow toggleplace to work on any Actor + Locatable --- .../com/sk89q/worldedit/command/GeneralCommands.java | 11 ++++++++--- worldedit-core/src/main/resources/lang/strings.json | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java index e58190fe4..21aa15ae5 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GeneralCommands.java @@ -44,6 +44,7 @@ import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Capability; +import com.sk89q.worldedit.extension.platform.Locatable; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.internal.command.CommandRegistrationHandler; @@ -405,11 +406,15 @@ public class GeneralCommands { desc = "Switch between your position and pos1 for placement" ) @CommandPermissions("worldedit.toggleplace") - public void togglePlace(Player player, LocalSession session) { + public void togglePlace(Actor actor, LocalSession session) { + if (!(actor instanceof Locatable)) { + actor.print(Caption.of("worldedit.toggleplace.not-locatable")); + return; + } if (session.togglePlacementPosition()) { - player.print(Caption.of("worldedit.toggleplace.pos1")); + actor.print(Caption.of("worldedit.toggleplace.pos1")); } else { - player.print(Caption.of("worldedit.toggleplace.player")); + actor.print(Caption.of("worldedit.toggleplace.player")); } } diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 9b73326da..95af5e49a 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -297,6 +297,7 @@ "worldedit.gmask.set": "Global mask set.", "worldedit.toggleplace.pos1": "Now placing at pos #1.", "worldedit.toggleplace.player": "Now placing at the block you stand in.", + "worldedit.toggleplace.not-locatable": "Cannot toggle placing in this context.", "worldedit.searchitem.too-short": "Enter a longer search string (len > 2).", "worldedit.searchitem.either-b-or-i": "You cannot use both the 'b' and 'i' flags simultaneously.", "worldedit.searchitem.searching": "(Please wait... searching items.)",