From f8e6feb1f22a08e12e26546f555a6f6a7ff714a7 Mon Sep 17 00:00:00 2001 From: NotMyFault Date: Sun, 20 Feb 2022 14:18:58 +0100 Subject: [PATCH] Update upstream 17b9f00 Move tinyurls to ehub.to (2033) 76ec878 Allow biome commands to be used from non-player actors (2034) --- .../worldedit/command/BiomeCommands.java | 51 ++++++++++++------- .../worldedit/command/GenerationCommands.java | 4 +- .../worldedit/command/RegionCommands.java | 2 +- .../worldedit/command/WorldEditCommands.java | 2 +- .../src/main/resources/lang/strings.json | 3 ++ 5 files changed, 40 insertions(+), 22 deletions(-) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java index e9a97ab68..149af4eed 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/BiomeCommands.java @@ -33,6 +33,7 @@ import com.sk89q.worldedit.command.util.annotation.Preload; import com.sk89q.worldedit.entity.Player; 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.function.RegionFunction; import com.sk89q.worldedit.function.RegionMaskingFilter; import com.sk89q.worldedit.function.biome.BiomeReplace; @@ -112,7 +113,7 @@ public class BiomeCommands { ) @CommandPermissions("worldedit.biome.info") public void biomeInfo( - Player player, LocalSession session, + Actor actor, World world, LocalSession session, @Switch(name = 't', desc = "Use the block you are looking at.") boolean useLineOfSight, @Switch(name = 'p', desc = "Use the block you are currently in.") @@ -124,23 +125,33 @@ public class BiomeCommands { String messageKey; if (useLineOfSight) { - Location blockPosition = player.getBlockTrace(300); - if (blockPosition == null) { - player.print(Caption.of("worldedit.raytrace.noblock")); + if (actor instanceof Player) { + Location blockPosition = ((Player) actor).getBlockTrace(300); + if (blockPosition == null) { + actor.print(Caption.of("worldedit.raytrace.noblock")); + return; + } + + BiomeType biome = world.getBiome(blockPosition.toVector().toBlockPoint()); + biomes.add(biome); + + messageKey = "worldedit.biomeinfo.lineofsight"; + } else { + actor.print(Caption.of("worldedit.raytrace.require-player")); return; } - BiomeType biome = player.getWorld().getBiome(blockPosition.toVector().toBlockPoint()); - biomes.add(biome); - - messageKey = "worldedit.biomeinfo.lineofsight"; } else if (usePosition) { - BiomeType biome = player.getWorld().getBiome(player.getLocation().toVector().toBlockPoint()); - biomes.add(biome); + if (actor instanceof Locatable) { + BiomeType biome = world.getBiome(((Locatable) actor).getLocation().toVector().toBlockPoint()); + biomes.add(biome); - messageKey = "worldedit.biomeinfo.position"; + messageKey = "worldedit.biomeinfo.position"; + } else { + actor.print(Caption.of("worldedit.biomeinfo.not-locatable")); + return; + } } else { - World world = player.getWorld(); Region region = session.getSelection(world); for (BlockVector3 pt : region) { @@ -155,7 +166,7 @@ public class BiomeCommands { HoverEvent.showText(TextComponent.of(biome.getId())) ) ).collect(Collectors.toList()); - player.print(Caption.of(messageKey, TextUtils.join(components, TextComponent.of(", ")))); + actor.print(Caption.of(messageKey, TextUtils.join(components, TextComponent.of(", ")))); } @Command( @@ -168,18 +179,22 @@ public class BiomeCommands { @Confirm(Confirm.Processor.REGION) @CommandPermissions("worldedit.biome.set") public void setBiome( - Player player, LocalSession session, EditSession editSession, + Actor actor, World world, LocalSession session, EditSession editSession, @Arg(desc = "Biome type.") BiomeType target, @Switch(name = 'p', desc = "Use your current position") boolean atPosition ) throws WorldEditException { - World world = player.getWorld(); Region region; Mask mask = editSession.getMask(); if (atPosition) { - final BlockVector3 pos = player.getLocation().toVector().toBlockPoint(); - region = new CuboidRegion(pos, pos); + if (actor instanceof Locatable) { + final BlockVector3 pos = ((Locatable) actor).getLocation().toVector().toBlockPoint(); + region = new CuboidRegion(pos, pos); + } else { + actor.print(Caption.of("worldedit.setbiome.not-locatable")); + return; + } } else { region = session.getSelection(world); } @@ -191,7 +206,7 @@ public class BiomeCommands { RegionVisitor visitor = new RegionVisitor(region, replace); Operations.completeLegacy(visitor); - player.print(Caption.of( + actor.print(Caption.of( "worldedit.setbiome.changed", TextComponent.of(visitor.getAffected() / (editSession.getMaxY() - editSession.getMinY())) )); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java index b34e7860f..f1fbf616d 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/GenerationCommands.java @@ -348,7 +348,7 @@ public class GenerationCommands { name = "/generate", aliases = {"/gen", "/g"}, desc = "Generates a shape according to a formula.", - descFooter = "See also https://tinyurl.com/weexpr." + descFooter = "For details, see https://ehub.to/we/expr" ) @CommandPermissions("worldedit.generation.shape") @Logging(ALL) @@ -432,7 +432,7 @@ public class GenerationCommands { desc = "Sets biome according to a formula.", descFooter = "Formula must return positive numbers (true) if the point is inside the shape\n" + "Sets the biome of blocks in that shape.\n" - + "See also https://tinyurl.com/weexpr." + + "For details, see https://ehub.to/we/expr" ) @CommandPermissions("worldedit.generation.shape.biome") @Logging(ALL) 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 361b0fa02..fcdbdb490 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 @@ -724,7 +724,7 @@ public class RegionCommands { desc = "Deforms a selected region with an expression", descFooter = "The expression is executed for each block and is expected\n" + "to modify the variables x, y and z to point to a new block\n" - + "to fetch. See also https://tinyurl.com/weexpr" + + "to fetch. For details, see https://ehub.to/we/expr" ) @CommandPermissions("worldedit.region.deform") @Logging(ALL) diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java index 136b52433..db611b75c 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/command/WorldEditCommands.java @@ -76,7 +76,7 @@ public class WorldEditCommands { String fVerStr = fVer == null ? "unknown" : "-" + fVer.build; actor.print(TextComponent.of("FastAsyncWorldEdit" + fVerStr)); actor.print(TextComponent.of("Authors: Empire92, MattBDev, IronApollo, dordsor21 and NotMyFault")); - actor.print(TextComponent.of("Wiki: https://git.io/JMEPa") + actor.print(TextComponent.of("Wiki: https://intellectualsites.github.io/fastasyncworldedit-documentation/") .clickEvent(ClickEvent.openUrl("https://intellectualsites.github.io/fastasyncworldedit-documentation/"))); actor.print(TextComponent.of("Discord: https://discord.gg/intellectualsites") .clickEvent(ClickEvent.openUrl("https://discord.gg/intellectualsites"))); diff --git a/worldedit-core/src/main/resources/lang/strings.json b/worldedit-core/src/main/resources/lang/strings.json index 6f4c5a737..4859b8f4d 100644 --- a/worldedit-core/src/main/resources/lang/strings.json +++ b/worldedit-core/src/main/resources/lang/strings.json @@ -204,6 +204,7 @@ "worldedit.biomeinfo.lineofsight": "Biomes at line of sight point: {0}", "worldedit.biomeinfo.position": "Biomes at your position: {0}", "worldedit.biomeinfo.selection": "Biomes in your selection: {0}", + "worldedit.biomeinfo.not-locatable": "Command sender must be present in the world to use the -p flag.", "worldedit.error.disabled": "This functionality is disabled (see WorldEdit configuration).", "worldedit.error.no-match": "No match for '{0}'.", "worldedit.error.unknown": "Unknown error occurred: {0}", @@ -278,6 +279,7 @@ "worldedit.brush.operation.equip": "Set brush to {0}.", "worldedit.brush.none.equip": "Brush unbound from your current item.", "worldedit.setbiome.changed": "Biomes were changed in {0} columns. You may have to rejoin your game (or close and reopen your world) to see a change.", + "worldedit.setbiome.not-locatable": "Command sender must be present in the world to use the -p flag.", "worldedit.drawsel.disabled": "Server CUI disabled.", "worldedit.drawsel.enabled": "Server CUI enabled. This only supports cuboid regions, with a maximum size of {0}x{1}x{2}.", "worldedit.drawsel.disabled.already": "Server CUI already disabled.", @@ -319,6 +321,7 @@ "worldedit.redo.none": "Nothing left to redo.", "worldedit.clearhistory.cleared": "History cleared.", "worldedit.raytrace.noblock": "No block in sight!", + "worldedit.raytrace.require-player": "Raytracing commands require a player!", "worldedit.restore.not-configured": "Snapshot/backup restore is not configured.", "worldedit.restore.not-available": "That snapshot does not exist or is not available.", "worldedit.restore.failed": "Failed to load snapshot: {0}",