Import cleanup
All checks were successful
Deploy API / docker (17, 3.8.5) (push) Successful in 1m42s

This commit is contained in:
Braydon 2024-04-26 16:41:54 -04:00
parent 00a9dc0ce8
commit ae94af5980
41 changed files with 70 additions and 73 deletions

@ -23,11 +23,11 @@
*/
package cc.restfulmc.api.common;
import cc.restfulmc.api.model.dns.impl.ARecord;
import cc.restfulmc.api.model.dns.impl.SRVRecord;
import lombok.NonNull;
import lombok.SneakyThrows;
import lombok.experimental.UtilityClass;
import cc.restfulmc.api.model.dns.impl.ARecord;
import cc.restfulmc.api.model.dns.impl.SRVRecord;
import org.xbill.DNS.Lookup;
import org.xbill.DNS.Record;
import org.xbill.DNS.Type;

@ -36,7 +36,7 @@ import java.util.regex.Pattern;
@UtilityClass
public final class MiscUtils {
private static final Pattern USERNAME_REGEX = Pattern.compile("^[a-zA-Z0-9_]{2,16}$");
private static final List<String> WHITELISTED_NAMES = Arrays.asList("8", "g");
private static final List<String> WHITELISTED_USERNAMES = Arrays.asList("8", "g");
/**
* Check if the given username is a valid.
@ -45,9 +45,6 @@ public final class MiscUtils {
* @return whether the username is valid
*/
public static boolean isUsernameValid(@NonNull String username) {
if (WHITELISTED_NAMES.contains(username.toLowerCase())) { // Name is whitelisted
return true;
}
return USERNAME_REGEX.matcher(username).matches();
return WHITELISTED_USERNAMES.contains(username.toLowerCase()) || USERNAME_REGEX.matcher(username).matches();
}
}

@ -23,8 +23,8 @@
*/
package cc.restfulmc.api.common.packet.impl.bedrock;
import lombok.NonNull;
import cc.restfulmc.api.common.packet.UDPPacket;
import lombok.NonNull;
import java.io.IOException;
import java.net.DatagramPacket;

@ -23,10 +23,10 @@
*/
package cc.restfulmc.api.common.packet.impl.bedrock;
import lombok.Getter;
import lombok.NonNull;
import cc.restfulmc.api.common.packet.UDPPacket;
import cc.restfulmc.api.model.server.BedrockMinecraftServer;
import lombok.Getter;
import lombok.NonNull;
import java.io.IOException;
import java.net.DatagramPacket;

@ -23,10 +23,10 @@
*/
package cc.restfulmc.api.common.packet.impl.java.tcp;
import cc.restfulmc.api.common.packet.TCPPacket;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import lombok.ToString;
import cc.restfulmc.api.common.packet.TCPPacket;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.common.packet.impl.java.tcp;
import cc.restfulmc.api.common.packet.TCPPacket;
import lombok.Getter;
import lombok.NonNull;
import cc.restfulmc.api.common.packet.TCPPacket;
import java.io.DataInputStream;
import java.io.DataOutputStream;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.common.packet.impl.java.udp;
import cc.restfulmc.api.common.packet.JavaQueryPacket;
import lombok.AllArgsConstructor;
import lombok.NonNull;
import cc.restfulmc.api.common.packet.JavaQueryPacket;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.common.packet.impl.java.udp;
import cc.restfulmc.api.common.packet.JavaQueryPacket;
import lombok.Getter;
import lombok.NonNull;
import cc.restfulmc.api.common.packet.JavaQueryPacket;
import java.io.IOException;
import java.net.DatagramPacket;

@ -23,8 +23,8 @@
*/
package cc.restfulmc.api.common.packet.impl.java.udp;
import lombok.NonNull;
import cc.restfulmc.api.common.packet.JavaQueryPacket;
import lombok.NonNull;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.common.packet.impl.java.udp;
import cc.restfulmc.api.common.packet.JavaQueryPacket;
import lombok.Getter;
import lombok.NonNull;
import cc.restfulmc.api.common.packet.JavaQueryPacket;
import java.io.IOException;
import java.net.DatagramPacket;

@ -23,8 +23,8 @@
*/
package cc.restfulmc.api.common.renderer;
import lombok.NonNull;
import cc.restfulmc.api.model.skin.ISkinPart;
import lombok.NonNull;
import java.awt.*;
import java.awt.geom.AffineTransform;

@ -23,11 +23,11 @@
*/
package cc.restfulmc.api.common.renderer;
import lombok.NonNull;
import lombok.SneakyThrows;
import cc.restfulmc.api.common.ImageUtils;
import cc.restfulmc.api.model.skin.ISkinPart;
import cc.restfulmc.api.model.skin.Skin;
import lombok.NonNull;
import lombok.SneakyThrows;
import javax.imageio.ImageIO;
import java.awt.*;

@ -23,11 +23,11 @@
*/
package cc.restfulmc.api.common.renderer.impl;
import lombok.NonNull;
import cc.restfulmc.api.common.ImageUtils;
import cc.restfulmc.api.common.renderer.SkinRenderer;
import cc.restfulmc.api.model.skin.ISkinPart;
import cc.restfulmc.api.model.skin.Skin;
import lombok.NonNull;
import java.awt.*;
import java.awt.image.BufferedImage;

@ -23,10 +23,10 @@
*/
package cc.restfulmc.api.common.renderer.impl;
import lombok.NonNull;
import cc.restfulmc.api.common.renderer.IsometricSkinRenderer;
import cc.restfulmc.api.model.skin.ISkinPart;
import cc.restfulmc.api.model.skin.Skin;
import lombok.NonNull;
import java.awt.*;
import java.awt.geom.AffineTransform;

@ -23,10 +23,10 @@
*/
package cc.restfulmc.api.common.renderer.impl;
import lombok.NonNull;
import cc.restfulmc.api.common.renderer.SkinRenderer;
import cc.restfulmc.api.model.skin.ISkinPart;
import cc.restfulmc.api.model.skin.Skin;
import lombok.NonNull;
import java.awt.*;
import java.awt.image.BufferedImage;

@ -23,11 +23,11 @@
*/
package cc.restfulmc.api.common.web;
import cc.restfulmc.api.config.AppConfig;
import lombok.AccessLevel;
import lombok.Getter;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import cc.restfulmc.api.config.AppConfig;
import org.springframework.http.HttpMethod;
import org.springframework.http.HttpStatus;

@ -23,12 +23,12 @@
*/
package cc.restfulmc.api.controller;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import cc.restfulmc.api.common.MojangServer;
import cc.restfulmc.api.exception.impl.BadRequestException;
import cc.restfulmc.api.service.MojangService;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;

@ -23,16 +23,16 @@
*/
package cc.restfulmc.api.controller;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import cc.restfulmc.api.exception.impl.BadRequestException;
import cc.restfulmc.api.exception.impl.MojangRateLimitException;
import cc.restfulmc.api.exception.impl.ResourceNotFoundException;
import cc.restfulmc.api.model.Player;
import cc.restfulmc.api.model.cache.CachedPlayer;
import cc.restfulmc.api.service.MojangService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;

@ -23,15 +23,15 @@
*/
package cc.restfulmc.api.controller;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import cc.restfulmc.api.exception.impl.BadRequestException;
import cc.restfulmc.api.exception.impl.ResourceNotFoundException;
import cc.restfulmc.api.model.MinecraftServer;
import cc.restfulmc.api.model.cache.CachedMinecraftServer;
import cc.restfulmc.api.service.MojangService;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;

@ -23,8 +23,8 @@
*/
package cc.restfulmc.api.exception;
import lombok.NonNull;
import cc.restfulmc.api.model.response.ErrorResponse;
import lombok.NonNull;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;

@ -23,11 +23,11 @@
*/
package cc.restfulmc.api.log;
import cc.restfulmc.api.common.IPUtils;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import lombok.NonNull;
import lombok.extern.slf4j.Slf4j;
import cc.restfulmc.api.common.IPUtils;
import org.springframework.core.MethodParameter;
import org.springframework.http.MediaType;
import org.springframework.http.converter.HttpMessageConverter;

@ -23,18 +23,18 @@
*/
package cc.restfulmc.api.model;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.record.City;
import com.maxmind.geoip2.record.Continent;
import com.maxmind.geoip2.record.Country;
import com.maxmind.geoip2.record.Location;
import lombok.*;
import cc.restfulmc.api.common.ColorUtils;
import cc.restfulmc.api.model.dns.DNSRecord;
import cc.restfulmc.api.model.token.JavaServerStatusToken;
import cc.restfulmc.api.service.pinger.MinecraftServerPinger;
import cc.restfulmc.api.service.pinger.impl.BedrockMinecraftServerPinger;
import cc.restfulmc.api.service.pinger.impl.JavaMinecraftServerPinger;
import com.maxmind.geoip2.model.CityResponse;
import com.maxmind.geoip2.record.City;
import com.maxmind.geoip2.record.Continent;
import com.maxmind.geoip2.record.Country;
import com.maxmind.geoip2.record.Location;
import lombok.*;
import java.util.ArrayList;
import java.util.Arrays;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.model;
import lombok.*;
import cc.restfulmc.api.model.skin.Skin;
import cc.restfulmc.api.model.token.MojangProfileToken;
import lombok.*;
import java.util.UUID;

@ -23,10 +23,10 @@
*/
package cc.restfulmc.api.model.cache;
import cc.restfulmc.api.model.MinecraftServer;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonUnwrapped;
import lombok.*;
import cc.restfulmc.api.model.MinecraftServer;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;

@ -23,16 +23,16 @@
*/
package cc.restfulmc.api.model.cache;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import cc.restfulmc.api.model.Cape;
import cc.restfulmc.api.model.Player;
import cc.restfulmc.api.model.ProfileAction;
import cc.restfulmc.api.model.skin.Skin;
import cc.restfulmc.api.model.token.MojangProfileToken;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Getter;
import lombok.NonNull;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;

@ -23,8 +23,8 @@
*/
package cc.restfulmc.api.model.dns.impl;
import lombok.*;
import cc.restfulmc.api.model.dns.DNSRecord;
import lombok.*;
import java.net.InetAddress;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.model.dns.impl;
import cc.restfulmc.api.model.dns.DNSRecord;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.*;
import cc.restfulmc.api.model.dns.DNSRecord;
import java.net.InetSocketAddress;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.model.server;
import lombok.*;
import cc.restfulmc.api.model.MinecraftServer;
import cc.restfulmc.api.model.dns.DNSRecord;
import lombok.*;
/**
* A Bedrock edition {@link MinecraftServer}.

@ -23,8 +23,6 @@
*/
package cc.restfulmc.api.model.server;
import com.google.gson.annotations.SerializedName;
import lombok.*;
import cc.restfulmc.api.common.JavaMinecraftVersion;
import cc.restfulmc.api.config.AppConfig;
import cc.restfulmc.api.model.MinecraftServer;
@ -32,6 +30,8 @@ import cc.restfulmc.api.model.dns.DNSRecord;
import cc.restfulmc.api.model.token.JavaServerChallengeStatusToken;
import cc.restfulmc.api.model.token.JavaServerStatusToken;
import cc.restfulmc.api.service.MojangService;
import com.google.gson.annotations.SerializedName;
import lombok.*;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.chat.ComponentSerializer;

@ -23,11 +23,11 @@
*/
package cc.restfulmc.api.model.skin;
import lombok.*;
import cc.restfulmc.api.common.renderer.SkinRenderer;
import cc.restfulmc.api.common.renderer.impl.BodySkinPartRenderer;
import cc.restfulmc.api.common.renderer.impl.IsometricHeadSkinPartRenderer;
import cc.restfulmc.api.common.renderer.impl.VanillaSkinPartRenderer;
import lombok.*;
import java.awt.image.BufferedImage;

@ -23,13 +23,13 @@
*/
package cc.restfulmc.api.model.skin;
import cc.restfulmc.api.common.ImageUtils;
import cc.restfulmc.api.config.AppConfig;
import cc.restfulmc.api.model.Player;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.google.gson.JsonObject;
import lombok.*;
import cc.restfulmc.api.common.ImageUtils;
import cc.restfulmc.api.config.AppConfig;
import cc.restfulmc.api.model.Player;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;

@ -23,8 +23,8 @@
*/
package cc.restfulmc.api.model.token;
import lombok.*;
import cc.restfulmc.api.model.server.JavaMinecraftServer;
import lombok.*;
import java.util.HashMap;
import java.util.Map;

@ -23,12 +23,12 @@
*/
package cc.restfulmc.api.model.token;
import cc.restfulmc.api.model.server.JavaMinecraftServer;
import com.google.gson.annotations.SerializedName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NonNull;
import lombok.ToString;
import cc.restfulmc.api.model.server.JavaMinecraftServer;
import java.util.UUID;

@ -23,13 +23,13 @@
*/
package cc.restfulmc.api.model.token;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.gson.JsonObject;
import lombok.*;
import cc.restfulmc.api.config.AppConfig;
import cc.restfulmc.api.model.Cape;
import cc.restfulmc.api.model.ProfileAction;
import cc.restfulmc.api.model.skin.Skin;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.google.gson.JsonObject;
import lombok.*;
import java.util.Base64;

@ -163,13 +163,13 @@ public final class MojangService {
}, 0L, 60L * 3L * 1000L);
// Schedule a task to fetch blocked
// servers from Mojang every 15 minutes.
// servers from Mojang every hour.
new Timer().scheduleAtFixedRate(new TimerTask() {
@Override
public void run() {
fetchBlockedServers();
}
}, 0L, 60L * 15L * 1000L);
}, 0L, 60L * 60L * 1000L);
}
/**

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.service.pinger;
import lombok.NonNull;
import cc.restfulmc.api.model.MinecraftServer;
import cc.restfulmc.api.model.dns.DNSRecord;
import lombok.NonNull;
/**
* A {@link MinecraftServerPinger} is

@ -23,8 +23,6 @@
*/
package cc.restfulmc.api.service.pinger.impl;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import cc.restfulmc.api.common.packet.impl.bedrock.BedrockUnconnectedPingPacket;
import cc.restfulmc.api.common.packet.impl.bedrock.BedrockUnconnectedPongPacket;
import cc.restfulmc.api.exception.impl.BadRequestException;
@ -32,6 +30,8 @@ import cc.restfulmc.api.exception.impl.ResourceNotFoundException;
import cc.restfulmc.api.model.dns.DNSRecord;
import cc.restfulmc.api.model.server.BedrockMinecraftServer;
import cc.restfulmc.api.service.pinger.MinecraftServerPinger;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import java.io.IOException;
import java.net.DatagramSocket;

@ -23,8 +23,6 @@
*/
package cc.restfulmc.api.service.pinger.impl;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import cc.restfulmc.api.common.JavaMinecraftVersion;
import cc.restfulmc.api.common.packet.impl.java.tcp.JavaHandshakingInSetProtocolPacket;
import cc.restfulmc.api.common.packet.impl.java.tcp.JavaStatusInStartPacket;
@ -40,6 +38,8 @@ import cc.restfulmc.api.model.server.JavaMinecraftServer;
import cc.restfulmc.api.model.token.JavaServerChallengeStatusToken;
import cc.restfulmc.api.model.token.JavaServerStatusToken;
import cc.restfulmc.api.service.pinger.MinecraftServerPinger;
import lombok.NonNull;
import lombok.extern.log4j.Log4j2;
import java.io.DataInputStream;
import java.io.DataOutputStream;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.test.controller;
import lombok.NonNull;
import cc.restfulmc.api.controller.MojangController;
import cc.restfulmc.api.test.config.TestRedisConfig;
import lombok.NonNull;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.test.controller;
import lombok.NonNull;
import cc.restfulmc.api.controller.PlayerController;
import cc.restfulmc.api.test.config.TestRedisConfig;
import lombok.NonNull;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;

@ -23,9 +23,9 @@
*/
package cc.restfulmc.api.test.controller;
import lombok.NonNull;
import cc.restfulmc.api.controller.ServerController;
import cc.restfulmc.api.test.config.TestRedisConfig;
import lombok.NonNull;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;