3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-03 14:50:30 +01:00

Call command argument handler with unmapped name

Dieser Commit ist enthalten in:
KennyTV 2021-02-05 13:04:57 +01:00
Ursprung bdfaf9a621
Commit 59c9018250
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 6BE3B555EBC5982B

Datei anzeigen

@ -21,55 +21,34 @@ public abstract class CommandRewriter {
this.protocol = protocol; this.protocol = protocol;
// Register default parsers // Register default parsers
this.parserHandlers.put("brigadier:double", new CommandArgumentConsumer() { this.parserHandlers.put("brigadier:double", wrapper -> {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.DOUBLE); // Min Value if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.DOUBLE); // Min Value
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.DOUBLE); // Max Value if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.DOUBLE); // Max Value
}
}); });
this.parserHandlers.put("brigadier:float", new CommandArgumentConsumer() { this.parserHandlers.put("brigadier:float", wrapper -> {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.FLOAT); // Min Value if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.FLOAT); // Min Value
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.FLOAT); // Max Value if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.FLOAT); // Max Value
}
}); });
this.parserHandlers.put("brigadier:integer", new CommandArgumentConsumer() { this.parserHandlers.put("brigadier:integer", wrapper -> {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.INT); // Min Value if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.INT); // Min Value
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.INT); // Max Value if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.INT); // Max Value
}
}); });
this.parserHandlers.put("brigadier:long", new CommandArgumentConsumer() { this.parserHandlers.put("brigadier:long", wrapper -> {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.LONG); // Min Value if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.LONG); // Min Value
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.LONG); // Max Value if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.LONG); // Max Value
}
}); });
this.parserHandlers.put("brigadier:string", new CommandArgumentConsumer() { this.parserHandlers.put("brigadier:string", wrapper -> {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.VAR_INT); // Flags wrapper.passthrough(Type.VAR_INT); // Flags
}
}); });
this.parserHandlers.put("minecraft:entity", new CommandArgumentConsumer() { this.parserHandlers.put("minecraft:entity", wrapper -> {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.BYTE); // Flags wrapper.passthrough(Type.BYTE); // Flags
}
}); });
this.parserHandlers.put("minecraft:score_holder", new CommandArgumentConsumer() { this.parserHandlers.put("minecraft:score_holder", wrapper -> {
@Override
public void accept(PacketWrapper wrapper) throws Exception {
wrapper.passthrough(Type.BYTE); // Flags wrapper.passthrough(Type.BYTE); // Flags
}
}); });
} }
@ -99,11 +78,14 @@ public abstract class CommandRewriter {
} }
if (nodeType == 2) { // Argument node if (nodeType == 2) { // Argument node
String argumentType = handleArgumentType(wrapper.read(Type.STRING)); String argumentType = wrapper.read(Type.STRING);
if (argumentType != null) { String newArgumentType = handleArgumentType(argumentType);
wrapper.write(Type.STRING, argumentType); if (newArgumentType != null) {
handleArgument(wrapper, argumentType); wrapper.write(Type.STRING, newArgumentType);
} }
// Always call the handler using the previous name
handleArgument(wrapper, argumentType);
} }
if ((flags & 0x10) != 0) { if ((flags & 0x10) != 0) {