Update to Minecraft 1.17

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-06-11 15:00:00 +10:00
parent 75faba7fde
commit b3a8254758
619 changed files with 10708 additions and 8451 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandDispatcher.java
+++ b/net/minecraft/commands/CommandDispatcher.java
@@ -102,12 +102,21 @@
@@ -103,6 +103,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -15,27 +15,28 @@
public class CommandDispatcher {
private static final Logger LOGGER = LogManager.getLogger();
private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> b = new com.mojang.brigadier.CommandDispatcher();
@@ -114,6 +122,7 @@
private final com.mojang.brigadier.CommandDispatcher<CommandListenerWrapper> dispatcher = new com.mojang.brigadier.CommandDispatcher();
public CommandDispatcher(CommandDispatcher.ServerType commanddispatcher_servertype) {
+ this(); // CraftBukkit
CommandAdvancement.a(this.b);
CommandAttribute.a(this.b);
CommandExecute.a(this.b);
@@ -188,17 +197,61 @@
CommandAdvancement.a(this.dispatcher);
CommandAttribute.a(this.dispatcher);
CommandExecute.a(this.dispatcher);
@@ -195,17 +204,61 @@
}
this.b.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
- CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection);
this.dispatcher.findAmbiguities((commandnode, commandnode1, commandnode2, collection) -> {
- CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection);
+ // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.b.getPath(commandnode1), this.b.getPath(commandnode2), collection); // CraftBukkit
});
- this.b.setConsumer((commandcontext, flag, i) -> {
- this.dispatcher.setConsumer((commandcontext, flag, i) -> {
- ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i);
+ }
+
+ // CraftBukkit start
+ public CommandDispatcher() {
+ this.b.setConsumer((commandcontext, flag1, i) -> {
+ this.dispatcher.setConsumer((commandcontext, flag1, i) -> {
+ ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i);
});
}
@@ -88,7 +89,7 @@
stringreader.skip();
}
@@ -222,7 +275,7 @@
@@ -229,7 +282,7 @@
if (commandsyntaxexception.getInput() != null && commandsyntaxexception.getCursor() >= 0) {
int j = Math.min(commandsyntaxexception.getInput().length(), commandsyntaxexception.getCursor());
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).a(EnumChatFormat.GRAY).format((chatmodifier) -> {
@@ -97,7 +98,7 @@
});
if (j > 10) {
@@ -272,11 +325,36 @@
@@ -279,11 +332,36 @@
}
public void a(EntityPlayer entityplayer) {
@@ -114,8 +115,8 @@
+ // Now build the global commands in a second pass
RootCommandNode<ICompletionProvider> rootcommandnode = new RootCommandNode();
map.put(this.b.getRoot(), rootcommandnode);
this.a(this.b.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map);
map.put(this.dispatcher.getRoot(), rootcommandnode);
this.a(this.dispatcher.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map);
+
+ Collection<String> bukkit = new LinkedHashSet<>();
+ for (CommandNode node : rootcommandnode.getChildren()) {
@@ -132,10 +133,10 @@
+ }
+ }
+ // CraftBukkit end
entityplayer.playerConnection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
entityplayer.connection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
}
@@ -287,7 +365,7 @@
@@ -294,7 +372,7 @@
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
if (commandnode2.canUse(commandlistenerwrapper)) {
@@ -144,7 +145,7 @@
argumentbuilder.requires((icompletionprovider) -> {
return true;
@@ -310,7 +388,7 @@
@@ -317,7 +395,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
}

View File

@@ -8,16 +8,16 @@
+
public class CommandListenerWrapper implements ICompletionProvider {
public static final SimpleCommandExceptionType a = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player"));
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player"));
@@ -53,6 +55,7 @@
private final ResultConsumer<CommandListenerWrapper> l;
private final ArgumentAnchor.Anchor m;
private final Vec2F n;
private final ResultConsumer<CommandListenerWrapper> consumer;
private final ArgumentAnchor.Anchor anchor;
private final Vec2F rotation;
+ public volatile CommandNode currentCommand; // CraftBukkit
public CommandListenerWrapper(ICommandListener icommandlistener, Vec3D vec3d, Vec2F vec2f, WorldServer worldserver, int i, String s, IChatBaseComponent ichatbasecomponent, MinecraftServer minecraftserver, @Nullable Entity entity) {
this(icommandlistener, vec3d, vec2f, worldserver, i, s, ichatbasecomponent, minecraftserver, entity, false, (commandcontext, flag, j) -> {
@@ -149,9 +152,23 @@
@@ -153,9 +156,23 @@
@Override
public boolean hasPermission(int i) {
@@ -28,36 +28,36 @@
+ }
+ // CraftBukkit end
+
return this.f >= i;
return this.permissionLevel >= i;
}
+ // CraftBukkit start
+ public boolean hasPermission(int i, String bukkitPermission) {
+ // World is null when loading functions
+ return ((getWorld() == null || !getWorld().getServer().ignoreVanillaPermissions) && this.f >= i) || getBukkitSender().hasPermission(bukkitPermission);
+ return ((getWorld() == null || !getWorld().getServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission);
+ }
+ // CraftBukkit end
+
public Vec3D getPosition() {
return this.d;
return this.worldPosition;
}
@@ -213,7 +230,7 @@
@@ -217,7 +234,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
- if (entityplayer != this.base && this.i.getPlayerList().isOp(entityplayer.getProfile())) {
+ if (entityplayer != this.base && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.b);
- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getProfile())) {
+ if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.NIL_UUID);
}
}
@@ -273,4 +290,10 @@
@@ -277,4 +294,10 @@
public IRegistryCustom q() {
return this.i.getCustomRegistry();
return this.server.getCustomRegistry();
}
+
+ // CraftBukkit start
+ public org.bukkit.command.CommandSender getBukkitSender() {
+ return base.getBukkitSender(this);
+ return source.getBukkitSender(this);
+ }
+ // CraftBukkit end
}

View File

@@ -14,10 +14,10 @@
};
void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid);
@@ -32,4 +39,6 @@
boolean shouldSendFailure();
boolean shouldBroadcastCommands();
@@ -36,4 +43,6 @@
default boolean c_() {
return false;
}
+
+ org.bukkit.command.CommandSender getBukkitSender(CommandListenerWrapper wrapper); // CraftBukkit
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/commands/arguments/ArgumentEntity.java
+++ b/net/minecraft/commands/arguments/ArgumentEntity.java
@@ -93,9 +93,15 @@
@@ -95,9 +95,15 @@
}
public EntitySelector parse(StringReader stringreader) throws CommandSyntaxException {
@@ -15,5 +15,5 @@
- EntitySelector entityselector = argumentparserselector.parse();
+ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit
if (entityselector.a() > 1 && this.h) {
if (this.i) {
if (entityselector.a() > 1 && this.single) {
if (this.playersOnly) {

View File

@@ -1,15 +1,15 @@
--- a/net/minecraft/commands/arguments/blocks/ArgumentBlock.java
+++ b/net/minecraft/commands/arguments/blocks/ArgumentBlock.java
@@ -55,7 +55,7 @@
@@ -61,7 +61,7 @@
};
private final StringReader i;
private final boolean j;
- private final Map<IBlockState<?>, Comparable<?>> k = Maps.newHashMap();
+ private final Map<IBlockState<?>, Comparable<?>> k = Maps.newLinkedHashMap(); // CraftBukkit - stable
private final Map<String, String> l = Maps.newHashMap();
private MinecraftKey m = new MinecraftKey("");
private BlockStateList<Block, IBlockData> n;
@@ -231,7 +231,7 @@
private final StringReader reader;
private final boolean forTesting;
- private final Map<IBlockState<?>, Comparable<?>> properties = Maps.newHashMap();
+ private final Map<IBlockState<?>, Comparable<?>> properties = Maps.newLinkedHashMap(); // CraftBukkit - stable
private final Map<String, String> vagueProperties = Maps.newHashMap();
private MinecraftKey id = new MinecraftKey("");
private BlockStateList<Block, IBlockData> definition;
@@ -237,7 +237,7 @@
Iterator iterator = iblockstate.getValues().iterator();
while (iterator.hasNext()) {
@@ -18,16 +18,16 @@
if (t0 instanceof Integer) {
suggestionsbuilder.suggest((Integer) t0);
@@ -500,7 +500,7 @@
@@ -506,7 +506,7 @@
Optional<T> optional = iblockstate.b(s);
if (optional.isPresent()) {
- this.o = (IBlockData) this.o.set(iblockstate, (Comparable) optional.get());
+ this.o = (IBlockData) this.o.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error
this.k.put(iblockstate, optional.get());
- this.state = (IBlockData) this.state.set(iblockstate, (Comparable) optional.get());
+ this.state = (IBlockData) this.state.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error
this.properties.put(iblockstate, (Comparable) optional.get());
} else {
this.i.setCursor(i);
@@ -534,7 +534,7 @@
this.reader.setCursor(i);
@@ -540,7 +540,7 @@
private static <T extends Comparable<T>> void a(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) {
stringbuilder.append(iblockstate.getName());
stringbuilder.append('=');

View File

@@ -1,28 +1,28 @@
--- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
+++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
@@ -137,7 +137,7 @@
axisalignedbb = this.a(this.v == null ? 0.0D : this.v, this.w == null ? 0.0D : this.w, this.x == null ? 0.0D : this.x);
@@ -149,7 +149,7 @@
axisalignedbb = this.a(this.deltaX == null ? 0.0D : this.deltaX, this.deltaY == null ? 0.0D : this.deltaY, this.deltaZ == null ? 0.0D : this.deltaZ);
}
- Function function;
+ Function<Vec3D, Vec3D> function; // CraftBukkit - decompile error
if (this.s == null && this.t == null && this.u == null) {
if (this.x == null && this.y == null && this.z == null) {
function = (vec3d) -> {
@@ -198,8 +198,10 @@
@@ -206,8 +206,10 @@
};
}
- protected void parseSelector() throws CommandSyntaxException {
- this.checkPermissions = true;
- this.usesSelectors = true;
+ // CraftBukkit start
+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException {
+ this.checkPermissions = !overridePermissions;
+ this.usesSelectors = !overridePermissions;
+ // CraftBukkit end
this.G = this::d;
if (!this.l.canRead()) {
throw ArgumentParserSelector.d.createWithContext(this.l);
@@ -453,6 +455,12 @@
this.suggestions = this::d;
if (!this.reader.canRead()) {
throw ArgumentParserSelector.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader);
@@ -465,6 +467,12 @@
}
public EntitySelector parse() throws CommandSyntaxException {
@@ -32,13 +32,13 @@
+
+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException {
+ // CraftBukkit end
this.E = this.l.getCursor();
this.G = this::b;
if (this.l.canRead() && this.l.peek() == '@') {
@@ -461,7 +469,7 @@
this.startPosition = this.reader.getCursor();
this.suggestions = this::b;
if (this.reader.canRead() && this.reader.peek() == '@') {
@@ -473,7 +481,7 @@
}
this.l.skip();
this.reader.skip();
- this.parseSelector();
+ this.parseSelector(overridePermissions); // CraftBukkit
} else {

View File

@@ -1,11 +1,11 @@
--- a/net/minecraft/commands/arguments/selector/EntitySelector.java
+++ b/net/minecraft/commands/arguments/selector/EntitySelector.java
@@ -75,7 +75,7 @@
@@ -90,7 +90,7 @@
}
private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
- if (this.checkPermissions && !commandlistenerwrapper.hasPermission(2)) {
+ if (this.checkPermissions && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit
throw ArgumentEntity.f.create();
- if (this.usesSelector && !commandlistenerwrapper.hasPermission(2)) {
+ if (this.usesSelector && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit
throw ArgumentEntity.ERROR_SELECTORS_NOT_ALLOWED.create();
}
}