From c1074faeb27b9937ee309980bebb2ec4675e38f7 Mon Sep 17 00:00:00 2001 From: TheBusyBiscuit Date: Sun, 16 Jan 2022 14:17:50 +0100 Subject: [PATCH] Added `PlayerProfile#hasUnlockedEverything()` and also updated all workflows to JDK 17 --- .github/workflows/discord-webhook.yml | 4 ++-- .github/workflows/json-validator.yml | 2 +- .github/workflows/maven-compiler.yml | 4 ++-- .github/workflows/sonarcloud.yml | 4 ++-- CHANGELOG.md | 1 + .../slimefun4/api/player/PlayerProfile.java | 18 ++++++++++++++++++ 6 files changed, 26 insertions(+), 7 deletions(-) diff --git a/.github/workflows/discord-webhook.yml b/.github/workflows/discord-webhook.yml index 43ddc6a8d..371f4903c 100644 --- a/.github/workflows/discord-webhook.yml +++ b/.github/workflows/discord-webhook.yml @@ -20,11 +20,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v2.4.0 - - name: Set up Java JDK 16 + - name: Set up Java JDK 17 uses: actions/setup-java@v2.5.0 with: distribution: 'adopt' - java-version: '16' + java-version: '17' java-package: jdk architecture: x64 diff --git a/.github/workflows/json-validator.yml b/.github/workflows/json-validator.yml index de56bec67..caebee9fb 100644 --- a/.github/workflows/json-validator.yml +++ b/.github/workflows/json-validator.yml @@ -17,7 +17,7 @@ jobs: steps: - name: Checkout Repository uses: actions/checkout@v2 - - name: Validate JSON + - name: Validate wiki.json uses: docker://orrosenblatt/validate-json-action:latest@sha256:02370758b8b199e0477da11ecfdd498c75c561685056b5c31b925a4ab95df7f4 env: INPUT_SCHEMA: '.github/configs/wiki-schema.json' diff --git a/.github/workflows/maven-compiler.yml b/.github/workflows/maven-compiler.yml index c437ac846..163f0309b 100644 --- a/.github/workflows/maven-compiler.yml +++ b/.github/workflows/maven-compiler.yml @@ -23,11 +23,11 @@ jobs: - name: Checkout repository uses: actions/checkout@v2 - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v2.5.0 with: distribution: 'adopt' - java-version: '16' + java-version: '17' java-package: jdk architecture: x64 diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index af54263c5..8274ddd3f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -20,11 +20,11 @@ jobs: with: fetch-depth: 0 - - name: Set up JDK 16 + - name: Set up JDK 17 uses: actions/setup-java@v2.5.0 with: distribution: 'adopt' - java-version: '16' + java-version: '17' java-package: jdk architecture: x64 diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f2cb8279..90294cb17 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,7 @@ * Added Glow Lichen as a fuel type for the Bio-Generator * Added Spore Blossom as a fuel type for the Bio-Generator * Added a new item setting for Freezers to allow them to use a 9:1 "vanilla" ratio instead of 1:1 (1:1 by default, like before) +* (API) Added `PlayerProfile#hasUnlockedEverything()` to check if a player has unlocked all researches #### Changes * (API) `BiomeMapParser` is now `public` diff --git a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java index 49e374851..bd7543b84 100644 --- a/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java +++ b/src/main/java/io/github/thebusybiscuit/slimefun4/api/player/PlayerProfile.java @@ -192,6 +192,7 @@ public class PlayerProfile { * * @param research * The {@link Research} that is being queried + * * @return Whether this {@link Research} has been unlocked */ public boolean hasUnlocked(@Nullable Research research) { @@ -203,6 +204,23 @@ public class PlayerProfile { return !research.isEnabled() || researches.contains(research); } + /** + * This method returns whether this {@link Player} has unlocked all {@link Research Researches}. + * + * @return Whether they unlocked every {@link Research} + */ + public boolean hasUnlockedEverything() { + for (Research research : Slimefun.getRegistry().getResearches()) { + // If there is a single Research not unlocked: They haven't unlocked everything. + if (!hasUnlocked(research)) { + return false; + } + } + + // Player has everything unlocked - Hooray! + return true; + } + /** * This Method will return all Researches that this {@link Player} has unlocked *