|
|
|
@ -21,11 +21,11 @@ package de.steamwar.bungeecore.commands;
|
|
|
|
|
|
|
|
|
|
import de.steamwar.command.SWCommand;
|
|
|
|
|
import de.steamwar.messages.ChatSender;
|
|
|
|
|
import de.steamwar.sql.SteamwarUser;
|
|
|
|
|
import de.steamwar.sql.Token;
|
|
|
|
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
|
|
|
|
|
|
|
|
|
import java.io.BufferedReader;
|
|
|
|
|
import java.io.IOException;
|
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
|
|
|
|
|
|
public class WebpasswordCommand extends SWCommand {
|
|
|
|
|
|
|
|
|
@ -41,25 +41,12 @@ public class WebpasswordCommand extends SWCommand {
|
|
|
|
|
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;
|
|
|
|
|
if((errorLine = reader.readLine()) != null) {
|
|
|
|
|
if ("updated".equals(errorLine)) {
|
|
|
|
|
ChatSender.of(player).system("WEB_UPDATED");
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
throw new SecurityException("Could not create webaccount " + errorLine);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
|
|
|
|
user.setPassword(password);
|
|
|
|
|
|
|
|
|
|
ChatSender.of(player).system("WEB_CREATED");
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
throw new SecurityException("Could not create webaccount", e);
|
|
|
|
|
}
|
|
|
|
|
Token.listUser(user).stream().filter(token -> token.getName().startsWith("Website: ")).forEach(token -> token.delete());
|
|
|
|
|
|
|
|
|
|
ChatSender.of(player).system("WEB_UPDATED");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void changeUsername(String oldUsername, String newUsername){
|
|
|
|
|