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:
Ursprung
bdfaf9a621
Commit
59c9018250
@ -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
|
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
|
||||||
public void accept(PacketWrapper wrapper) throws Exception {
|
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.DOUBLE); // Min Value
|
||||||
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
|
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.DOUBLE); // Max Value
|
||||||
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.DOUBLE); // Min 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
|
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
|
||||||
public void accept(PacketWrapper wrapper) throws Exception {
|
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.FLOAT); // Min Value
|
||||||
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
|
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.FLOAT); // Max Value
|
||||||
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.FLOAT); // Min 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
|
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
|
||||||
public void accept(PacketWrapper wrapper) throws Exception {
|
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.INT); // Min Value
|
||||||
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
|
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.INT); // Max Value
|
||||||
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.INT); // Min 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
|
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
|
||||||
public void accept(PacketWrapper wrapper) throws Exception {
|
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.LONG); // Min Value
|
||||||
byte propertyFlags = wrapper.passthrough(Type.BYTE); // Flags
|
if ((propertyFlags & 0x02) != 0) wrapper.passthrough(Type.LONG); // Max Value
|
||||||
if ((propertyFlags & 0x01) != 0) wrapper.passthrough(Type.LONG); // Min 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
|
wrapper.passthrough(Type.VAR_INT); // Flags
|
||||||
public void accept(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.passthrough(Type.VAR_INT); // Flags
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.parserHandlers.put("minecraft:entity", new CommandArgumentConsumer() {
|
this.parserHandlers.put("minecraft:entity", wrapper -> {
|
||||||
@Override
|
wrapper.passthrough(Type.BYTE); // Flags
|
||||||
public void accept(PacketWrapper wrapper) throws Exception {
|
|
||||||
wrapper.passthrough(Type.BYTE); // Flags
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.parserHandlers.put("minecraft:score_holder", new CommandArgumentConsumer() {
|
this.parserHandlers.put("minecraft:score_holder", wrapper -> {
|
||||||
@Override
|
wrapper.passthrough(Type.BYTE); // Flags
|
||||||
public void accept(PacketWrapper wrapper) throws Exception {
|
|
||||||
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) {
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren