Move changed time handling out of base CommandRewriter

This commit is contained in:
Nassim Jahnke 2023-01-18 18:03:09 +01:00
parent 50adff90f2
commit 50b94abcb1
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
3 changed files with 16 additions and 18 deletions

View File

@ -30,7 +30,6 @@ import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
import com.viaversion.viaversion.api.type.types.version.Types1_14;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ServerboundPackets1_13;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.CommandRewriter1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.ComponentRewriter1_14;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data.MappingData;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.metadata.MetadataRewriter1_14To1_13_2;
@ -40,9 +39,11 @@ import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.PlayerPa
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.packets.WorldPackets;
import com.viaversion.viaversion.protocols.protocol1_14to1_13_2.storage.EntityTracker1_14;
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import com.viaversion.viaversion.rewriter.CommandRewriter;
import com.viaversion.viaversion.rewriter.ComponentRewriter;
import com.viaversion.viaversion.rewriter.SoundRewriter;
import com.viaversion.viaversion.rewriter.StatisticsRewriter;
import org.checkerframework.checker.nullness.qual.Nullable;
public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_13, ClientboundPackets1_14, ServerboundPackets1_13, ServerboundPackets1_14> {
@ -69,7 +70,15 @@ public class Protocol1_14To1_13_2 extends AbstractProtocol<ClientboundPackets1_1
ComponentRewriter componentRewriter = new ComponentRewriter1_14(this);
componentRewriter.registerComponentPacket(ClientboundPackets1_13.CHAT_MESSAGE);
CommandRewriter1_14 commandRewriter = new CommandRewriter1_14(this);
CommandRewriter commandRewriter = new CommandRewriter(this) {
@Override
public @Nullable String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:nbt")) {
return "minecraft:nbt_compound_tag";
}
return super.handleArgumentType(argumentType);
}
};
commandRewriter.registerDeclareCommands(ClientboundPackets1_13.DECLARE_COMMANDS);
registerClientbound(ClientboundPackets1_13.TAGS, new PacketRemapper() {

View File

@ -15,24 +15,16 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package com.viaversion.viaversion.protocols.protocol1_14to1_13_2.data;
package com.viaversion.viaversion.protocols.protocol1_19_4to1_19_3.rewriter;
import com.viaversion.viaversion.api.protocol.Protocol;
import com.viaversion.viaversion.api.type.Type;
import com.viaversion.viaversion.rewriter.CommandRewriter;
import org.checkerframework.checker.nullness.qual.Nullable;
public class CommandRewriter1_14 extends CommandRewriter {
public class CommandRewriter1_19_3 extends CommandRewriter {
public CommandRewriter1_14(Protocol protocol) {
public CommandRewriter1_19_3(Protocol protocol) {
super(protocol);
this.parserHandlers.put("minecraft:time", wrapper -> wrapper.passthrough(Type.INT)); // Minimum
}
@Override
public @Nullable String handleArgumentType(String argumentType) {
if (argumentType.equals("minecraft:nbt")) {
return "minecraft:nbt_compound_tag";
}
return super.handleArgumentType(argumentType);
}
}

View File

@ -80,9 +80,6 @@ public class CommandRewriter {
this.parserHandlers.put("minecraft:resource_key", wrapper -> {
wrapper.passthrough(Type.STRING); // Resource location/tag
});
this.parserHandlers.put("minecraft:time", wrapper -> {
wrapper.passthrough(Type.INT); // Minimum
});
}
public void handleArgument(PacketWrapper wrapper, String argumentType) throws Exception {