Optimize imports and update to java 17

This commit is contained in:
MiGoYAm 2021-12-10 17:24:07 +01:00
parent 4c5439082c
commit 3dfa56e1c5
5 changed files with 12 additions and 28 deletions

View File

@ -2,7 +2,6 @@ package ru.nanit.limbo.configuration;
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;

View File

@ -112,8 +112,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
}
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);
@ -178,8 +177,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
return;
}
if (packet instanceof PacketLoginPluginResponse) {
PacketLoginPluginResponse response = (PacketLoginPluginResponse) packet;
if (packet instanceof PacketLoginPluginResponse response) {
if (server.getConfig().getInfoForwarding().isModern()
&& response.getMessageId() == velocityLoginMessageId) {
@ -321,8 +319,7 @@ public class ClientConnection extends ChannelInboundHandlerAdapter {
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;

View File

@ -35,15 +35,9 @@ public class PacketTitleLegacy implements PacketOut {
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);
}
}

View File

@ -44,7 +44,7 @@ public final class Logger {
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();
}
}

View File

@ -47,19 +47,13 @@ public final class DimensionRegistry {
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;
}
}
}