Skip to content

Commit

Permalink
Optimize imports and update to java 17
Browse files Browse the repository at this point in the history
  • Loading branch information
MiGoYAm committed Dec 10, 2021
1 parent 4c54390 commit 3dfa56e
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.ConfigurationNode;
import org.spongepowered.configurate.serialize.SerializationException;
import org.spongepowered.configurate.serialize.TypeSerializer;

import java.lang.reflect.Type;
Expand Down
9 changes: 3 additions & 6 deletions src/main/java/ru/nanit/limbo/connection/ClientConnection.java
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ public void channelRead(ChannelHandlerContext ctx, Object msg) {
}

public void handlePacket(Object packet) {
if (packet instanceof PacketHandshake) {
PacketHandshake handshake = (PacketHandshake) packet;
if (packet instanceof PacketHandshake handshake) {
clientVersion = handshake.getVersion();

updateStateAndVersion(handshake.getNextState(), clientVersion);
Expand Down Expand Up @@ -178,8 +177,7 @@ public void handlePacket(Object packet) {
return;
}

if (packet instanceof PacketLoginPluginResponse) {
PacketLoginPluginResponse response = (PacketLoginPluginResponse) packet;
if (packet instanceof PacketLoginPluginResponse response) {

if (server.getConfig().getInfoForwarding().isModern()
&& response.getMessageId() == velocityLoginMessageId) {
Expand Down Expand Up @@ -321,8 +319,7 @@ private boolean checkBungeeGuardHandshake(String handshake) {
String token = null;

for (Object obj : arr) {
if (obj instanceof JsonObject) {
JsonObject prop = (JsonObject) obj;
if (obj instanceof JsonObject prop) {
if (prop.getString("name").equals("bungeeguard-token")) {
token = prop.getString("value");
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,15 +35,9 @@ public void encode(ByteMessage msg, Version version) {
msg.writeVarInt(action.getId(version));

switch (action) {
case SET_TITLE:
title.encode(msg, version);
break;
case SET_SUBTITLE:
subtitle.encode(msg, version);
break;
case SET_TIMES_AND_DISPLAY:
times.encode(msg, version);
break;
case SET_TITLE -> title.encode(msg, version);
case SET_SUBTITLE -> subtitle.encode(msg, version);
case SET_TIMES_AND_DISPLAY -> times.encode(msg, version);
}
}

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
16 changes: 5 additions & 11 deletions src/main/java/ru/nanit/limbo/world/DimensionRegistry.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,19 +47,13 @@ public void load(String def) throws IOException {
CompoundBinaryTag theEnd = (CompoundBinaryTag) ((CompoundBinaryTag) dimensions.get(3)).get("element");

switch (def.toLowerCase()) {
case "overworld":
defaultDimension = new Dimension(0, "minecraft:overworld", overWorld);
break;
case "nether":
defaultDimension = new Dimension(-1, "minecraft:nether", nether);
break;
case "the_end":
defaultDimension = new Dimension(1, "minecraft:the_end", theEnd);
break;
default:
case "overworld" -> defaultDimension = new Dimension(0, "minecraft:overworld", overWorld);
case "nether" -> defaultDimension = new Dimension(-1, "minecraft:nether", nether);
case "the_end" -> defaultDimension = new Dimension(1, "minecraft:the_end", theEnd);
default -> {
defaultDimension = new Dimension(1, "minecraft:the_end", theEnd);
Logger.warning("Undefined dimension type: '%s'. Using THE_END as default", def);
break;
}
}
}

Expand Down

0 comments on commit 3dfa56e

Please sign in to comment.