diff --git a/build.gradle b/build.gradle index 919c806..ef84d66 100644 --- a/build.gradle +++ b/build.gradle @@ -23,10 +23,14 @@ dependencies { modCompile "net.fabricmc.fabric-api:fabric-api:${project.fabric_version}" // Argon2 library for password hashing - compile 'de.mkammerer:argon2-jvm:2.6' + implementation 'de.mkammerer:argon2-jvm:2.6' + include 'de.mkammerer:argon2-jvm:2.6' // JDBC SQLite Driver - compile group:'org.xerial', name:'sqlite-jdbc', version:'3.8.11.2' + include group:'org.xerial', name:'sqlite-jdbc', version:'3.8.11.2' + + // JNA lib + include 'net.java.dev.jna:jna:5.5.0' // PSA: Some older mods, compiled on Loom 0.2.1, might have outdated Maven POMs. // You may need to force-disable transitiveness on them. diff --git a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java index 29e2b8e..6e8bb9a 100644 --- a/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java +++ b/src/main/java/org/samo_lego/simpleauth/SimpleAuth.java @@ -54,7 +54,6 @@ public class SimpleAuth implements DedicatedServerModInitializer { PlayerJoinServerCallback.EVENT.register(AuthEventHandler::onPlayerJoin); PlayerLeaveServerCallback.EVENT.register(AuthEventHandler::onPlayerLeave); DropItemCallback.EVENT.register(AuthEventHandler::onDropItem); - //todo OnChatCallback.EVENT.register(AuthEventHandler::onPlayerChat); OnPlayerMoveCallback.EVENT.register(AuthEventHandler::onPlayerMove); // From Fabric API diff --git a/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java b/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java index 899b776..69b2869 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java +++ b/src/main/java/org/samo_lego/simpleauth/commands/AuthCommand.java @@ -1,32 +1,24 @@ package org.samo_lego.simpleauth.commands; import com.mojang.brigadier.CommandDispatcher; -import com.mojang.brigadier.exceptions.CommandSyntaxException; -import de.mkammerer.argon2.Argon2; -import de.mkammerer.argon2.Argon2Factory; import net.minecraft.entity.Entity; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; -import net.minecraft.server.network.ServerPlayerEntity; -import net.minecraft.text.LiteralText; -import net.minecraft.text.Text; import net.minecraft.text.TranslatableText; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import org.samo_lego.simpleauth.SimpleAuth; import org.samo_lego.simpleauth.utils.AuthHelper; -import static com.mojang.brigadier.arguments.StringArgumentType.*; +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.authenticatedUsers; -import static org.samo_lego.simpleauth.SimpleAuth.isAuthenticated; public class AuthCommand { private static final Logger LOGGER = LogManager.getLogger(); - private static TranslatableText userdataDeleted = new TranslatableText("command.simpleauth.userdataDeleted"); - private static TranslatableText userdataUpdated = new TranslatableText("command.simpleauth.userdataUpdated"); + private static TranslatableText userdataDeleted = new TranslatableText("§aUserdata deleted."); + private static TranslatableText userdataUpdated = new TranslatableText("§aUserdata updated."); public static void registerCommand(CommandDispatcher dispatcher) { // Registering the "/auth" command diff --git a/src/main/java/org/samo_lego/simpleauth/commands/ChangepwCommand.java b/src/main/java/org/samo_lego/simpleauth/commands/ChangepwCommand.java index 4e1f2c5..27bec2c 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/ChangepwCommand.java +++ b/src/main/java/org/samo_lego/simpleauth/commands/ChangepwCommand.java @@ -16,10 +16,10 @@ import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; public class ChangepwCommand { - private static TranslatableText enterNewPassword = new TranslatableText("command.simpleauth.passwordNew"); - private static TranslatableText enterPassword = new TranslatableText("command.simpleauth.password"); - private static TranslatableText wrongPassword = new TranslatableText("command.simpleauth.wrongPassword"); - private static TranslatableText passwordUpdated = new TranslatableText("command.simpleauth.passwordUpdated"); + private static TranslatableText enterNewPassword = new TranslatableText("§4You need to enter new password!"); + private static TranslatableText enterPassword = new TranslatableText("§6You need to enter your password!"); + private static TranslatableText wrongPassword = new TranslatableText("§4Wrong password!"); + private static TranslatableText passwordUpdated = new TranslatableText("§4Your password was updated successfully!"); public static void registerCommand(CommandDispatcher dispatcher) { // Registering the "/changepw" command diff --git a/src/main/java/org/samo_lego/simpleauth/commands/LoginCommand.java b/src/main/java/org/samo_lego/simpleauth/commands/LoginCommand.java index 4a48d27..bbce329 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/LoginCommand.java +++ b/src/main/java/org/samo_lego/simpleauth/commands/LoginCommand.java @@ -2,9 +2,6 @@ package org.samo_lego.simpleauth.commands; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import de.mkammerer.argon2.Argon2; -import de.mkammerer.argon2.Argon2Factory; -import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.LiteralText; @@ -19,10 +16,10 @@ import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; public class LoginCommand { - private static TranslatableText enterPassword = new TranslatableText("command.simpleauth.password"); - private static TranslatableText wrongPassword = new TranslatableText("command.simpleauth.wrongPassword"); - private static TranslatableText alreadyAuthenticated = new TranslatableText("command.simpleauth.alreadyAuthenticated"); - private static Text text = new LiteralText("You have entered login command"); + private static TranslatableText enterPassword = new TranslatableText("§6You need to enter your password!"); + private static TranslatableText wrongPassword = new TranslatableText("§4Wrong password!"); + private static TranslatableText alreadyAuthenticated = new TranslatableText("§4You are already authenticated."); + private static Text text = new LiteralText("§aYou are now authenticated."); public static void registerCommand(CommandDispatcher dispatcher) { // Registering the "/login" command diff --git a/src/main/java/org/samo_lego/simpleauth/commands/RegisterCommand.java b/src/main/java/org/samo_lego/simpleauth/commands/RegisterCommand.java index df0be6a..fa97bd6 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/RegisterCommand.java +++ b/src/main/java/org/samo_lego/simpleauth/commands/RegisterCommand.java @@ -2,8 +2,6 @@ package org.samo_lego.simpleauth.commands; import com.mojang.brigadier.CommandDispatcher; import com.mojang.brigadier.exceptions.CommandSyntaxException; -import de.mkammerer.argon2.Argon2; -import de.mkammerer.argon2.Argon2Factory; import net.minecraft.server.command.ServerCommandSource; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.text.LiteralText; @@ -11,8 +9,6 @@ import net.minecraft.text.TranslatableText; import org.samo_lego.simpleauth.SimpleAuth; import org.samo_lego.simpleauth.utils.AuthHelper; -import java.util.Objects; - import static com.mojang.brigadier.arguments.StringArgumentType.getString; import static com.mojang.brigadier.arguments.StringArgumentType.word; import static net.minecraft.server.command.CommandManager.argument; @@ -20,11 +16,11 @@ import static net.minecraft.server.command.CommandManager.literal; public class RegisterCommand { - private static TranslatableText pleaseRegister = new TranslatableText("§4Type /register to login."); - private static TranslatableText enterPassword = new TranslatableText("command.simpleauth.passwordTwice"); - private static TranslatableText alreadyAuthenticated = new TranslatableText("command.simpleauth.alreadyAuthenticated"); - private static TranslatableText alreadyRegistered = new TranslatableText("command.simpleauth.alreadyRegistered"); - private static TranslatableText registerSuccess = new TranslatableText("command.simpleauth.registerSuccess"); + private static TranslatableText enterPassword = new TranslatableText("§6You need to enter your password!"); + private static TranslatableText alreadyAuthenticated = new TranslatableText("§4You are already authenticated."); + private static TranslatableText alreadyRegistered = new TranslatableText("§6This account name is already registered!"); + private static TranslatableText registerSuccess = new TranslatableText("§aYou are now authenticated."); + private static TranslatableText matchPass = new TranslatableText( "§6Passwords must match!"); public static void registerCommand(CommandDispatcher dispatcher) { @@ -59,9 +55,7 @@ public class RegisterCommand { player.sendMessage(alreadyRegistered); return 0; } - player.sendMessage( - new LiteralText(source.getName() + ", passwords must match!") - ); + player.sendMessage(matchPass); return 0; } } diff --git a/src/main/java/org/samo_lego/simpleauth/commands/UnregisterCommand.java b/src/main/java/org/samo_lego/simpleauth/commands/UnregisterCommand.java index a117449..beb063d 100644 --- a/src/main/java/org/samo_lego/simpleauth/commands/UnregisterCommand.java +++ b/src/main/java/org/samo_lego/simpleauth/commands/UnregisterCommand.java @@ -16,9 +16,9 @@ import static net.minecraft.server.command.CommandManager.argument; import static net.minecraft.server.command.CommandManager.literal; public class UnregisterCommand { - private static TranslatableText enterPassword = new TranslatableText("command.simpleauth.password"); - private static TranslatableText wrongPassword = new TranslatableText("command.simpleauth.wrongPassword"); - private static TranslatableText accountDeleted = new TranslatableText("command.simpleauth.accountDeleted"); + private static TranslatableText enterPassword = new TranslatableText("§6You need to enter your password!"); + private static TranslatableText wrongPassword = new TranslatableText("§4Wrong password!"); + private static TranslatableText accountDeleted = new TranslatableText("§4Your account was successfully deleted!"); public static void registerCommand(CommandDispatcher dispatcher) { // Registering the "/unregister" command diff --git a/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java b/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java index 4b26195..878a1ad 100644 --- a/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java +++ b/src/main/java/org/samo_lego/simpleauth/event/AuthEventHandler.java @@ -1,10 +1,7 @@ package org.samo_lego.simpleauth.event; -import net.fabricmc.fabric.api.network.ServerSidePacketRegistry; -import net.minecraft.client.network.packet.InventoryS2CPacket; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.item.ItemStack; -import net.minecraft.network.PacketEncoder; import net.minecraft.server.network.ServerPlayerEntity; import net.minecraft.server.network.packet.ChatMessageC2SPacket; import net.minecraft.text.TranslatableText; @@ -17,7 +14,7 @@ import org.samo_lego.simpleauth.SimpleAuth; * and cancels them if they aren't authenticated */ public class AuthEventHandler { - private static TranslatableText notAuthenticated = new TranslatableText("command.simpleauth.notAuthenticated"); + private static TranslatableText notAuthenticated = new TranslatableText("§4You are not authenticated!\nTry with /login or /register."); // Player joining the server public static void onPlayerJoin(ServerPlayerEntity player) { diff --git a/src/main/java/org/samo_lego/simpleauth/utils/AuthHelper.java b/src/main/java/org/samo_lego/simpleauth/utils/AuthHelper.java index 0c0b3b4..e0d0941 100644 --- a/src/main/java/org/samo_lego/simpleauth/utils/AuthHelper.java +++ b/src/main/java/org/samo_lego/simpleauth/utils/AuthHelper.java @@ -19,7 +19,7 @@ public class AuthHelper { // Verify password return argon2.verify(hashed, pass); } catch(Error e) { - LOGGER.error("SimpleAut error: " + e); + LOGGER.error("[SimpleAuth] error: " + e); } finally { // Wipe confidential data argon2.wipeArray(pass);