From 6e148958eca7be913650346c6f3d4e1288ff2e7b Mon Sep 17 00:00:00 2001 From: NikitaCartes Date: Thu, 15 Jul 2021 13:02:10 +0300 Subject: [PATCH] Raname packages --- README.md | 4 +- build.gradle | 2 +- .../nikitacartes/easyauth/EasyAuth.java} | 30 +++--- .../easyauth}/commands/AccountCommand.java | 8 +- .../easyauth}/commands/AuthCommand.java | 94 +++++++++---------- .../easyauth}/commands/LoginCommand.java | 8 +- .../easyauth}/commands/LogoutCommand.java | 8 +- .../easyauth}/commands/RegisterCommand.java | 38 ++++---- .../easyauth}/event/AuthEventHandler.java | 52 +++++----- .../mixin/MixinPlayerAdvancementTracker.java | 11 +-- .../easyauth}/mixin/MixinPlayerManager.java | 8 +- .../mixin/MixinServerLoginNetworkHandler.java | 19 ++-- .../mixin/MixinServerPlayNetworkHandler.java | 4 +- .../mixin/MixinServerPlayerEntity.java | 63 ++++++------- .../easyauth}/mixin/MixinSlot.java | 4 +- .../mixin/MixinWorldSaveHandler.java | 20 ++-- .../mixin/ServerStatHandlerAccessor.java | 2 +- .../easyauth}/storage/AuthConfig.java | 28 +++--- .../easyauth}/storage/DBHelper.java | 12 +-- .../easyauth}/storage/PlayerCache.java | 15 +-- .../easyauth}/storage/database/LevelDB.java | 27 +++--- .../easyauth}/storage/database/MongoDB.java | 6 +- .../easyauth}/utils/AuthHelper.java | 10 +- .../easyauth}/utils/CarpetHelper.java | 2 +- .../easyauth/utils/EasyLogger.java} | 4 +- .../easyauth}/utils/PlayerAuth.java | 2 +- .../easyauth}/utils/hashing/HasherArgon2.java | 9 +- .../easyauth}/utils/hashing/HasherBCrypt.java | 9 +- ...h.accesswidener => easyauth.accesswidener} | 0 src/main/resources/fabric.mod.json | 6 +- ...s.simpleauth.json => mixins.easyauth.json} | 2 +- 31 files changed, 247 insertions(+), 260 deletions(-) rename src/main/java/{org/samo_lego/simpleauth/SimpleAuth.java => xyz/nikitacartes/easyauth/EasyAuth.java} (84%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/commands/AccountCommand.java (96%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/commands/AuthCommand.java (75%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/commands/LoginCommand.java (94%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/commands/LogoutCommand.java (84%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/commands/RegisterCommand.java (57%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/event/AuthEventHandler.java (78%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/mixin/MixinPlayerAdvancementTracker.java (77%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/mixin/MixinPlayerManager.java (94%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/mixin/MixinServerLoginNetworkHandler.java (84%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/mixin/MixinServerPlayNetworkHandler.java (97%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/mixin/MixinServerPlayerEntity.java (75%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/mixin/MixinSlot.java (93%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/mixin/MixinWorldSaveHandler.java (83%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/mixin/ServerStatHandlerAccessor.java (90%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/storage/AuthConfig.java (90%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/storage/DBHelper.java (88%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/storage/PlayerCache.java (82%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/storage/database/LevelDB.java (81%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/storage/database/MongoDB.java (95%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/utils/AuthHelper.java (85%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/utils/CarpetHelper.java (90%) rename src/main/java/{org/samo_lego/simpleauth/utils/SimpleLogger.java => xyz/nikitacartes/easyauth/utils/EasyLogger.java} (83%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/utils/PlayerAuth.java (98%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/utils/hashing/HasherArgon2.java (80%) rename src/main/java/{org/samo_lego/simpleauth => xyz/nikitacartes/easyauth}/utils/hashing/HasherBCrypt.java (77%) rename src/main/resources/{simpleauth.accesswidener => easyauth.accesswidener} (100%) rename src/main/resources/{mixins.simpleauth.json => mixins.easyauth.json} (89%) diff --git a/README.md b/README.md index 92253917..29258e98 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@ -## Simple Authentication Mod +## Easy Authentication Mod Since samo_lego deprecated his mod, I consider updating it to the latest version. For Minecraft 1.16 and below you can check [original repository](https://github.com/samolego/SimpleAuth). -See [wiki](https://github.com/samolego/SimpleAuth/wiki) for more information. +See [wiki](https://github.com/NikitaCartes/EasyAuth/wiki) for more information. ## License Libraries that the project is using: diff --git a/build.gradle b/build.gradle index a4c6a590..d7ecfb1d 100644 --- a/build.gradle +++ b/build.gradle @@ -17,7 +17,7 @@ minecraft { } loom { - accessWidener("src/main/resources/simpleauth.accesswidener") + accessWidener("src/main/resources/easyauth.accesswidener") } // Declare dependencies diff --git a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java b/src/main/java/xyz/nikitacartes/easyauth/EasyAuth.java similarity index 84% rename from src/main/java/org/samo_lego/simpleauth/SimpleAuth.java rename to src/main/java/xyz/nikitacartes/easyauth/EasyAuth.java index 163cd58e..5acb4102 100644 --- a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java +++ b/src/main/java/xyz/nikitacartes/easyauth/EasyAuth.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth; +package xyz.nikitacartes.easyauth; import net.fabricmc.api.ModInitializer; import net.fabricmc.fabric.api.command.v1.CommandRegistrationCallback; @@ -6,11 +6,12 @@ import net.fabricmc.fabric.api.event.player.*; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.server.MinecraftServer; -import org.samo_lego.simpleauth.commands.*; -import org.samo_lego.simpleauth.event.AuthEventHandler; -import org.samo_lego.simpleauth.storage.AuthConfig; -import org.samo_lego.simpleauth.storage.DBHelper; -import org.samo_lego.simpleauth.storage.PlayerCache; +import xyz.nikitacartes.easyauth.commands.*; +import xyz.nikitacartes.easyauth.event.AuthEventHandler; +import xyz.nikitacartes.easyauth.storage.AuthConfig; +import xyz.nikitacartes.easyauth.storage.DBHelper; +import xyz.nikitacartes.easyauth.storage.PlayerCache; +import xyz.nikitacartes.easyauth.utils.EasyLogger; import java.io.File; import java.io.FileReader; @@ -23,10 +24,7 @@ import java.util.concurrent.Executors; import java.util.concurrent.TimeUnit; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logError; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo; - -public class SimpleAuth implements ModInitializer { +public class EasyAuth implements ModInitializer { public static final String MOD_ID = "easyauth"; @@ -61,14 +59,14 @@ public class SimpleAuth implements ModInitializer { public static void init(Path gameDir) { gameDirectory = gameDir; - logInfo("EasyAuth mod by samo_lego, NikitaCartes."); + EasyLogger.logInfo("EasyAuth mod by samo_lego, NikitaCartes."); // The support on discord was great! I really appreciate your help. // logInfo("This mod wouldn't exist without the awesome Fabric Community. TYSM guys!"); try { serverProp.load(new FileReader(gameDirectory + "/server.properties")); } catch (IOException e) { - logError("Error while reading server properties: " + e.getMessage()); + EasyLogger.logError("Error while reading server properties: " + e.getMessage()); } // Creating data directory (database and config files are stored there) @@ -85,7 +83,7 @@ public static void init(Path gameDir) { * Called on server stop. */ public static void stop() { - logInfo("Shutting down EasyAuth."); + EasyLogger.logInfo("Shutting down EasyAuth."); DB.saveAll(playerCacheMap); // Closing threads @@ -95,7 +93,7 @@ public static void stop() { Thread.currentThread().interrupt(); } } catch (InterruptedException e) { - logError(e.getMessage()); + EasyLogger.logError(e.getMessage()); THREADPOOL.shutdownNow(); } @@ -105,7 +103,7 @@ public static void stop() { @Override public void onInitialize() { - SimpleAuth.init(FabricLoader.getInstance().getGameDir()); + EasyAuth.init(FabricLoader.getInstance().getGameDir()); // Registering the commands CommandRegistrationCallback.EVENT.register((dispatcher, dedicated) -> { @@ -127,6 +125,6 @@ public void onInitialize() { } private void onStopServer(MinecraftServer server) { - SimpleAuth.stop(); + EasyAuth.stop(); } } diff --git a/src/main/java/org/samo_lego/simpleauth/commands/AccountCommand.java b/src/main/java/xyz/nikitacartes/easyauth/commands/AccountCommand.java similarity index 96% rename from src/main/java/org/samo_lego/simpleauth/commands/AccountCommand.java rename to src/main/java/xyz/nikitacartes/easyauth/commands/AccountCommand.java index c5ed2947..4cd39f65 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/AccountCommand.java +++ b/src/main/java/xyz/nikitacartes/easyauth/commands/AccountCommand.java @@ -1,18 +1,18 @@ -package org.samo_lego.simpleauth.commands; +package xyz.nikitacartes.easyauth.commands; import com.mojang.brigadier.CommandDispatcher; 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.utils.AuthHelper; -import org.samo_lego.simpleauth.utils.PlayerAuth; +import xyz.nikitacartes.easyauth.utils.AuthHelper; +import xyz.nikitacartes.easyauth.utils.PlayerAuth; import static com.mojang.brigadier.arguments.StringArgumentType.getString; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; -import static org.samo_lego.simpleauth.SimpleAuth.*; +import static xyz.nikitacartes.easyauth.EasyAuth.*; public class AccountCommand { diff --git a/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java b/src/main/java/xyz/nikitacartes/easyauth/commands/AuthCommand.java similarity index 75% rename from src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java rename to src/main/java/xyz/nikitacartes/easyauth/commands/AuthCommand.java index dfa8423f..3333b064 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java +++ b/src/main/java/xyz/nikitacartes/easyauth/commands/AuthCommand.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.commands; +package xyz.nikitacartes.easyauth.commands; import com.mojang.brigadier.CommandDispatcher; import net.minecraft.command.argument.BlockPosArgumentType; @@ -9,9 +9,11 @@ import net.minecraft.server.command.ServerCommandSource; import net.minecraft.text.LiteralText; import net.minecraft.util.Identifier; -import org.samo_lego.simpleauth.storage.AuthConfig; -import org.samo_lego.simpleauth.storage.PlayerCache; -import org.samo_lego.simpleauth.utils.AuthHelper; +import xyz.nikitacartes.easyauth.EasyAuth; +import xyz.nikitacartes.easyauth.storage.AuthConfig; +import xyz.nikitacartes.easyauth.storage.PlayerCache; +import xyz.nikitacartes.easyauth.utils.AuthHelper; +import xyz.nikitacartes.easyauth.utils.EasyLogger; import java.io.File; @@ -19,8 +21,6 @@ import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; -import static org.samo_lego.simpleauth.SimpleAuth.*; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo; public class AuthCommand { @@ -110,12 +110,12 @@ public static void registerCommand(CommandDispatcher dispat * @return 0 */ public static int reloadConfig(Entity sender) { - config = AuthConfig.load(new File("./mods/EasyAuth/config.json")); + EasyAuth.config = AuthConfig.load(new File("./mods/EasyAuth/config.json")); if(sender != null) - ((PlayerEntity) sender).sendMessage(new LiteralText(config.lang.configurationReloaded), false); + ((PlayerEntity) sender).sendMessage(new LiteralText(EasyAuth.config.lang.configurationReloaded), false); else - logInfo(config.lang.configurationReloaded); + EasyLogger.logInfo(EasyAuth.config.lang.configurationReloaded); return 1; } @@ -130,17 +130,17 @@ private static int setGlobalPassword(ServerCommandSource source, String password // Getting the player who send the command Entity sender = source.getEntity(); // Different thread to avoid lag spikes - THREADPOOL.submit(() -> { + EasyAuth.THREADPOOL.submit(() -> { // Writing the global pass to config - config.main.globalPassword = AuthHelper.hashPassword(password.toCharArray()); - config.main.enableGlobalPassword = true; - config.save(new File("./mods/EasyAuth/config.json")); + EasyAuth.config.main.globalPassword = AuthHelper.hashPassword(password.toCharArray()); + EasyAuth.config.main.enableGlobalPassword = true; + EasyAuth.config.save(new File("./mods/EasyAuth/config.json")); }); if(sender != null) - ((PlayerEntity) sender).sendMessage(new LiteralText(config.lang.globalPasswordSet), false); + ((PlayerEntity) sender).sendMessage(new LiteralText(EasyAuth.config.lang.globalPasswordSet), false); else - logInfo(config.lang.globalPasswordSet); + EasyLogger.logInfo(EasyAuth.config.lang.globalPasswordSet); return 1; } @@ -158,21 +158,21 @@ private static int setGlobalPassword(ServerCommandSource source, String password */ private static int setSpawn(ServerCommandSource source, Identifier world, double x, double y, double z, float yaw, float pitch) { // Setting config values and saving - config.worldSpawn.dimension = String.valueOf(world); - config.worldSpawn.x = x; - config.worldSpawn.y = y; - config.worldSpawn.z = z; - config.worldSpawn.yaw = yaw; - config.worldSpawn.pitch = pitch; - config.main.spawnOnJoin = true; - config.save(new File("./mods/EasyAuth/config.json")); + EasyAuth.config.worldSpawn.dimension = String.valueOf(world); + EasyAuth.config.worldSpawn.x = x; + EasyAuth.config.worldSpawn.y = y; + EasyAuth.config.worldSpawn.z = z; + EasyAuth.config.worldSpawn.yaw = yaw; + EasyAuth.config.worldSpawn.pitch = pitch; + EasyAuth.config.main.spawnOnJoin = true; + EasyAuth.config.save(new File("./mods/EasyAuth/config.json")); // Getting sender Entity sender = source.getEntity(); if(sender != null) - ((PlayerEntity) sender).sendMessage(new LiteralText(config.lang.worldSpawnSet), false); + ((PlayerEntity) sender).sendMessage(new LiteralText(EasyAuth.config.lang.worldSpawnSet), false); else - logInfo(config.lang.worldSpawnSet); + EasyLogger.logInfo(EasyAuth.config.lang.worldSpawnSet); return 1; } @@ -185,15 +185,15 @@ private static int setSpawn(ServerCommandSource source, Identifier world, double */ private static int removeAccount(ServerCommandSource source, String uuid) { Entity sender = source.getEntity(); - THREADPOOL.submit(() -> { - DB.deleteUserData(uuid); - playerCacheMap.put(uuid, null); + EasyAuth.THREADPOOL.submit(() -> { + EasyAuth.DB.deleteUserData(uuid); + EasyAuth.playerCacheMap.put(uuid, null); }); if(sender != null) - ((PlayerEntity) sender).sendMessage(new LiteralText(config.lang.userdataDeleted), false); + ((PlayerEntity) sender).sendMessage(new LiteralText(EasyAuth.config.lang.userdataDeleted), false); else - logInfo(config.lang.userdataDeleted); + EasyLogger.logInfo(EasyAuth.config.lang.userdataDeleted); return 1; // Success } @@ -209,22 +209,22 @@ private static int registerUser(ServerCommandSource source, String uuid, String // Getting the player who send the command Entity sender = source.getEntity(); - THREADPOOL.submit(() -> { + EasyAuth.THREADPOOL.submit(() -> { PlayerCache playerCache; - if(playerCacheMap.containsKey(uuid)) { - playerCache = playerCacheMap.get(uuid); + if(EasyAuth.playerCacheMap.containsKey(uuid)) { + playerCache = EasyAuth.playerCacheMap.get(uuid); } else { playerCache = PlayerCache.fromJson(null, uuid); } - playerCacheMap.put(uuid, playerCache); - playerCacheMap.get(uuid).password = AuthHelper.hashPassword(password.toCharArray()); + EasyAuth.playerCacheMap.put(uuid, playerCache); + EasyAuth.playerCacheMap.get(uuid).password = AuthHelper.hashPassword(password.toCharArray()); if (sender != null) - ((PlayerEntity) sender).sendMessage(new LiteralText(config.lang.userdataUpdated), false); + ((PlayerEntity) sender).sendMessage(new LiteralText(EasyAuth.config.lang.userdataUpdated), false); else - logInfo(config.lang.userdataUpdated); + EasyLogger.logInfo(EasyAuth.config.lang.userdataUpdated); }); return 0; } @@ -241,29 +241,29 @@ private static int updatePassword(ServerCommandSource source, String uuid, Strin // Getting the player who send the command Entity sender = source.getEntity(); - THREADPOOL.submit(() -> { + EasyAuth.THREADPOOL.submit(() -> { PlayerCache playerCache; - if(playerCacheMap.containsKey(uuid)) { - playerCache = playerCacheMap.get(uuid); + if(EasyAuth.playerCacheMap.containsKey(uuid)) { + playerCache = EasyAuth.playerCacheMap.get(uuid); } else { playerCache = PlayerCache.fromJson(null, uuid); } - playerCacheMap.put(uuid, playerCache); - if(!playerCacheMap.get(uuid).password.isEmpty()) { + EasyAuth.playerCacheMap.put(uuid, playerCache); + if(!EasyAuth.playerCacheMap.get(uuid).password.isEmpty()) { if (sender != null) - ((PlayerEntity) sender).sendMessage(new LiteralText(config.lang.userNotRegistered), false); + ((PlayerEntity) sender).sendMessage(new LiteralText(EasyAuth.config.lang.userNotRegistered), false); else - logInfo(config.lang.userNotRegistered); + EasyLogger.logInfo(EasyAuth.config.lang.userNotRegistered); return; } - playerCacheMap.get(uuid).password = AuthHelper.hashPassword(password.toCharArray()); + EasyAuth.playerCacheMap.get(uuid).password = AuthHelper.hashPassword(password.toCharArray()); if (sender != null) - ((PlayerEntity) sender).sendMessage(new LiteralText(config.lang.userdataUpdated), false); + ((PlayerEntity) sender).sendMessage(new LiteralText(EasyAuth.config.lang.userdataUpdated), false); else - logInfo(config.lang.userdataUpdated); + EasyLogger.logInfo(EasyAuth.config.lang.userdataUpdated); }); return 0; } diff --git a/src/main/java/org/samo_lego/simpleauth/commands/LoginCommand.java b/src/main/java/xyz/nikitacartes/easyauth/commands/LoginCommand.java similarity index 94% rename from src/main/java/org/samo_lego/simpleauth/commands/LoginCommand.java rename to src/main/java/xyz/nikitacartes/easyauth/commands/LoginCommand.java index 5571c2a6..8d9fcd27 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/LoginCommand.java +++ b/src/main/java/xyz/nikitacartes/easyauth/commands/LoginCommand.java @@ -1,18 +1,18 @@ -package org.samo_lego.simpleauth.commands; +package xyz.nikitacartes.easyauth.commands; import com.mojang.brigadier.CommandDispatcher; 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.utils.AuthHelper; -import org.samo_lego.simpleauth.utils.PlayerAuth; +import xyz.nikitacartes.easyauth.utils.AuthHelper; +import xyz.nikitacartes.easyauth.utils.PlayerAuth; import static com.mojang.brigadier.arguments.StringArgumentType.getString; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; -import static org.samo_lego.simpleauth.SimpleAuth.*; +import static xyz.nikitacartes.easyauth.EasyAuth.*; public class LoginCommand { diff --git a/src/main/java/org/samo_lego/simpleauth/commands/LogoutCommand.java b/src/main/java/xyz/nikitacartes/easyauth/commands/LogoutCommand.java similarity index 84% rename from src/main/java/org/samo_lego/simpleauth/commands/LogoutCommand.java rename to src/main/java/xyz/nikitacartes/easyauth/commands/LogoutCommand.java index d9dac8c1..b07f6df5 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/LogoutCommand.java +++ b/src/main/java/xyz/nikitacartes/easyauth/commands/LogoutCommand.java @@ -1,15 +1,15 @@ -package org.samo_lego.simpleauth.commands; +package xyz.nikitacartes.easyauth.commands; import com.mojang.brigadier.CommandDispatcher; 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.utils.PlayerAuth; +import xyz.nikitacartes.easyauth.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.mojangAccountNamesCache; +import static xyz.nikitacartes.easyauth.EasyAuth.config; +import static xyz.nikitacartes.easyauth.EasyAuth.mojangAccountNamesCache; public class LogoutCommand { diff --git a/src/main/java/org/samo_lego/simpleauth/commands/RegisterCommand.java b/src/main/java/xyz/nikitacartes/easyauth/commands/RegisterCommand.java similarity index 57% rename from src/main/java/org/samo_lego/simpleauth/commands/RegisterCommand.java rename to src/main/java/xyz/nikitacartes/easyauth/commands/RegisterCommand.java index 0ff9373e..7bb16f2f 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/RegisterCommand.java +++ b/src/main/java/xyz/nikitacartes/easyauth/commands/RegisterCommand.java @@ -1,19 +1,19 @@ -package org.samo_lego.simpleauth.commands; +package xyz.nikitacartes.easyauth.commands; import com.mojang.brigadier.CommandDispatcher; 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 xyz.nikitacartes.easyauth.EasyAuth; +import xyz.nikitacartes.easyauth.storage.PlayerCache; +import xyz.nikitacartes.easyauth.utils.PlayerAuth; +import xyz.nikitacartes.easyauth.utils.AuthHelper; import static com.mojang.brigadier.arguments.StringArgumentType.getString; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; -import static org.samo_lego.simpleauth.SimpleAuth.*; -import static org.samo_lego.simpleauth.utils.AuthHelper.hashPassword; public class RegisterCommand { @@ -27,7 +27,7 @@ public static void registerCommand(CommandDispatcher dispat .executes( ctx -> register(ctx.getSource(), getString(ctx, "password"), getString(ctx, "passwordAgain"))) )) .executes(ctx -> { - ctx.getSource().getPlayer().sendMessage(new LiteralText(config.lang.enterPassword), false); + ctx.getSource().getPlayer().sendMessage(new LiteralText(EasyAuth.config.lang.enterPassword), false); return 0; })); } @@ -35,42 +35,42 @@ public static void registerCommand(CommandDispatcher dispat // Method called for hashing the password & writing to DB private static int register(ServerCommandSource source, String pass1, String pass2) throws CommandSyntaxException { ServerPlayerEntity player = source.getPlayer(); - if(config.main.enableGlobalPassword) { - player.sendMessage(new LiteralText(config.lang.loginRequired), false); + if(EasyAuth.config.main.enableGlobalPassword) { + player.sendMessage(new LiteralText(EasyAuth.config.lang.loginRequired), false); return 0; } else if(((PlayerAuth) player).isAuthenticated()) { - player.sendMessage(new LiteralText(config.lang.alreadyAuthenticated), false); + player.sendMessage(new LiteralText(EasyAuth.config.lang.alreadyAuthenticated), false); return 0; } else if(!pass1.equals(pass2)) { - player.sendMessage(new LiteralText(config.lang.matchPassword), false); + player.sendMessage(new LiteralText(EasyAuth.config.lang.matchPassword), false); return 0; } // Different thread to avoid lag spikes - THREADPOOL.submit(() -> { - if(pass1.length() < config.main.minPasswordChars) { + EasyAuth.THREADPOOL.submit(() -> { + if(pass1.length() < EasyAuth.config.main.minPasswordChars) { player.sendMessage(new LiteralText( - String.format(config.lang.minPasswordChars, config.main.minPasswordChars) + String.format(EasyAuth.config.lang.minPasswordChars, EasyAuth.config.main.minPasswordChars) ), false); return; } - else if(pass1.length() > config.main.maxPasswordChars && config.main.maxPasswordChars != -1) { + else if(pass1.length() > EasyAuth.config.main.maxPasswordChars && EasyAuth.config.main.maxPasswordChars != -1) { player.sendMessage(new LiteralText( - String.format(config.lang.maxPasswordChars, config.main.maxPasswordChars) + String.format(EasyAuth.config.lang.maxPasswordChars, EasyAuth.config.main.maxPasswordChars) ), false); return; } - PlayerCache playerCache = playerCacheMap.get(((PlayerAuth) player).getFakeUuid()); + PlayerCache playerCache = EasyAuth.playerCacheMap.get(((PlayerAuth) player).getFakeUuid()); if (playerCache.password.isEmpty()) { ((PlayerAuth) player).setAuthenticated(true); - player.sendMessage(new LiteralText(config.lang.registerSuccess), false); + player.sendMessage(new LiteralText(EasyAuth.config.lang.registerSuccess), false); - playerCache.password = hashPassword(pass1.toCharArray()); + playerCache.password = AuthHelper.hashPassword(pass1.toCharArray()); return; } - player.sendMessage(new LiteralText(config.lang.alreadyRegistered), false); + player.sendMessage(new LiteralText(EasyAuth.config.lang.alreadyRegistered), false); }); return 0; } diff --git a/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java b/src/main/java/xyz/nikitacartes/easyauth/event/AuthEventHandler.java similarity index 78% rename from src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java rename to src/main/java/xyz/nikitacartes/easyauth/event/AuthEventHandler.java index 8d376206..826d6a42 100644 --- a/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java +++ b/src/main/java/xyz/nikitacartes/easyauth/event/AuthEventHandler.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.event; +package xyz.nikitacartes.easyauth.event; import com.mojang.authlib.GameProfile; import net.minecraft.block.Blocks; @@ -11,15 +11,13 @@ import net.minecraft.util.ActionResult; import net.minecraft.util.TypedActionResult; import net.minecraft.util.math.BlockPos; -import org.samo_lego.simpleauth.storage.PlayerCache; -import org.samo_lego.simpleauth.utils.PlayerAuth; +import xyz.nikitacartes.easyauth.EasyAuth; +import xyz.nikitacartes.easyauth.storage.PlayerCache; +import xyz.nikitacartes.easyauth.utils.PlayerAuth; import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.samo_lego.simpleauth.SimpleAuth.config; -import static org.samo_lego.simpleauth.SimpleAuth.playerCacheMap; - /** * This class will take care of actions players try to do, * and cancel them if they aren't authenticated @@ -40,24 +38,24 @@ public static LiteralText checkCanPlayerJoinServer(GameProfile profile, PlayerMa PlayerEntity onlinePlayer = manager.getPlayer(incomingPlayerUsername); // Checking if player username is valid - String regex = config.main.usernameRegex; + String regex = EasyAuth.config.main.usernameRegex; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(incomingPlayerUsername); - if((onlinePlayer != null && !((PlayerAuth) onlinePlayer).canSkipAuth()) && config.experimental.preventAnotherLocationKick) { + if((onlinePlayer != null && !((PlayerAuth) onlinePlayer).canSkipAuth()) && EasyAuth.config.experimental.preventAnotherLocationKick) { // Player needs to be kicked, since there's already a player with that name // playing on the server return new LiteralText( String.format( - config.lang.playerAlreadyOnline, onlinePlayer.getName().asString() + EasyAuth.config.lang.playerAlreadyOnline, onlinePlayer.getName().asString() ) ); } else if(!matcher.matches()) { return new LiteralText( String.format( - config.lang.disallowedUsername, regex + EasyAuth.config.lang.disallowedUsername, regex ) ); } @@ -73,13 +71,13 @@ public static void onPlayerJoin(ServerPlayerEntity player) { String uuid = ((PlayerAuth) player).getFakeUuid(); PlayerCache playerCache; - if(!playerCacheMap.containsKey(uuid)) { + if(!EasyAuth.playerCacheMap.containsKey(uuid)) { // First join playerCache = PlayerCache.fromJson(player, uuid); - playerCacheMap.put(uuid, playerCache); + EasyAuth.playerCacheMap.put(uuid, playerCache); } else { - playerCache = playerCacheMap.get(uuid); + playerCache = EasyAuth.playerCacheMap.get(uuid); } if ( @@ -94,7 +92,7 @@ public static void onPlayerJoin(ServerPlayerEntity player) { // Tries to rescue player from nether portal - if(config.main.tryPortalRescue && player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL)) { + if(EasyAuth.config.main.tryPortalRescue && player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL)) { BlockPos pos = player.getBlockPos(); // Teleporting player to the middle of the block @@ -113,17 +111,17 @@ public static void onPlayerLeave(ServerPlayerEntity player) { if(((PlayerAuth) player).canSkipAuth()) return; String uuid = ((PlayerAuth) player).getFakeUuid(); - PlayerCache playerCache = playerCacheMap.get(uuid); + PlayerCache playerCache = EasyAuth.playerCacheMap.get(uuid); if(playerCache.isAuthenticated) { playerCache.lastIp = player.getIp(); playerCache.wasInPortal = player.getBlockStateAtPos().getBlock().equals(Blocks.NETHER_PORTAL); // Setting the session expire time - if(config.main.sessionTimeoutTime != -1) - playerCache.validUntil = System.currentTimeMillis() + config.main.sessionTimeoutTime * 1000L; + if(EasyAuth.config.main.sessionTimeoutTime != -1) + playerCache.validUntil = System.currentTimeMillis() + EasyAuth.config.main.sessionTimeoutTime * 1000L; } - else if(config.main.spawnOnJoin) { + else if(EasyAuth.config.main.spawnOnJoin) { ((PlayerAuth) player).hidePosition(false); player.setInvulnerable(false); @@ -138,7 +136,7 @@ public static ActionResult onPlayerChat(ServerPlayerEntity player, String messag !((PlayerAuth) player).isAuthenticated() && !message.startsWith("/login") && !message.startsWith("/register") && - (!config.experimental.allowChat || message.startsWith("/")) + (!EasyAuth.config.experimental.allowChat || message.startsWith("/")) ) { player.sendMessage(((PlayerAuth) player).getAuthMessage(), false); return ActionResult.FAIL; @@ -151,7 +149,7 @@ public static ActionResult onPlayerMove(ServerPlayerEntity player) { // Player will fall if enabled (prevent fly kick) boolean auth = ((PlayerAuth) player).isAuthenticated(); // Otherwise movement should be disabled - if(!auth && !config.experimental.allowMovement) { + if(!auth && !EasyAuth.config.experimental.allowMovement) { if(!player.isInvulnerable()) player.setInvulnerable(true); return ActionResult.FAIL; @@ -161,7 +159,7 @@ public static ActionResult onPlayerMove(ServerPlayerEntity player) { // Using a block (right-click function) public static ActionResult onUseBlock(PlayerEntity player) { - if(!((PlayerAuth) player).isAuthenticated() && !config.experimental.allowBlockUse) { + if(!((PlayerAuth) player).isAuthenticated() && !EasyAuth.config.experimental.allowBlockUse) { player.sendMessage(((PlayerAuth) player).getAuthMessage(), false); return ActionResult.FAIL; } @@ -170,7 +168,7 @@ public static ActionResult onUseBlock(PlayerEntity player) { // Breaking a block public static boolean onBreakBlock(PlayerEntity player) { - if(!((PlayerAuth) player).isAuthenticated() && !config.experimental.allowBlockPunch) { + if(!((PlayerAuth) player).isAuthenticated() && !EasyAuth.config.experimental.allowBlockPunch) { player.sendMessage(((PlayerAuth) player).getAuthMessage(), false); return false; } @@ -179,7 +177,7 @@ public static boolean onBreakBlock(PlayerEntity player) { // Using an item public static TypedActionResult onUseItem(PlayerEntity player) { - if(!((PlayerAuth) player).isAuthenticated() && !config.experimental.allowItemUse) { + if(!((PlayerAuth) player).isAuthenticated() && !EasyAuth.config.experimental.allowItemUse) { player.sendMessage(((PlayerAuth) player).getAuthMessage(), false); return TypedActionResult.fail(ItemStack.EMPTY); } @@ -188,7 +186,7 @@ public static TypedActionResult onUseItem(PlayerEntity player) { } // Dropping an item public static ActionResult onDropItem(PlayerEntity player) { - if(!((PlayerAuth) player).isAuthenticated() && !config.experimental.allowItemDrop) { + if(!((PlayerAuth) player).isAuthenticated() && !EasyAuth.config.experimental.allowItemDrop) { player.sendMessage(((PlayerAuth) player).getAuthMessage(), false); return ActionResult.FAIL; } @@ -196,7 +194,7 @@ public static ActionResult onDropItem(PlayerEntity player) { } // Changing inventory (item moving etc.) public static ActionResult onTakeItem(ServerPlayerEntity player) { - if(!((PlayerAuth) player).isAuthenticated() && !config.experimental.allowItemMoving) { + if(!((PlayerAuth) player).isAuthenticated() && !EasyAuth.config.experimental.allowItemMoving) { player.sendMessage(((PlayerAuth) player).getAuthMessage(), false); return ActionResult.FAIL; } @@ -205,7 +203,7 @@ public static ActionResult onTakeItem(ServerPlayerEntity player) { } // Attacking an entity public static ActionResult onAttackEntity(PlayerEntity player) { - if(!((PlayerAuth) player).isAuthenticated() && !config.experimental.allowEntityPunch) { + if(!((PlayerAuth) player).isAuthenticated() && !EasyAuth.config.experimental.allowEntityPunch) { player.sendMessage(((PlayerAuth) player).getAuthMessage(), false); return ActionResult.FAIL; } @@ -214,7 +212,7 @@ public static ActionResult onAttackEntity(PlayerEntity player) { } // Interacting with entity public static ActionResult onUseEntity(PlayerEntity player) { - if(!((PlayerAuth) player).isAuthenticated() && !config.main.allowEntityInteract) { + if(!((PlayerAuth) player).isAuthenticated() && !EasyAuth.config.main.allowEntityInteract) { player.sendMessage(((PlayerAuth) player).getAuthMessage(), false); return ActionResult.FAIL; } diff --git a/src/main/java/org/samo_lego/simpleauth/mixin/MixinPlayerAdvancementTracker.java b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinPlayerAdvancementTracker.java similarity index 77% rename from src/main/java/org/samo_lego/simpleauth/mixin/MixinPlayerAdvancementTracker.java rename to src/main/java/xyz/nikitacartes/easyauth/mixin/MixinPlayerAdvancementTracker.java index 2265db9e..026b4acb 100644 --- a/src/main/java/org/samo_lego/simpleauth/mixin/MixinPlayerAdvancementTracker.java +++ b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinPlayerAdvancementTracker.java @@ -1,10 +1,11 @@ -package org.samo_lego.simpleauth.mixin; +package xyz.nikitacartes.easyauth.mixin; import net.minecraft.advancement.PlayerAdvancementTracker; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.ServerAdvancementLoader; import net.minecraft.server.network.ServerPlayerEntity; -import org.samo_lego.simpleauth.utils.PlayerAuth; +import xyz.nikitacartes.easyauth.EasyAuth; +import xyz.nikitacartes.easyauth.utils.PlayerAuth; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Mutable; @@ -15,8 +16,6 @@ import java.io.File; -import static org.samo_lego.simpleauth.SimpleAuth.config; - @Mixin(PlayerAdvancementTracker.class) public class MixinPlayerAdvancementTracker { @@ -30,7 +29,7 @@ public class MixinPlayerAdvancementTracker { @Inject(method = "load(Lnet/minecraft/server/ServerAdvancementLoader;)V", at = @At("HEAD")) private void startMigratingOfflineAdvancements(ServerAdvancementLoader advancementLoader, CallbackInfo ci) { - if(config.main.premiumAutologin && !config.experimental.forceoOfflineUuids && ((PlayerAuth) this.owner).isUsingMojangAccount() && !this.advancementFile.isFile()) { + if(EasyAuth.config.main.premiumAutologin && !EasyAuth.config.experimental.forceoOfflineUuids && ((PlayerAuth) this.owner).isUsingMojangAccount() && !this.advancementFile.isFile()) { // Migrate String playername = owner.getGameProfile().getName(); this.advancementFile = new File(this.advancementFile.getParent(), PlayerEntity.getOfflinePlayerUuid(playername).toString() + ".json"); @@ -39,7 +38,7 @@ private void startMigratingOfflineAdvancements(ServerAdvancementLoader advanceme @Inject(method = "load(Lnet/minecraft/server/ServerAdvancementLoader;)V", at = @At("TAIL")) private void endMigratingOfflineAdvancements(ServerAdvancementLoader advancementLoader, CallbackInfo ci) { - if(config.main.premiumAutologin && !config.experimental.forceoOfflineUuids && ((PlayerAuth) this.owner).isUsingMojangAccount()) { + if(EasyAuth.config.main.premiumAutologin && !EasyAuth.config.experimental.forceoOfflineUuids && ((PlayerAuth) this.owner).isUsingMojangAccount()) { // Changes the file name to use online UUID this.advancementFile = new File(this.advancementFile.getParent(), owner.getUuid() + ".json"); } diff --git a/src/main/java/org/samo_lego/simpleauth/mixin/MixinPlayerManager.java b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinPlayerManager.java similarity index 94% rename from src/main/java/org/samo_lego/simpleauth/mixin/MixinPlayerManager.java rename to src/main/java/xyz/nikitacartes/easyauth/mixin/MixinPlayerManager.java index 9617aa4f..4672b64b 100644 --- a/src/main/java/org/samo_lego/simpleauth/mixin/MixinPlayerManager.java +++ b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinPlayerManager.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.mixin; +package xyz.nikitacartes.easyauth.mixin; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.PlayerEntity; @@ -8,8 +8,8 @@ import net.minecraft.stat.ServerStatHandler; import net.minecraft.text.LiteralText; import net.minecraft.text.Text; -import org.samo_lego.simpleauth.event.AuthEventHandler; -import org.samo_lego.simpleauth.utils.PlayerAuth; +import xyz.nikitacartes.easyauth.event.AuthEventHandler; +import xyz.nikitacartes.easyauth.utils.PlayerAuth; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; @@ -21,7 +21,7 @@ import java.net.SocketAddress; import java.util.UUID; -import static org.samo_lego.simpleauth.SimpleAuth.config; +import static xyz.nikitacartes.easyauth.EasyAuth.config; @Mixin(PlayerManager.class) public abstract class MixinPlayerManager { diff --git a/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerLoginNetworkHandler.java similarity index 84% rename from src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java rename to src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerLoginNetworkHandler.java index 353155b2..d979a7c6 100644 --- a/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerLoginNetworkHandler.java +++ b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerLoginNetworkHandler.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.mixin; +package xyz.nikitacartes.easyauth.mixin; import com.mojang.authlib.GameProfile; import net.minecraft.entity.player.PlayerEntity; @@ -9,6 +9,8 @@ import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; +import xyz.nikitacartes.easyauth.EasyAuth; +import xyz.nikitacartes.easyauth.utils.EasyLogger; import javax.net.ssl.HttpsURLConnection; import java.io.IOException; @@ -17,9 +19,6 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; -import static org.samo_lego.simpleauth.SimpleAuth.*; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logError; - @Mixin(ServerLoginNetworkHandler.class) public abstract class MixinServerLoginNetworkHandler { @@ -32,7 +31,7 @@ public abstract class MixinServerLoginNetworkHandler { @Inject(method = "acceptPlayer()V", at = @At("HEAD")) private void acceptPlayer(CallbackInfo ci) { - if(config.experimental.forceoOfflineUuids) { + if(EasyAuth.config.experimental.forceoOfflineUuids) { this.profile = this.toOfflineProfile(this.profile); } } @@ -54,19 +53,19 @@ private void acceptPlayer(CallbackInfo ci) { cancellable = true ) private void checkPremium(LoginHelloC2SPacket packet, CallbackInfo ci) { - if(config.main.premiumAutologin) { + if(EasyAuth.config.main.premiumAutologin) { try { String playername = packet.getProfile().getName().toLowerCase(); Pattern pattern = Pattern.compile("^[a-z0-9_]{3,16}$"); Matcher matcher = pattern.matcher(playername); - if(playerCacheMap.containsKey(PlayerEntity.getOfflinePlayerUuid(playername).toString()) || !matcher.matches() || config.main.forcedOfflinePlayers.contains(playername)) { + if(EasyAuth.playerCacheMap.containsKey(PlayerEntity.getOfflinePlayerUuid(playername).toString()) || !matcher.matches() || EasyAuth.config.main.forcedOfflinePlayers.contains(playername)) { // Player definitely doesn't have a mojang account state = ServerLoginNetworkHandler.State.READY_TO_ACCEPT; this.profile = packet.getProfile(); ci.cancel(); } - else if(!mojangAccountNamesCache.contains(playername)) { + else if(!EasyAuth.mojangAccountNamesCache.contains(playername)) { // Checking account status from API HttpsURLConnection httpsURLConnection = (HttpsURLConnection) new URL("https://api.mojang.com/users/profiles/minecraft/" + playername).openConnection(); httpsURLConnection.setRequestMethod("GET"); @@ -80,7 +79,7 @@ else if(!mojangAccountNamesCache.contains(playername)) { // Caches the request - mojangAccountNamesCache.add(playername); + EasyAuth.mojangAccountNamesCache.add(playername); // Authentication continues in original method } else if(response == HttpURLConnection.HTTP_NO_CONTENT) { @@ -93,7 +92,7 @@ else if(response == HttpURLConnection.HTTP_NO_CONTENT) { } } } catch (IOException e) { - logError(e.getMessage()); + EasyLogger.logError(e.getMessage()); } } } diff --git a/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayNetworkHandler.java b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerPlayNetworkHandler.java similarity index 97% rename from src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayNetworkHandler.java rename to src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerPlayNetworkHandler.java index 0038998c..b6089fbe 100644 --- a/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayNetworkHandler.java +++ b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerPlayNetworkHandler.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.mixin; +package xyz.nikitacartes.easyauth.mixin; import net.minecraft.network.packet.c2s.play.CreativeInventoryActionC2SPacket; import net.minecraft.network.packet.c2s.play.PlayerActionC2SPacket; @@ -7,7 +7,7 @@ import net.minecraft.server.network.ServerPlayNetworkHandler; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.ActionResult; -import org.samo_lego.simpleauth.event.AuthEventHandler; +import xyz.nikitacartes.easyauth.event.AuthEventHandler; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; import org.spongepowered.asm.mixin.injection.At; diff --git a/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayerEntity.java b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerPlayerEntity.java similarity index 75% rename from src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayerEntity.java rename to src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerPlayerEntity.java index ed08beca..56bc6e75 100644 --- a/src/main/java/org/samo_lego/simpleauth/mixin/MixinServerPlayerEntity.java +++ b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinServerPlayerEntity.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.mixin; +package xyz.nikitacartes.easyauth.mixin; import net.fabricmc.loader.api.FabricLoader; import net.minecraft.entity.player.PlayerEntity; @@ -12,10 +12,11 @@ import net.minecraft.util.registry.Registry; import net.minecraft.util.registry.RegistryKey; import net.minecraft.world.World; -import org.samo_lego.simpleauth.event.AuthEventHandler; -import org.samo_lego.simpleauth.storage.PlayerCache; -import org.samo_lego.simpleauth.utils.CarpetHelper; -import org.samo_lego.simpleauth.utils.PlayerAuth; +import xyz.nikitacartes.easyauth.EasyAuth; +import xyz.nikitacartes.easyauth.event.AuthEventHandler; +import xyz.nikitacartes.easyauth.storage.PlayerCache; +import xyz.nikitacartes.easyauth.utils.CarpetHelper; +import xyz.nikitacartes.easyauth.utils.PlayerAuth; import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; @@ -24,9 +25,7 @@ import org.spongepowered.asm.mixin.injection.Inject; import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; - -import static org.samo_lego.simpleauth.SimpleAuth.*; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo; +import xyz.nikitacartes.easyauth.utils.EasyLogger; @Mixin(ServerPlayerEntity.class) public class MixinServerPlayerEntity implements PlayerAuth { @@ -35,7 +34,7 @@ public class MixinServerPlayerEntity implements PlayerAuth { // * 20 for 20 ticks in second @Unique - private int kickTimer = config.main.kickTime * 20; + private int kickTimer = EasyAuth.config.main.kickTime * 20; @Final @Shadow @@ -49,9 +48,9 @@ public class MixinServerPlayerEntity implements PlayerAuth { */ @Override public void hidePosition(boolean hide) { - PlayerCache cache = playerCacheMap.get(this.getFakeUuid()); - if(config.experimental.debugMode) - logInfo("Teleporting " + player.getName().asString() + (hide ? " to spawn." : " to original position.")); + PlayerCache cache = EasyAuth.playerCacheMap.get(this.getFakeUuid()); + if(EasyAuth.config.experimental.debugMode) + EasyLogger.logInfo("Teleporting " + player.getName().asString() + (hide ? " to spawn." : " to original position.")); if (hide) { // Saving position cache.lastLocation.dimension = player.getServerWorld(); @@ -61,12 +60,12 @@ public void hidePosition(boolean hide) { // Teleports player to spawn player.teleport( - server.getWorld(RegistryKey.of(Registry.WORLD_KEY, new Identifier(config.worldSpawn.dimension))), - config.worldSpawn.x, - config.worldSpawn.y, - config.worldSpawn.z, - config.worldSpawn.yaw, - config.worldSpawn.pitch + server.getWorld(RegistryKey.of(Registry.WORLD_KEY, new Identifier(EasyAuth.config.worldSpawn.dimension))), + EasyAuth.config.worldSpawn.x, + EasyAuth.config.worldSpawn.y, + EasyAuth.config.worldSpawn.z, + EasyAuth.config.worldSpawn.yaw, + EasyAuth.config.worldSpawn.pitch ); return; } @@ -92,7 +91,7 @@ public void hidePosition(boolean hide) { public String getFakeUuid() { // If server is in online mode online-mode UUIDs should be used assert server != null; - if(server.isOnlineMode() && this.isUsingMojangAccount() && !config.experimental.forceoOfflineUuids) + if(server.isOnlineMode() && this.isUsingMojangAccount() && !EasyAuth.config.experimental.forceoOfflineUuids) return player.getUuidAsString(); /* Lower case is used for Player and PlAyEr to get same UUID (for password storing) @@ -112,18 +111,18 @@ Lower case is used for Player and PlAyEr to get same UUID (for password storing) */ @Override public void setAuthenticated(boolean authenticated) { - PlayerCache playerCache = playerCacheMap.get(this.getFakeUuid()); + PlayerCache playerCache = EasyAuth.playerCacheMap.get(this.getFakeUuid()); playerCache.isAuthenticated = authenticated; - player.setInvulnerable(!authenticated && config.experimental.playerInvulnerable); - player.setInvisible(!authenticated && config.experimental.playerInvisible); + player.setInvulnerable(!authenticated && EasyAuth.config.experimental.playerInvulnerable); + player.setInvisible(!authenticated && EasyAuth.config.experimental.playerInvisible); // Teleporting player (hiding / restoring position) - if(config.main.spawnOnJoin) + if(EasyAuth.config.main.spawnOnJoin) this.hidePosition(!authenticated); if(authenticated) { - kickTimer = config.main.kickTime * 20; + kickTimer = EasyAuth.config.main.kickTime * 20; // Updating blocks if needed (if portal rescue action happened) if(playerCache.wasInPortal) { World world = player.getEntityWorld(); @@ -145,13 +144,13 @@ public void setAuthenticated(boolean authenticated) { */ @Override public Text getAuthMessage() { - final PlayerCache cache = playerCacheMap.get(((PlayerAuth) player).getFakeUuid()); - if(!config.main.enableGlobalPassword && cache.password.isEmpty()) + final PlayerCache cache = EasyAuth.playerCacheMap.get(((PlayerAuth) player).getFakeUuid()); + if(!EasyAuth.config.main.enableGlobalPassword && cache.password.isEmpty()) return new LiteralText( - config.lang.notAuthenticated+ "\n" + config.lang.registerRequired + EasyAuth.config.lang.notAuthenticated+ "\n" + EasyAuth.config.lang.registerRequired ); return new LiteralText( - config.lang.notAuthenticated + "\n" + config.lang.loginRequired + EasyAuth.config.lang.notAuthenticated + "\n" + EasyAuth.config.lang.loginRequired ); } @@ -162,7 +161,7 @@ public Text getAuthMessage() { */ @Override public boolean canSkipAuth() { - return (FabricLoader.getInstance().isModLoaded("carpet") && CarpetHelper.isPlayerFake(this.player)) || (isUsingMojangAccount() && config.main.premiumAutologin); + return (FabricLoader.getInstance().isModLoaded("carpet") && CarpetHelper.isPlayerFake(this.player)) || (isUsingMojangAccount() && EasyAuth.config.main.premiumAutologin); } /** @@ -172,7 +171,7 @@ public boolean canSkipAuth() { */ @Override public boolean isUsingMojangAccount() { - return mojangAccountNamesCache.contains(player.getGameProfile().getName().toLowerCase()); + return EasyAuth.mojangAccountNamesCache.contains(player.getGameProfile().getName().toLowerCase()); } /** @@ -183,7 +182,7 @@ public boolean isUsingMojangAccount() { @Override public boolean isAuthenticated() { String uuid = ((PlayerAuth) player).getFakeUuid(); - return this.canSkipAuth() || (playerCacheMap.containsKey(uuid) && playerCacheMap.get(uuid).isAuthenticated); + return this.canSkipAuth() || (EasyAuth.playerCacheMap.containsKey(uuid) && EasyAuth.playerCacheMap.get(uuid).isAuthenticated); } @Inject(method = "playerTick()V", at = @At("HEAD"), cancellable = true) @@ -191,7 +190,7 @@ private void playerTick(CallbackInfo ci) { if(!this.isAuthenticated()) { // Checking player timer if(kickTimer <= 0 && player.networkHandler.getConnection().isOpen()) { - player.networkHandler.disconnect(new LiteralText(config.lang.timeExpired)); + player.networkHandler.disconnect(new LiteralText(EasyAuth.config.lang.timeExpired)); } else { // Sending authentication prompt every 10 seconds diff --git a/src/main/java/org/samo_lego/simpleauth/mixin/MixinSlot.java b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinSlot.java similarity index 93% rename from src/main/java/org/samo_lego/simpleauth/mixin/MixinSlot.java rename to src/main/java/xyz/nikitacartes/easyauth/mixin/MixinSlot.java index b781d5bd..788f93dd 100644 --- a/src/main/java/org/samo_lego/simpleauth/mixin/MixinSlot.java +++ b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinSlot.java @@ -1,11 +1,11 @@ -package org.samo_lego.simpleauth.mixin; +package xyz.nikitacartes.easyauth.mixin; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.network.packet.s2c.play.ScreenHandlerSlotUpdateS2CPacket; import net.minecraft.screen.slot.Slot; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.util.ActionResult; -import org.samo_lego.simpleauth.event.AuthEventHandler; +import xyz.nikitacartes.easyauth.event.AuthEventHandler; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; diff --git a/src/main/java/org/samo_lego/simpleauth/mixin/MixinWorldSaveHandler.java b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinWorldSaveHandler.java similarity index 83% rename from src/main/java/org/samo_lego/simpleauth/mixin/MixinWorldSaveHandler.java rename to src/main/java/xyz/nikitacartes/easyauth/mixin/MixinWorldSaveHandler.java index 677820dc..cb6c1ec7 100644 --- a/src/main/java/org/samo_lego/simpleauth/mixin/MixinWorldSaveHandler.java +++ b/src/main/java/xyz/nikitacartes/easyauth/mixin/MixinWorldSaveHandler.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.mixin; +package xyz.nikitacartes.easyauth.mixin; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.nbt.NbtCompound; @@ -14,15 +14,13 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; import org.spongepowered.asm.mixin.injection.callback.LocalCapture; +import xyz.nikitacartes.easyauth.EasyAuth; +import xyz.nikitacartes.easyauth.utils.EasyLogger; import java.io.File; import java.io.FileInputStream; import java.io.IOException; -import static org.samo_lego.simpleauth.SimpleAuth.config; -import static org.samo_lego.simpleauth.SimpleAuth.mojangAccountNamesCache; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo; - @Mixin(WorldSaveHandler.class) public class MixinWorldSaveHandler { @@ -75,9 +73,9 @@ private void fileExists(PlayerEntity playerEntity, CallbackInfoReturnable. */ -package org.samo_lego.simpleauth.storage; +package xyz.nikitacartes.easyauth.storage; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import xyz.nikitacartes.easyauth.utils.EasyLogger; import java.io.*; import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.Arrays; -import java.util.List; -import static org.samo_lego.simpleauth.SimpleAuth.serverProp; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logError; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo; +import static xyz.nikitacartes.easyauth.EasyAuth.serverProp; public class AuthConfig { private static final Gson gson = new GsonBuilder() @@ -53,7 +51,7 @@ public static class MainConfig { public int kickTime = 60; /** * Disables registering and forces logging in with global password. - * @see wiki + * @see wiki */ public boolean enableGlobalPassword = false; /** @@ -62,7 +60,7 @@ public static class MainConfig { public String globalPassword; /** * Tries to rescue players if they are stuck inside a portal on logging in. - * @see wiki + * @see wiki */ public boolean tryPortalRescue = true; /** @@ -76,13 +74,13 @@ public static class MainConfig { public int maxPasswordChars = -1; /** * Regex of valid playername characters. You probably don't want to change this. - * @see wiki + * @see wiki */ public String usernameRegex = "^[a-zA-Z0-9_]{3,16}$"; /** * How long to keep session (auto-logging in the player), in seconds * Set to -1 to disable - * @see wiki + * @see wiki */ public int sessionTimeoutTime = 60; @@ -93,7 +91,7 @@ public static class MainConfig { /** * Data for spawn (where deauthenticated players are teleported temporarily). - * @see wiki + * @see wiki */ public static class WorldSpawn { /** @@ -258,7 +256,7 @@ public static class ExperimentalConfig { public boolean debugMode = false; /** * Whether to use BCrypt instead of Argon2 (GLIBC_2.25 error). - * @see wiki + * @see wiki */ public boolean useBCryptLibrary = false; /** @@ -288,7 +286,7 @@ public static class ExperimentalConfig { /** - * Loads SimpleAuth's config file. + * Loads EasyAuth's config file. * * @param file file to load config from * @return AuthConfig config object @@ -302,11 +300,11 @@ public static AuthConfig load(File file) { config = gson.fromJson(fileReader, AuthConfig.class); if(!Boolean.parseBoolean(serverProp.getProperty("online-mode"))) { if(config.experimental.forceoOfflineUuids) { - logInfo("Server is in offline mode, forceoOfflineUuids option is irrelevant. Setting it to false."); + EasyLogger.logInfo("Server is in offline mode, forceoOfflineUuids option is irrelevant. Setting it to false."); config.experimental.forceoOfflineUuids = false; } if(config.main.premiumAutologin) { - logError("You cannot use server in offline mode and premiumAutologin! Disabling the latter."); + EasyLogger.logError("You cannot use server in offline mode and premiumAutologin! Disabling the latter."); config.main.premiumAutologin = false; } } @@ -331,7 +329,7 @@ public void save(File file) { try (Writer writer = new OutputStreamWriter(new FileOutputStream(file), StandardCharsets.UTF_8)) { gson.toJson(this, writer); } catch (IOException e) { - logError("Problem occurred when saving config: " + e.getMessage()); + EasyLogger.logError("Problem occurred when saving config: " + e.getMessage()); } } } \ No newline at end of file diff --git a/src/main/java/org/samo_lego/simpleauth/storage/DBHelper.java b/src/main/java/xyz/nikitacartes/easyauth/storage/DBHelper.java similarity index 88% rename from src/main/java/org/samo_lego/simpleauth/storage/DBHelper.java rename to src/main/java/xyz/nikitacartes/easyauth/storage/DBHelper.java index 85de30ad..78b12d9c 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/DBHelper.java +++ b/src/main/java/xyz/nikitacartes/easyauth/storage/DBHelper.java @@ -1,12 +1,12 @@ -package org.samo_lego.simpleauth.storage; +package xyz.nikitacartes.easyauth.storage; -import org.samo_lego.simpleauth.storage.database.LevelDB; -import org.samo_lego.simpleauth.storage.database.MongoDB; +import xyz.nikitacartes.easyauth.storage.database.LevelDB; +import xyz.nikitacartes.easyauth.storage.database.MongoDB; +import xyz.nikitacartes.easyauth.utils.EasyLogger; import java.util.HashMap; -import static org.samo_lego.simpleauth.SimpleAuth.config; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo; +import static xyz.nikitacartes.easyauth.EasyAuth.config; public class DBHelper { @@ -25,7 +25,7 @@ public void openConnection() { */ public void close() { if(config.main.useMongoDB && MongoDB.close() || LevelDB.close()) - logInfo("Database connection closed successfully."); + EasyLogger.logInfo("Database connection closed successfully."); } /** diff --git a/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java b/src/main/java/xyz/nikitacartes/easyauth/storage/PlayerCache.java similarity index 82% rename from src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java rename to src/main/java/xyz/nikitacartes/easyauth/storage/PlayerCache.java index df937d65..785538af 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/PlayerCache.java +++ b/src/main/java/xyz/nikitacartes/easyauth/storage/PlayerCache.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.storage; +package xyz.nikitacartes.easyauth.storage; import com.google.gson.Gson; import com.google.gson.GsonBuilder; @@ -8,12 +8,13 @@ import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.Vec3d; +import xyz.nikitacartes.easyauth.event.AuthEventHandler; +import xyz.nikitacartes.easyauth.utils.EasyLogger; import java.util.Objects; -import static org.samo_lego.simpleauth.SimpleAuth.DB; -import static org.samo_lego.simpleauth.SimpleAuth.config; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logInfo; +import static xyz.nikitacartes.easyauth.EasyAuth.DB; +import static xyz.nikitacartes.easyauth.EasyAuth.config; /** * Class used for storing the non-authenticated player's cache @@ -21,7 +22,7 @@ public class PlayerCache { /** * Whether player is authenticated. - * Used for {@link org.samo_lego.simpleauth.event.AuthEventHandler#onPlayerJoin(ServerPlayerEntity) session validation}. + * Used for {@link AuthEventHandler#onPlayerJoin(ServerPlayerEntity) session validation}. */ @Expose @SerializedName("is_authenticated") @@ -37,7 +38,7 @@ public class PlayerCache { public int loginTries = 0; /** * Last recorded IP of player. - * Used for {@link org.samo_lego.simpleauth.event.AuthEventHandler#onPlayerJoin(ServerPlayerEntity) sessions}. + * Used for {@link AuthEventHandler#onPlayerJoin(ServerPlayerEntity) sessions}. */ @Expose @SerializedName("last_ip") @@ -80,7 +81,7 @@ public static class LastLocation { public static PlayerCache fromJson(ServerPlayerEntity player, String fakeUuid) { if(config.experimental.debugMode) - logInfo("Creating cache for " + Objects.requireNonNull(player).getGameProfile().getName()); + EasyLogger.logInfo("Creating cache for " + Objects.requireNonNull(player).getGameProfile().getName()); String json = DB.getUserData(fakeUuid); PlayerCache playerCache; diff --git a/src/main/java/org/samo_lego/simpleauth/storage/database/LevelDB.java b/src/main/java/xyz/nikitacartes/easyauth/storage/database/LevelDB.java similarity index 81% rename from src/main/java/org/samo_lego/simpleauth/storage/database/LevelDB.java rename to src/main/java/xyz/nikitacartes/easyauth/storage/database/LevelDB.java index d62185c5..229aa3b8 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/database/LevelDB.java +++ b/src/main/java/xyz/nikitacartes/easyauth/storage/database/LevelDB.java @@ -1,12 +1,12 @@ -package org.samo_lego.simpleauth.storage.database; +package xyz.nikitacartes.easyauth.storage.database; import org.iq80.leveldb.DB; import org.iq80.leveldb.DBException; import org.iq80.leveldb.Options; import org.iq80.leveldb.WriteBatch; -import org.samo_lego.simpleauth.SimpleAuth; -import org.samo_lego.simpleauth.storage.PlayerCache; -import static org.samo_lego.simpleauth.SimpleAuth.config; +import xyz.nikitacartes.easyauth.EasyAuth; +import xyz.nikitacartes.easyauth.storage.PlayerCache; +import xyz.nikitacartes.easyauth.utils.EasyLogger; import java.io.File; import java.io.IOException; @@ -14,7 +14,6 @@ import static org.iq80.leveldb.impl.Iq80DBFactory.bytes; import static org.iq80.leveldb.impl.Iq80DBFactory.factory; -import static org.samo_lego.simpleauth.utils.SimpleLogger.logError; public class LevelDB { private static DB levelDBStore; @@ -25,9 +24,9 @@ public class LevelDB { public static void initialize() { Options options = new Options(); try { - levelDBStore = factory.open(new File(SimpleAuth.gameDirectory + "/mods/" + config.experimental.databaseFolder + "/levelDBStore"), options); + levelDBStore = factory.open(new File(EasyAuth.gameDirectory + "/mods/" + EasyAuth.config.experimental.databaseFolder + "/levelDBStore"), options); } catch (IOException e) { - logError(e.getMessage()); + EasyLogger.logError(e.getMessage()); } } @@ -40,7 +39,7 @@ public static boolean close() { levelDBStore.close(); return true; } catch (Error | IOException e) { - logError(e.getMessage()); + EasyLogger.logError(e.getMessage()); } } return false; @@ -72,7 +71,7 @@ public static boolean registerUser(String uuid, String data) { } return false; } catch (Error e) { - logError("Register error: " + e.getMessage()); + EasyLogger.logError("Register error: " + e.getMessage()); return false; } } @@ -87,7 +86,7 @@ public static boolean isUserRegistered(String uuid) { try { return levelDBStore.get(bytes("UUID:" + uuid)) != null; } catch (DBException e) { - logError(e.getMessage()); + EasyLogger.logError(e.getMessage()); } return false; } @@ -101,7 +100,7 @@ public static void deleteUserData(String uuid) { try { levelDBStore.delete(bytes("UUID:" + uuid)); } catch (Error e) { - logError(e.getMessage()); + EasyLogger.logError(e.getMessage()); } } @@ -116,7 +115,7 @@ public static void updateUserData(String uuid, String data) { try { levelDBStore.put(bytes("UUID:" + uuid), bytes("data:" + data)); } catch (Error e) { - logError(e.getMessage()); + EasyLogger.logError(e.getMessage()); } } @@ -131,7 +130,7 @@ public static String getUserData(String uuid){ if(isUserRegistered(uuid)) // Gets password from db and removes "data:" prefix from it return new String(levelDBStore.get(bytes("UUID:" + uuid))).substring(5); } catch (Error e) { - logError("Error getting data: " + e.getMessage()); + EasyLogger.logError("Error getting data: " + e.getMessage()); } return ""; } @@ -148,7 +147,7 @@ public static void saveFromCache(HashMap playerCacheMap) { levelDBStore.write(batch); batch.close(); } catch (IOException e) { - logError("Error saving player data! " + e.getMessage()); + EasyLogger.logError("Error saving player data! " + e.getMessage()); } } } diff --git a/src/main/java/org/samo_lego/simpleauth/storage/database/MongoDB.java b/src/main/java/xyz/nikitacartes/easyauth/storage/database/MongoDB.java similarity index 95% rename from src/main/java/org/samo_lego/simpleauth/storage/database/MongoDB.java rename to src/main/java/xyz/nikitacartes/easyauth/storage/database/MongoDB.java index 90e505bb..69da3d96 100644 --- a/src/main/java/org/samo_lego/simpleauth/storage/database/MongoDB.java +++ b/src/main/java/xyz/nikitacartes/easyauth/storage/database/MongoDB.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.storage.database; +package xyz.nikitacartes.easyauth.storage.database; import com.mongodb.client.MongoClient; @@ -8,14 +8,14 @@ import com.mongodb.client.model.InsertOneModel; import com.mongodb.client.model.ReplaceOneModel; import org.bson.Document; -import org.samo_lego.simpleauth.storage.PlayerCache; +import xyz.nikitacartes.easyauth.storage.PlayerCache; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import static com.mongodb.client.model.Filters.eq; -import static org.samo_lego.simpleauth.SimpleAuth.config; +import static xyz.nikitacartes.easyauth.EasyAuth.config; public class MongoDB { private static MongoCollection collection; diff --git a/src/main/java/org/samo_lego/simpleauth/utils/AuthHelper.java b/src/main/java/xyz/nikitacartes/easyauth/utils/AuthHelper.java similarity index 85% rename from src/main/java/org/samo_lego/simpleauth/utils/AuthHelper.java rename to src/main/java/xyz/nikitacartes/easyauth/utils/AuthHelper.java index 301f786d..4ffcc832 100644 --- a/src/main/java/org/samo_lego/simpleauth/utils/AuthHelper.java +++ b/src/main/java/xyz/nikitacartes/easyauth/utils/AuthHelper.java @@ -1,10 +1,10 @@ -package org.samo_lego.simpleauth.utils; +package xyz.nikitacartes.easyauth.utils; -import org.samo_lego.simpleauth.utils.hashing.HasherArgon2; -import org.samo_lego.simpleauth.utils.hashing.HasherBCrypt; +import xyz.nikitacartes.easyauth.utils.hashing.HasherArgon2; +import xyz.nikitacartes.easyauth.utils.hashing.HasherBCrypt; -import static org.samo_lego.simpleauth.SimpleAuth.config; -import static org.samo_lego.simpleauth.SimpleAuth.playerCacheMap; +import static xyz.nikitacartes.easyauth.EasyAuth.config; +import static xyz.nikitacartes.easyauth.EasyAuth.playerCacheMap; public class AuthHelper { /** diff --git a/src/main/java/org/samo_lego/simpleauth/utils/CarpetHelper.java b/src/main/java/xyz/nikitacartes/easyauth/utils/CarpetHelper.java similarity index 90% rename from src/main/java/org/samo_lego/simpleauth/utils/CarpetHelper.java rename to src/main/java/xyz/nikitacartes/easyauth/utils/CarpetHelper.java index daf8b0be..14967d8f 100644 --- a/src/main/java/org/samo_lego/simpleauth/utils/CarpetHelper.java +++ b/src/main/java/xyz/nikitacartes/easyauth/utils/CarpetHelper.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.utils; +package xyz.nikitacartes.easyauth.utils; import carpet.patches.EntityPlayerMPFake; import net.minecraft.entity.player.PlayerEntity; diff --git a/src/main/java/org/samo_lego/simpleauth/utils/SimpleLogger.java b/src/main/java/xyz/nikitacartes/easyauth/utils/EasyLogger.java similarity index 83% rename from src/main/java/org/samo_lego/simpleauth/utils/SimpleLogger.java rename to src/main/java/xyz/nikitacartes/easyauth/utils/EasyLogger.java index 1258f931..5738d9fc 100644 --- a/src/main/java/org/samo_lego/simpleauth/utils/SimpleLogger.java +++ b/src/main/java/xyz/nikitacartes/easyauth/utils/EasyLogger.java @@ -1,9 +1,9 @@ -package org.samo_lego.simpleauth.utils; +package xyz.nikitacartes.easyauth.utils; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -public class SimpleLogger { +public class EasyLogger { private static final Logger LOGGER = LogManager.getLogger(); public static void logError(String error) { diff --git a/src/main/java/org/samo_lego/simpleauth/utils/PlayerAuth.java b/src/main/java/xyz/nikitacartes/easyauth/utils/PlayerAuth.java similarity index 98% rename from src/main/java/org/samo_lego/simpleauth/utils/PlayerAuth.java rename to src/main/java/xyz/nikitacartes/easyauth/utils/PlayerAuth.java index 35abc37a..243b58f7 100644 --- a/src/main/java/org/samo_lego/simpleauth/utils/PlayerAuth.java +++ b/src/main/java/xyz/nikitacartes/easyauth/utils/PlayerAuth.java @@ -1,4 +1,4 @@ -package org.samo_lego.simpleauth.utils; +package xyz.nikitacartes.easyauth.utils; import net.minecraft.text.Text; diff --git a/src/main/java/org/samo_lego/simpleauth/utils/hashing/HasherArgon2.java b/src/main/java/xyz/nikitacartes/easyauth/utils/hashing/HasherArgon2.java similarity index 80% rename from src/main/java/org/samo_lego/simpleauth/utils/hashing/HasherArgon2.java rename to src/main/java/xyz/nikitacartes/easyauth/utils/hashing/HasherArgon2.java index 726643e1..66916900 100644 --- a/src/main/java/org/samo_lego/simpleauth/utils/hashing/HasherArgon2.java +++ b/src/main/java/xyz/nikitacartes/easyauth/utils/hashing/HasherArgon2.java @@ -1,9 +1,8 @@ -package org.samo_lego.simpleauth.utils.hashing; +package xyz.nikitacartes.easyauth.utils.hashing; import de.mkammerer.argon2.Argon2; import de.mkammerer.argon2.Argon2Factory; - -import static org.samo_lego.simpleauth.utils.SimpleLogger.logError; +import xyz.nikitacartes.easyauth.utils.EasyLogger; public class HasherArgon2 { @@ -22,7 +21,7 @@ public static boolean verify(char[] password, String hashed) { return HASHER.verify(hashed, password); } catch (Error e) { - logError("Argon2 password verification error: " + e); + EasyLogger.logError("Argon2 password verification error: " + e); return false; } finally { // Wipe confidential data @@ -40,7 +39,7 @@ public static String hash(char[] password) { try { return HASHER.hash(10, 65536, 1, password); } catch (Error e) { - logError("Argon2 password hashing error: " + e); + EasyLogger.logError("Argon2 password hashing error: " + e); } return null; } diff --git a/src/main/java/org/samo_lego/simpleauth/utils/hashing/HasherBCrypt.java b/src/main/java/xyz/nikitacartes/easyauth/utils/hashing/HasherBCrypt.java similarity index 77% rename from src/main/java/org/samo_lego/simpleauth/utils/hashing/HasherBCrypt.java rename to src/main/java/xyz/nikitacartes/easyauth/utils/hashing/HasherBCrypt.java index f04db2a2..f05b9d5b 100644 --- a/src/main/java/org/samo_lego/simpleauth/utils/hashing/HasherBCrypt.java +++ b/src/main/java/xyz/nikitacartes/easyauth/utils/hashing/HasherBCrypt.java @@ -1,8 +1,7 @@ -package org.samo_lego.simpleauth.utils.hashing; +package xyz.nikitacartes.easyauth.utils.hashing; import at.favre.lib.crypto.bcrypt.BCrypt; - -import static org.samo_lego.simpleauth.utils.SimpleLogger.logError; +import xyz.nikitacartes.easyauth.utils.EasyLogger; public class HasherBCrypt { @@ -18,7 +17,7 @@ public static boolean verify(char[] password, String hashed) { return BCrypt.verifyer().verify(password, hashed).verified; } catch (Error e) { - logError("BCrypt password verification error: " + e); + EasyLogger.logError("BCrypt password verification error: " + e); return false; } } @@ -33,7 +32,7 @@ public static String hash(char[] password) { try { return BCrypt.withDefaults().hashToString(12, password); } catch (Error e) { - logError("BCrypt password hashing error: " + e); + EasyLogger.logError("BCrypt password hashing error: " + e); } return null; } diff --git a/src/main/resources/simpleauth.accesswidener b/src/main/resources/easyauth.accesswidener similarity index 100% rename from src/main/resources/simpleauth.accesswidener rename to src/main/resources/easyauth.accesswidener diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index 50c99401..49138deb 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -18,12 +18,12 @@ "environment": "*", "entrypoints": { "main": [ - "org.samo_lego.simpleauth.SimpleAuth" + "xyz.nikitacartes.easyauth.EasyAuth" ] }, - "accessWidener": "simpleauth.accesswidener", + "accessWidener": "easyauth.accesswidener", "mixins": [ - "mixins.simpleauth.json" + "mixins.easyauth.json" ], "depends": { "fabricloader": ">=0.11.3", diff --git a/src/main/resources/mixins.simpleauth.json b/src/main/resources/mixins.easyauth.json similarity index 89% rename from src/main/resources/mixins.simpleauth.json rename to src/main/resources/mixins.easyauth.json index 93c575d4..e40aea47 100644 --- a/src/main/resources/mixins.simpleauth.json +++ b/src/main/resources/mixins.easyauth.json @@ -1,6 +1,6 @@ { "required": true, - "package": "org.samo_lego.simpleauth.mixin", + "package": "xyz.nikitacartes.easyauth.mixin", "compatibilityLevel": "JAVA_16", "mixins": [ "MixinPlayerAdvancementTracker",