diff --git a/Core/pom.xml b/Core/pom.xml index fdd87ea..a96adf4 100644 --- a/Core/pom.xml +++ b/Core/pom.xml @@ -19,6 +19,10 @@ sonatype-oss-snapshots https://oss.sonatype.org/content/repositories/snapshots/ + + opencollab-snapshot + https://repo.opencollab.dev/maven-snapshots/ + @@ -58,6 +62,14 @@ javaluator 3.0.3 + + + + org.geysermc.floodgate + api + 2.0-SNAPSHOT + provided + diff --git a/Core/src/main/java/fr/pandacube/lib/core/players/IOffPlayer.java b/Core/src/main/java/fr/pandacube/lib/core/players/IOffPlayer.java index ee1c602..a648be2 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/players/IOffPlayer.java +++ b/Core/src/main/java/fr/pandacube/lib/core/players/IOffPlayer.java @@ -18,10 +18,33 @@ public interface IOffPlayer { */ /** + * Return the ID of the minecraft account. + * * @return the id of the player */ public abstract UUID getUniqueId(); + + /** + * Tells if the current account is an alt account generated by Pandacube. + * + * An alt account uses a specific bit in the UUID to distinguish themselves from the original account. + */ + public default boolean isAltAccount() { + return (getUniqueId().getMostSignificantBits() & 0x8000L) == 0x8000L; + } + + /** + * Gets the index of the current alt account generated by Pandacube. + * + * The first generated alt account will be numbered 1, the second 2, ... + * + * This method will return undetermined value if {@link #isAltAccount()} is false. + */ + public default int getAltIndex() { + return (int) (getUniqueId().getMostSignificantBits() >> 8) & 0xF; + } + /** * @return the last known player name of this player, or null if this player never joined the network. */ @@ -38,6 +61,17 @@ public interface IOffPlayer { + /* + * Floodgate related stuff + */ + + public default boolean isBedrockAccount() { + int v = getUniqueId().version(); + return v == 0 || v == 8; // also 8 if one day we supports alt accounts for floodgate players + } + + + /* * Related class instances */ diff --git a/Core/src/main/java/fr/pandacube/lib/core/players/IOnlinePlayer.java b/Core/src/main/java/fr/pandacube/lib/core/players/IOnlinePlayer.java index 783aa7f..ae6fbf1 100644 --- a/Core/src/main/java/fr/pandacube/lib/core/players/IOnlinePlayer.java +++ b/Core/src/main/java/fr/pandacube/lib/core/players/IOnlinePlayer.java @@ -3,6 +3,9 @@ package fr.pandacube.lib.core.players; import java.util.Locale; import java.util.UUID; +import org.geysermc.floodgate.api.FloodgateApi; +import org.geysermc.floodgate.api.player.FloodgatePlayer; + import fr.pandacube.lib.core.chat.Chat; import fr.pandacube.lib.core.db.DBException; import net.kyori.adventure.identity.Identified; @@ -31,7 +34,26 @@ public interface IOnlinePlayer extends IOffPlayer { public abstract String getWorldName(); + + + /* + * Floodgate related + */ + + public default boolean isBedrockClient() { + return FloodgateApi.getInstance().isFloodgatePlayer(getUniqueId()); + } + + public default FloodgatePlayer getBedrockClient() { + return FloodgateApi.getInstance().getPlayer(getUniqueId()); + } + + + + /* + * Related class instances + */ /** * @throws IllegalStateException if the player was not found in the database (should never happen) @@ -49,14 +71,6 @@ public interface IOnlinePlayer extends IOffPlayer { - /* - * Related class instances - */ - - - - - /*