Update webpassword command and clean up deprecated logic

This commit is contained in:
2025-02-23 17:27:29 +01:00
parent a2b3661605
commit fd82707414
4 changed files with 12 additions and 13 deletions
@@ -543,7 +543,6 @@ WEB_USAGE=§8/§7webpassword §8[§epassword§8]
WEB_UPDATED=§7Your password was updated. WEB_UPDATED=§7Your password was updated.
WEB_CREATED=§7Your webaccount was created. WEB_CREATED=§7Your webaccount was created.
WEB_PASSWORD_LENGTH=§cYour password is shorter than 8 characters. WEB_PASSWORD_LENGTH=§cYour password is shorter than 8 characters.
WEB_RESET_URL=§7You can reset your Password here: §ehttps://steamwar.de/reset-password?token={0}
#ChatListener #ChatListener
CHAT_LIXFEL_ACTION_BAR=§4§lTechnical problems? CHAT_LIXFEL_ACTION_BAR=§4§lTechnical problems?
@@ -518,7 +518,6 @@ WEB_USAGE=§8/§7webpassword §8[§ePasswort§8]
WEB_UPDATED=§7Dein Passwort wurde aktualisiert. WEB_UPDATED=§7Dein Passwort wurde aktualisiert.
WEB_CREATED=§7Dein Webaccount wurde erstellt. WEB_CREATED=§7Dein Webaccount wurde erstellt.
WEB_PASSWORD_LENGTH=§cDein Passwort ist kürzer als 8 Zeichen. WEB_PASSWORD_LENGTH=§cDein Passwort ist kürzer als 8 Zeichen.
WEB_RESET_URL=§7Hier kannst du dein Passwort zurücksetzen: §ehttps://steamwar.de/passwort-setzen?token={0}
#ChatListener #ChatListener
CHAT_LIXFEL_ACTION_BAR=§4§lTechnische Probleme? CHAT_LIXFEL_ACTION_BAR=§4§lTechnische Probleme?
@@ -22,11 +22,6 @@ package de.steamwar.velocitycore.commands;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import de.steamwar.messages.Chatter; import de.steamwar.messages.Chatter;
import de.steamwar.sql.SteamwarUser; import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Token;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.nio.charset.StandardCharsets;
public class WebpasswordCommand extends SWCommand { public class WebpasswordCommand extends SWCommand {
@@ -34,13 +29,19 @@ public class WebpasswordCommand extends SWCommand {
super("webpassword", "webpw", "web"); super("webpassword", "webpw", "web");
} }
private static final HttpClient client = HttpClient.newHttpClient();
@Register(description = "WEB_USAGE") @Register(description = "WEB_USAGE")
public void genericCommand(Chatter sender) { public void genericCommand(Chatter sender, String password) {
SteamwarUser user = sender.user(); if(password.length() < 8) {
sender.system("WEB_PASSWORD_LENGTH");
return;
}
String token = Token.createToken("PT" + user.getUserName(), user); SteamwarUser user = sender.user();
sender.system("WEB_RESET_URL", URLEncoder.encode(token, StandardCharsets.UTF_8)); boolean resetPW = user.hasPassword();
user.setPassword(password);
sender.system(resetPW ? "WEB_UPDATED" : "WEB_CREATED");
} }
} }
@@ -54,7 +54,7 @@ public class ChatListener extends BasicListener {
private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemTypeOrInternalName).toList(); private static final List<String> rankedModes = ArenaMode.getAllModes().stream().filter(ArenaMode::isRanked).map(ArenaMode::getSchemTypeOrInternalName).toList();
private static final Set<String> noLogCommands = Set.of("webpw", "webpassword"); private static final Set<String> noLogCommands = Set.of("webpw", "webpassword", "web");
@Subscribe(order = PostOrder.FIRST) @Subscribe(order = PostOrder.FIRST)
public void fixCommands(CommandExecuteEvent e) { public void fixCommands(CommandExecuteEvent e) {