From 43a9b92b41413ba0b830babda550ef903b3af166 Mon Sep 17 00:00:00 2001 From: Lixfel Date: Sat, 20 Aug 2022 19:10:26 +0200 Subject: [PATCH] Bye Bye Mail. Signed-off-by: Lixfel --- src/de/steamwar/bungeecore/BungeeCore.java | 2 +- ...erCommand.java => WebpasswordCommand.java} | 49 +++++++------------ .../steamwar/bungeecore/sql/SteamwarUser.java | 4 +- .../steamwar/messages/BungeeCore.properties | 11 ++--- .../messages/BungeeCore_de.properties | 11 ++--- 5 files changed, 29 insertions(+), 48 deletions(-) rename src/de/steamwar/bungeecore/commands/{WebregisterCommand.java => WebpasswordCommand.java} (56%) diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java index 5660af1..a63d71a 100644 --- a/src/de/steamwar/bungeecore/BungeeCore.java +++ b/src/de/steamwar/bungeecore/BungeeCore.java @@ -168,7 +168,7 @@ public class BungeeCore extends Plugin { if(!EVENT_MODE){ new BauCommand(); - new WebregisterCommand(); + new WebpasswordCommand(); new FightCommand(); new ChallengeCommand(); new HistoricCommand(); diff --git a/src/de/steamwar/bungeecore/commands/WebregisterCommand.java b/src/de/steamwar/bungeecore/commands/WebpasswordCommand.java similarity index 56% rename from src/de/steamwar/bungeecore/commands/WebregisterCommand.java rename to src/de/steamwar/bungeecore/commands/WebpasswordCommand.java index 6197f0f..d5bc7ec 100644 --- a/src/de/steamwar/bungeecore/commands/WebregisterCommand.java +++ b/src/de/steamwar/bungeecore/commands/WebpasswordCommand.java @@ -20,57 +20,44 @@ package de.steamwar.bungeecore.commands; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.sql.SWException; import de.steamwar.command.SWCommand; +import de.steamwar.messages.ChatSender; import net.md_5.bungee.api.connection.ProxiedPlayer; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -public class WebregisterCommand extends SWCommand { +public class WebpasswordCommand extends SWCommand { - public WebregisterCommand() { - super("webregister", null, "web", "webpw"); + public WebpasswordCommand() { + super("webpassword", null, "web", "webpw"); } @Register(description = "WEB_USAGE") - public void genericCommand(ProxiedPlayer player, String email) { - ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), email); + public void genericCommand(ProxiedPlayer player, String password) { + if(password.length() < 8) { + ChatSender.of(player).system("WEB_PASSWORD_LENGTH"); + return; + } + + ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", player.getName(), password); pb.redirectErrorStream(true); try { Process regProcess = pb.start(); BufferedReader reader = new BufferedReader(new InputStreamReader(regProcess.getInputStream())); String errorLine; - boolean error = false; - while((errorLine = reader.readLine()) != null){ - switch(errorLine){ - case "username_exists": - Message.send("WEB_ALREADY", player); - break; - case "email_exists": - Message.send("WEB_ALREADY_EMAIL", player); - // SWException.log("Bungee", "Duplicate E-Mail", player.getName() + " " + args[0]); - break; - case "invalid_email": - Message.send("WEB_NOT_EMAIL", player); - break; - case "email_updated": - Message.send("WEB_EMAIL_REFRESH", player); - break; - default: - Message.send("WEB_INTERNAL_ERROR", player); - SWException.log("Bungee", "Unknown Wordpress User Creation Error", errorLine); + if((errorLine = reader.readLine()) != null) { + if ("updated".equals(errorLine)) { + Message.send("WEB_UPDATED", player); + return; + } else { + throw new SecurityException("Could not create webaccount " + errorLine); } - error = true; } - if(error) - return; - - Message.send("WEB_EMAIL_SEND", player); + Message.send("WEB_CREATED", player); } catch (IOException e) { - Message.send("WEB_INTERNAL_ERROR", player); throw new SecurityException("Could not create webaccount", e); } } diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 96c92d5..a5cb605 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -22,7 +22,7 @@ package de.steamwar.bungeecore.sql; import com.google.gson.JsonParser; import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.Message; -import de.steamwar.bungeecore.commands.WebregisterCommand; +import de.steamwar.bungeecore.commands.WebpasswordCommand; import de.steamwar.bungeecore.listeners.ConnectionListener; import de.steamwar.bungeecore.network.NetworkSender; import de.steamwar.messages.ChatSender; @@ -121,7 +121,7 @@ public class SteamwarUser { String userName = connection.getName(); if (!user.userName.equals(userName)) { updateName.update(userName, user.id); - WebregisterCommand.changeUsername(user.userName, userName); + WebpasswordCommand.changeUsername(user.userName, userName); user.userName = userName; } } else { diff --git a/src/de/steamwar/messages/BungeeCore.properties b/src/de/steamwar/messages/BungeeCore.properties index 203618f..a2ba6ff 100644 --- a/src/de/steamwar/messages/BungeeCore.properties +++ b/src/de/steamwar/messages/BungeeCore.properties @@ -498,13 +498,10 @@ UNIGNORE_NOT_IGNORED=§cYou are not ignoring this player. UNIGNORE_UNIGNORED=§7You ignored §e{0}§8. #WebregisterCommand -WEB_USAGE=§8/§7webregister §8[§eE-Mail§8] -WEB_ALREADY=§cYou already have a webaccount. -WEB_ALREADY_EMAIL=§cYou already used this E-Mail address on another account... -WEB_NOT_EMAIL=§c[E-Mail], not [free text]! -WEB_EMAIL_REFRESH=§aYour E-Mail was updated. -WEB_INTERNAL_ERROR=§cAn internal error occurred, please contact a developer. -WEB_EMAIL_SEND=§aAn E-Mail to reset your password has been sent. +WEB_USAGE=§8/§7webpassword §8[§epassword§8] +WEB_UPDATED=§7Your password was updated. +WEB_CREATED=§7Your webaccount was created. +WEB_PASSWORD_LENGTH=§cYour password is shorter than 8 characters. #ChatListener CHAT_LIXFEL_ACTION_BAR=§4§lTechnical problems? diff --git a/src/de/steamwar/messages/BungeeCore_de.properties b/src/de/steamwar/messages/BungeeCore_de.properties index 28df9b1..b23a577 100644 --- a/src/de/steamwar/messages/BungeeCore_de.properties +++ b/src/de/steamwar/messages/BungeeCore_de.properties @@ -477,13 +477,10 @@ UNIGNORE_NOT_IGNORED=§cDu ignorierst diesen Spieler nicht. UNIGNORE_UNIGNORED=§7Du empfängst nun wieder Nachrichten von §e{0}§8. #WebregisterCommand -WEB_USAGE=§8/§7webregister §8[§eE-Mail§8] -WEB_ALREADY=§cDu hast bereits einen Webaccount. -WEB_ALREADY_EMAIL=§cDie E-Mail hast du bereits für einen anderen Account verwendet... -WEB_NOT_EMAIL=§c[E-Mail], nicht [Freitext]! -WEB_EMAIL_REFRESH=§aDeine E-Mail-Adresse wurde aktualisiert. -WEB_INTERNAL_ERROR=§cEin interner Fehler ist aufgetreten, bitte wende dich an einen Developer. -WEB_EMAIL_SEND=§aEine E-Mail zum Setzen des Passworts wurde gesendet. +WEB_USAGE=§8/§7webpassword §8[§ePasswort§8] +WEB_UPDATED=§7Dein Passwort wurde aktualisiert. +WEB_CREATED=§7Dein Webaccount wurde erstellt. +WEB_PASSWORD_LENGTH=§cDein Passwort ist kürzer als 8 Zeichen. #ChatListener CHAT_LIXFEL_ACTION_BAR=§4§lTechnische Probleme?