Change message verification task to add todo comments in same order

- Make verification task add todo comments to YML files in the same order as the MessageKey enum
- Use DefaultCharsets everywhere instead of Guava's Charsets class (thanks to DNx5)
This commit is contained in:
ljacqu
2016-09-17 10:56:30 +02:00
parent 20fdc3693a
commit f804b528e5
9 changed files with 78 additions and 45 deletions
@@ -1,6 +1,5 @@
package fr.xephi.authme.cache.backup;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
@@ -26,6 +25,7 @@ import javax.inject.Inject;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Type;
import java.nio.charset.StandardCharsets;
/**
* Class used to store player's data (OP, flying, speed, position) to disk.
@@ -71,7 +71,7 @@ public class PlayerDataStorage {
}
try {
String str = Files.toString(file, Charsets.UTF_8);
String str = Files.toString(file, StandardCharsets.UTF_8);
return gson.fromJson(str, PlayerData.class);
} catch (IOException e) {
ConsoleLogger.logException("Could not read player data on disk for '" + player.getName() + "'", e);
@@ -100,7 +100,7 @@ public class PlayerDataStorage {
File file = new File(cacheDir, id + File.separator + "data.json");
Files.createParentDirs(file);
Files.touch(file);
Files.write(gson.toJson(playerData), file, Charsets.UTF_8);
Files.write(gson.toJson(playerData), file, StandardCharsets.UTF_8);
} catch (IOException e) {
ConsoleLogger.logException("Failed to write " + player.getName() + " data.", e);
}
@@ -1,9 +1,9 @@
package fr.xephi.authme.security.crypts;
import com.google.common.base.Charsets;
import fr.xephi.authme.security.HashUtils;
import fr.xephi.authme.security.MessageDigestAlgorithm;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
public class CRAZYCRYPT1 extends UsernameSaltMethod {
@@ -24,7 +24,7 @@ public class CRAZYCRYPT1 extends UsernameSaltMethod {
public HashedPassword computeHash(String password, String name) {
final String text = "ÜÄaeut//&/=I " + password + "7421€547" + name + "__+IÄIH§%NK " + password;
final MessageDigest md = HashUtils.getDigest(MessageDigestAlgorithm.SHA512);
md.update(text.getBytes(Charsets.UTF_8), 0, text.length());
md.update(text.getBytes(StandardCharsets.UTF_8), 0, text.length());
return new HashedPassword(byteArrayToHexString(md.digest()));
}
@@ -4,7 +4,6 @@ import com.github.authme.configme.SettingsManager;
import com.github.authme.configme.knownproperties.PropertyEntry;
import com.github.authme.configme.migration.MigrationService;
import com.github.authme.configme.resource.PropertyResource;
import com.google.common.base.Charsets;
import com.google.common.io.Files;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.properties.PluginSettings;
@@ -12,6 +11,7 @@ import fr.xephi.authme.util.StringUtils;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.List;
import static fr.xephi.authme.util.FileUtils.copyFileFromResource;
@@ -133,7 +133,7 @@ public class Settings extends SettingsManager {
final File file = new File(pluginFolder, filename);
if (copyFileFromResource(file, filename)) {
try {
return Files.toString(file, Charsets.UTF_8);
return Files.toString(file, StandardCharsets.UTF_8);
} catch (IOException e) {
ConsoleLogger.logException("Failed to read file '" + filename + "':", e);
}