Disabled changing password / unregistering if global password is enabled. Updated unregitser lang config.
This commit is contained in:
parent
ff1b6749c6
commit
a5a30ba3e6
|
@ -6,7 +6,6 @@ import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.LiteralText;
|
import net.minecraft.text.LiteralText;
|
||||||
import net.minecraft.text.Text;
|
import net.minecraft.text.Text;
|
||||||
import net.minecraft.text.Text;
|
|
||||||
import org.samo_lego.simpleauth.SimpleAuth;
|
import org.samo_lego.simpleauth.SimpleAuth;
|
||||||
import org.samo_lego.simpleauth.utils.AuthHelper;
|
import org.samo_lego.simpleauth.utils.AuthHelper;
|
||||||
|
|
||||||
|
@ -20,6 +19,7 @@ public class ChangepwCommand {
|
||||||
private static Text enterPassword = new LiteralText(SimpleAuth.config.lang.enterPassword);
|
private static Text enterPassword = new LiteralText(SimpleAuth.config.lang.enterPassword);
|
||||||
private static Text wrongPassword = new LiteralText(SimpleAuth.config.lang.wrongPassword);
|
private static Text wrongPassword = new LiteralText(SimpleAuth.config.lang.wrongPassword);
|
||||||
private static Text passwordUpdated = new LiteralText(SimpleAuth.config.lang.passwordUpdated);
|
private static Text passwordUpdated = new LiteralText(SimpleAuth.config.lang.passwordUpdated);
|
||||||
|
private static Text cannotChangePassword = new LiteralText(SimpleAuth.config.lang.cannotChangePassword);
|
||||||
|
|
||||||
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
// Registering the "/changepw" command
|
// Registering the "/changepw" command
|
||||||
|
@ -50,7 +50,11 @@ public class ChangepwCommand {
|
||||||
// Getting the player who send the command
|
// Getting the player who send the command
|
||||||
ServerPlayerEntity player = source.getPlayer();
|
ServerPlayerEntity player = source.getPlayer();
|
||||||
|
|
||||||
if (AuthHelper.checkPass(player.getUuidAsString(), oldPass.toCharArray())) {
|
if (SimpleAuth.config.main.enableGlobalPassword) {
|
||||||
|
player.sendMessage(cannotChangePassword);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (AuthHelper.checkPass(player.getUuidAsString(), oldPass.toCharArray())) {
|
||||||
SimpleAuth.db.update(
|
SimpleAuth.db.update(
|
||||||
player.getUuidAsString(),
|
player.getUuidAsString(),
|
||||||
null,
|
null,
|
||||||
|
|
|
@ -4,7 +4,8 @@ import com.mojang.brigadier.CommandDispatcher;
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.server.command.ServerCommandSource;
|
import net.minecraft.server.command.ServerCommandSource;
|
||||||
import net.minecraft.server.network.ServerPlayerEntity;
|
import net.minecraft.server.network.ServerPlayerEntity;
|
||||||
import net.minecraft.text.TranslatableText;
|
import net.minecraft.text.LiteralText;
|
||||||
|
import net.minecraft.text.Text;
|
||||||
import org.samo_lego.simpleauth.SimpleAuth;
|
import org.samo_lego.simpleauth.SimpleAuth;
|
||||||
import org.samo_lego.simpleauth.utils.AuthHelper;
|
import org.samo_lego.simpleauth.utils.AuthHelper;
|
||||||
|
|
||||||
|
@ -14,9 +15,10 @@ import static net.minecraft.server.command.CommandManager.argument;
|
||||||
import static net.minecraft.server.command.CommandManager.literal;
|
import static net.minecraft.server.command.CommandManager.literal;
|
||||||
|
|
||||||
public class UnregisterCommand {
|
public class UnregisterCommand {
|
||||||
private static TranslatableText enterPassword = new TranslatableText("§6You need to enter your password!");
|
private static Text enterPassword = new LiteralText(SimpleAuth.config.lang.enterPassword);
|
||||||
private static TranslatableText wrongPassword = new TranslatableText("§4Wrong password!");
|
private static Text wrongPassword = new LiteralText(SimpleAuth.config.lang.wrongPassword);
|
||||||
private static TranslatableText accountDeleted = new TranslatableText("§4Your account was successfully deleted!");
|
private static Text accountDeleted = new LiteralText(SimpleAuth.config.lang.accountDeleted);
|
||||||
|
private static Text cannotUnregister = new LiteralText(SimpleAuth.config.lang.cannotUnregister);
|
||||||
|
|
||||||
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
|
public static void registerCommand(CommandDispatcher<ServerCommandSource> dispatcher) {
|
||||||
// Registering the "/unregister" command
|
// Registering the "/unregister" command
|
||||||
|
@ -39,7 +41,11 @@ public class UnregisterCommand {
|
||||||
private static int unregister(ServerCommandSource source, String pass) throws CommandSyntaxException {
|
private static int unregister(ServerCommandSource source, String pass) throws CommandSyntaxException {
|
||||||
// Getting the player who send the command
|
// Getting the player who send the command
|
||||||
ServerPlayerEntity player = source.getPlayer();
|
ServerPlayerEntity player = source.getPlayer();
|
||||||
if (AuthHelper.checkPass(player.getUuidAsString(), pass.toCharArray())) {
|
if (SimpleAuth.config.main.enableGlobalPassword) {
|
||||||
|
player.sendMessage(cannotUnregister);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
else if (AuthHelper.checkPass(player.getUuidAsString(), pass.toCharArray())) {
|
||||||
SimpleAuth.db.delete(player.getUuidAsString(), null);
|
SimpleAuth.db.delete(player.getUuidAsString(), null);
|
||||||
player.sendMessage(accountDeleted);
|
player.sendMessage(accountDeleted);
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
@ -68,6 +68,8 @@ public class AuthConfig {
|
||||||
public String passwordUpdated = "§4Your password was updated successfully!";
|
public String passwordUpdated = "§4Your password was updated successfully!";
|
||||||
public String loginRequired = "§cYou are not authenticated!\n§6Use /login to authenticate!";
|
public String loginRequired = "§cYou are not authenticated!\n§6Use /login to authenticate!";
|
||||||
public String globalPasswordSet = "§aGlobal password was successfully set!";
|
public String globalPasswordSet = "§aGlobal password was successfully set!";
|
||||||
|
public String cannotChangePassword = "§aYou cannot change password!";
|
||||||
|
public String cannotUnregister = "§aYou cannot unregister this account!";
|
||||||
public String notAuthenticated = "§cYou are not authenticated!\n§6Try with /login or /register.";
|
public String notAuthenticated = "§cYou are not authenticated!\n§6Try with /login or /register.";
|
||||||
public String alreadyAuthenticated = "§4You are already authenticated.";
|
public String alreadyAuthenticated = "§4You are already authenticated.";
|
||||||
public String successfullyAuthenticated = "§aYou are now authenticated.";
|
public String successfullyAuthenticated = "§aYou are now authenticated.";
|
||||||
|
@ -76,6 +78,7 @@ public class AuthConfig {
|
||||||
public String registerSuccess = "§aYou are now authenticated.";
|
public String registerSuccess = "§aYou are now authenticated.";
|
||||||
public String userdataDeleted = "§aUserdata deleted.";
|
public String userdataDeleted = "§aUserdata deleted.";
|
||||||
public String userdataUpdated = "§aUserdata updated.";
|
public String userdataUpdated = "§aUserdata updated.";
|
||||||
|
public String accountDeleted = "§4Your account was successfully deleted!";
|
||||||
public String configurationReloaded = "§aConfiguration file was reloaded successfully.";
|
public String configurationReloaded = "§aConfiguration file was reloaded successfully.";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue