feat: add global & server leveling, quests, achievements, guilds land-claiming, social & toggleable configs
This commit is contained in:
1 parent
4b79f69c20
commit
b4cef85b1f
40 files changed
+10261
-27
No files matched your search
@@ -9,6 +9,7 @@ import java.util.function.*;
|
||||
public final class Integration implements AutoCloseable {
|
||||
public static final String UNAVAILABLE = "SCOPENET sign-in is unavailable. Please try again shortly.";
|
||||
public final Activity activity = new Activity();
|
||||
private final Settings settings;
|
||||
private final PanelClient client;
|
||||
private final JsonObject hello;
|
||||
private final Consumer<String> log;
|
||||
@@ -27,6 +28,7 @@ public final class Integration implements AutoCloseable {
|
||||
public Integration(Settings settings, String software, String mcVersion, String version,
|
||||
boolean onlineMode, int maxPlayers, Consumer<String> log, BiConsumer<UUID, String> kick) {
|
||||
if (!onlineMode) throw new IllegalArgumentException("SCOPENET requires online-mode=true and authlib-injector");
|
||||
this.settings = settings;
|
||||
this.client = new PanelClient(settings);
|
||||
this.log = log;
|
||||
this.kick = kick;
|
||||
@@ -72,7 +74,10 @@ public final class Integration implements AutoCloseable {
|
||||
try { sync(tps); }
|
||||
catch (Exception e) {
|
||||
if (e instanceof InterruptedException) Thread.currentThread().interrupt();
|
||||
log.accept("SCOPENET sync failed; retained batch will be retried (" + e.getClass().getSimpleName() + ")");
|
||||
String msg = e.getMessage() != null && !e.getMessage().isBlank()
|
||||
? e.getClass().getSimpleName() + ": " + e.getMessage()
|
||||
: e.getClass().getSimpleName();
|
||||
log.accept("SCOPENET sync failed to connect to panel at " + settings.panel() + "; retained batch will be retried (" + msg + ")");
|
||||
} finally { syncing.set(false); }
|
||||
});
|
||||
}
|
||||
@@ -83,7 +88,19 @@ public final class Integration implements AutoCloseable {
|
||||
if (!response.has("server_id")) throw new IllegalStateException("Invalid hello response");
|
||||
registered = true;
|
||||
}
|
||||
if (pending == null) pending = activity.drain(tps);
|
||||
if (pending == null) {
|
||||
pending = activity.drain(tps);
|
||||
JsonObject features = new JsonObject();
|
||||
features.addProperty("leveling_enabled", settings.levelingEnabled());
|
||||
features.addProperty("global_xp_multiplier", settings.globalXpMultiplier());
|
||||
features.addProperty("server_xp_multiplier", settings.serverXpMultiplier());
|
||||
features.addProperty("quests_enabled", settings.questsEnabled());
|
||||
features.addProperty("achievements_enabled", settings.achievementsEnabled());
|
||||
features.addProperty("guilds_enabled", settings.guildsEnabled());
|
||||
features.addProperty("land_claiming_enabled", settings.landClaimingEnabled());
|
||||
features.addProperty("social_enabled", settings.socialEnabled());
|
||||
pending.add("features", features);
|
||||
}
|
||||
JsonObject response = client.post("sync", pending);
|
||||
if (!response.has("ok") || !response.get("ok").getAsBoolean() || !response.has("kick")
|
||||
|| !response.get("kick").isJsonArray()) throw new IllegalStateException("Invalid sync response");
|
||||
@@ -98,6 +115,14 @@ public final class Integration implements AutoCloseable {
|
||||
}
|
||||
}
|
||||
|
||||
public Settings settings() {
|
||||
return settings;
|
||||
}
|
||||
|
||||
public ChunkCheckResult checkChunk(String dimension, int chunkX, int chunkZ, UUID uuid) {
|
||||
return client.checkChunk(dimension, chunkX, chunkZ, uuid);
|
||||
}
|
||||
|
||||
@Override public void close() {
|
||||
closed = true;
|
||||
loginWorker.shutdownNow();
|
||||
|
||||
Reference in new issue
Block a user