forked from MinecraftUtilities/Backend
add mods and plugins to server response
This commit is contained in:
parent
28cd7f192d
commit
63a3587586
8
pom.xml
8
pom.xml
@ -59,14 +59,6 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
<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>
|
</dependency>
|
||||||
|
|
||||||
<!-- Redis for caching -->
|
<!-- Redis for caching -->
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package cc.fascinated;
|
package cc.fascinated;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import com.google.gson.GsonBuilder;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
import lombok.extern.log4j.Log4j2;
|
import lombok.extern.log4j.Log4j2;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
@ -16,7 +17,9 @@ import java.util.Objects;
|
|||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
public class Main {
|
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();
|
public static final HttpClient HTTP_CLIENT = HttpClient.newHttpClient();
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
|
@ -60,7 +60,7 @@ public class PlayerUtils {
|
|||||||
* @return the part data
|
* @return the part data
|
||||||
*/
|
*/
|
||||||
public static byte[] getSkinPartBytes(Skin skin, Skin.Parts part, int size) {
|
public static byte[] getSkinPartBytes(Skin skin, Skin.Parts part, int size) {
|
||||||
if (size == -1) {
|
if (size <= 0) {
|
||||||
size = part.getDefaultSize();
|
size = part.getDefaultSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
package cc.fascinated.common;
|
package cc.fascinated.common;
|
||||||
|
|
||||||
import cc.fascinated.exception.impl.BadRequestException;
|
|
||||||
import lombok.experimental.UtilityClass;
|
import lombok.experimental.UtilityClass;
|
||||||
|
|
||||||
@UtilityClass
|
@UtilityClass
|
||||||
|
@ -5,8 +5,8 @@ import lombok.Getter;
|
|||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
@Configuration
|
|
||||||
@Getter
|
@Getter
|
||||||
|
@Configuration
|
||||||
public class Config {
|
public class Config {
|
||||||
public static Config INSTANCE;
|
public static Config INSTANCE;
|
||||||
|
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package cc.fascinated.controller;
|
package cc.fascinated.controller;
|
||||||
|
|
||||||
import cc.fascinated.common.ServerUtils;
|
|
||||||
import cc.fascinated.common.Tuple;
|
|
||||||
import cc.fascinated.model.cache.CachedMinecraftServer;
|
import cc.fascinated.model.cache.CachedMinecraftServer;
|
||||||
import cc.fascinated.service.MojangService;
|
import cc.fascinated.service.MojangService;
|
||||||
import cc.fascinated.service.ServerService;
|
import cc.fascinated.service.ServerService;
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package cc.fascinated.model.cache;
|
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.annotation.Id;
|
||||||
import org.springframework.data.redis.core.RedisHash;
|
import org.springframework.data.redis.core.RedisHash;
|
||||||
|
|
||||||
|
@ -22,6 +22,16 @@ public final class JavaServerStatusToken {
|
|||||||
*/
|
*/
|
||||||
private final MinecraftServer.Players players;
|
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.
|
* The motd of the server.
|
||||||
*/
|
*/
|
||||||
|
@ -28,15 +28,28 @@ public final class JavaMinecraftServer extends MinecraftServer {
|
|||||||
*/
|
*/
|
||||||
private Favicon favicon;
|
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.
|
* The mojang banned status of the server.
|
||||||
*/
|
*/
|
||||||
private boolean mojangBanned;
|
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);
|
super(hostname, ip, port, motd, players);
|
||||||
this.version = version;
|
this.version = version;
|
||||||
this.favicon = favicon;
|
this.favicon = favicon;
|
||||||
|
this.mods = mods;
|
||||||
|
this.plugins = plugins;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -59,9 +72,11 @@ public final class JavaMinecraftServer extends MinecraftServer {
|
|||||||
ip,
|
ip,
|
||||||
port,
|
port,
|
||||||
MinecraftServer.MOTD.create(motdString),
|
MinecraftServer.MOTD.create(motdString),
|
||||||
token.getVersion().detailedCopy(),
|
|
||||||
token.getPlayers(),
|
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.
|
* Player count data for a server.
|
||||||
*/
|
*/
|
||||||
@AllArgsConstructor @Getter @ToString
|
@AllArgsConstructor @Getter
|
||||||
public static class Players {
|
public static class Players {
|
||||||
/**
|
/**
|
||||||
* The online players on this server.
|
* The online players on this server.
|
||||||
@ -141,4 +141,40 @@ public class MinecraftServer {
|
|||||||
@NonNull private final String name;
|
@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;
|
package cc.fascinated.repository;
|
||||||
|
|
||||||
import cc.fascinated.model.cache.CachedPlayerName;
|
|
||||||
import cc.fascinated.model.cache.CachedPlayerSkinPart;
|
import cc.fascinated.model.cache.CachedPlayerSkinPart;
|
||||||
import org.springframework.data.repository.CrudRepository;
|
import org.springframework.data.repository.CrudRepository;
|
||||||
|
|
||||||
|
@ -3,9 +3,9 @@ server:
|
|||||||
port: 80
|
port: 80
|
||||||
servlet:
|
servlet:
|
||||||
context-path: /
|
context-path: /
|
||||||
error:
|
|
||||||
whitelabel:
|
# The public URL of the application
|
||||||
enabled: false
|
public-url: http://localhost:80
|
||||||
|
|
||||||
# Spring Configuration
|
# Spring Configuration
|
||||||
spring:
|
spring:
|
||||||
@ -17,4 +17,7 @@ spring:
|
|||||||
database: 0
|
database: 0
|
||||||
auth: "" # Leave blank for no auth
|
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