From 6229032bfa9567cee72764ebf0edd8a2351385f4 Mon Sep 17 00:00:00 2001 From: Petr Ilin Date: Wed, 7 Dec 2022 03:00:52 +0300 Subject: Improved check of whether player is premium --- src/main/java/net/elytrium/limboauth/Settings.java | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) (limited to 'src/main/java/net/elytrium/limboauth/Settings.java') diff --git a/src/main/java/net/elytrium/limboauth/Settings.java b/src/main/java/net/elytrium/limboauth/Settings.java index 8a34d3b..99bb2f0 100644 --- a/src/main/java/net/elytrium/limboauth/Settings.java +++ b/src/main/java/net/elytrium/limboauth/Settings.java @@ -139,12 +139,32 @@ public class Settings extends YamlConfig { @Comment({ "Custom isPremium URL", "You can use Mojang one's API (set by default)", - "Or CloudFlare one's: https://api.ashcon.app/mojang/v1/user/%s", + "Or CloudFlare one's: https://api.ashcon.app/mojang/v2/user/%s", "Or use this code to make your own API: https://blog.cloudflare.com/minecraft-api-with-workers-coffeescript/", - "Or implement your own API, it should just respond with HTTP code 200 only if the player is premium" + "Or implement your own API, it should just respond with HTTP code 200 (see parameters below) only if the player is premium" }) public String ISPREMIUM_AUTH_URL = "https://api.mojang.com/users/profiles/minecraft/%s"; + @Comment({ + "Status codes (see the comment above)", + "Responses with unlisted status codes will be identified as responses with a server error", + "Set 200 if you use using Mojang or CloudFlare API" + }) + public int STATUS_CODE_USER_EXISTS = 200; + @Comment("Set 204 if you use Mojang API, 404 if you use CloudFlare API") + public int STATUS_CODE_USER_NOT_EXISTS = 204; + @Comment("Set 429 if you use Mojang or CloudFlare API") + public int STATUS_CODE_RATE_LIMIT = 429; + + @Comment({ + "Sample Mojang API response: {\"name\":\"hevav\",\"id\":\"9c7024b2a48746b3b3934f397ae5d70f\"}", + "Sample CloudFlare API response: {\"uuid\":\"9c7024b2a48746b3b3934f397ae5d70f\",\"username\":\"hevav\", ...}", + "Responses with an invalid scheme will be identified as responses with a server error", + "Set this parameter to [], to disable JSON scheme validation" + }) + public List USER_EXISTS_JSON_VALIDATOR_FIELDS = List.of("name", "id"); + public List USER_NOT_EXISTS_JSON_VALIDATOR_FIELDS = List.of(); + @Comment({ "If Mojang rate-limits your server, we cannot determine if the player is premium or not", "This option allows you to choose whether every player will be defined as premium or as cracked while Mojang is rate-limiting the server", @@ -152,6 +172,13 @@ public class Settings extends YamlConfig { }) public boolean ON_RATE_LIMIT_PREMIUM = true; + @Comment({ + "If Mojang API is down, we cannot determine if the player is premium or not", + "This option allows you to choose whether every player will be defined as premium or as cracked while Mojang API is unavailable", + "True - as premium; False - as cracked" + }) + public boolean ON_SERVER_ERROR_PREMIUM = true; + public List REGISTER_COMMAND = List.of("/r", "/reg", "/register"); public List LOGIN_COMMAND = List.of("/l", "/log", "/login"); public List TOTP_COMMAND = List.of("/2fa", "/totp"); -- cgit