1
0
mirror of https://github.com/GeyserMC/Floodgate.git synced 2025-12-19 14:59:20 +00:00

Added PMD Plugin and changed isBedrockPlayer to isFloodgatePlayer

This commit is contained in:
Tim203
2021-01-16 16:52:04 +01:00
parent 4cf92c6551
commit b737184fb0
44 changed files with 392 additions and 225 deletions

View File

@@ -36,7 +36,7 @@ public interface FloodgateApi {
* Returns the Floodgate API instance.
*/
static FloodgateApi getInstance() {
return InstanceHolder.getInstance();
return InstanceHolder.getApi();
}
/**
@@ -45,7 +45,7 @@ public interface FloodgateApi {
* @param uuid The uuid of the <b>online</b> player
* @return true if the given <b>online</b> player is a Bedrock player
*/
boolean isBedrockPlayer(UUID uuid);
boolean isFloodgatePlayer(UUID uuid);
/**
* Get info about the given Bedrock player
@@ -66,7 +66,7 @@ public interface FloodgateApi {
/**
* Checks if the uuid of the player has the {@link #createJavaPlayerId(long)} format. This
* method can't validate a linked player uuid, since that doesn't equal the format. Use {@link
* #isBedrockPlayer(UUID)} if you want to include linked accounts.
* #isFloodgatePlayer(UUID)} if you want to include linked accounts.
*
* @param uuid the uuid to check
* @return true if the given uuid has the correct format.

View File

@@ -32,25 +32,28 @@ import org.geysermc.floodgate.api.inject.PlatformInjector;
import org.geysermc.floodgate.api.link.PlayerLink;
public final class InstanceHolder {
@Getter private static FloodgateApi instance;
@Getter private static FloodgateApi api;
@Getter private static PlayerLink playerLink;
@Getter private static PlatformInjector injector;
@Getter private static HandshakeHandlers handshakeHandlers;
private static UUID key;
private static UUID storedKey;
public static boolean setInstance(
public static boolean set(
FloodgateApi floodgateApi,
PlayerLink link,
PlatformInjector platformInjector,
HandshakeHandlers handshakeHandlers,
UUID key
) {
if (instance == null) {
InstanceHolder.key = key;
} else if (!InstanceHolder.key.equals(key)) {
return false;
UUID key) {
if (storedKey != null) {
if (!storedKey.equals(key)) {
return false;
}
} else {
storedKey = key;
}
instance = floodgateApi;
api = floodgateApi;
playerLink = link;
injector = platformInjector;
InstanceHolder.handshakeHandlers = handshakeHandlers;
@@ -59,6 +62,6 @@ public final class InstanceHolder {
@SuppressWarnings("unchecked")
public static <T extends FloodgateApi> T castApi(Class<T> cast) {
return (T) instance;
return (T) api;
}
}

View File

@@ -27,6 +27,7 @@ package org.geysermc.floodgate.api.link;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.geysermc.floodgate.util.LinkedPlayer;
/**
@@ -49,7 +50,8 @@ public interface PlayerLink {
* @return a completable future with the {@link LinkedPlayer}. The future will have a null value
* if that Bedrock player isn't linked
*/
CompletableFuture<LinkedPlayer> getLinkedPlayer(UUID bedrockId);
@NonNull
CompletableFuture<LinkedPlayer> getLinkedPlayer(@NonNull UUID bedrockId);
/**
* Tells if the given player is a linked player
@@ -57,7 +59,8 @@ public interface PlayerLink {
* @param playerId the uuid of the player to check, can be both a Java or a Bedrock uuid
* @return true if the player is a linked player
*/
CompletableFuture<Boolean> isLinkedPlayer(UUID playerId);
@NonNull
CompletableFuture<Boolean> isLinkedPlayer(@NonNull UUID playerId);
/**
* Links a Java account to a Bedrock account.
@@ -67,7 +70,11 @@ public interface PlayerLink {
* @param username the username of the Java player
* @return a future holding void on success or completed exceptionally when failed
*/
CompletableFuture<Void> linkPlayer(UUID bedrockId, UUID javaId, String username);
@NonNull
CompletableFuture<Void> linkPlayer(
@NonNull UUID bedrockId,
@NonNull UUID javaId,
@NonNull String username);
/**
* Unlinks a Java account from a Bedrock account.
@@ -75,7 +82,8 @@ public interface PlayerLink {
* @param javaId the uuid of the Java player
* @return a future holding void on success or completed exceptionally when failed
*/
CompletableFuture<Void> unlinkPlayer(UUID javaId);
@NonNull
CompletableFuture<Void> unlinkPlayer(@NonNull UUID javaId);
/**
* Creates a link request for the given Java player.
@@ -86,10 +94,11 @@ public interface PlayerLink {
* @return a future holding the result of the link request which will be a {@link
* LinkRequestResult} on failure and the link code (string) on success
*/
@NonNull
CompletableFuture<?> createLinkRequest(
UUID javaId,
String javaUsername,
String bedrockUsername
@NonNull UUID javaId,
@NonNull String javaUsername,
@NonNull String bedrockUsername
);
/**
@@ -101,11 +110,12 @@ public interface PlayerLink {
* @param code the code created in {@link #createLinkRequest(UUID, String, String)}
* @return a future holding the result of the link verification
*/
@NonNull
CompletableFuture<LinkRequestResult> verifyLinkRequest(
UUID bedrockId,
String javaUsername,
String bedrockUsername,
String code
@NonNull UUID bedrockId,
@NonNull String javaUsername,
@NonNull String bedrockUsername,
@NonNull String code
);
/**

View File

@@ -51,18 +51,6 @@ public class PropertyKey {
this.removable = removable;
}
@Override
public boolean equals(Object obj) {
if (obj instanceof PropertyKey) {
return key.equals(((PropertyKey) obj).key);
}
if (obj instanceof String) {
return key.equals(obj);
}
return false;
}
public Result isAddAllowed(Object obj) { //todo use for add and remove
if (obj instanceof PropertyKey) {
PropertyKey propertyKey = (PropertyKey) obj;