From 9cc25f9eeb85a787a9ec2e7c671a3e0c7dd5e5c3 Mon Sep 17 00:00:00 2001 From: samo_lego <34912839+samolego@users.noreply.github.com> Date: Thu, 15 Oct 2020 21:47:28 +0200 Subject: [PATCH] Compiling + javadoc fixes --- .../simpleauth/commands/LogoutCommand.java | 9 ---- .../simpleauth/storage/AuthConfig.java | 4 +- .../simpleauth/utils/PlayerAuth.java | 45 +++++++++++++++++++ 3 files changed, 47 insertions(+), 11 deletions(-) diff --git a/src/main/java/org/samo_lego/simpleauth/commands/LogoutCommand.java b/src/main/java/org/samo_lego/simpleauth/commands/LogoutCommand.java index f0b5665..4266829 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/LogoutCommand.java +++ b/src/main/java/org/samo_lego/simpleauth/commands/LogoutCommand.java @@ -5,12 +5,10 @@ import com.mojang.brigadier.exceptions.CommandSyntaxException; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.LiteralText; -import org.samo_lego.simpleauth.storage.PlayerCache; import org.samo_lego.simpleauth.utils.PlayerAuth; import static net.minecraft.server.command.CommandManager.literal; import static org.samo_lego.simpleauth.SimpleAuth.config; -import static org.samo_lego.simpleauth.SimpleAuth.playerCacheMap; public class LogoutCommand { @@ -23,13 +21,6 @@ public class LogoutCommand { private static int logout(ServerCommandSource serverCommandSource) throws CommandSyntaxException { ServerPlayerEntity player = serverCommandSource.getPlayer(); - PlayerCache playerCache = playerCacheMap.get(((PlayerAuth) player).getFakeUuid()); - playerCache.lastLocation.lastDim = String.valueOf(player.getEntityWorld().getRegistryKey().getValue()); - playerCache.lastLocation.lastX = player.getX(); - playerCache.lastLocation.lastY = player.getY(); - playerCache.lastLocation.lastZ = player.getZ(); - playerCache.lastLocation.yaw = player.yaw; - playerCache.lastLocation.pitch = player.pitch; ((PlayerAuth) player).setAuthenticated(false); player.sendMessage(new LiteralText(config.lang.successfulLogout), false); diff --git a/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java b/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java index 1aeaace..7b58941 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java +++ b/src/main/java/org/samo_lego/simpleauth/storage/AuthConfig.java @@ -86,12 +86,12 @@ public class AuthConfig { public boolean allowFalling = false; /** - * Whether to tp player to spawn when joining (to hide coordinates) + * Whether to tp player to spawn when joining (to hide original player coordinates) */ public boolean spawnOnJoin = false; /** - * Data for spawn (where deauthenticated players are teleported). + * Data for spawn (where deauthenticated players are teleported temporarily). * @see wiki */ public static class WorldSpawn { diff --git a/src/main/java/org/samo_lego/simpleauth/utils/PlayerAuth.java b/src/main/java/org/samo_lego/simpleauth/utils/PlayerAuth.java index 1fbf435..6aebecc 100644 --- a/src/main/java/org/samo_lego/simpleauth/utils/PlayerAuth.java +++ b/src/main/java/org/samo_lego/simpleauth/utils/PlayerAuth.java @@ -2,15 +2,60 @@ package org.samo_lego.simpleauth.utils; import net.minecraft.text.Text; +/** + * PLayer authentication extension. + */ public interface PlayerAuth { + /** + * Teleports player to spawn or last location that is recorded. + * Last location means the location before de-authentication. + * + * @param hide whether to teleport player to spawn (provided in config) or last recorded position + * @see See implementation + */ void hidePosition(boolean hide); + /** + * Converts player uuid, to ensure player with "nAmE" and "NamE" get same uuid. + * Both players are not allowed to play, since mod mimics Mojang behaviour. + * of not allowing accounts with same names but different capitalization. + * + * @return converted UUID as string + * @see See implementation + */ String getFakeUuid(); + + /** + * Sets the authentication status of the player. + * + * @param authenticated whether player should be authenticated + * @see See implementation + */ void setAuthenticated(boolean authenticated); + + /** + * Checks whether player is authenticated. + * + * @return false if player is not authenticated, otherwise true. + * @see See implementation + */ boolean isAuthenticated(); + /** + * Gets the text which tells the player + * to login or register, depending on account status. + * + * @return LiteralText with appropriate string (login or register) + * @see See implementation + */ Text getAuthMessage(); + /** + * Checks whether player is a fake player (from CarpetMod). + * + * @return true if player is fake (can skip authentication process), otherwise false + * @see See implementation + */ boolean canSkipAuth(); }