From a2ce616dbbc527a19d7a7fea19c6d5ad44091fe2 Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 19 Dec 2023 20:49:37 +0100 Subject: [PATCH] Code Review Stuff --- CommonCore | 2 +- .../bungeecore/commands/PunishmentCommand.java | 2 +- .../bungeecore/commands/WebpasswordCommand.java | 12 +++++++++--- .../steamwar/bungeecore/listeners/BanListener.java | 2 +- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/CommonCore b/CommonCore index e83ab47..9a3630b 160000 --- a/CommonCore +++ b/CommonCore @@ -1 +1 @@ -Subproject commit e83ab4762d77567a01b0b71bdf12b65bf2aca3bd +Subproject commit 9a3630b07cb870266669ba120985a2c0a8ebbf5c diff --git a/src/de/steamwar/bungeecore/commands/PunishmentCommand.java b/src/de/steamwar/bungeecore/commands/PunishmentCommand.java index 5f4724d..47ed67a 100644 --- a/src/de/steamwar/bungeecore/commands/PunishmentCommand.java +++ b/src/de/steamwar/bungeecore/commands/PunishmentCommand.java @@ -66,7 +66,7 @@ public class PunishmentCommand { return null; } - return SteamwarUser.getOrCreate(uuid, name, u -> {}); + return SteamwarUser.getOrCreate(uuid, name, u -> {}, (o, n) -> {}); } private static UUID getUUIDofOfflinePlayer(String playerName) { diff --git a/src/de/steamwar/bungeecore/commands/WebpasswordCommand.java b/src/de/steamwar/bungeecore/commands/WebpasswordCommand.java index edbfd05..be60a2d 100644 --- a/src/de/steamwar/bungeecore/commands/WebpasswordCommand.java +++ b/src/de/steamwar/bungeecore/commands/WebpasswordCommand.java @@ -19,16 +19,13 @@ package de.steamwar.bungeecore.commands; -import de.steamwar.bungeecore.BungeeCore; 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 { @@ -51,4 +48,13 @@ public class WebpasswordCommand extends SWCommand { ChatSender.of(player).system("WEB_UPDATED"); } + + 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/listeners/BanListener.java b/src/de/steamwar/bungeecore/listeners/BanListener.java index 975e86c..df8fa0e 100644 --- a/src/de/steamwar/bungeecore/listeners/BanListener.java +++ b/src/de/steamwar/bungeecore/listeners/BanListener.java @@ -46,7 +46,7 @@ public class BanListener extends BasicListener { event.registerIntent(BungeeCore.get()); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> { PendingConnection connection = event.getConnection(); - SteamwarUser user = SteamwarUser.getOrCreate(connection.getUniqueId(), connection.getName(), ConnectionListener::newPlayer); + SteamwarUser user = SteamwarUser.getOrCreate(connection.getUniqueId(), connection.getName(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername); if (user.isPunished(Punishment.PunishmentType.Ban)) { event.setCancelled(true); BannedUserIPs.banIP(user.getId(), connection.getAddress().getAddress().getHostAddress());