mirror of
https://github.com/PaperMC/Paper.git
synced 2025-08-11 18:22:08 -07:00
Move patches to unapplied
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
--- a/net/minecraft/commands/arguments/EntityArgument.java
|
||||
+++ b/net/minecraft/commands/arguments/EntityArgument.java
|
||||
@@ -102,21 +102,27 @@
|
||||
}
|
||||
|
||||
private EntitySelector parse(StringReader reader, boolean allowAtSelectors) throws CommandSyntaxException {
|
||||
+ // CraftBukkit start
|
||||
+ return this.parse(reader, allowAtSelectors, false);
|
||||
+ }
|
||||
+
|
||||
+ public EntitySelector parse(StringReader stringreader, boolean flag, boolean overridePermissions) throws CommandSyntaxException {
|
||||
+ // CraftBukkit end
|
||||
boolean flag1 = false;
|
||||
- EntitySelectorParser argumentparserselector = new EntitySelectorParser(reader, allowAtSelectors);
|
||||
- EntitySelector entityselector = argumentparserselector.parse();
|
||||
+ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, flag);
|
||||
+ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit
|
||||
|
||||
if (entityselector.getMaxResults() > 1 && this.single) {
|
||||
if (this.playersOnly) {
|
||||
- reader.setCursor(0);
|
||||
- throw EntityArgument.ERROR_NOT_SINGLE_PLAYER.createWithContext(reader);
|
||||
+ stringreader.setCursor(0);
|
||||
+ throw EntityArgument.ERROR_NOT_SINGLE_PLAYER.createWithContext(stringreader);
|
||||
} else {
|
||||
- reader.setCursor(0);
|
||||
- throw EntityArgument.ERROR_NOT_SINGLE_ENTITY.createWithContext(reader);
|
||||
+ stringreader.setCursor(0);
|
||||
+ throw EntityArgument.ERROR_NOT_SINGLE_ENTITY.createWithContext(stringreader);
|
||||
}
|
||||
} else if (entityselector.includesEntities() && this.playersOnly && !entityselector.isSelfSelector()) {
|
||||
- reader.setCursor(0);
|
||||
- throw EntityArgument.ERROR_ONLY_PLAYERS_ALLOWED.createWithContext(reader);
|
||||
+ stringreader.setCursor(0);
|
||||
+ throw EntityArgument.ERROR_ONLY_PLAYERS_ALLOWED.createWithContext(stringreader);
|
||||
} else {
|
||||
return entityselector;
|
||||
}
|
||||
@@ -129,7 +135,12 @@
|
||||
StringReader stringreader = new StringReader(suggestionsbuilder.getInput());
|
||||
|
||||
stringreader.setCursor(suggestionsbuilder.getStart());
|
||||
- EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, EntitySelectorParser.allowSelectors(icompletionprovider));
|
||||
+ // Paper start - Fix EntityArgument permissions
|
||||
+ final boolean permission = object instanceof CommandSourceStack stack
|
||||
+ ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector")
|
||||
+ : icompletionprovider.hasPermission(2);
|
||||
+ EntitySelectorParser argumentparserselector = new EntitySelectorParser(stringreader, permission);
|
||||
+ // Paper end - Fix EntityArgument permissions
|
||||
|
||||
try {
|
||||
argumentparserselector.parse();
|
@@ -0,0 +1,41 @@
|
||||
--- a/net/minecraft/commands/arguments/MessageArgument.java
|
||||
+++ b/net/minecraft/commands/arguments/MessageArgument.java
|
||||
@@ -40,6 +40,11 @@
|
||||
|
||||
public static void resolveChatMessage(CommandContext<CommandSourceStack> context, String name, Consumer<PlayerChatMessage> callback) throws CommandSyntaxException {
|
||||
MessageArgument.Message message = context.getArgument(name, MessageArgument.Message.class);
|
||||
+ // Paper start
|
||||
+ resolveChatMessage(message, context, name, callback);
|
||||
+ }
|
||||
+ public static void resolveChatMessage(MessageArgument.Message message, CommandContext<CommandSourceStack> context, String name, Consumer<PlayerChatMessage> callback) throws CommandSyntaxException {
|
||||
+ // Paper end
|
||||
CommandSourceStack commandSourceStack = context.getSource();
|
||||
Component component = message.resolveComponent(commandSourceStack);
|
||||
CommandSigningContext commandSigningContext = commandSourceStack.getSigningContext();
|
||||
@@ -54,17 +59,21 @@
|
||||
private static void resolveSignedMessage(Consumer<PlayerChatMessage> callback, CommandSourceStack source, PlayerChatMessage message) {
|
||||
MinecraftServer minecraftServer = source.getServer();
|
||||
CompletableFuture<FilteredText> completableFuture = filterPlainText(source, message);
|
||||
- Component component = minecraftServer.getChatDecorator().decorate(source.getPlayer(), message.decoratedContent());
|
||||
- source.getChatMessageChainer().append(completableFuture, filtered -> {
|
||||
- PlayerChatMessage playerChatMessage2 = message.withUnsignedContent(component).filter(filtered.mask());
|
||||
+ // Paper start - support asynchronous chat decoration
|
||||
+ CompletableFuture<Component> componentFuture = minecraftServer.getChatDecorator().decorate(source.getPlayer(), source, message.decoratedContent());
|
||||
+ source.getChatMessageChainer().append(CompletableFuture.allOf(completableFuture, componentFuture), filtered -> {
|
||||
+ PlayerChatMessage playerChatMessage2 = message.withUnsignedContent(componentFuture.join()).filter(completableFuture.join().mask());
|
||||
+ // Paper end - support asynchronous chat decoration
|
||||
callback.accept(playerChatMessage2);
|
||||
});
|
||||
}
|
||||
|
||||
private static void resolveDisguisedMessage(Consumer<PlayerChatMessage> callback, CommandSourceStack source, PlayerChatMessage message) {
|
||||
ChatDecorator chatDecorator = source.getServer().getChatDecorator();
|
||||
- Component component = chatDecorator.decorate(source.getPlayer(), message.decoratedContent());
|
||||
- callback.accept(message.withUnsignedContent(component));
|
||||
+ // Paper start - support asynchronous chat decoration
|
||||
+ CompletableFuture<Component> componentFuture = chatDecorator.decorate(source.getPlayer(), source, message.decoratedContent());
|
||||
+ source.getChatMessageChainer().append(componentFuture, (result) -> callback.accept(message.withUnsignedContent(result)));
|
||||
+ // Paper end - support asynchronous chat decoration
|
||||
}
|
||||
|
||||
private static CompletableFuture<FilteredText> filterPlainText(CommandSourceStack source, PlayerChatMessage message) {
|
@@ -0,0 +1,38 @@
|
||||
--- a/net/minecraft/commands/arguments/blocks/BlockStateParser.java
|
||||
+++ b/net/minecraft/commands/arguments/blocks/BlockStateParser.java
|
||||
@@ -67,7 +67,7 @@
|
||||
private final StringReader reader;
|
||||
private final boolean forTesting;
|
||||
private final boolean allowNbt;
|
||||
- private final Map<Property<?>, Comparable<?>> properties = Maps.newHashMap();
|
||||
+ private final Map<Property<?>, Comparable<?>> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable
|
||||
private final Map<String, String> vagueProperties = Maps.newHashMap();
|
||||
private ResourceLocation id = ResourceLocation.withDefaultNamespace("");
|
||||
@Nullable
|
||||
@@ -275,7 +275,7 @@
|
||||
Iterator iterator = property.getPossibleValues().iterator();
|
||||
|
||||
while (iterator.hasNext()) {
|
||||
- T t0 = (Comparable) iterator.next();
|
||||
+ T t0 = (T) iterator.next(); // CraftBukkit - decompile error
|
||||
|
||||
if (t0 instanceof Integer integer) {
|
||||
builder.suggest(integer);
|
||||
@@ -545,7 +545,7 @@
|
||||
Optional<T> optional = property.getValue(value);
|
||||
|
||||
if (optional.isPresent()) {
|
||||
- this.state = (BlockState) this.state.setValue(property, (Comparable) optional.get());
|
||||
+ this.state = (BlockState) this.state.setValue(property, (T) optional.get()); // CraftBukkit - decompile error
|
||||
this.properties.put(property, (Comparable) optional.get());
|
||||
} else {
|
||||
this.reader.setCursor(cursor);
|
||||
@@ -581,7 +581,7 @@
|
||||
private static <T extends Comparable<T>> void appendProperty(StringBuilder builder, Property<T> property, Comparable<?> value) {
|
||||
builder.append(property.getName());
|
||||
builder.append('=');
|
||||
- builder.append(property.getName(value));
|
||||
+ builder.append(property.getName((T) value)); // CraftBukkit - decompile error
|
||||
}
|
||||
|
||||
public static record BlockResult(BlockState blockState, Map<Property<?>, Comparable<?>> properties, @Nullable CompoundTag nbt) {
|
@@ -0,0 +1,10 @@
|
||||
--- a/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
+++ b/net/minecraft/commands/arguments/item/ItemInput.java
|
||||
@@ -78,6 +78,6 @@
|
||||
}
|
||||
|
||||
private String getItemName() {
|
||||
- return this.item.unwrapKey().map(ResourceKey::location).orElseGet(() -> "unknown[" + this.item + "]").toString();
|
||||
+ return this.item.unwrapKey().<Object>map(ResourceKey::location).orElseGet(() -> "unknown[" + this.item + "]").toString(); // Paper - decompile fix
|
||||
}
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
+++ b/net/minecraft/commands/arguments/selector/EntitySelector.java
|
||||
@@ -93,7 +93,7 @@
|
||||
}
|
||||
|
||||
private void checkPermissions(CommandSourceStack source) throws CommandSyntaxException {
|
||||
- if (this.usesSelector && !source.hasPermission(2)) {
|
||||
+ if (!source.bypassSelectorPermissions && (this.usesSelector && !source.hasPermission(2, "minecraft.command.selector"))) { // CraftBukkit // Paper - add bypass for selector perms
|
||||
throw EntityArgument.ERROR_SELECTORS_NOT_ALLOWED.create();
|
||||
}
|
||||
}
|
@@ -0,0 +1,55 @@
|
||||
--- a/net/minecraft/commands/arguments/selector/EntitySelectorParser.java
|
||||
+++ b/net/minecraft/commands/arguments/selector/EntitySelectorParser.java
|
||||
@@ -133,7 +133,7 @@
|
||||
boolean flag;
|
||||
|
||||
if (source instanceof SharedSuggestionProvider icompletionprovider) {
|
||||
- if (icompletionprovider.hasPermission(2)) {
|
||||
+ if (source instanceof net.minecraft.commands.CommandSourceStack stack ? stack.bypassSelectorPermissions || stack.hasPermission(2, "minecraft.command.selector") : icompletionprovider.hasPermission(2)) { // Paper - Fix EntityArgument permissions
|
||||
flag = true;
|
||||
return flag;
|
||||
}
|
||||
@@ -158,7 +158,7 @@
|
||||
axisalignedbb = this.createAabb(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ);
|
||||
}
|
||||
|
||||
- Function function;
|
||||
+ Function<Vec3, Vec3> function; // CraftBukkit - decompile error
|
||||
|
||||
if (this.x == null && this.y == null && this.z == null) {
|
||||
function = (vec3d) -> {
|
||||
@@ -215,8 +215,10 @@
|
||||
};
|
||||
}
|
||||
|
||||
- protected void parseSelector() throws CommandSyntaxException {
|
||||
- this.usesSelectors = true;
|
||||
+ // CraftBukkit start
|
||||
+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException {
|
||||
+ this.usesSelectors = !overridePermissions;
|
||||
+ // CraftBukkit end
|
||||
this.suggestions = this::suggestSelector;
|
||||
if (!this.reader.canRead()) {
|
||||
throw EntitySelectorParser.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader);
|
||||
@@ -505,6 +507,12 @@
|
||||
}
|
||||
|
||||
public EntitySelector parse() throws CommandSyntaxException {
|
||||
+ // CraftBukkit start
|
||||
+ return this.parse(false);
|
||||
+ }
|
||||
+
|
||||
+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException {
|
||||
+ // CraftBukkit end
|
||||
this.startPosition = this.reader.getCursor();
|
||||
this.suggestions = this::suggestNameOrSelector;
|
||||
if (this.reader.canRead() && this.reader.peek() == '@') {
|
||||
@@ -513,7 +521,7 @@
|
||||
}
|
||||
|
||||
this.reader.skip();
|
||||
- this.parseSelector();
|
||||
+ this.parseSelector(overridePermissions); // CraftBukkit
|
||||
} else {
|
||||
this.parseNameOrUUID();
|
||||
}
|
@@ -0,0 +1,11 @@
|
||||
--- a/net/minecraft/commands/arguments/selector/SelectorPattern.java
|
||||
+++ b/net/minecraft/commands/arguments/selector/SelectorPattern.java
|
||||
@@ -13,7 +13,7 @@
|
||||
EntitySelectorParser entitySelectorParser = new EntitySelectorParser(new StringReader(selector), true);
|
||||
return DataResult.success(new SelectorPattern(selector, entitySelectorParser.parse()));
|
||||
} catch (CommandSyntaxException var2) {
|
||||
- return DataResult.error(() -> "Invalid selector component: " + selector + ": " + var2.getMessage());
|
||||
+ return DataResult.error(() -> "Invalid selector component"); // Paper - limit selector error message
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user