Selective upstream merge

This commit is contained in:
matt 2019-04-02 16:26:51 -04:00
parent 7ad364917f
commit 47e66913e3
7 changed files with 47 additions and 21 deletions

View File

@ -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;

View File

@ -35,6 +35,9 @@ public class VaultResolver implements PermissionsResolver {
return null;
}
RegisteredServiceProvider<Permission> rsp = server.getServicesManager().getRegistration(Permission.class);
if (rsp == null) {
return null;
}
perms = rsp.getProvider();
if (perms == null) {
return null;

View File

@ -290,7 +290,7 @@ public class BukkitPlayer extends AbstractPlayerActor {
}
@Override
public <B extends BlockStateHolder<B>> 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());

View File

@ -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<Property<Object>, Object> resolveProperties(Map<String, String> states, BlockType type) {
Map<String, ? extends Property<?>> existing = type.getPropertyMap();
Map<Property<Object>, Object> newMap = Maps.newHashMap();
states.forEach((key, value) -> {
@SuppressWarnings("unchecked")
Property<Object> prop = (Property<Object>) 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;
}
}

View File

@ -227,7 +227,7 @@ public class RegionCommands extends MethodCommands {
@Command(
aliases = {"/line"},
usage = "<pattern> [thickness]",
usage = "<block> [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 = "<pattern> [thickness]",
usage = "<block> [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] <to-pattern>",
aliases = { "/replace", "/re", "/rep" },
usage = "[from-block] <to-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 = "<pattern>",
usage = "<block>",
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 = "<pattern>",
usage = "<block>",
desc = "Set the center block(s)",
min = 1,
max = 1
@ -423,7 +423,7 @@ public class RegionCommands extends MethodCommands {
@Command(
aliases = {"/walls"},
usage = "<pattern>",
usage = "<block>",
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 = "<pattern>",
usage = "<block>",
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 = "[<thickness>[ <pattern>]]",
usage = "[<thickness>[ <block>]]",
desc = "Hollows out the object contained in this selection",
help =
"Hollows out the object contained in this selection.\n" +

View File

@ -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");