From f95a2db7f5c94ded66adc5ecb9777911093f7a2f Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Sun, 8 Oct 2023 01:38:39 +0200 Subject: [PATCH] Small code cleanup. --- .../metadata/MetadataRewriter.java | 16 ++----- .../types/CustomStringType.java | 48 ------------------- 2 files changed, 5 insertions(+), 59 deletions(-) delete mode 100644 common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java index cbcca48ce..a41059c39 100644 --- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java +++ b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/metadata/MetadataRewriter.java @@ -86,18 +86,12 @@ public static void transform(Entity1_10Types.EntityType type, List lis entry.setValue(ItemRewriter.toClient((Item) value)); break; case Float: - entry.setValue(value); + case String: + case Short: + case Position: + entry.setValue(value); break; - case Short: - entry.setValue(value); - break; - case String: - entry.setValue(value); - break; - case Position: - entry.setValue(value); - break; - default: + default: ViaRewind.getPlatform().getLogger().warning("[Out] Unhandled MetaDataType: " + metaIndex.getNewType()); list.remove(entry); break; diff --git a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java b/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java deleted file mode 100644 index 8a75e119b..000000000 --- a/common/src/main/java/com/viaversion/viarewind/protocol/protocol1_7_6_10to1_8/types/CustomStringType.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * This file is part of ViaRewind - https://github.com/ViaVersion/ViaRewind - * Copyright (C) 2016-2023 ViaVersion and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.viaversion.viarewind.protocol.protocol1_7_6_10to1_8.types; - -import com.viaversion.viaversion.api.type.PartialType; -import com.viaversion.viaversion.api.type.Type; -import io.netty.buffer.ByteBuf; - -public class CustomStringType extends PartialType { - - public CustomStringType(Integer param) { - super(param, String[].class); - } - - @Override - public String[] read(ByteBuf buffer, Integer size) throws Exception { - if (buffer.readableBytes() < size / 4) { - throw new RuntimeException("Readable bytes does not match expected!"); - } else { - String[] array = new String[size]; - for (int i = 0; i < size; i++) { - array[i] = Type.STRING.read(buffer); - } - return array; - } - } - - @Override - public void write(ByteBuf buffer, Integer size, String[] strings) throws Exception { - for (String s : strings) Type.STRING.write(buffer, s); - } -}