add mods and plugins to server response
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m31s
All checks were successful
Deploy App / docker (ubuntu-latest, 2.44.0, 17, 3.8.5) (push) Successful in 1m31s
This commit is contained in:
parent
28cd7f192d
commit
63a3587586
8
pom.xml
8
pom.xml
@ -59,14 +59,6 @@
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
|
||||
<!-- Exclude the default Jackson dependency -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-json</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<!-- Redis for caching -->
|
||||
|
@ -1,6 +1,7 @@
|
||||
package cc.fascinated;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.log4j.Log4j2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
@ -16,7 +17,9 @@ import java.util.Objects;
|
||||
@SpringBootApplication
|
||||
public class Main {
|
||||
|
||||
public static final Gson GSON = new Gson();
|
||||
public static final Gson GSON = new GsonBuilder()
|
||||
.setDateFormat("MM-dd-yyyy HH:mm:ss")
|
||||
.create();
|
||||
public static final HttpClient HTTP_CLIENT = HttpClient.newHttpClient();
|
||||
|
||||
@SneakyThrows
|
||||
|
@ -60,7 +60,7 @@ public class PlayerUtils {
|
||||
* @return the part data
|
||||
*/
|
||||
public static byte[] getSkinPartBytes(Skin skin, Skin.Parts part, int size) {
|
||||
if (size == -1) {
|
||||
if (size <= 0) {
|
||||
size = part.getDefaultSize();
|
||||
}
|
||||
|
||||
|
@ -1,6 +1,5 @@
|
||||
package cc.fascinated.common;
|
||||
|
||||
import cc.fascinated.exception.impl.BadRequestException;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
@UtilityClass
|
||||
|
@ -5,8 +5,8 @@ import lombok.Getter;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Configuration
|
||||
@Getter
|
||||
@Configuration
|
||||
public class Config {
|
||||
public static Config INSTANCE;
|
||||
|
||||
|
@ -1,7 +1,5 @@
|
||||
package cc.fascinated.controller;
|
||||
|
||||
import cc.fascinated.common.ServerUtils;
|
||||
import cc.fascinated.common.Tuple;
|
||||
import cc.fascinated.model.cache.CachedMinecraftServer;
|
||||
import cc.fascinated.service.MojangService;
|
||||
import cc.fascinated.service.ServerService;
|
||||
|
@ -1,6 +1,9 @@
|
||||
package cc.fascinated.model.cache;
|
||||
|
||||
import lombok.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.Setter;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.redis.core.RedisHash;
|
||||
|
||||
|
@ -22,6 +22,16 @@ public final class JavaServerStatusToken {
|
||||
*/
|
||||
private final MinecraftServer.Players players;
|
||||
|
||||
/**
|
||||
* The mods running on the server.
|
||||
*/
|
||||
private final MinecraftServer.Mod[] mods;
|
||||
|
||||
/**
|
||||
* The plugins running on the server.
|
||||
*/
|
||||
private final MinecraftServer.Plugin[] plugins;
|
||||
|
||||
/**
|
||||
* The motd of the server.
|
||||
*/
|
||||
|
@ -28,15 +28,28 @@ public final class JavaMinecraftServer extends MinecraftServer {
|
||||
*/
|
||||
private Favicon favicon;
|
||||
|
||||
/**
|
||||
* The mods of the server.
|
||||
*/
|
||||
private MinecraftServer.Mod[] mods;
|
||||
|
||||
/**
|
||||
* The plugins of the server.
|
||||
*/
|
||||
private MinecraftServer.Plugin[] plugins;
|
||||
|
||||
/**
|
||||
* The mojang banned status of the server.
|
||||
*/
|
||||
private boolean mojangBanned;
|
||||
|
||||
public JavaMinecraftServer(String hostname, String ip, int port, MOTD motd, @NonNull Version version, Players players, Favicon favicon) {
|
||||
public JavaMinecraftServer(String hostname, String ip, int port, MOTD motd, Players players,
|
||||
@NonNull Version version, Favicon favicon, Mod[] mods, Plugin[] plugins) {
|
||||
super(hostname, ip, port, motd, players);
|
||||
this.version = version;
|
||||
this.favicon = favicon;
|
||||
this.mods = mods;
|
||||
this.plugins = plugins;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -59,9 +72,11 @@ public final class JavaMinecraftServer extends MinecraftServer {
|
||||
ip,
|
||||
port,
|
||||
MinecraftServer.MOTD.create(motdString),
|
||||
token.getVersion().detailedCopy(),
|
||||
token.getPlayers(),
|
||||
JavaMinecraftServer.Favicon.create(token.getFavicon(), ServerUtils.getAddress(hostname, port))
|
||||
token.getVersion().detailedCopy(),
|
||||
JavaMinecraftServer.Favicon.create(token.getFavicon(), ServerUtils.getAddress(hostname, port)),
|
||||
token.getMods(),
|
||||
token.getPlugins()
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -108,7 +108,7 @@ public class MinecraftServer {
|
||||
/**
|
||||
* Player count data for a server.
|
||||
*/
|
||||
@AllArgsConstructor @Getter @ToString
|
||||
@AllArgsConstructor @Getter
|
||||
public static class Players {
|
||||
/**
|
||||
* The online players on this server.
|
||||
@ -141,4 +141,40 @@ public class MinecraftServer {
|
||||
@NonNull private final String name;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Mod data for a server.
|
||||
*/
|
||||
@AllArgsConstructor @Getter
|
||||
public static final class Mod {
|
||||
|
||||
/**
|
||||
* The name of the mod.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
|
||||
/**
|
||||
* The version of the mod.
|
||||
*/
|
||||
private final String version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Plugin data for a server.
|
||||
*/
|
||||
@AllArgsConstructor @Getter
|
||||
public static final class Plugin {
|
||||
|
||||
/**
|
||||
* The name of the plugin.
|
||||
*/
|
||||
private final String name;
|
||||
|
||||
|
||||
/**
|
||||
* The version of the plugin.
|
||||
*/
|
||||
private final String version;
|
||||
}
|
||||
}
|
@ -1,6 +1,5 @@
|
||||
package cc.fascinated.repository;
|
||||
|
||||
import cc.fascinated.model.cache.CachedPlayerName;
|
||||
import cc.fascinated.model.cache.CachedPlayerSkinPart;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
|
||||
|
@ -3,9 +3,9 @@ server:
|
||||
port: 80
|
||||
servlet:
|
||||
context-path: /
|
||||
error:
|
||||
whitelabel:
|
||||
enabled: false
|
||||
|
||||
# The public URL of the application
|
||||
public-url: http://localhost:80
|
||||
|
||||
# Spring Configuration
|
||||
spring:
|
||||
@ -17,4 +17,7 @@ spring:
|
||||
database: 0
|
||||
auth: "" # Leave blank for no auth
|
||||
|
||||
public-url: http://localhost:80
|
||||
# Don't serialize null values
|
||||
jackson:
|
||||
default-property-inclusion: non_null
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user