Mirror von
https://github.com/PaperMC/Paper.git
synchronisiert 2024-12-24 15:20:11 +01:00
4d20922b79
* Updated Upstream (Bukkit/CraftBukkit/Spigot) Upstream has released updates that appear to apply and compile correctly. This update has not been tested by PaperMC and as with ANY update, please do your own testing Bukkit Changes: e86f4dc4 PR-1041: Improve getPlayer(String) docs to clarify it matches the name 9738f005 Fix spawner API documentation 69ebd9fd PR-1034: Add TrialSpawnerSpawnEvent 23cffd9c PR-973: Improve spawner API and add API for Trial Spawners 8bf19163 PR-1038: Clarify HumanEntity#openInventory(InventoryView) JavaDoc 1ff76351 SPIGOT-7732, SPIGOT-7786: Add freezing damage modifier 02161cb4 PR-1034: Add CreatureSpawnEvent.SpawnReason#TRIAL_SPAWNER f9cb6f34 SPIGOT-7777: All entity potion effects are removed on death 25d548eb PR-1031: Expose Creeper igniter ccbf0915 SPIGOT-7770: Reserve spaces in shaped recipes for blank ingredients 17f7097c Clarify ambiguity around what is API 71714f0c Remove note from InventoryView JavaDoc aaf49731 PR-1030: Deprecate more unused methods in UnsafeValues 3a9dc689 SPIGOT-7771: Material.getDefaultAttributes always returns an empty map CraftBukkit Changes: c3ceeb6f7 SPIGOT-7814: Call PlayerShearEntityEvent for Bogged 97b1e4f58 Fix wolf armor not dropping from use of shears fd2ef563a SPIGOT-7812: Revert "SPIGOT-7809: Restore shield/banner conversion for base colours" f672c351b SPIGOT-7811: Enchantments are applied on sweeping attack even if damage event is cancelled cfe29350b SPIGOT-7808: Fix implementation of Enchantment#getName() for bad name return 19335f69e SPIGOT-7809: Restore shield/banner conversion for base colours ae4f5a0be SPIGOT-7805: Fix jukebox deserialization 62e3b73a4 SPIGOT-7804: Fix written book serialization aac911d26 SPIGOT-7800, SPIGOT-7801: Keep vanilla behaviour for items dropped on player death 13ece474f PR-1429: Implement TrialSpawnerSpawnEvent bf13e9113 PR-1354: Improve spawner API and add API for Trial Spawners 515fe49e1 Increase outdated build delay 9cd5a19a0 SPIGOT-7794: Cancelling InventoryItemMoveEvent destroys items ce40c7b14 SPIGOT-7796: Kickplayer newlines not working 5167256ff SPIGOT-7795: Fix damage/stats ignore the invulnerable damage time f993563ee Improve cross-world teleportation handling ab29122cf PR-1433: HumanEntity#openInventory(InventoryView) should only support views belonging to the player 764a541c5 SPIGOT-7732: Issue with the "hurt()" method of EntityLiving and invulnerable time 820084b5f SPIGOT-7791: Skull BlockState with null profile causes NullPointerException 5e46f1c82 SPIGOT-7785: Teleporting a player at the right moment can mess up vanilla teleportation cbd95a6b3 SPIGOT-7772: Include hidden / non-sampled players in player count 3153debc5 SPIGOT-7790: Server crashes after bee nest is forced to update e77bb26bb SPIGOT-7788: The healing power of friendship advancement is never granted ee3d7258a SPIGOT-7789: Fix NPE in CraftMetaFirework applyToItem 2889b3a11 PR-1429: Add CreatureSpawnEvent.SpawnReason#TRIAL_SPAWNER cdd05bc7f SPIGOT-7777: Speed attribute stays after death; missing EntityPotionEffectEvent call d0e6af2d4 PR-1428: Expose Creeper igniter d01c70e93 PR-1425: Fix bytecode transformation taking care of class-to-interface compatibility. b2b08f68c SPIGOT-7770: Fix certain shaped recipes not registering 3f8e4161f PR-1426: Deprecate more unused methods in UnsafeValues 2c9dd879e SPIGOT-7771: Material.getDefaultAttributes always returns an empty map Spigot Changes: 491f3675 Rebuild patches 0a642bd7 Rebuild patches 8897571b Rebuild patches cb8cf80c Fix newlines in custom restart message 1aabe506 Rebuild patches
136 Zeilen
7.3 KiB
Diff
136 Zeilen
7.3 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jason Penilla <11360596+jpenilla@users.noreply.github.com>
|
|
Date: Mon, 1 Jul 2024 11:58:49 -0700
|
|
Subject: [PATCH] Prioritize Minecraft commands in function parsing and command
|
|
blocks
|
|
|
|
|
|
diff --git a/src/main/java/com/mojang/brigadier/CommandDispatcher.java b/src/main/java/com/mojang/brigadier/CommandDispatcher.java
|
|
index a4d5d7017e0be79844b996de85a63cad5f8488bc..770aec1976bd391eb5712b57b6c6a0290b4723a8 100644
|
|
--- a/src/main/java/com/mojang/brigadier/CommandDispatcher.java
|
|
+++ b/src/main/java/com/mojang/brigadier/CommandDispatcher.java
|
|
@@ -298,7 +298,7 @@ public class CommandDispatcher<S> {
|
|
List<ParseResults<S>> potentials = null;
|
|
final int cursor = originalReader.getCursor();
|
|
|
|
- for (final CommandNode<S> child : node.getRelevantNodes(originalReader)) {
|
|
+ for (final CommandNode<S> child : node.getRelevantNodes(originalReader, source)) { // Paper - prioritize mc commands in function parsing
|
|
if (!child.canUse(source)) {
|
|
continue;
|
|
}
|
|
diff --git a/src/main/java/com/mojang/brigadier/tree/CommandNode.java b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
|
index 03ce8a2abb6dceaa922dcce7f3adbc228bbde4bc..dc76fcf4c6cc6cd65ce117b1855c15ede60f30ab 100644
|
|
--- a/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
|
+++ b/src/main/java/com/mojang/brigadier/tree/CommandNode.java
|
|
@@ -173,6 +173,12 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
|
protected abstract String getSortedKey();
|
|
|
|
public Collection<? extends CommandNode<S>> getRelevantNodes(final StringReader input) {
|
|
+ // Paper start - prioritize mc commands in function parsing
|
|
+ return this.getRelevantNodes(input, null);
|
|
+ }
|
|
+ @org.jetbrains.annotations.ApiStatus.Internal
|
|
+ public Collection<? extends CommandNode<S>> getRelevantNodes(final StringReader input, final Object source) {
|
|
+ // Paper end - prioritize mc commands in function parsing
|
|
if (this.literals.size() > 0) {
|
|
final int cursor = input.getCursor();
|
|
while (input.canRead() && input.peek() != ' ') {
|
|
@@ -180,7 +186,21 @@ public abstract class CommandNode<S> implements Comparable<CommandNode<S>> {
|
|
}
|
|
final String text = input.getString().substring(cursor, input.getCursor());
|
|
input.setCursor(cursor);
|
|
- final LiteralCommandNode<S> literal = this.literals.get(text);
|
|
+ // Paper start - prioritize mc commands in function parsing
|
|
+ LiteralCommandNode<S> literal = null;
|
|
+ if (source instanceof CommandSourceStack css && css.source == net.minecraft.commands.CommandSource.NULL) {
|
|
+ if (!text.contains(":")) {
|
|
+ literal = this.literals.get("minecraft:" + text);
|
|
+ }
|
|
+ } else if (source instanceof CommandSourceStack css && css.source instanceof net.minecraft.world.level.BaseCommandBlock) {
|
|
+ if (css.getServer().server.getCommandBlockOverride(text) && !text.contains(":")) {
|
|
+ literal = this.literals.get("minecraft:" + text);
|
|
+ }
|
|
+ }
|
|
+ if (literal == null) {
|
|
+ literal = this.literals.get(text);
|
|
+ }
|
|
+ // Paper end - prioritize mc commands in function parsing
|
|
if (literal != null) {
|
|
return Collections.singleton(literal);
|
|
} else {
|
|
diff --git a/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java b/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java
|
|
index 85a890403645f0f9d381e85b48efcae126673945..bcc27fec043a57eb5064934c967982deff9cdee4 100644
|
|
--- a/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java
|
|
+++ b/src/main/java/com/mojang/brigadier/tree/LiteralCommandNode.java
|
|
@@ -23,11 +23,19 @@ import java.util.function.Predicate;
|
|
public class LiteralCommandNode<S> extends CommandNode<S> {
|
|
private final String literal;
|
|
private final String literalLowerCase;
|
|
+ private final String nonPrefixed; // Paper - prioritize mc commands in function parsing
|
|
|
|
public LiteralCommandNode(final String literal, final Command<S> command, final Predicate<S> requirement, final CommandNode<S> redirect, final RedirectModifier<S> modifier, final boolean forks) {
|
|
super(command, requirement, redirect, modifier, forks);
|
|
this.literal = literal;
|
|
this.literalLowerCase = literal.toLowerCase(Locale.ROOT);
|
|
+ // Paper start - prioritize mc commands in function parsing
|
|
+ if (literal.startsWith("minecraft:")) {
|
|
+ this.nonPrefixed = literal.substring("minecraft:".length());
|
|
+ } else {
|
|
+ this.nonPrefixed = null;
|
|
+ }
|
|
+ // Paper end - prioritize mc commands in function parsing
|
|
}
|
|
|
|
public String getLiteral() {
|
|
@@ -42,7 +50,12 @@ public class LiteralCommandNode<S> extends CommandNode<S> {
|
|
@Override
|
|
public void parse(final StringReader reader, final CommandContextBuilder<S> contextBuilder) throws CommandSyntaxException {
|
|
final int start = reader.getCursor();
|
|
- final int end = parse(reader);
|
|
+ // Paper start - prioritize mc commands in function parsing
|
|
+ int end = parse(reader, false);
|
|
+ if (end == -1 && this.nonPrefixed != null) {
|
|
+ end = parse(reader, true);
|
|
+ }
|
|
+ // Paper end - prioritize mc commands in function parsing
|
|
if (end > -1) {
|
|
contextBuilder.withNode(this, StringRange.between(start, end));
|
|
return;
|
|
@@ -51,7 +64,10 @@ public class LiteralCommandNode<S> extends CommandNode<S> {
|
|
throw CommandSyntaxException.BUILT_IN_EXCEPTIONS.literalIncorrect().createWithContext(reader, literal);
|
|
}
|
|
|
|
- private int parse(final StringReader reader) {
|
|
+ // Paper start - prioritize mc commands in function parsing
|
|
+ private int parse(final StringReader reader, final boolean secondPass) {
|
|
+ String literal = secondPass ? this.nonPrefixed : this.literal;
|
|
+ // Paper end - prioritize mc commands in function parsing
|
|
final int start = reader.getCursor();
|
|
if (reader.canRead(literal.length())) {
|
|
final int end = start + literal.length();
|
|
@@ -78,7 +94,7 @@ public class LiteralCommandNode<S> extends CommandNode<S> {
|
|
|
|
@Override
|
|
public boolean isValidInput(final String input) {
|
|
- return parse(new StringReader(input)) > -1;
|
|
+ return parse(new StringReader(input), false) > -1; // Paper - prioritize mc commands in function parsing
|
|
}
|
|
|
|
@Override
|
|
diff --git a/src/main/java/net/minecraft/commands/Commands.java b/src/main/java/net/minecraft/commands/Commands.java
|
|
index 3e454515360c22a26c9329e4032d525579110d7e..1d1e76de60e40224f5cb81893f9ee50fe987badb 100644
|
|
--- a/src/main/java/net/minecraft/commands/Commands.java
|
|
+++ b/src/main/java/net/minecraft/commands/Commands.java
|
|
@@ -310,10 +310,7 @@ public class Commands {
|
|
|
|
// Paper - Fix permission levels for command blocks
|
|
|
|
- // Handle vanilla commands;
|
|
- if (sender.getLevel().getCraftServer().getCommandBlockOverride(args[0])) {
|
|
- args[0] = "minecraft:" + args[0];
|
|
- }
|
|
+ // Handle vanilla commands; // Paper - handled in CommandNode/CommandDispatcher
|
|
|
|
String newCommand = joiner.join(args);
|
|
this.performPrefixedCommand(sender, newCommand, newCommand);
|