From 1d1c8baf43ebe4ed56b8159ea6f6a24fbd78b41a Mon Sep 17 00:00:00 2001 From: Lixfel Date: Tue, 10 Mar 2020 07:00:15 +0100 Subject: [PATCH] Change username on website with username change Signed-off-by: Lixfel --- .../steamwar/bungeecore/commands/WebregisterCommand.java | 9 +++++++++ src/de/steamwar/bungeecore/sql/SteamwarUser.java | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/de/steamwar/bungeecore/commands/WebregisterCommand.java b/src/de/steamwar/bungeecore/commands/WebregisterCommand.java index e04cf187..0eb502c3 100644 --- a/src/de/steamwar/bungeecore/commands/WebregisterCommand.java +++ b/src/de/steamwar/bungeecore/commands/WebregisterCommand.java @@ -61,4 +61,13 @@ public class WebregisterCommand extends BasicCommand { throw new SecurityException("Could not create webaccount", e); } } + + public static void changeUsername(String oldUsername, String newUsername){ + ProcessBuilder pb = new ProcessBuilder("php", "/var/www/changename.php", oldUsername, newUsername); + try { + pb.start(); + } catch (IOException e) { + throw new SecurityException("Could not change username", e); + } + } } diff --git a/src/de/steamwar/bungeecore/sql/SteamwarUser.java b/src/de/steamwar/bungeecore/sql/SteamwarUser.java index 726fb09b..b0320b51 100644 --- a/src/de/steamwar/bungeecore/sql/SteamwarUser.java +++ b/src/de/steamwar/bungeecore/sql/SteamwarUser.java @@ -1,6 +1,7 @@ package de.steamwar.bungeecore.sql; import de.steamwar.bungeecore.BungeeCore; +import de.steamwar.bungeecore.commands.WebregisterCommand; import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.connection.PendingConnection; @@ -53,6 +54,7 @@ public class SteamwarUser { String userName = connection.getName(); if(!user.userName.equals(userName)){ SQL.update("UPDATE UserData SET UserName = ? WHERE id = ?", userName, user.id); + WebregisterCommand.changeUsername(user.userName, userName); user.userName = userName; } }else{