forked from SteamWar/SteamWar
Merge pull request 'Update Schematic Download and /webpw to new Website' (#3) from Schematics/new-website into main
Reviewed-on: SteamWar/SteamWar#3
This commit is contained in:
@@ -61,7 +61,7 @@ public class PunishmentCommand {
|
||||
return null;
|
||||
}
|
||||
|
||||
return SteamwarUser.getOrCreate(uuid, name, u -> {}, (o, n) -> {});
|
||||
return SteamwarUser.getOrCreate(uuid, name, u -> {});
|
||||
}
|
||||
|
||||
private static UUID getUUIDofOfflinePlayer(String playerName) {
|
||||
|
||||
@@ -21,10 +21,7 @@ package de.steamwar.velocitycore.commands;
|
||||
|
||||
import de.steamwar.command.SWCommand;
|
||||
import de.steamwar.messages.Chatter;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import de.steamwar.sql.SteamwarUser;
|
||||
|
||||
public class WebpasswordCommand extends SWCommand {
|
||||
|
||||
@@ -40,33 +37,11 @@ public class WebpasswordCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
ProcessBuilder pb = new ProcessBuilder("php", "/var/www/register.php", sender.user().getUserName(), 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)) {
|
||||
sender.system("WEB_UPDATED");
|
||||
return;
|
||||
} else {
|
||||
throw new SecurityException("Could not create webaccount " + errorLine);
|
||||
}
|
||||
}
|
||||
SteamwarUser user = sender.user();
|
||||
boolean resetPW = user.hasPassword();
|
||||
|
||||
sender.system("WEB_CREATED");
|
||||
} catch (IOException e) {
|
||||
throw new SecurityException("Could not create webaccount", e);
|
||||
}
|
||||
}
|
||||
user.setPassword(password);
|
||||
|
||||
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);
|
||||
}
|
||||
sender.system(resetPW ? "WEB_UPDATED" : "WEB_CREATED");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import net.kyori.adventure.text.event.ClickEvent;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.function.BiConsumer;
|
||||
|
||||
public class ConnectionListener extends BasicListener {
|
||||
|
||||
@@ -56,7 +57,7 @@ public class ConnectionListener extends BasicListener {
|
||||
if(!(subject instanceof Player player))
|
||||
return perm -> Tristate.TRUE;
|
||||
|
||||
Set<UserPerm> perms = SteamwarUser.getOrCreate(player.getUniqueId(), player.getUsername(), ConnectionListener::newPlayer, WebpasswordCommand::changeUsername).perms();
|
||||
Set<UserPerm> perms = SteamwarUser.getOrCreate(player.getUniqueId(), player.getUsername(), ConnectionListener::newPlayer).perms();
|
||||
if(perms.contains(UserPerm.ADMINISTRATION))
|
||||
return perm -> Tristate.TRUE;
|
||||
else if(perms.contains(UserPerm.TEAM))
|
||||
|
||||
Reference in New Issue
Block a user