From 22379eda6fcdf71f7f6cc8263e5242981b18df84 Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 22 Sep 2021 10:16:42 +0200 Subject: [PATCH 1/2] Add todo --- .../protocol1_13to1_12_2/storage/BlockStorage.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/BlockStorage.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/BlockStorage.java index e27ee3cba..73b2967a4 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/BlockStorage.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/storage/BlockStorage.java @@ -25,6 +25,7 @@ import it.unimi.dsi.fastutil.ints.IntSet; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +// TODO Fix memory leak lolz (only a smol one tho) public class BlockStorage implements StorableObject { private static final IntSet WHITELIST = new IntOpenHashSet(46, 1F); private final Map blocks = new ConcurrentHashMap<>(); @@ -81,8 +82,8 @@ public class BlockStorage implements StorableObject { return blocks.remove(position); } - public static class ReplacementData { - private int original; + public static final class ReplacementData { + private final int original; private int replacement; public ReplacementData(int original, int replacement) { @@ -94,10 +95,6 @@ public class BlockStorage implements StorableObject { return original; } - public void setOriginal(int original) { - this.original = original; - } - public int getReplacement() { return replacement; } From 12e2be40e84a9f10e334d46d608e9685224ffdff Mon Sep 17 00:00:00 2001 From: Nassim Jahnke Date: Wed, 22 Sep 2021 11:15:36 +0200 Subject: [PATCH 2/2] Remove some old todos, don't send empty 1.14->1.15 meta packet --- .../viaversion/api/minecraft/entities/Entity1_11Types.java | 2 +- .../api/minecraft/nbt/StringTagParseException.java | 2 -- .../viaversion/api/minecraft/nbt/TagStringReader.java | 5 ++--- .../viaversion/api/minecraft/nbt/TagStringWriter.java | 6 +++--- .../java/com/viaversion/viaversion/ViaVersionPlugin.java | 1 - .../viaversion/bungee/handlers/BungeeServerHandler.java | 1 - .../protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java | 2 +- .../protocol1_12to1_11_1/Protocol1_12To1_11_1.java | 2 +- .../protocol1_13to1_12_2/data/ParticleRewriter.java | 4 ++-- .../protocol1_13to1_12_2/packets/InventoryPackets.java | 3 +-- .../metadata/MetadataRewriter1_14To1_13_2.java | 5 ++--- .../metadata/MetadataRewriter1_15To1_14_4.java | 2 +- .../protocol1_15to1_14_4/packets/EntityPackets.java | 3 +++ 13 files changed, 17 insertions(+), 21 deletions(-) diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/Entity1_11Types.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/Entity1_11Types.java index f6f23449b..04d1e3825 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/Entity1_11Types.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/entities/Entity1_11Types.java @@ -28,7 +28,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; -// 1.11 Entity / Object ids TODO maybe in the future instead of copying it, some api. +// 1.11 Entity / Object ids public class Entity1_11Types { public static EntityType getTypeFromId(int typeID, boolean isObject) { diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/StringTagParseException.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/StringTagParseException.java index a4ceecdc0..57e6d633c 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/StringTagParseException.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/StringTagParseException.java @@ -39,8 +39,6 @@ import java.io.IOException; this.position = position; } - // TODO: Provide more specific position information - @Override public String getMessage() { return super.getMessage() + "(at position " + this.position + ")"; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringReader.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringReader.java index a17d2f93f..6a17af19e 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringReader.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringReader.java @@ -86,7 +86,6 @@ import java.util.stream.IntStream; } final Tag next = this.tag(); - // TODO: validate type listTag.add(next); if (this.separatorOrCompleteWith(Tokens.ARRAY_END)) { return listTag; @@ -128,7 +127,7 @@ import java.util.stream.IntStream; if (this.separatorOrCompleteWith(Tokens.ARRAY_END)) { final byte[] result = new byte[bytes.size()]; - for (int i = 0; i < bytes.size(); ++i) { // todo yikes, let's do less boxing + for (int i = 0; i < bytes.size(); ++i) { result[i] = bytes.get(i); } return result; @@ -164,7 +163,7 @@ import java.util.stream.IntStream; if (this.separatorOrCompleteWith(Tokens.ARRAY_END)) { final long[] result = new long[longs.size()]; - for (int i = 0; i < longs.size(); ++i) { // todo yikes + for (int i = 0; i < longs.size(); ++i) { result[i] = longs.get(i); } return result; diff --git a/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringWriter.java b/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringWriter.java index a83b2f045..32b67ae13 100644 --- a/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringWriter.java +++ b/api/src/main/java/com/viaversion/viaversion/api/minecraft/nbt/TagStringWriter.java @@ -46,7 +46,7 @@ import java.util.Map; */ /* package */ final class TagStringWriter implements AutoCloseable { private final Appendable out; - private final String indent = " "; // TODO: pretty-printing + private final String indent = " "; private int level; /** * Whether a {@link Tokens#VALUE_SEPARATOR} needs to be printed before the beginning of the next object. @@ -165,7 +165,7 @@ import java.util.Map; public TagStringWriter key(final String key) throws IOException { this.printAndResetSeparator(); this.writeMaybeQuoted(key, false); - this.out.append(Tokens.COMPOUND_KEY_TERMINATOR); // TODO: spacing/pretty-printing + this.out.append(Tokens.COMPOUND_KEY_TERMINATOR); return this; } @@ -216,7 +216,7 @@ import java.util.Map; } } } - if (requireQuotes) { // TODO: single quotes + if (requireQuotes) { this.out.append(Tokens.DOUBLE_QUOTE); this.out.append(escape(content, Tokens.DOUBLE_QUOTE)); this.out.append(Tokens.DOUBLE_QUOTE); diff --git a/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java b/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java index 9aa908dce..bfc56b6ac 100644 --- a/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java +++ b/bukkit/src/main/java/com/viaversion/viaversion/ViaVersionPlugin.java @@ -272,7 +272,6 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform plugins.add(new PluginInfo(p.isEnabled(), p.getDescription().getName(), p.getDescription().getVersion(), p.getDescription().getMain(), p.getDescription().getAuthors())); platformSpecific.add("plugins", GsonUtil.getGson().toJsonTree(plugins)); - // TODO more? ProtocolLib things etc? return platformSpecific; } diff --git a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java index 836da0908..df934343c 100644 --- a/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java +++ b/bungee/src/main/java/com/viaversion/viaversion/bungee/handlers/BungeeServerHandler.java @@ -166,7 +166,6 @@ public class BungeeServerHandler implements Listener { if (protocolId <= ProtocolVersion.v1_8.getVersion()) { // 1.8 doesn't have BossBar packet if (storage.getBossbar() != null) { - // TODO: Verify whether this packet needs to be sent when 1.8 -> 1.9 protocol isn't present in the pipeline // This ensures we can encode it properly as only the 1.9 protocol is currently implemented. if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) { for (UUID uuid : storage.getBossbar()) { diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java index 04c8c7f84..ba6471976 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_10to1_9_3/Protocol1_10To1_9_3_4.java @@ -242,7 +242,7 @@ public class Protocol1_10To1_9_3_4 extends AbstractProtocol= 24) //Blame the enchantment table sound newId += 1; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java index c29e0eb32..31bf69306 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_12to1_11_1/Protocol1_12To1_11_1.java @@ -229,7 +229,7 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol= 26) // End Portal Sounds newId += 2; diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java index e45d38722..497d9281a 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/data/ParticleRewriter.java @@ -62,7 +62,7 @@ public class ParticleRewriter { add(15); // (25->15) enchantmenttable -> minecraft:enchant add(23); // (26->23) flame -> minecraft:flame add(31); // (27->31) lava -> minecraft:lava - add(-1); // (28->-1) footstap -> REMOVED (TODO REPLACEMENT/CLIENT_SIDED?) + add(-1); // (28->-1) footstap -> REMOVED add(5); // (29->5) cloud -> minecraft:cloud add(11, reddustHandler()); // (30->11) reddust -> minecraft:dust // Red Float Red value, 0-1 @@ -81,7 +81,7 @@ public class ParticleRewriter { add(3, blockHandler()); // (38->3) blockdust_(id) -> minecraft:block // BlockState VarInt The ID of the block state. add(36); // (39->36) droplet -> minecraft:rain - add(-1); // (40->-1) take -> REMOVED (TODO REPLACENT/CLIENT_SIDED?) + add(-1); // (40->-1) take -> REMOVED add(13); // (41->13) mobappearance -> minecraft:elder_guardian add(8); // (42->8) dragonbreath -> minecraft:dragon_breath add(16); // (43->16) endrod -> minecraft:end_rod diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java index b07a7e0d1..e1fa3fd8b 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_13to1_12_2/packets/InventoryPackets.java @@ -106,7 +106,7 @@ public class InventoryPackets extends ItemRewriter { @Override public void handle(PacketWrapper wrapper) throws Exception { String channel = wrapper.get(Type.STRING, 0); - // Handle stopsound change TODO change location of this remap to other class? + // Handle stopsound change if (channel.equalsIgnoreCase("MC|StopSound")) { String originalSource = wrapper.read(Type.STRING); String originalSound = wrapper.read(Type.STRING); @@ -194,7 +194,6 @@ public class InventoryPackets extends ItemRewriter { } wrapper.set(Type.STRING, 0, channel); } - // TODO Fix trading GUI }); } }); diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java index 88a849900..8e054bb50 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_14to1_13_2/metadata/MetadataRewriter1_14To1_13_2.java @@ -42,7 +42,7 @@ public class MetadataRewriter1_14To1_13_2 extends EntityRewriter= 14) { // TODO 19w13 added a new boolean (raid participant - is celebrating) with id 14 + if (metadata.id() >= 14) { // 19w13 added a new boolean (raid participant - is celebrating) with id 14 metadata.setId(metadata.id() + 1); } } diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java index f8b9d86c9..dc1a3b9e6 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/metadata/MetadataRewriter1_15To1_14_4.java @@ -60,7 +60,7 @@ public class MetadataRewriter1_15To1_14_4 extends EntityRewriter 11 && type.isOrHasParent(Entity1_15Types.LIVINGENTITY)) { - metadata.setId(metadata.id() + 1); //TODO is it 11 or 12? what is it for? + metadata.setId(metadata.id() + 1); } //NOTES: diff --git a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/EntityPackets.java b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/EntityPackets.java index 85c1bf5e8..5a0df78e3 100644 --- a/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/EntityPackets.java +++ b/common/src/main/java/com/viaversion/viaversion/protocols/protocol1_15to1_14_4/packets/EntityPackets.java @@ -86,6 +86,9 @@ public class EntityPackets { private static void sendMetadataPacket(PacketWrapper wrapper, int entityId, EntityRewriter rewriter) throws Exception { // Meta is no longer included in the spawn packets, but sent separately List metadata = wrapper.read(Types1_14.METADATA_LIST); + if (metadata.isEmpty()) { + return; + } // Send the spawn packet manually wrapper.send(Protocol1_15To1_14_4.class);