13
0
geforkt von Mirrors/Velocity

Fix Checkstyle issues.

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-12-29 11:07:45 -05:00
Ursprung 76fc39660c
Commit 5f3c31bc48
2 geänderte Dateien mit 17 neuen und 7 gelöschten Zeilen

Datei anzeigen

@ -25,13 +25,10 @@ import com.velocitypowered.proxy.protocol.packet.brigadier.ArgumentPropertyRegis
import io.netty.buffer.ByteBuf; import io.netty.buffer.ByteBuf;
import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2IntLinkedOpenHashMap;
import it.unimi.dsi.fastutil.objects.Object2IntMap; import it.unimi.dsi.fastutil.objects.Object2IntMap;
import it.unimi.dsi.fastutil.objects.Object2IntOpenHashMap;
import java.util.ArrayDeque; import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Deque; import java.util.Deque;
import java.util.Iterator; import java.util.Iterator;
import java.util.List;
import java.util.Queue; import java.util.Queue;
import java.util.concurrent.CompletableFuture; import java.util.concurrent.CompletableFuture;
import org.checkerframework.checker.nullness.qual.MonotonicNonNull; import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
@ -51,6 +48,10 @@ public class AvailableCommands implements MinecraftPacket {
@MonotonicNonNull @MonotonicNonNull
private RootCommandNode<Object> rootNode; private RootCommandNode<Object> rootNode;
/**
* Returns the root node.
* @return the root node
*/
public RootCommandNode<Object> getRootNode() { public RootCommandNode<Object> getRootNode() {
if (rootNode == null) { if (rootNode == null) {
throw new IllegalStateException("Packet not yet deserialized"); throw new IllegalStateException("Packet not yet deserialized");
@ -63,8 +64,7 @@ public class AvailableCommands implements MinecraftPacket {
int commands = ProtocolUtils.readVarInt(buf); int commands = ProtocolUtils.readVarInt(buf);
WireNode[] wireNodes = new WireNode[commands]; WireNode[] wireNodes = new WireNode[commands];
for (int i = 0; i < commands; i++) { for (int i = 0; i < commands; i++) {
WireNode node = deserializeNode(buf, i); wireNodes[i] = deserializeNode(buf, i);
wireNodes[i] = node;
} }
// Iterate over the deserialized nodes and attempt to form a graph. We also resolve any cycles // Iterate over the deserialized nodes and attempt to form a graph. We also resolve any cycles
@ -104,7 +104,7 @@ public class AvailableCommands implements MinecraftPacket {
} }
} }
// Now serialize the children // Now serialize the children.
ProtocolUtils.writeVarInt(buf, idMappings.size()); ProtocolUtils.writeVarInt(buf, idMappings.size());
for (CommandNode<Object> child : idMappings.keySet()) { for (CommandNode<Object> child : idMappings.keySet()) {
serializeNode(child, buf, idMappings); serializeNode(child, buf, idMappings);
@ -220,7 +220,7 @@ public class AvailableCommands implements MinecraftPacket {
this.args = args; this.args = args;
} }
public boolean toNode(WireNode[] wireNodes) { boolean toNode(WireNode[] wireNodes) {
if (this.built == null) { if (this.built == null) {
// Ensure all children exist. Note that we delay checking if the node has been built yet; // Ensure all children exist. Note that we delay checking if the node has been built yet;
// that needs to come after this node is built. // that needs to come after this node is built.

Datei anzeigen

@ -38,6 +38,11 @@ public class ArgumentPropertyRegistry {
byId.put(identifier, serializer); byId.put(identifier, serializer);
} }
/**
* Deserializes the {@link ArgumentType}.
* @param buf the buffer to deserialize
* @return the deserialized {@link ArgumentType}
*/
public static ArgumentType<?> deserialize(ByteBuf buf) { public static ArgumentType<?> deserialize(ByteBuf buf) {
String identifier = ProtocolUtils.readString(buf); String identifier = ProtocolUtils.readString(buf);
ArgumentPropertySerializer<?> serializer = byId.get(identifier); ArgumentPropertySerializer<?> serializer = byId.get(identifier);
@ -53,6 +58,11 @@ public class ArgumentPropertyRegistry {
} }
} }
/**
* Serializes the {@code type} into the provided {@code buf}.
* @param buf the buffer to serialize into
* @param type the type to serialize
*/
public static void serialize(ByteBuf buf, ArgumentType<?> type) { public static void serialize(ByteBuf buf, ArgumentType<?> type) {
if (type instanceof DummyProperty) { if (type instanceof DummyProperty) {
DummyProperty property = (DummyProperty) type; DummyProperty property = (DummyProperty) type;