mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE] Replaced String.format to formatted (#665)
This commit is contained in:
parent
9d49eebffe
commit
b12c43676b
18 changed files with 52 additions and 53 deletions
|
@ -512,7 +512,7 @@ public void collect() {
|
||||||
launcherPackDir = getPath(LAUNCHERPACK_NAME);
|
launcherPackDir = getPath(LAUNCHERPACK_NAME);
|
||||||
if (keyDirectory == null) keyDirectory = getPath(KEY_NAME);
|
if (keyDirectory == null) keyDirectory = getPath(KEY_NAME);
|
||||||
if (tmpDir == null)
|
if (tmpDir == null)
|
||||||
tmpDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve(String.format("launchserver-%s", SecurityHelper.randomStringToken()));
|
tmpDir = Paths.get(System.getProperty("java.io.tmpdir")).resolve("launchserver-%s".formatted(SecurityHelper.randomStringToken()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Path getPath(String dirName) {
|
private Path getPath(String dirName) {
|
||||||
|
|
|
@ -92,7 +92,7 @@ public void visit(final String name, final Object value) {
|
||||||
if ("value".equals(name)) {
|
if ("value".equals(name)) {
|
||||||
if (value.getClass() != String.class)
|
if (value.getClass() != String.class)
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
String.format("Invalid annotation with value class %s", field.getClass().getName()));
|
"Invalid annotation with value class %s".formatted(field.getClass().getName()));
|
||||||
valueName.set(value.toString());
|
valueName.set(value.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ public void visit(final String name, final Object value) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (initMethod == null) {
|
if (initMethod == null) {
|
||||||
throw new IllegalArgumentException(String.format("Not found init in target: %s", classNode.name));
|
throw new IllegalArgumentException("Not found init in target: %s".formatted(classNode.name));
|
||||||
}
|
}
|
||||||
List<FieldInsnNode> putFieldNodes = Arrays.stream(initMethod.instructions.toArray())
|
List<FieldInsnNode> putFieldNodes = Arrays.stream(initMethod.instructions.toArray())
|
||||||
.filter(node -> node instanceof FieldInsnNode && node.getOpcode() == Opcodes.PUTFIELD).map(p -> (FieldInsnNode) p)
|
.filter(node -> node instanceof FieldInsnNode && node.getOpcode() == Opcodes.PUTFIELD).map(p -> (FieldInsnNode) p)
|
||||||
|
@ -173,8 +173,7 @@ private static InsnList serializeValue(Object value) {
|
||||||
return ((Serializer) serializerEntry.getValue()).serialize(value);
|
return ((Serializer) serializerEntry.getValue()).serialize(value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new UnsupportedOperationException(String.format("Serialization of type %s is not supported",
|
throw new UnsupportedOperationException("Serialization of type %s is not supported".formatted(value.getClass()));
|
||||||
value.getClass()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean isSerializableValue(Object value) {
|
public static boolean isSerializableValue(Object value) {
|
||||||
|
|
|
@ -72,11 +72,11 @@ public final void link(LaunchServer srv) {
|
||||||
links.forEach((k, v) -> {
|
links.forEach((k, v) -> {
|
||||||
AuthProviderPair pair = srv.config.getAuthProviderPair(v);
|
AuthProviderPair pair = srv.config.getAuthProviderPair(v);
|
||||||
if (pair == null) {
|
if (pair == null) {
|
||||||
throw new NullPointerException(String.format("Auth %s link failed. Pair %s not found", name, v));
|
throw new NullPointerException("Auth %s link failed. Pair %s not found".formatted(name, v));
|
||||||
}
|
}
|
||||||
if ("core".equals(k)) {
|
if ("core".equals(k)) {
|
||||||
if (pair.core == null)
|
if (pair.core == null)
|
||||||
throw new NullPointerException(String.format("Auth %s link failed. %s.core is null", name, v));
|
throw new NullPointerException("Auth %s link failed. %s.core is null".formatted(name, v));
|
||||||
core = pair.core;
|
core = pair.core;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -170,20 +170,20 @@ public void init(LaunchServer server) {
|
||||||
if (table == null) logger.error("table cannot be null");
|
if (table == null) logger.error("table cannot be null");
|
||||||
// Prepare SQL queries
|
// Prepare SQL queries
|
||||||
String userInfoCols = makeUserCols();
|
String userInfoCols = makeUserCols();
|
||||||
queryByUUIDSQL = customQueryByUUIDSQL != null ? customQueryByUUIDSQL : String.format("SELECT %s FROM %s WHERE %s=? LIMIT 1", userInfoCols,
|
queryByUUIDSQL = customQueryByUUIDSQL != null ? customQueryByUUIDSQL :
|
||||||
table, uuidColumn);
|
"SELECT %s FROM %s WHERE %s=? LIMIT 1".formatted(userInfoCols, table, uuidColumn);
|
||||||
queryByUsernameSQL = customQueryByUsernameSQL != null ? customQueryByUsernameSQL : String.format("SELECT %s FROM %s WHERE %s=? LIMIT 1",
|
queryByUsernameSQL = customQueryByUsernameSQL != null ? customQueryByUsernameSQL :
|
||||||
userInfoCols, table, usernameColumn);
|
"SELECT %s FROM %s WHERE %s=? LIMIT 1".formatted(userInfoCols, table, usernameColumn);
|
||||||
queryByLoginSQL = customQueryByLoginSQL != null ? customQueryByLoginSQL : queryByUsernameSQL;
|
queryByLoginSQL = customQueryByLoginSQL != null ? customQueryByLoginSQL : queryByUsernameSQL;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
updateAuthSQL = customUpdateAuthSQL != null ? customUpdateAuthSQL : String.format("UPDATE %s SET %s=?, %s=NULL WHERE %s=?",
|
updateAuthSQL = customUpdateAuthSQL != null ? customUpdateAuthSQL :
|
||||||
table, accessTokenColumn, serverIDColumn, uuidColumn);
|
"UPDATE %s SET %s=?, %s=NULL WHERE %s=?".formatted(table, accessTokenColumn, serverIDColumn, uuidColumn);
|
||||||
updateServerIDSQL = customUpdateServerIdSQL != null ? customUpdateServerIdSQL : String.format("UPDATE %s SET %s=? WHERE %s=?",
|
updateServerIDSQL = customUpdateServerIdSQL != null ? customUpdateServerIdSQL :
|
||||||
table, serverIDColumn, uuidColumn);
|
"UPDATE %s SET %s=? WHERE %s=?".formatted(table, serverIDColumn, uuidColumn);
|
||||||
if (isEnabledPermissions()) {
|
if (isEnabledPermissions()) {
|
||||||
if(isEnabledRoles()) {
|
if(isEnabledRoles()) {
|
||||||
queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL :
|
queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL :
|
||||||
|
@ -198,14 +198,14 @@ public void init(LaunchServer server) {
|
||||||
"INNER JOIN " + permissionsTable + " pr ON r." + rolesUUIDColumn + "=substring(pr." + permissionsPermissionColumn + " from 6) or r." + rolesNameColumn + "=substring(pr." + permissionsPermissionColumn + " from 6)\n" +
|
"INNER JOIN " + permissionsTable + " pr ON r." + rolesUUIDColumn + "=substring(pr." + permissionsPermissionColumn + " from 6) or r." + rolesNameColumn + "=substring(pr." + permissionsPermissionColumn + " from 6)\n" +
|
||||||
"WHERE pr." + permissionsUUIDColumn + " = ?";
|
"WHERE pr." + permissionsUUIDColumn + " = ?";
|
||||||
} else {
|
} else {
|
||||||
queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL : String.format("SELECT (%s) FROM %s WHERE %s=?",
|
queryPermissionsByUUIDSQL = customQueryPermissionsByUUIDSQL != null ? customQueryPermissionsByUUIDSQL :
|
||||||
permissionsPermissionColumn, permissionsTable, permissionsUUIDColumn);
|
"SELECT (%s) FROM %s WHERE %s=?".formatted(permissionsPermissionColumn, permissionsTable, permissionsUUIDColumn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected String makeUserCols() {
|
protected String makeUserCols() {
|
||||||
return String.format("%s, %s, %s, %s, %s", uuidColumn, usernameColumn, accessTokenColumn, serverIDColumn, passwordColumn);
|
return "%s, %s, %s, %s, %s".formatted(uuidColumn, usernameColumn, accessTokenColumn, serverIDColumn, passwordColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateAuth(User user, String accessToken) throws IOException {
|
protected void updateAuth(User user, String accessToken) throws IOException {
|
||||||
|
|
|
@ -46,21 +46,21 @@ public void init(LaunchServer server) {
|
||||||
String userInfoCols = makeUserCols();
|
String userInfoCols = makeUserCols();
|
||||||
String hardwareInfoCols = "id, hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, graphicCard, banned, publicKey";
|
String hardwareInfoCols = "id, hwDiskId, baseboardSerialNumber, displayId, bitness, totalMemory, logicalProcessors, physicalProcessors, processorMaxFreq, battery, id, graphicCard, banned, publicKey";
|
||||||
if (sqlFindHardwareByPublicKey == null)
|
if (sqlFindHardwareByPublicKey == null)
|
||||||
sqlFindHardwareByPublicKey = String.format("SELECT %s FROM %s WHERE `publicKey` = ?", hardwareInfoCols, tableHWID);
|
sqlFindHardwareByPublicKey = "SELECT %s FROM %s WHERE `publicKey` = ?".formatted(hardwareInfoCols, tableHWID);
|
||||||
if (sqlFindHardwareById == null)
|
if (sqlFindHardwareById == null)
|
||||||
sqlFindHardwareById = String.format("SELECT %s FROM %s WHERE `id` = ?", hardwareInfoCols, tableHWID);
|
sqlFindHardwareById = "SELECT %s FROM %s WHERE `id` = ?".formatted(hardwareInfoCols, tableHWID);
|
||||||
if (sqlUsersByHwidId == null)
|
if (sqlUsersByHwidId == null)
|
||||||
sqlUsersByHwidId = String.format("SELECT %s FROM %s WHERE `%s` = ?", userInfoCols, table, hardwareIdColumn);
|
sqlUsersByHwidId = "SELECT %s FROM %s WHERE `%s` = ?".formatted(userInfoCols, table, hardwareIdColumn);
|
||||||
if (sqlFindHardwareByData == null)
|
if (sqlFindHardwareByData == null)
|
||||||
sqlFindHardwareByData = String.format("SELECT %s FROM %s", hardwareInfoCols, tableHWID);
|
sqlFindHardwareByData = "SELECT %s FROM %s".formatted(hardwareInfoCols, tableHWID);
|
||||||
if (sqlCreateHardware == null)
|
if (sqlCreateHardware == null)
|
||||||
sqlCreateHardware = String.format("INSERT INTO `%s` (`publickey`, `hwDiskId`, `baseboardSerialNumber`, `displayId`, `bitness`, `totalMemory`, `logicalProcessors`, `physicalProcessors`, `processorMaxFreq`, `graphicCard`, `battery`, `banned`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '0')", tableHWID);
|
sqlCreateHardware = "INSERT INTO `%s` (`publickey`, `hwDiskId`, `baseboardSerialNumber`, `displayId`, `bitness`, `totalMemory`, `logicalProcessors`, `physicalProcessors`, `processorMaxFreq`, `graphicCard`, `battery`, `banned`) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, '0')".formatted(tableHWID);
|
||||||
if (sqlCreateHWIDLog == null)
|
if (sqlCreateHWIDLog == null)
|
||||||
sqlCreateHWIDLog = String.format("INSERT INTO %s (`hwidId`, `newPublicKey`) VALUES (?, ?)", tableHWIDLog);
|
sqlCreateHWIDLog = "INSERT INTO %s (`hwidId`, `newPublicKey`) VALUES (?, ?)".formatted(tableHWIDLog);
|
||||||
if (sqlUpdateHardwarePublicKey == null)
|
if (sqlUpdateHardwarePublicKey == null)
|
||||||
sqlUpdateHardwarePublicKey = String.format("UPDATE %s SET `publicKey` = ? WHERE `id` = ?", tableHWID);
|
sqlUpdateHardwarePublicKey = "UPDATE %s SET `publicKey` = ? WHERE `id` = ?".formatted(tableHWID);
|
||||||
sqlUpdateHardwareBanned = String.format("UPDATE %s SET `banned` = ? WHERE `id` = ?", tableHWID);
|
sqlUpdateHardwareBanned = "UPDATE %s SET `banned` = ? WHERE `id` = ?".formatted(tableHWID);
|
||||||
sqlUpdateUsers = String.format("UPDATE %s SET `%s` = ? WHERE `%s` = ?", table, hardwareIdColumn, uuidColumn);
|
sqlUpdateUsers = "UPDATE %s SET `%s` = ? WHERE `%s` = ?".formatted(table, hardwareIdColumn, uuidColumn);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,11 +44,11 @@ public boolean canGetUpdates(String updatesDirName, Client client) {
|
||||||
|
|
||||||
private boolean isWhitelisted(String property, ClientProfile profile, Client client) {
|
private boolean isWhitelisted(String property, ClientProfile profile, Client client) {
|
||||||
if (client.permissions != null) {
|
if (client.permissions != null) {
|
||||||
String permByUUID = String.format(property, profile.getUUID());
|
String permByUUID = property.formatted(profile.getUUID());
|
||||||
if (client.permissions.hasPerm(permByUUID)) {
|
if (client.permissions.hasPerm(permByUUID)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
String permByTitle = String.format(property, profile.getTitle().toLowerCase(Locale.ROOT));
|
String permByTitle = property.formatted(profile.getTitle().toLowerCase(Locale.ROOT));
|
||||||
if (client.permissions.hasPerm(permByTitle)) {
|
if (client.permissions.hasPerm(permByTitle)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -98,7 +98,7 @@ public void build(Path target, boolean deleteTempFiles) throws IOException {
|
||||||
}
|
}
|
||||||
|
|
||||||
public String nextName(String taskName) {
|
public String nextName(String taskName) {
|
||||||
return String.format(nameFormat, taskName, count.getAndIncrement());
|
return nameFormat.formatted(taskName, count.getAndIncrement());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Path nextPath(String taskName) {
|
public Path nextPath(String taskName) {
|
||||||
|
|
|
@ -27,7 +27,7 @@ public Launch4JTask(LaunchServer launchServer) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String formatVars(String mask) {
|
public static String formatVars(String mask) {
|
||||||
return String.format(mask, VERSION, BUILD);
|
return mask.formatted(VERSION, BUILD);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -59,7 +59,7 @@ protected Downloader downloadWithProgressBar(String taskName, List<AsyncDownload
|
||||||
.setStyle(ProgressBarStyle.COLORFUL_UNICODE_BLOCK)
|
.setStyle(ProgressBarStyle.COLORFUL_UNICODE_BLOCK)
|
||||||
.setUnit("MB", 1024 * 1024)
|
.setUnit("MB", 1024 * 1024)
|
||||||
.build();
|
.build();
|
||||||
bar.setExtraMessage(String.format(" [0/%d]", totalFiles));
|
bar.setExtraMessage(" [0/%d]".formatted(totalFiles));
|
||||||
Downloader downloader = Downloader.downloadList(list, baseUrl, targetDir, new Downloader.DownloadCallback() {
|
Downloader downloader = Downloader.downloadList(list, baseUrl, targetDir, new Downloader.DownloadCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void apply(long fullDiff) {
|
public void apply(long fullDiff) {
|
||||||
|
@ -69,7 +69,7 @@ public void apply(long fullDiff) {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete(Path path) {
|
public void onComplete(Path path) {
|
||||||
bar.setExtraMessage(String.format(" [%d/%d]", currentFiles.incrementAndGet(), totalFiles));
|
bar.setExtraMessage(" [%d/%d]".formatted(currentFiles.incrementAndGet(), totalFiles));
|
||||||
}
|
}
|
||||||
}, null, 4);
|
}, null, 4);
|
||||||
downloader.getFuture().handle((v, e) -> {
|
downloader.getFuture().handle((v, e) -> {
|
||||||
|
|
|
@ -38,11 +38,11 @@ public SecurityCheckCommand(LaunchServer server) {
|
||||||
|
|
||||||
public static void printCheckResult(String module, String comment, Boolean status) {
|
public static void printCheckResult(String module, String comment, Boolean status) {
|
||||||
if (status == null) {
|
if (status == null) {
|
||||||
logger.warn(String.format("[%s] %s", module, comment));
|
logger.warn("[%s] %s".formatted(module, comment));
|
||||||
} else if (status) {
|
} else if (status) {
|
||||||
logger.info(String.format("[%s] %s OK", module, comment));
|
logger.info("[%s] %s OK".formatted(module, comment));
|
||||||
} else {
|
} else {
|
||||||
logger.error(String.format("[%s] %s", module, comment));
|
logger.error("[%s] %s".formatted(module, comment));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,11 +153,11 @@ public void invoke(String... args) {
|
||||||
//Profiles
|
//Profiles
|
||||||
for (ClientProfile profile : server.getProfiles()) {
|
for (ClientProfile profile : server.getProfiles()) {
|
||||||
boolean bad = false;
|
boolean bad = false;
|
||||||
String profileModuleName = String.format("profiles.%s", profile.getTitle());
|
String profileModuleName = "profiles.%s".formatted(profile.getTitle());
|
||||||
for (String exc : profile.getUpdateExclusions()) {
|
for (String exc : profile.getUpdateExclusions()) {
|
||||||
StringTokenizer tokenizer = new StringTokenizer(exc, "/");
|
StringTokenizer tokenizer = new StringTokenizer(exc, "/");
|
||||||
if (exc.endsWith(".jar")) {
|
if (exc.endsWith(".jar")) {
|
||||||
printCheckResult(profileModuleName, String.format("updateExclusions %s not safe. Cheats may be injected very easy!", exc), false);
|
printCheckResult(profileModuleName, "updateExclusions %s not safe. Cheats may be injected very easy!".formatted(exc), false);
|
||||||
bad = true;
|
bad = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -165,12 +165,12 @@ public void invoke(String... args) {
|
||||||
String nextToken = tokenizer.nextToken();
|
String nextToken = tokenizer.nextToken();
|
||||||
if (!tokenizer.hasMoreTokens()) {
|
if (!tokenizer.hasMoreTokens()) {
|
||||||
if (!exc.endsWith("/")) {
|
if (!exc.endsWith("/")) {
|
||||||
printCheckResult(profileModuleName, String.format("updateExclusions %s not safe. Cheats may be injected very easy!", exc), false);
|
printCheckResult(profileModuleName, "updateExclusions %s not safe. Cheats may be injected very easy!".formatted(exc), false);
|
||||||
bad = true;
|
bad = true;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (nextToken.equals("memory_repo") || nextToken.equals(profile.getVersion().toString())) {
|
if (nextToken.equals("memory_repo") || nextToken.equals(profile.getVersion().toString())) {
|
||||||
printCheckResult(profileModuleName, String.format("updateExclusions %s not safe. Cheats may be injected very easy!", exc), false);
|
printCheckResult(profileModuleName, "updateExclusions %s not safe. Cheats may be injected very easy!".formatted(exc), false);
|
||||||
bad = true;
|
bad = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -34,7 +34,7 @@ public void invoke(String... args) throws Exception {
|
||||||
verifyArgs(args, 1);
|
verifyArgs(args, 1);
|
||||||
Path targetDir = Paths.get(args[0]);
|
Path targetDir = Paths.get(args[0]);
|
||||||
if (!IOHelper.isDir(targetDir))
|
if (!IOHelper.isDir(targetDir))
|
||||||
throw new IllegalArgumentException(String.format("%s not directory", targetDir));
|
throw new IllegalArgumentException("%s not directory".formatted(targetDir));
|
||||||
Optional<SignJarTask> task = server.launcherBinary.getTaskByClass(SignJarTask.class);
|
Optional<SignJarTask> task = server.launcherBinary.getTaskByClass(SignJarTask.class);
|
||||||
if (task.isEmpty()) throw new IllegalStateException("SignJarTask not found");
|
if (task.isEmpty()) throw new IllegalStateException("SignJarTask not found");
|
||||||
IOHelper.walk(targetDir, new SignJarVisitor(task.get()), true);
|
IOHelper.walk(targetDir, new SignJarVisitor(task.get()), true);
|
||||||
|
|
|
@ -133,7 +133,7 @@ public Path process(Path inputFile) throws IOException {
|
||||||
if (component.enabled) {
|
if (component.enabled) {
|
||||||
Configuration proguard_cfg = new Configuration();
|
Configuration proguard_cfg = new Configuration();
|
||||||
if (!checkJMods(IOHelper.JVM_DIR.resolve("jmods"))) {
|
if (!checkJMods(IOHelper.JVM_DIR.resolve("jmods"))) {
|
||||||
throw new RuntimeException(String.format("Java path: %s is not JDK! Please install JDK", IOHelper.JVM_DIR));
|
throw new RuntimeException("Java path: %s is not JDK! Please install JDK".formatted(IOHelper.JVM_DIR));
|
||||||
}
|
}
|
||||||
Path jfxPath = tryFindOpenJFXPath(IOHelper.JVM_DIR);
|
Path jfxPath = tryFindOpenJFXPath(IOHelper.JVM_DIR);
|
||||||
if (checkFXJMods(IOHelper.JVM_DIR.resolve("jmods"))) {
|
if (checkFXJMods(IOHelper.JVM_DIR.resolve("jmods"))) {
|
||||||
|
@ -212,7 +212,7 @@ public String[] buildConfig(Path inputJar, Path outputJar, Path[] jfxPath) {
|
||||||
Collections.addAll(confStrs, JAVA9_OPTS);
|
Collections.addAll(confStrs, JAVA9_OPTS);
|
||||||
if (jfxPath != null) {
|
if (jfxPath != null) {
|
||||||
for (Path path : jfxPath) {
|
for (Path path : jfxPath) {
|
||||||
confStrs.add(String.format("-libraryjars '%s'", path.toAbsolutePath()));
|
confStrs.add("-libraryjars '%s'".formatted(path.toAbsolutePath()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
srv.launcherBinary.coreLibs.stream()
|
srv.launcherBinary.coreLibs.stream()
|
||||||
|
|
|
@ -108,7 +108,7 @@ public T getOrThrow() throws RequestException {
|
||||||
if (isSuccessful()) {
|
if (isSuccessful()) {
|
||||||
return result;
|
return result;
|
||||||
} else {
|
} else {
|
||||||
throw new RequestException(error == null ? String.format("statusCode %d", statusCode) : error.toString());
|
throw new RequestException(error == null ? "statusCode %d".formatted(statusCode) : error.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@ public static String makeRefreshTokenFromPassword(String username, String rawPas
|
||||||
rawPassword = "";
|
rawPassword = "";
|
||||||
}
|
}
|
||||||
return SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA256,
|
return SecurityHelper.toHex(SecurityHelper.digest(SecurityHelper.DigestAlgorithm.SHA256,
|
||||||
String.format("%s.%s.%s.%s", secretSalt, username, rawPassword, secretSalt)));
|
"%s.%s.%s.%s".formatted(secretSalt, username, rawPassword, secretSalt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public record JwtTokenInfo(String username, UUID uuid) {
|
public record JwtTokenInfo(String username, UUID uuid) {
|
||||||
|
|
|
@ -313,7 +313,7 @@ public boolean accept(Client client, AuthProviderPair pair, String extendedToken
|
||||||
client.auth = server.config.getAuthProviderPair(info.authId);
|
client.auth = server.config.getAuthProviderPair(info.authId);
|
||||||
if (client.permissions == null) client.permissions = new ClientPermissions();
|
if (client.permissions == null) client.permissions = new ClientPermissions();
|
||||||
client.permissions.addPerm("launchserver.checkserver");
|
client.permissions.addPerm("launchserver.checkserver");
|
||||||
client.permissions.addPerm(String.format("launchserver.profile.%s.show", info.serverName));
|
client.permissions.addPerm("launchserver.profile.%s.show".formatted(info.serverName));
|
||||||
client.setProperty("launchserver.serverName", info.serverName);
|
client.setProperty("launchserver.serverName", info.serverName);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public void downloadZip(Path path, String mask, Object... args) throws IOExcepti
|
||||||
if (downloadZip(mirror, path, mask, args)) return;
|
if (downloadZip(mirror, path, mask, args)) return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
throw new IOException(String.format("Error download %s. All mirrors return error", path.toString()));
|
throw new IOException("Error download %s. All mirrors return error".formatted(path.toString()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public JsonElement jsonRequest(Mirror mirror, JsonElement request, String method, String mask, Object... args) throws IOException {
|
public JsonElement jsonRequest(Mirror mirror, JsonElement request, String method, String mask, Object... args) throws IOException {
|
||||||
|
@ -111,7 +111,7 @@ public static class Mirror {
|
||||||
|
|
||||||
private URL formatArgs(String mask, Object... args) throws MalformedURLException {
|
private URL formatArgs(String mask, Object... args) throws MalformedURLException {
|
||||||
Object[] data = Arrays.stream(args).map(e -> IOHelper.urlEncode(e.toString())).toArray();
|
Object[] data = Arrays.stream(args).map(e -> IOHelper.urlEncode(e.toString())).toArray();
|
||||||
return new URL(baseUrl.concat(String.format(mask, data)));
|
return new URL(baseUrl.concat(mask.formatted(data)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public URL getURL(String mask, Object... args) throws MalformedURLException {
|
public URL getURL(String mask, Object... args) throws MalformedURLException {
|
||||||
|
|
|
@ -14,7 +14,7 @@ public class ReconfigurableManager {
|
||||||
|
|
||||||
public void registerReconfigurable(String name, Reconfigurable reconfigurable) {
|
public void registerReconfigurable(String name, Reconfigurable reconfigurable) {
|
||||||
VerifyHelper.putIfAbsent(RECONFIGURABLE, name.toLowerCase(), new ReconfigurableVirtualCommand(reconfigurable.getCommands()),
|
VerifyHelper.putIfAbsent(RECONFIGURABLE, name.toLowerCase(), new ReconfigurableVirtualCommand(reconfigurable.getCommands()),
|
||||||
String.format("Reconfigurable has been already registered: '%s'", name));
|
"Reconfigurable has been already registered: '%s'".formatted(name));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void unregisterReconfigurable(String name) {
|
public void unregisterReconfigurable(String name) {
|
||||||
|
@ -23,15 +23,15 @@ public void unregisterReconfigurable(String name) {
|
||||||
|
|
||||||
public void call(String name, String action, String[] args) throws Exception {
|
public void call(String name, String action, String[] args) throws Exception {
|
||||||
Command commands = RECONFIGURABLE.get(name);
|
Command commands = RECONFIGURABLE.get(name);
|
||||||
if (commands == null) throw new CommandException(String.format("Reconfigurable %s not found", name));
|
if (commands == null) throw new CommandException("Reconfigurable %s not found".formatted(name));
|
||||||
Command command = commands.childCommands.get(action);
|
Command command = commands.childCommands.get(action);
|
||||||
if (command == null) throw new CommandException(String.format("Action %s.%s not found", name, action));
|
if (command == null) throw new CommandException("Action %s.%s not found".formatted(name, action));
|
||||||
command.invoke(args);
|
command.invoke(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printHelp(String name) throws CommandException {
|
public void printHelp(String name) throws CommandException {
|
||||||
Command commands = RECONFIGURABLE.get(name);
|
Command commands = RECONFIGURABLE.get(name);
|
||||||
if (commands == null) throw new CommandException(String.format("Reconfigurable %s not found", name));
|
if (commands == null) throw new CommandException("Reconfigurable %s not found".formatted(name));
|
||||||
HelpCommand.printSubCommandsHelp(name, commands);
|
HelpCommand.printSubCommandsHelp(name, commands);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ public void execute(ChannelHandlerContext ctx, Client client) {
|
||||||
}
|
}
|
||||||
HashedDir dir = server.updatesManager.getUpdate(dirName);
|
HashedDir dir = server.updatesManager.getUpdate(dirName);
|
||||||
if (dir == null) {
|
if (dir == null) {
|
||||||
sendError(String.format("Directory %s not found", dirName));
|
sendError("Directory %s not found".formatted(dirName));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String url = server.config.netty.downloadURL.replace("%dirname%", IOHelper.urlEncode(dirName));
|
String url = server.config.netty.downloadURL.replace("%dirname%", IOHelper.urlEncode(dirName));
|
||||||
|
|
Loading…
Reference in a new issue