3
0
Mirror von https://github.com/PaperMC/Velocity.git synchronisiert 2024-11-17 05:20:14 +01:00

Prettier, conciser, and more useful ProtocolVersion#toString()

Dieser Commit ist enthalten in:
Andrew Steinborn 2018-09-03 23:45:11 -04:00
Ursprung c30cc66461
Commit c5dcfb1ba6

Datei anzeigen

@ -1,5 +1,6 @@
package com.velocitypowered.proxy.protocol;
import com.google.common.base.Strings;
import com.google.common.primitives.ImmutableIntArray;
import com.velocitypowered.proxy.protocol.packet.*;
import io.netty.util.collection.IntObjectHashMap;
@ -258,9 +259,18 @@ public enum StateRegistry {
@Override
public String toString() {
StringBuilder mappingAsString = new StringBuilder("{");
for (Object2IntMap.Entry<Class<? extends MinecraftPacket>> entry : packetClassToId.object2IntEntrySet()) {
mappingAsString.append(entry.getKey().getSimpleName()).append(" -> ")
.append("0x")
.append(Strings.padStart(Integer.toHexString(entry.getIntValue()), 2, '0'))
.append(", ");
}
mappingAsString.setLength(mappingAsString.length() - 2);
mappingAsString.append("}");
return "ProtocolVersion{" +
"id=" + id +
", packetClassToId=" + packetClassToId +
", packetClassToId=" + mappingAsString.toString() +
'}';
}
}