Skip to content

Commit

Permalink
Minor code optimizations
Browse files Browse the repository at this point in the history
  • Loading branch information
Nan1t committed Jan 23, 2022
1 parent 1d75272 commit 4bdf856
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/main/java/ru/nanit/limbo/protocol/registry/State.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public enum State {
clientBound.register(PacketPluginMessage::new,
map(0x19, V1_13, V1_13_2),
map(0x18, V1_14, V1_14_4),
map(0x19, V1_15,V1_15_2),
map(0x19, V1_15, V1_15_2),
map(0x18, V1_16, V1_16_1),
map(0x17, V1_16_2, V1_16_4),
map(0x18, V1_17, V1_18)
Expand Down
11 changes: 8 additions & 3 deletions src/main/java/ru/nanit/limbo/protocol/registry/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,19 @@ public enum Version {
V1_17(755),
V1_17_1(756),
V1_18(757);
// 1.18.1 has same protocol number

private static final Map<Integer, Version> VERSION_MAP;
private static final Version MAX;

static {
Version[] values = values();

VERSION_MAP = new HashMap<>();
MAX = values[values.length - 1];

Version last = null;
for (Version version : values()) {
for (Version version : values) {
version.prev = last;
last = version;
VERSION_MAP.put(version.getProtocolNumber(), version);
Expand Down Expand Up @@ -97,8 +103,7 @@ public static Version getMin() {
}

public static Version getMax() {
Version[] values = Version.values();
return values[values.length - 1];
return MAX;
}

public static Version of(int protocolNumber) {
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/ru/nanit/limbo/util/Logger.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static void error(Object msg, Throwable t, Object... args) {

public static void print(Level level, Object msg, Throwable t, Object... args) {
if (debugLevel >= level.getIndex()) {
System.out.println(String.format("%s: %s", getPrefix(level), String.format(msg.toString(), args)));
System.out.printf("%s: %s%n", getPrefix(level), String.format(msg.toString(), args));
if (t != null) t.printStackTrace();
}
}
Expand Down

0 comments on commit 4bdf856

Please sign in to comment.