From 47e66913e3988bc264f9e34af393b21c004e1355 Mon Sep 17 00:00:00 2001 From: matt <4009945+MattBDev@users.noreply.github.com> Date: Tue, 2 Apr 2019 16:26:51 -0400 Subject: [PATCH] Selective upstream merge --- .../bukkit/util/CommandRegistration.java | 6 +---- .../java/com/sk89q/wepif/VaultResolver.java | 3 +++ .../bukkit/BukkitBlockCategoryRegistry.java | 2 +- .../sk89q/worldedit/bukkit/BukkitPlayer.java | 2 +- .../com/sk89q/worldedit/blocks/Blocks.java | 27 +++++++++++++++++++ .../worldedit/command/RegionCommands.java | 24 ++++++++--------- .../world/block/BlockCategories.java | 4 +-- 7 files changed, 47 insertions(+), 21 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java index 0e47b5f9a..e7df6832c 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/bukkit/util/CommandRegistration.java @@ -35,11 +35,7 @@ import java.util.Set; public class CommandRegistration { static { - try { - Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, new DynamicPluginCommandHelpTopic.Factory()); - } catch (Throwable e) { - e.printStackTrace(); - } + Bukkit.getServer().getHelpMap().registerHelpTopicFactory(DynamicPluginCommand.class, new DynamicPluginCommandHelpTopic.Factory()); } protected final Plugin plugin; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java b/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java index a97017ceb..a918d601a 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/wepif/VaultResolver.java @@ -35,6 +35,9 @@ public class VaultResolver implements PermissionsResolver { return null; } RegisteredServiceProvider rsp = server.getServicesManager().getRegistration(Permission.class); + if (rsp == null) { + return null; + } perms = rsp.getProvider(); if (perms == null) { return null; diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java index 24cbe0f6b..cecec0691 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/BukkitBlockCategoryRegistry.java @@ -49,4 +49,4 @@ public class BukkitBlockCategoryRegistry implements BlockCategoryRegistry { public Set getAll(Category category) { return getCategorisedByName(category.getId()); } -} \ No newline at end of file +} 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 b3674e986..b9aa53a25 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 @@ -290,7 +290,7 @@ public class BukkitPlayer extends AbstractPlayerActor { } @Override - public > void sendFakeBlock(BlockVector3 pos, B block) { + public void sendFakeBlock(BlockVector3 pos, BlockStateHolder block) { Location loc = new Location(player.getWorld(), pos.getX(), pos.getY(), pos.getZ()); if (block == null) { player.sendBlockChange(loc, player.getWorld().getBlockAt(loc).getBlockData()); diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java index 83ebddc85..db59ddce6 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/blocks/Blocks.java @@ -19,6 +19,8 @@ package com.sk89q.worldedit.blocks; +import com.google.common.collect.Maps; +import com.sk89q.worldedit.registry.state.Property; import com.sk89q.worldedit.world.block.BlockCategories; import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockType; @@ -26,6 +28,7 @@ import com.sk89q.worldedit.world.block.BlockTypes; import java.util.Collection; import java.util.HashSet; +import java.util.Map; import java.util.Set; /** @@ -190,4 +193,28 @@ public final class Blocks { return false; } + /** + * Parses a string->string map to find the matching Property and values for the given BlockType. + * + * @param states the desired states and values + * @param type the block type to get properties and values for + * @return a property->value map + */ + public static Map, Object> resolveProperties(Map states, BlockType type) { + Map> existing = type.getPropertyMap(); + Map, Object> newMap = Maps.newHashMap(); + states.forEach((key, value) -> { + @SuppressWarnings("unchecked") + Property prop = (Property) existing.get(key); + if (prop == null) return; + Object val = null; + try { + val = prop.getValueFor(value); + } catch (IllegalArgumentException ignored) { + } + if (val == null) return; + newMap.put(prop, val); + }); + return newMap; + } } 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 64d3f250c..ea648056d 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 @@ -227,7 +227,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = {"/line"}, - usage = " [thickness]", + usage = " [thickness]", desc = "Draws a line segment between cuboid selection corners", help = "Draws a line segment between cuboid selection corners.\n" + @@ -261,7 +261,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = {"/curve", "/spline"}, - usage = " [thickness]", + usage = " [thickness]", desc = "Draws a spline through selected points", help = "Draws a spline through selected points.\n" + @@ -297,8 +297,8 @@ public class RegionCommands extends MethodCommands { } @Command( - aliases = {"/replace", "/re", "/rep", "/r"}, - usage = "[from-mask] ", + aliases = { "/replace", "/re", "/rep" }, + usage = "[from-block] ", desc = "Replace all blocks in the selection with another", flags = "f", min = 1, @@ -343,7 +343,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = {"/overlay"}, - usage = "", + usage = "", desc = "Set a block on top of blocks in the region", min = 1, max = 1 @@ -393,7 +393,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = {"/center", "/middle"}, - usage = "", + usage = "", desc = "Set the center block(s)", min = 1, max = 1 @@ -423,7 +423,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = {"/walls"}, - usage = "", + usage = "", desc = "Build the four sides of the selection", min = 1, max = 1 @@ -439,7 +439,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = {"/faces", "/outline"}, - usage = "", + usage = "", desc = "Build the walls, ceiling, and floor of a selection", min = 1, max = 1 @@ -527,7 +527,7 @@ public class RegionCommands extends MethodCommands { desc = "Move the contents of the selection", help = "Moves the contents of the selection.\n" + - " -s flag shifts the selection to the target location.\n" + + "The -s flag shifts the selection to the target location.\n" + " -b also copies biomes\n" + " -e ignores entities\n" + " -a ignores air\n" + @@ -621,7 +621,7 @@ public class RegionCommands extends MethodCommands { if (moveSelection) { try { final BlockVector3 size = region.getMaximumPoint().subtract(region.getMinimumPoint()).add(1, 1, 1); - BlockVector3 shiftVector = BlockVector3.at(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count); + final BlockVector3 shiftVector = BlockVector3.at(direction.getX() * size.getX() * count, direction.getY() * size.getY() * count, direction.getZ() * size.getZ() * count); region.shift(shiftVector); session.getRegionSelector(player.getWorld()).learnChanges(); @@ -735,7 +735,7 @@ public class RegionCommands extends MethodCommands { @Command( aliases = {"/hollow"}, - usage = "[[ ]]", + usage = "[[ ]]", desc = "Hollows out the object contained in this selection", help = "Hollows out the object contained in this selection.\n" + @@ -803,4 +803,4 @@ public class RegionCommands extends MethodCommands { } -} \ No newline at end of file +} diff --git a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java index d60c96985..b9e08aab8 100644 --- a/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java +++ b/worldedit-core/src/main/java/com/sk89q/worldedit/world/block/BlockCategories.java @@ -32,8 +32,8 @@ public final class BlockCategories { public static final BlockCategory BIRCH_LOGS = register("minecraft:birch_logs"); public static final BlockCategory BUTTONS = register("minecraft:buttons"); public static final BlockCategory CARPETS = register("minecraft:carpets"); - public static final BlockCategory CORAL = register("minecraft:coral"); - public static final BlockCategory CORAL_PLANTS = register("minecraft:coral_plants"); + public static final BlockCategory CORALS = register("minecraft:corals"); + public static final BlockCategory CORAL_BLOCKS = register("minecraft:coral_blocks"); public static final BlockCategory DARK_OAK_LOGS = register("minecraft:dark_oak_logs"); public static final BlockCategory DOORS = register("minecraft:doors"); public static final BlockCategory ENDERMAN_HOLDABLE = register("minecraft:enderman_holdable");