pls work first try
This commit is contained in:
58
src/main/java/xyz/mcutils/models/CachedResponse.java
Normal file
58
src/main/java/xyz/mcutils/models/CachedResponse.java
Normal file
@ -0,0 +1,58 @@
|
||||
package xyz.mcutils.models;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
public class CachedResponse {
|
||||
|
||||
/**
|
||||
* The cache information for this response.
|
||||
*/
|
||||
private Cache cache;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Setter
|
||||
public static class Cache {
|
||||
/**
|
||||
* Whether this request is cached.
|
||||
*/
|
||||
private boolean cached;
|
||||
|
||||
/**
|
||||
* The unix timestamp of when this was cached.
|
||||
*/
|
||||
private long cachedTime;
|
||||
|
||||
/**
|
||||
* Create a new cache information object with the default values.
|
||||
* <p>
|
||||
* The default values are:
|
||||
* <br>
|
||||
* <ul>
|
||||
* <li>cached: true</li>
|
||||
* <li>cachedAt: {@link System#currentTimeMillis()}</li>
|
||||
* </ul>
|
||||
* <br>
|
||||
* </p>
|
||||
*
|
||||
* @return the default cache information object
|
||||
*/
|
||||
public static Cache defaultCache() {
|
||||
return new Cache(true, System.currentTimeMillis());
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets if this request is cached.
|
||||
*
|
||||
* @param cached the new value of if this request is cached
|
||||
*/
|
||||
public void setCached(boolean cached) {
|
||||
this.cached = cached;
|
||||
if (!cached) {
|
||||
cachedTime = -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
29
src/main/java/xyz/mcutils/models/dns/DNSRecord.java
Normal file
29
src/main/java/xyz/mcutils/models/dns/DNSRecord.java
Normal file
@ -0,0 +1,29 @@
|
||||
package xyz.mcutils.models.dns;
|
||||
|
||||
import io.micrometer.common.lang.NonNull;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter @Getter
|
||||
@NoArgsConstructor @AllArgsConstructor
|
||||
public class DNSRecord {
|
||||
/**
|
||||
* The type of this record.
|
||||
*/
|
||||
@NonNull
|
||||
private Type type;
|
||||
|
||||
/**
|
||||
* The TTL (Time To Live) of this record.
|
||||
*/
|
||||
private long ttl;
|
||||
|
||||
/**
|
||||
* Types of a record.
|
||||
*/
|
||||
public enum Type {
|
||||
A, SRV
|
||||
}
|
||||
}
|
15
src/main/java/xyz/mcutils/models/dns/impl/ARecord.java
Normal file
15
src/main/java/xyz/mcutils/models/dns/impl/ARecord.java
Normal file
@ -0,0 +1,15 @@
|
||||
package xyz.mcutils.models.dns.impl;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import xyz.mcutils.models.dns.DNSRecord;
|
||||
|
||||
@Setter @Getter
|
||||
@NoArgsConstructor
|
||||
public final class ARecord extends DNSRecord {
|
||||
/**
|
||||
* The address of this record, null if unresolved.
|
||||
*/
|
||||
private String address;
|
||||
}
|
31
src/main/java/xyz/mcutils/models/dns/impl/SRVRecord.java
Normal file
31
src/main/java/xyz/mcutils/models/dns/impl/SRVRecord.java
Normal file
@ -0,0 +1,31 @@
|
||||
package xyz.mcutils.models.dns.impl;
|
||||
|
||||
import io.micrometer.common.lang.NonNull;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
import xyz.mcutils.models.dns.DNSRecord;
|
||||
|
||||
@Setter @Getter
|
||||
@NoArgsConstructor
|
||||
public final class SRVRecord extends DNSRecord {
|
||||
/**
|
||||
* The priority of this record.
|
||||
*/
|
||||
private int priority;
|
||||
|
||||
/**
|
||||
* The weight of this record.
|
||||
*/
|
||||
private int weight;
|
||||
|
||||
/**
|
||||
* The port of this record.
|
||||
*/
|
||||
private int port;
|
||||
|
||||
/**
|
||||
* The target of this record.
|
||||
*/
|
||||
@NonNull private String target;
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package xyz.mcutils.models.mojang;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import xyz.mcutils.models.CachedResponse;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class CachedMojangEndpointStatus extends CachedResponse {
|
||||
|
||||
/**
|
||||
* The list of endpoints and their status.
|
||||
*/
|
||||
private Map<String, Status> endpoints;
|
||||
|
||||
public enum Status {
|
||||
/**
|
||||
* The service is online and operational.
|
||||
*/
|
||||
ONLINE,
|
||||
|
||||
/**
|
||||
* The service is online, but may be experiencing issues.
|
||||
* This could be due to high load or other issues.
|
||||
*/
|
||||
DEGRADED,
|
||||
|
||||
/**
|
||||
* The service is offline and not operational.
|
||||
*/
|
||||
OFFLINE
|
||||
}
|
||||
}
|
62
src/main/java/xyz/mcutils/models/player/CachedPlayer.java
Normal file
62
src/main/java/xyz/mcutils/models/player/CachedPlayer.java
Normal file
@ -0,0 +1,62 @@
|
||||
package xyz.mcutils.models.player;
|
||||
|
||||
import lombok.Getter;
|
||||
import xyz.mcutils.models.CachedResponse;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class CachedPlayer extends CachedResponse {
|
||||
|
||||
/**
|
||||
* The UUID of the player
|
||||
*/
|
||||
private UUID uniqueId;
|
||||
|
||||
/**
|
||||
* The trimmed UUID of the player
|
||||
*/
|
||||
private String trimmedUniqueId;
|
||||
|
||||
/**
|
||||
* The username of the player
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* The skin of the player, null if the
|
||||
* player does not have a skin
|
||||
*/
|
||||
private Skin skin;
|
||||
|
||||
/**
|
||||
* The cape of the player, null if the
|
||||
* player does not have a cape
|
||||
*/
|
||||
private Cape cape;
|
||||
|
||||
/**
|
||||
* The raw properties of the player
|
||||
*/
|
||||
private ProfileProperty[] rawProperties;
|
||||
|
||||
/**
|
||||
* A profile property for the player.
|
||||
*/
|
||||
private static class ProfileProperty {
|
||||
/**
|
||||
* The name of the property.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The base64 value of the property.
|
||||
*/
|
||||
private String value;
|
||||
|
||||
/**
|
||||
* Whether the property is signed.
|
||||
*/
|
||||
private boolean signed;
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package xyz.mcutils.models.player;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor @Getter
|
||||
public class CachedPlayerSkinPart {
|
||||
/**
|
||||
* The bytes for the skin part
|
||||
*/
|
||||
private byte[] partBytes;
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
package xyz.mcutils.models.player;
|
||||
|
||||
import lombok.Getter;
|
||||
import xyz.mcutils.models.CachedResponse;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class CachedUsernameToUuid extends CachedResponse {
|
||||
/**
|
||||
* The username of the player.
|
||||
*/
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* The unique id of the player.
|
||||
*/
|
||||
private UUID uniqueId;
|
||||
}
|
8
src/main/java/xyz/mcutils/models/player/Cape.java
Normal file
8
src/main/java/xyz/mcutils/models/player/Cape.java
Normal file
@ -0,0 +1,8 @@
|
||||
package xyz.mcutils.models.player;
|
||||
|
||||
public class Cape {
|
||||
/**
|
||||
* The URL of the cape
|
||||
*/
|
||||
private String url;
|
||||
}
|
51
src/main/java/xyz/mcutils/models/player/Skin.java
Normal file
51
src/main/java/xyz/mcutils/models/player/Skin.java
Normal file
@ -0,0 +1,51 @@
|
||||
package xyz.mcutils.models.player;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class Skin {
|
||||
/**
|
||||
* The URL for the skin
|
||||
*/
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* The model for the skin
|
||||
*/
|
||||
private Model model;
|
||||
|
||||
/**
|
||||
* The legacy status of the skin
|
||||
*/
|
||||
private boolean legacy;
|
||||
|
||||
/**
|
||||
* The part URLs of the skin
|
||||
*/
|
||||
private Map<String, String> parts = new HashMap<>();
|
||||
|
||||
/**
|
||||
* The model of the skin.
|
||||
*/
|
||||
public enum Model {
|
||||
DEFAULT,
|
||||
SLIM
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum SkinPart {
|
||||
HEAD("head"),
|
||||
FACE("face"),
|
||||
BODY("body");
|
||||
|
||||
/**
|
||||
* The name of the skin part
|
||||
*/
|
||||
private final String name;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package xyz.mcutils.models.server;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
public class CachedBedrockMinecraftServer extends MinecraftServer {
|
||||
/**
|
||||
* The unique ID of this server.
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* The edition of this server.
|
||||
*/
|
||||
private Edition edition;
|
||||
|
||||
/**
|
||||
* The version information of this server.
|
||||
*/
|
||||
private Version version;
|
||||
|
||||
/**
|
||||
* The gamemode of this server.
|
||||
*/
|
||||
private GameMode gamemode;
|
||||
|
||||
/**
|
||||
* The edition of a Bedrock server.
|
||||
*/
|
||||
@Getter
|
||||
public enum Edition {
|
||||
/**
|
||||
* Minecraft: Pocket Edition.
|
||||
*/
|
||||
MCPE,
|
||||
|
||||
/**
|
||||
* Minecraft: Education Edition.
|
||||
*/
|
||||
MCEE
|
||||
}
|
||||
|
||||
/**
|
||||
* Version information for a server.
|
||||
*/
|
||||
@Getter @ToString
|
||||
public static class Version {
|
||||
/**
|
||||
* The protocol version of the server.
|
||||
*/
|
||||
private int protocol;
|
||||
|
||||
/**
|
||||
* The version name of the server.
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The gamemode of a server.
|
||||
*/
|
||||
@Getter @ToString
|
||||
public static class GameMode {
|
||||
/**
|
||||
* The name of this gamemode.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The numeric of this gamemode.
|
||||
*/
|
||||
private int numericId;
|
||||
}
|
||||
}
|
@ -0,0 +1,181 @@
|
||||
package xyz.mcutils.models.server;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
@Getter
|
||||
public class CachedJavaMinecraftServer extends MinecraftServer {
|
||||
|
||||
/**
|
||||
* The version of the server.
|
||||
*/
|
||||
private Version version;
|
||||
|
||||
/**
|
||||
* The favicon of the server.
|
||||
*/
|
||||
private Favicon favicon;
|
||||
|
||||
/**
|
||||
* The mods running on this server.
|
||||
*/
|
||||
private ForgeModInfo modInfo;
|
||||
|
||||
/**
|
||||
* The mods running on this server.
|
||||
* <p>
|
||||
* This is only used for servers
|
||||
* running 1.13 and above.
|
||||
* </p>
|
||||
*/
|
||||
private ForgeData forgeData;
|
||||
|
||||
/**
|
||||
* Whether the server prevents chat reports.
|
||||
*/
|
||||
private boolean preventsChatReports;
|
||||
|
||||
/**
|
||||
* Whether the server enforces secure chat.
|
||||
*/
|
||||
private boolean enforcesSecureChat;
|
||||
|
||||
/**
|
||||
* Whether the server has previews chat enabled.
|
||||
* <p>
|
||||
* Chat Preview sends chat messages to the server as they are typed, even before they're sent.
|
||||
* <a href="https://www.minecraft.net/es-mx/article/minecraft-snapshot-22w19a">More information</a>
|
||||
* </p>
|
||||
*/
|
||||
private boolean previewsChat;
|
||||
|
||||
/**
|
||||
* The mojang blocked status for the server.
|
||||
*/
|
||||
private boolean mojangBlocked;
|
||||
|
||||
@Getter
|
||||
public static class Version {
|
||||
/**
|
||||
* The version name of the server.
|
||||
*/
|
||||
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The server platform.
|
||||
*/
|
||||
private String platform;
|
||||
|
||||
/**
|
||||
* The protocol version.
|
||||
*/
|
||||
private int protocol;
|
||||
|
||||
/**
|
||||
* The name of the protocol, null if not found.
|
||||
*/
|
||||
private String protocolName;
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class Favicon {
|
||||
|
||||
/**
|
||||
* The raw base64 of the favicon.
|
||||
*/
|
||||
private String base64;
|
||||
|
||||
/**
|
||||
* The url to the favicon.
|
||||
*/
|
||||
private String url;
|
||||
}
|
||||
|
||||
/**
|
||||
* Forge mod information for a server.
|
||||
*/
|
||||
@Getter @ToString
|
||||
public static class ForgeModInfo {
|
||||
/**
|
||||
* The type of modded server this is.
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* The list of mods on this server, null or empty if none.
|
||||
*/
|
||||
private ForgeMod[] modList;
|
||||
|
||||
/**
|
||||
* A forge mod for a server.
|
||||
*/
|
||||
@Getter @ToString
|
||||
private static class ForgeMod {
|
||||
/**
|
||||
* The id of this mod.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The version of this mod.
|
||||
*/
|
||||
private String version;
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class ForgeData {
|
||||
|
||||
/**
|
||||
* The list of mod channels on this server, null or empty if none.
|
||||
*/
|
||||
private Channel[] channels;
|
||||
|
||||
/**
|
||||
* The list of mods on this server, null or empty if none.
|
||||
*/
|
||||
private Mod[] mods;
|
||||
|
||||
/**
|
||||
* Whether the mod list is truncated.
|
||||
*/
|
||||
private boolean truncated;
|
||||
|
||||
/**
|
||||
* The version of the FML network.
|
||||
*/
|
||||
private int fmlNetworkVersion;
|
||||
|
||||
@Getter
|
||||
public static class Channel {
|
||||
/**
|
||||
* The id of this mod channel.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The version of this mod channel.
|
||||
*/
|
||||
private String version;
|
||||
|
||||
/**
|
||||
* Whether this mod channel is required to join.
|
||||
*/
|
||||
private boolean required;
|
||||
}
|
||||
|
||||
@Getter
|
||||
public static class Mod {
|
||||
/**
|
||||
* The id of this mod.
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* The version of this mod.
|
||||
*/
|
||||
private String version;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package xyz.mcutils.models.server;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor @Getter
|
||||
public class CachedServerBlockedStatus {
|
||||
/**
|
||||
* Whether the server is Mojang blocked.
|
||||
*/
|
||||
private boolean blocked;
|
||||
}
|
@ -0,0 +1,12 @@
|
||||
package xyz.mcutils.models.server;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor @Getter
|
||||
public class CachedServerIcon {
|
||||
/**
|
||||
* The bytes for the server icon.
|
||||
*/
|
||||
private byte[] bytes;
|
||||
}
|
97
src/main/java/xyz/mcutils/models/server/MinecraftServer.java
Normal file
97
src/main/java/xyz/mcutils/models/server/MinecraftServer.java
Normal file
@ -0,0 +1,97 @@
|
||||
package xyz.mcutils.models.server;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
import xyz.mcutils.models.dns.DNSRecord;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@Getter
|
||||
public class MinecraftServer {
|
||||
/**
|
||||
* The hostname of the server.
|
||||
*/
|
||||
private String hostname;
|
||||
|
||||
/**
|
||||
* The IP address of the server.
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* The port of the server.
|
||||
*/
|
||||
private int port;
|
||||
|
||||
/**
|
||||
* The DNS records for the server.
|
||||
*/
|
||||
private DNSRecord[] records;
|
||||
|
||||
/**
|
||||
* The motd for the server.
|
||||
*/
|
||||
private MOTD motd;
|
||||
|
||||
/**
|
||||
* The players on the server.
|
||||
*/
|
||||
private Players players;
|
||||
|
||||
@AllArgsConstructor @Getter
|
||||
private static class MOTD {
|
||||
|
||||
/**
|
||||
* The raw motd lines
|
||||
*/
|
||||
private String[] raw;
|
||||
|
||||
/**
|
||||
* The clean motd lines
|
||||
*/
|
||||
private String[] clean;
|
||||
|
||||
/**
|
||||
* The html motd lines
|
||||
*/
|
||||
private String[] html;
|
||||
}
|
||||
|
||||
/**
|
||||
* Player count data for a server.
|
||||
*/
|
||||
@Getter
|
||||
private static class Players {
|
||||
/**
|
||||
* The online players on this server.
|
||||
*/
|
||||
private int online;
|
||||
|
||||
/**
|
||||
* The maximum allowed players on this server.
|
||||
*/
|
||||
private int max;
|
||||
|
||||
/**
|
||||
* A sample of players on this server, null or empty if no sample.
|
||||
*/
|
||||
private Sample[] sample;
|
||||
|
||||
/**
|
||||
* A sample player.
|
||||
*/
|
||||
@Getter @ToString
|
||||
private static class Sample {
|
||||
/**
|
||||
* The unique id of this player.
|
||||
*/
|
||||
private UUID id;
|
||||
|
||||
/**
|
||||
* The name of this player.
|
||||
*/
|
||||
private String name;
|
||||
}
|
||||
}
|
||||
}
|
20
src/main/java/xyz/mcutils/models/server/ServerPlatform.java
Normal file
20
src/main/java/xyz/mcutils/models/server/ServerPlatform.java
Normal file
@ -0,0 +1,20 @@
|
||||
package xyz.mcutils.models.server;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum ServerPlatform {
|
||||
/**
|
||||
* The platform is Java Edition.
|
||||
*/
|
||||
JAVA,
|
||||
/**
|
||||
* The platform is Bedrock Edition.
|
||||
*/
|
||||
BEDROCK;
|
||||
|
||||
/**
|
||||
* The name of the platform.
|
||||
*/
|
||||
private final String name = name().toLowerCase();
|
||||
}
|
Reference in New Issue
Block a user