Update to Minecraft 1.18-pre5

By: md_5 <git@md-5.net>
This commit is contained in:
CraftBukkit/Spigot
2021-11-22 09:00:00 +11:00
parent a852b81a69
commit 43702a9e10
700 changed files with 10286 additions and 10098 deletions

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandDispatcher.java
+++ b/net/minecraft/commands/CommandDispatcher.java
@@ -103,6 +103,14 @@
@@ -106,6 +106,14 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -15,32 +15,32 @@
public class CommandDispatcher {
private static final Logger LOGGER = LogManager.getLogger();
@@ -114,6 +122,7 @@
@@ -117,6 +125,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.dispatcher);
CommandAttribute.a(this.dispatcher);
CommandExecute.a(this.dispatcher);
@@ -195,17 +204,61 @@
CommandAdvancement.register(this.dispatcher);
CommandAttribute.register(this.dispatcher);
CommandExecute.register(this.dispatcher);
@@ -202,17 +211,63 @@
}
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
+ // CommandDispatcher.LOGGER.warn("Ambiguity between arguments {} and {} with inputs: {}", this.dispatcher.getPath(commandnode1), this.dispatcher.getPath(commandnode2), collection); // CraftBukkit
});
- this.dispatcher.setConsumer((commandcontext, flag, i) -> {
- ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag, i);
+ // CraftBukkit start
+ }
+
+ // CraftBukkit start
+ public CommandDispatcher() {
+ this.dispatcher.setConsumer((commandcontext, flag1, i) -> {
+ ((CommandListenerWrapper) commandcontext.getSource()).a(commandcontext, flag1, i);
+ // CraftBukkkit end
this.dispatcher.setConsumer((commandcontext, flag, i) -> {
((CommandListenerWrapper) commandcontext.getSource()).onCommandComplete(commandcontext, flag, i);
});
}
+ // CraftBukkit start
+ public int dispatchServerCommand(CommandListenerWrapper sender, String command) {
+ Joiner joiner = Joiner.on(" ");
+ if (command.startsWith("/")) {
@@ -68,19 +68,19 @@
+ }
+
+ // Handle vanilla commands;
+ if (sender.getWorld().getCraftServer().getCommandBlockOverride(args[0])) {
+ if (sender.getLevel().getCraftServer().getCommandBlockOverride(args[0])) {
+ args[0] = "minecraft:" + args[0];
+ }
+
+ String newCommand = joiner.join(args);
+ return this.a(sender, newCommand, newCommand, false);
+ return this.performCommand(sender, newCommand, newCommand, false);
+ }
+
public int a(CommandListenerWrapper commandlistenerwrapper, String s) {
+ return this.a(commandlistenerwrapper, s, s, true);
public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s) {
+ return this.performCommand(commandlistenerwrapper, s, s, true);
+ }
+
+ public int a(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) {
+ public int performCommand(CommandListenerWrapper commandlistenerwrapper, String s, String label, boolean stripSlash) {
StringReader stringreader = new StringReader(s);
- if (stringreader.canRead() && stringreader.peek() == '/') {
@@ -89,34 +89,34 @@
stringreader.skip();
}
@@ -229,7 +282,7 @@
@@ -236,7 +291,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) -> {
- return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s));
+ return chatmodifier.setChatClickable(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit
IChatMutableComponent ichatmutablecomponent = (new ChatComponentText("")).withStyle(EnumChatFormat.GRAY).withStyle((chatmodifier) -> {
- return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, s));
+ return chatmodifier.withClickEvent(new ChatClickable(ChatClickable.EnumClickAction.SUGGEST_COMMAND, label)); // CraftBukkit
});
if (j > 10) {
@@ -279,11 +332,36 @@
@@ -286,11 +341,36 @@
}
public void a(EntityPlayer entityplayer) {
public void sendCommands(EntityPlayer entityplayer) {
- Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newHashMap();
+ // CraftBukkit start
+ // Register Vanilla commands into builtRoot as before
+ Map<CommandNode<CommandListenerWrapper>, CommandNode<ICompletionProvider>> map = Maps.newIdentityHashMap(); // Use identity to prevent aliasing issues
+ RootCommandNode vanillaRoot = new RootCommandNode();
+
+ RootCommandNode<CommandListenerWrapper> vanilla = entityplayer.server.vanillaCommandDispatcher.a().getRoot();
+ RootCommandNode<CommandListenerWrapper> vanilla = entityplayer.server.vanillaCommandDispatcher.getDispatcher().getRoot();
+ map.put(vanilla, vanillaRoot);
+ this.a(vanilla, vanillaRoot, entityplayer.getCommandListener(), (Map) map);
+ this.fillUsableCommands(vanilla, vanillaRoot, entityplayer.createCommandSourceStack(), (Map) map);
+
+ // Now build the global commands in a second pass
RootCommandNode<ICompletionProvider> rootcommandnode = new RootCommandNode();
map.put(this.dispatcher.getRoot(), rootcommandnode);
this.a(this.dispatcher.getRoot(), rootcommandnode, entityplayer.getCommandListener(), (Map) map);
this.fillUsableCommands(this.dispatcher.getRoot(), rootcommandnode, entityplayer.createCommandSourceStack(), map);
+
+ Collection<String> bukkit = new LinkedHashSet<>();
+ for (CommandNode node : rootcommandnode.getChildren()) {
@@ -133,10 +133,10 @@
+ }
+ }
+ // CraftBukkit end
entityplayer.connection.sendPacket(new PacketPlayOutCommands(rootcommandnode));
entityplayer.connection.send(new PacketPlayOutCommands(rootcommandnode));
}
@@ -294,7 +372,7 @@
@@ -301,7 +381,7 @@
CommandNode<CommandListenerWrapper> commandnode2 = (CommandNode) iterator.next();
if (commandnode2.canUse(commandlistenerwrapper)) {
@@ -145,7 +145,7 @@
argumentbuilder.requires((icompletionprovider) -> {
return true;
@@ -317,7 +395,7 @@
@@ -324,7 +404,7 @@
argumentbuilder.redirect((CommandNode) map.get(argumentbuilder.getRedirect()));
}

View File

@@ -1,6 +1,6 @@
--- a/net/minecraft/commands/CommandListenerWrapper.java
+++ b/net/minecraft/commands/CommandListenerWrapper.java
@@ -36,6 +36,8 @@
@@ -37,6 +37,8 @@
import net.minecraft.world.phys.Vec2F;
import net.minecraft.world.phys.Vec3D;
@@ -9,7 +9,7 @@
public class CommandListenerWrapper implements ICompletionProvider {
public static final SimpleCommandExceptionType ERROR_NOT_PLAYER = new SimpleCommandExceptionType(new ChatMessage("permissions.requires.player"));
@@ -53,6 +55,7 @@
@@ -55,6 +57,7 @@
private final ResultConsumer<CommandListenerWrapper> consumer;
private final ArgumentAnchor.Anchor anchor;
private final Vec2F rotation;
@@ -17,7 +17,7 @@
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) -> {
@@ -153,9 +156,23 @@
@@ -155,9 +158,23 @@
@Override
public boolean hasPermission(int i) {
@@ -34,25 +34,25 @@
+ // CraftBukkit start
+ public boolean hasPermission(int i, String bukkitPermission) {
+ // World is null when loading functions
+ return ((getWorld() == null || !getWorld().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission);
+ return ((getLevel() == null || !getLevel().getCraftServer().ignoreVanillaPermissions) && this.permissionLevel >= i) || getBukkitSender().hasPermission(bukkitPermission);
+ }
+ // CraftBukkit end
+
public Vec3D getPosition() {
return this.worldPosition;
}
@@ -217,7 +234,7 @@
@@ -219,7 +236,7 @@
while (iterator.hasNext()) {
EntityPlayer entityplayer = (EntityPlayer) iterator.next();
- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getProfile())) {
- if (entityplayer != this.source && this.server.getPlayerList().isOp(entityplayer.getGameProfile())) {
+ if (entityplayer != this.source && entityplayer.getBukkitEntity().hasPermission("minecraft.admin.command_feedback")) { // CraftBukkit
entityplayer.sendMessage(ichatmutablecomponent, SystemUtils.NIL_UUID);
}
}
@@ -277,4 +294,10 @@
public IRegistryCustom q() {
return this.server.getCustomRegistry();
@@ -279,4 +296,10 @@
public IRegistryCustom registryAccess() {
return this.server.registryAccess();
}
+
+ // CraftBukkit start

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/commands/ICommandListener.java
+++ b/net/minecraft/commands/ICommandListener.java
@@ -23,6 +23,13 @@
public boolean shouldBroadcastCommands() {
public boolean shouldInformAdmins() {
return false;
}
+
@@ -15,7 +15,7 @@
void sendMessage(IChatBaseComponent ichatbasecomponent, UUID uuid);
@@ -36,4 +43,6 @@
default boolean c_() {
default boolean alwaysAccepts() {
return false;
}
+

View File

@@ -15,5 +15,5 @@
- EntitySelector entityselector = argumentparserselector.parse();
+ EntitySelector entityselector = argumentparserselector.parse(overridePermissions); // CraftBukkit
if (entityselector.a() > 1 && this.single) {
if (entityselector.getMaxResults() > 1 && this.single) {
if (this.playersOnly) {

View File

@@ -10,7 +10,7 @@
private MinecraftKey id = new MinecraftKey("");
private BlockStateList<Block, IBlockData> definition;
@@ -237,7 +237,7 @@
Iterator iterator = iblockstate.getValues().iterator();
Iterator iterator = iblockstate.getPossibleValues().iterator();
while (iterator.hasNext()) {
- T t0 = (Comparable) iterator.next();
@@ -19,20 +19,20 @@
if (t0 instanceof Integer) {
suggestionsbuilder.suggest((Integer) t0);
@@ -506,7 +506,7 @@
Optional<T> optional = iblockstate.b(s);
Optional<T> optional = iblockstate.getValue(s);
if (optional.isPresent()) {
- this.state = (IBlockData) this.state.set(iblockstate, (Comparable) optional.get());
+ this.state = (IBlockData) this.state.set(iblockstate, (T) optional.get()); // CraftBukkit - decompile error
- this.state = (IBlockData) this.state.setValue(iblockstate, (Comparable) optional.get());
+ this.state = (IBlockData) this.state.setValue(iblockstate, (T) optional.get()); // CraftBukkit - decompile error
this.properties.put(iblockstate, (Comparable) optional.get());
} else {
this.reader.setCursor(i);
@@ -540,7 +540,7 @@
private static <T extends Comparable<T>> void a(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) {
private static <T extends Comparable<T>> void appendProperty(StringBuilder stringbuilder, IBlockState<T> iblockstate, Comparable<?> comparable) {
stringbuilder.append(iblockstate.getName());
stringbuilder.append('=');
- stringbuilder.append(iblockstate.a(comparable));
+ stringbuilder.append(iblockstate.a((T) comparable)); // CraftBukkit - decompile error
- stringbuilder.append(iblockstate.getName(comparable));
+ stringbuilder.append(iblockstate.getName((T) comparable)); // CraftBukkit - decompile error
}
public CompletableFuture<Suggestions> a(SuggestionsBuilder suggestionsbuilder, Tags<Block> tags) {
public CompletableFuture<Suggestions> fillSuggestions(SuggestionsBuilder suggestionsbuilder, Tags<Block> tags) {

View File

@@ -1,7 +1,7 @@
--- a/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
+++ b/net/minecraft/commands/arguments/selector/ArgumentParserSelector.java
@@ -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);
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;
@@ -19,7 +19,7 @@
+ protected void parseSelector(boolean overridePermissions) throws CommandSyntaxException {
+ this.usesSelectors = !overridePermissions;
+ // CraftBukkit end
this.suggestions = this::d;
this.suggestions = this::suggestSelector;
if (!this.reader.canRead()) {
throw ArgumentParserSelector.ERROR_MISSING_SELECTOR_TYPE.createWithContext(this.reader);
@@ -465,6 +467,12 @@
@@ -33,7 +33,7 @@
+ public EntitySelector parse(boolean overridePermissions) throws CommandSyntaxException {
+ // CraftBukkit end
this.startPosition = this.reader.getCursor();
this.suggestions = this::b;
this.suggestions = this::suggestNameOrSelector;
if (this.reader.canRead() && this.reader.peek() == '@') {
@@ -473,7 +481,7 @@
}
@@ -42,5 +42,5 @@
- this.parseSelector();
+ this.parseSelector(overridePermissions); // CraftBukkit
} else {
this.c();
this.parseNameOrUUID();
}

View File

@@ -3,7 +3,7 @@
@@ -90,7 +90,7 @@
}
private void e(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
private void checkPermissions(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
- if (this.usesSelector && !commandlistenerwrapper.hasPermission(2)) {
+ if (this.usesSelector && !commandlistenerwrapper.hasPermission(2, "minecraft.command.selector")) { // CraftBukkit
throw ArgumentEntity.ERROR_SELECTORS_NOT_ALLOWED.create();