Fix minor Checkstyle violations
- Mostly missing JavaDoc, some line lengths
This commit is contained in:
parent
98bd0f7a6b
commit
fddb3bf265
@ -172,6 +172,11 @@ class MySqlDefaultChanger implements DebugSection {
|
|||||||
+ sender.getName() + "'");
|
+ sender.getName() + "'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Outputs the current definitions of all {@link Columns} which can be migrated.
|
||||||
|
*
|
||||||
|
* @param sender command sender to output the data to
|
||||||
|
*/
|
||||||
private void showColumnDetails(CommandSender sender) {
|
private void showColumnDetails(CommandSender sender) {
|
||||||
sender.sendMessage(ChatColor.BLUE + "MySQL column details");
|
sender.sendMessage(ChatColor.BLUE + "MySQL column details");
|
||||||
final String tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
final String tableName = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
||||||
|
|||||||
@ -28,6 +28,10 @@ import java.util.Set;
|
|||||||
import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong;
|
import static fr.xephi.authme.datasource.SqlDataSourceUtils.getNullableLong;
|
||||||
import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException;
|
import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* MySQL data source.
|
||||||
|
*/
|
||||||
|
@SuppressWarnings({"checkstyle:AbbreviationAsWordInName"}) // Justification: Class name cannot be changed anymore
|
||||||
public class MySQL implements DataSource {
|
public class MySQL implements DataSource {
|
||||||
|
|
||||||
private boolean useSsl;
|
private boolean useSsl;
|
||||||
@ -728,6 +732,13 @@ public class MySQL implements DataSource {
|
|||||||
return players;
|
return players;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a {@link PlayerAuth} object with the data from the provided result set.
|
||||||
|
*
|
||||||
|
* @param row the result set to read from
|
||||||
|
* @return generated player auth object with the data from the result set
|
||||||
|
* @throws SQLException .
|
||||||
|
*/
|
||||||
private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
|
private PlayerAuth buildAuthFromResultSet(ResultSet row) throws SQLException {
|
||||||
String salt = col.SALT.isEmpty() ? null : row.getString(col.SALT);
|
String salt = col.SALT.isEmpty() ? null : row.getString(col.SALT);
|
||||||
int group = col.GROUP.isEmpty() ? -1 : row.getInt(col.GROUP);
|
int group = col.GROUP.isEmpty() ? -1 : row.getInt(col.GROUP);
|
||||||
|
|||||||
@ -28,6 +28,7 @@ import static fr.xephi.authme.datasource.SqlDataSourceUtils.logSqlException;
|
|||||||
/**
|
/**
|
||||||
* SQLite data source.
|
* SQLite data source.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings({"checkstyle:AbbreviationAsWordInName"}) // Justification: Class name cannot be changed anymore
|
||||||
public class SQLite implements DataSource {
|
public class SQLite implements DataSource {
|
||||||
|
|
||||||
private final Settings settings;
|
private final Settings settings;
|
||||||
|
|||||||
@ -12,10 +12,11 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
public class PlayerListener19Spigot implements Listener {
|
public class PlayerListener19Spigot implements Listener {
|
||||||
|
|
||||||
|
private static boolean isPlayerSpawnLocationEventCalled = false;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private TeleportationService teleportationService;
|
private TeleportationService teleportationService;
|
||||||
|
|
||||||
private static boolean isPlayerSpawnLocationEventCalled = false;
|
|
||||||
|
|
||||||
public static boolean isPlayerSpawnLocationEventCalled() {
|
public static boolean isPlayerSpawnLocationEventCalled() {
|
||||||
return isPlayerSpawnLocationEventCalled;
|
return isPlayerSpawnLocationEventCalled;
|
||||||
|
|||||||
@ -62,7 +62,8 @@ public class LuckPermsHandler implements PermissionHandler {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
DataMutateResult result = user.setPermissionUnchecked(luckPermsApi.getNodeFactory().makeGroupNode(newGroup).build());
|
DataMutateResult result = user.setPermissionUnchecked(
|
||||||
|
luckPermsApi.getNodeFactory().makeGroupNode(newGroup).build());
|
||||||
if (result == DataMutateResult.FAIL) {
|
if (result == DataMutateResult.FAIL) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -10,7 +10,9 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs synchronous tasks after a successful {@link RegistrationType#EMAIL email registration}.
|
||||||
|
*/
|
||||||
public class ProcessSyncEmailRegister implements SynchronousProcess {
|
public class ProcessSyncEmailRegister implements SynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@ -22,6 +24,11 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
|
|||||||
ProcessSyncEmailRegister() {
|
ProcessSyncEmailRegister() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Performs sync tasks for a player which has just registered by email.
|
||||||
|
*
|
||||||
|
* @param player the recently registered player
|
||||||
|
*/
|
||||||
public void processEmailRegister(Player player) {
|
public void processEmailRegister(Player player) {
|
||||||
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
||||||
limboService.replaceTasksAfterRegistration(player);
|
limboService.replaceTasksAfterRegistration(player);
|
||||||
|
|||||||
@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Performs synchronous tasks after a successful {@link RegistrationType#PASSWORD password registration}.
|
||||||
*/
|
*/
|
||||||
public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
||||||
|
|
||||||
@ -46,6 +47,11 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Processes a player having registered with a password.
|
||||||
|
*
|
||||||
|
* @param player the newly registered player
|
||||||
|
*/
|
||||||
public void processPasswordRegister(Player player) {
|
public void processPasswordRegister(Player player) {
|
||||||
service.send(player, MessageKey.REGISTER_SUCCESS);
|
service.send(player, MessageKey.REGISTER_SUCCESS);
|
||||||
|
|
||||||
|
|||||||
@ -56,9 +56,9 @@ public class SettingsWarner {
|
|||||||
// Warn if spigot.yml has settings.bungeecord set to true but config.yml has Hooks.bungeecord set to false
|
// Warn if spigot.yml has settings.bungeecord set to true but config.yml has Hooks.bungeecord set to false
|
||||||
if (Utils.isSpigot() && Bukkit.spigot().getConfig().getBoolean("settings.bungeecord")
|
if (Utils.isSpigot() && Bukkit.spigot().getConfig().getBoolean("settings.bungeecord")
|
||||||
&& !settings.getProperty(HooksSettings.BUNGEECORD)) {
|
&& !settings.getProperty(HooksSettings.BUNGEECORD)) {
|
||||||
ConsoleLogger.warning("Note: Hooks.bungeecord is set to false but your server appears to be running in" +
|
ConsoleLogger.warning("Note: Hooks.bungeecord is set to false but your server appears to be running in"
|
||||||
" bungeecord mode (see your spigot.yml). In order to allow the datasource caching and the AuthMeBungee" +
|
+ " bungeecord mode (see your spigot.yml). In order to allow the datasource caching and the"
|
||||||
" add-on to work properly you have to enable this option!");
|
+ " AuthMeBungee add-on to work properly you have to enable this option!");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if argon2 library is present and can be loaded
|
// Check if argon2 library is present and can be loaded
|
||||||
|
|||||||
@ -61,6 +61,11 @@ public class PurgeExecutor {
|
|||||||
purgePermissions(players);
|
purgePermissions(players);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purges data from the AntiXray plugin.
|
||||||
|
*
|
||||||
|
* @param cleared the players whose data should be cleared
|
||||||
|
*/
|
||||||
synchronized void purgeAntiXray(Collection<String> cleared) {
|
synchronized void purgeAntiXray(Collection<String> cleared) {
|
||||||
if (!settings.getProperty(PurgeSettings.REMOVE_ANTI_XRAY_FILE)) {
|
if (!settings.getProperty(PurgeSettings.REMOVE_ANTI_XRAY_FILE)) {
|
||||||
return;
|
return;
|
||||||
@ -95,6 +100,11 @@ public class PurgeExecutor {
|
|||||||
ConsoleLogger.info(ChatColor.GOLD + "Deleted " + names.size() + " user accounts");
|
ConsoleLogger.info(ChatColor.GOLD + "Deleted " + names.size() + " user accounts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Purges data from the LimitedCreative plugin.
|
||||||
|
*
|
||||||
|
* @param cleared the players whose data should be cleared
|
||||||
|
*/
|
||||||
synchronized void purgeLimitedCreative(Collection<String> cleared) {
|
synchronized void purgeLimitedCreative(Collection<String> cleared) {
|
||||||
if (!settings.getProperty(PurgeSettings.REMOVE_LIMITED_CREATIVE_INVENTORIES)) {
|
if (!settings.getProperty(PurgeSettings.REMOVE_LIMITED_CREATIVE_INVENTORIES)) {
|
||||||
return;
|
return;
|
||||||
@ -191,6 +201,11 @@ public class PurgeExecutor {
|
|||||||
ConsoleLogger.info("AutoPurge: Removed " + deletedFiles + " EssentialsFiles");
|
ConsoleLogger.info("AutoPurge: Removed " + deletedFiles + " EssentialsFiles");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Removes permission data (groups a user belongs to) for the given players.
|
||||||
|
*
|
||||||
|
* @param cleared the players to remove data for
|
||||||
|
*/
|
||||||
synchronized void purgePermissions(Collection<OfflinePlayer> cleared) {
|
synchronized void purgePermissions(Collection<OfflinePlayer> cleared) {
|
||||||
if (!settings.getProperty(PurgeSettings.REMOVE_PERMISSIONS)) {
|
if (!settings.getProperty(PurgeSettings.REMOVE_PERMISSIONS)) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* Custom matchers for AuthMe entities.
|
* Custom matchers for AuthMe entities.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod") // Justification: Javadoc would be huge because of the many parameters
|
||||||
public final class AuthMeMatchers {
|
public final class AuthMeMatchers {
|
||||||
|
|
||||||
private AuthMeMatchers() {
|
private AuthMeMatchers() {
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public class ClassCollector {
|
|||||||
public List<Class<?>> collectClasses(Predicate<Class<?>> filter) {
|
public List<Class<?>> collectClasses(Predicate<Class<?>> filter) {
|
||||||
File rootFolder = new File(root);
|
File rootFolder = new File(root);
|
||||||
List<Class<?>> collection = new ArrayList<>();
|
List<Class<?>> collection = new ArrayList<>();
|
||||||
collectClasses(rootFolder, filter, collection);
|
gatherClassesFromFile(rootFolder, filter, collection);
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,14 +124,14 @@ public class ClassCollector {
|
|||||||
* @param filter the class predicate
|
* @param filter the class predicate
|
||||||
* @param collection collection to add classes to
|
* @param collection collection to add classes to
|
||||||
*/
|
*/
|
||||||
private void collectClasses(File folder, Predicate<Class<?>> filter, List<Class<?>> collection) {
|
private void gatherClassesFromFile(File folder, Predicate<Class<?>> filter, List<Class<?>> collection) {
|
||||||
File[] files = folder.listFiles();
|
File[] files = folder.listFiles();
|
||||||
if (files == null) {
|
if (files == null) {
|
||||||
throw new IllegalStateException("Could not read files from '" + folder + "'");
|
throw new IllegalStateException("Could not read files from '" + folder + "'");
|
||||||
}
|
}
|
||||||
for (File file : files) {
|
for (File file : files) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
collectClasses(file, filter, collection);
|
gatherClassesFromFile(file, filter, collection);
|
||||||
} else if (file.isFile()) {
|
} else if (file.isFile()) {
|
||||||
Class<?> clazz = loadTaskClassFromFile(file);
|
Class<?> clazz = loadTaskClassFromFile(file);
|
||||||
if (clazz != null && filter.test(clazz)) {
|
if (clazz != null && filter.test(clazz)) {
|
||||||
|
|||||||
@ -82,7 +82,6 @@ public final class ReflectionTestUtils {
|
|||||||
* @param clazz the class to retrieve a method from
|
* @param clazz the class to retrieve a method from
|
||||||
* @param methodName the name of the method
|
* @param methodName the name of the method
|
||||||
* @param parameterTypes the parameter types the method to retrieve has
|
* @param parameterTypes the parameter types the method to retrieve has
|
||||||
*
|
|
||||||
* @return the method of the class, set to be accessible
|
* @return the method of the class, set to be accessible
|
||||||
*/
|
*/
|
||||||
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
|
public static Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
|
||||||
@ -96,6 +95,15 @@ public final class ReflectionTestUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Invokes the given method on the provided instance with the given parameters.
|
||||||
|
*
|
||||||
|
* @param method the method to invoke
|
||||||
|
* @param instance the instance to invoke the method on (null for static methods)
|
||||||
|
* @param parameters the parameters to pass to the method
|
||||||
|
* @param <V> return value of the method
|
||||||
|
* @return method return value
|
||||||
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public static <V> V invokeMethod(Method method, Object instance, Object... parameters) {
|
public static <V> V invokeMethod(Method method, Object instance, Object... parameters) {
|
||||||
method.setAccessible(true);
|
method.setAccessible(true);
|
||||||
|
|||||||
@ -14,6 +14,7 @@ import static org.hamcrest.collection.IsIterableContainingInOrder.contains;
|
|||||||
/**
|
/**
|
||||||
* Contains matchers for LimboPlayer.
|
* Contains matchers for LimboPlayer.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("checkstyle:JavadocMethod") // Justification: Javadoc would be huge because of the many parameters
|
||||||
public final class LimboPlayerMatchers {
|
public final class LimboPlayerMatchers {
|
||||||
|
|
||||||
private LimboPlayerMatchers() {
|
private LimboPlayerMatchers() {
|
||||||
@ -45,7 +46,8 @@ public final class LimboPlayerMatchers {
|
|||||||
@Override
|
@Override
|
||||||
public void describeMismatchSafely(LimboPlayer item, Description description) {
|
public void describeMismatchSafely(LimboPlayer item, Description description) {
|
||||||
description.appendText(format("Limbo with isOp=%s, groups={%s}, canFly=%s, walkSpeed=%f, flySpeed=%f",
|
description.appendText(format("Limbo with isOp=%s, groups={%s}, canFly=%s, walkSpeed=%f, flySpeed=%f",
|
||||||
item.isOperator(), String.join(" ,", item.getGroups()), item.isCanFly(), item.getWalkSpeed(), item.getFlySpeed()));
|
item.isOperator(), String.join(" ,", item.getGroups()), item.isCanFly(),
|
||||||
|
item.getWalkSpeed(), item.getFlySpeed()));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -27,6 +27,15 @@ public final class SqlDataSourceTestUtil {
|
|||||||
return new MySQL(settings, hikariDataSource, extensionsFactory);
|
return new MySQL(settings, hikariDataSource, extensionsFactory);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a SQLite implementation for testing purposes. Methods are overridden so the
|
||||||
|
* provided connection is never overridden.
|
||||||
|
*
|
||||||
|
* @param settings settings instance
|
||||||
|
* @param dataFolder data folder
|
||||||
|
* @param connection connection to use
|
||||||
|
* @return the created SQLite instance
|
||||||
|
*/
|
||||||
public static SQLite createSqlite(Settings settings, File dataFolder, Connection connection) {
|
public static SQLite createSqlite(Settings settings, File dataFolder, Connection connection) {
|
||||||
return new SQLite(settings, dataFolder, connection) {
|
return new SQLite(settings, dataFolder, connection) {
|
||||||
// Override reload() so it doesn't run SQLite#connect, since we're given a specific Connection to use
|
// Override reload() so it doesn't run SQLite#connect, since we're given a specific Connection to use
|
||||||
|
|||||||
@ -131,7 +131,8 @@ public class DrawDependency implements ToolTask {
|
|||||||
private Class<?> unwrapGenericClass(Type genericType) {
|
private Class<?> unwrapGenericClass(Type genericType) {
|
||||||
if (genericType == Factory.class || genericType == SingletonStore.class) {
|
if (genericType == Factory.class || genericType == SingletonStore.class) {
|
||||||
Class<?> parameterType = ReflectionUtils.getGenericType(genericType);
|
Class<?> parameterType = ReflectionUtils.getGenericType(genericType);
|
||||||
Objects.requireNonNull(parameterType, "Parameter type for '" + genericType + "' should be a concrete class");
|
Objects.requireNonNull(parameterType,
|
||||||
|
"Parameter type for '" + genericType + "' should be a concrete class");
|
||||||
return parameterType;
|
return parameterType;
|
||||||
}
|
}
|
||||||
return InjectorUtils.convertToClass(genericType);
|
return InjectorUtils.convertToClass(genericType);
|
||||||
|
|||||||
@ -56,6 +56,12 @@ public class EncryptionMethodInfoGatherer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a description of the given hash algorithm based on its annotations.
|
||||||
|
*
|
||||||
|
* @param algorithm the algorithm to describe
|
||||||
|
* @return description of the hash algorithm
|
||||||
|
*/
|
||||||
private static MethodDescription createDescription(HashAlgorithm algorithm) {
|
private static MethodDescription createDescription(HashAlgorithm algorithm) {
|
||||||
Class<? extends EncryptionMethod> clazz = algorithm.getClazz();
|
Class<? extends EncryptionMethod> clazz = algorithm.getClazz();
|
||||||
EncryptionMethod method = createEncryptionMethod(clazz);
|
EncryptionMethod method = createEncryptionMethod(clazz);
|
||||||
|
|||||||
@ -37,6 +37,7 @@ public class PermissionNodesGatherer {
|
|||||||
/**
|
/**
|
||||||
* Return a sorted collection of all permission nodes, including its JavaDoc description.
|
* Return a sorted collection of all permission nodes, including its JavaDoc description.
|
||||||
*
|
*
|
||||||
|
* @param <T> permission node enum type
|
||||||
* @return Ordered map whose keys are the permission nodes and the values the associated JavaDoc
|
* @return Ordered map whose keys are the permission nodes and the values the associated JavaDoc
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
|
|||||||
@ -4,18 +4,20 @@ import tools.utils.AutoToolTask;
|
|||||||
import tools.utils.FileIoUtils;
|
import tools.utils.FileIoUtils;
|
||||||
import tools.utils.TagValue.NestedTagValue;
|
import tools.utils.TagValue.NestedTagValue;
|
||||||
import tools.utils.TagValueHolder;
|
import tools.utils.TagValueHolder;
|
||||||
import tools.utils.ToolsConstants;
|
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import static tools.utils.ToolsConstants.DOCS_FOLDER;
|
||||||
|
import static tools.utils.ToolsConstants.TOOLS_SOURCE_ROOT;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Task responsible for formatting a permissions node list and
|
* Task responsible for formatting a permissions node list and
|
||||||
* for writing it to a file if desired.
|
* for writing it to a file if desired.
|
||||||
*/
|
*/
|
||||||
public class PermissionsListWriter implements AutoToolTask {
|
public class PermissionsListWriter implements AutoToolTask {
|
||||||
|
|
||||||
private static final String TEMPLATE_FILE = ToolsConstants.TOOLS_SOURCE_ROOT + "docs/permissions/permission_nodes.tpl.md";
|
private static final String TEMPLATE_FILE = TOOLS_SOURCE_ROOT + "docs/permissions/permission_nodes.tpl.md";
|
||||||
private static final String PERMISSIONS_OUTPUT_FILE = ToolsConstants.DOCS_FOLDER + "permission_nodes.md";
|
private static final String PERMISSIONS_OUTPUT_FILE = DOCS_FOLDER + "permission_nodes.md";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getTaskName() {
|
public String getTaskName() {
|
||||||
|
|||||||
@ -45,10 +45,10 @@ public class TranslationPageGenerator implements AutoToolTask {
|
|||||||
NestedTagValue translationValuesHolder = new NestedTagValue();
|
NestedTagValue translationValuesHolder = new NestedTagValue();
|
||||||
|
|
||||||
for (TranslationInfo translation : gatherer.getTranslationInfo()) {
|
for (TranslationInfo translation : gatherer.getTranslationInfo()) {
|
||||||
int percentage = (int) Math.round(translation.percentTranslated * 100);
|
int percentage = (int) Math.round(translation.getPercentTranslated() * 100);
|
||||||
String name = firstNonNull(LANGUAGE_NAMES.get(translation.code), "?");
|
String name = firstNonNull(LANGUAGE_NAMES.get(translation.getCode()), "?");
|
||||||
TagValueHolder valueHolder = TagValueHolder.create()
|
TagValueHolder valueHolder = TagValueHolder.create()
|
||||||
.put("code", translation.code)
|
.put("code", translation.getCode())
|
||||||
.put("name", name)
|
.put("name", name)
|
||||||
.put("percentage", Integer.toString(percentage))
|
.put("percentage", Integer.toString(percentage))
|
||||||
.put("color", computeColor(percentage));
|
.put("color", computeColor(percentage));
|
||||||
|
|||||||
@ -25,7 +25,7 @@ public class TranslationsGatherer {
|
|||||||
|
|
||||||
public TranslationsGatherer() {
|
public TranslationsGatherer() {
|
||||||
gatherTranslations();
|
gatherTranslations();
|
||||||
translationInfo.sort((e1, e2) -> getCode(e1).compareTo(getCode(e2)));
|
translationInfo.sort((e1, e2) -> getSortCode(e1).compareTo(getSortCode(e2)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<TranslationInfo> getTranslationInfo() {
|
public List<TranslationInfo> getTranslationInfo() {
|
||||||
@ -61,16 +61,6 @@ public class TranslationsGatherer {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class TranslationInfo {
|
|
||||||
public final String code;
|
|
||||||
public final double percentTranslated;
|
|
||||||
|
|
||||||
TranslationInfo(String code, double percentTranslated) {
|
|
||||||
this.code = code;
|
|
||||||
this.percentTranslated = percentTranslated;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the language code from the translation info for sorting purposes.
|
* Returns the language code from the translation info for sorting purposes.
|
||||||
* Returns "a" for "en" language code to sort English on top.
|
* Returns "a" for "en" language code to sort English on top.
|
||||||
@ -78,8 +68,26 @@ public class TranslationsGatherer {
|
|||||||
* @param info the translation info
|
* @param info the translation info
|
||||||
* @return the language code for sorting
|
* @return the language code for sorting
|
||||||
*/
|
*/
|
||||||
private static String getCode(TranslationInfo info) {
|
private static String getSortCode(TranslationInfo info) {
|
||||||
return "en".equals(info.code) ? "a" : info.code;
|
return "en".equals(info.code) ? "a" : info.code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static final class TranslationInfo {
|
||||||
|
private final String code;
|
||||||
|
private final double percentTranslated;
|
||||||
|
|
||||||
|
TranslationInfo(String code, double percentTranslated) {
|
||||||
|
this.code = code;
|
||||||
|
this.percentTranslated = percentTranslated;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getPercentTranslated() {
|
||||||
|
return percentTranslated;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -67,7 +67,7 @@ public class GeneratePluginYml implements AutoToolTask {
|
|||||||
List<String> pluginYmlLines = FileIoUtils.readLinesFromFile(Paths.get(PLUGIN_YML_FILE));
|
List<String> pluginYmlLines = FileIoUtils.readLinesFromFile(Paths.get(PLUGIN_YML_FILE));
|
||||||
int lineNr = 0;
|
int lineNr = 0;
|
||||||
for (String line : pluginYmlLines) {
|
for (String line : pluginYmlLines) {
|
||||||
if (line.equals("commands:")) {
|
if ("commands:".equals(line)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++lineNr;
|
++lineNr;
|
||||||
|
|||||||
@ -33,8 +33,8 @@ public class CheckMessageKeyUsages implements AutoToolTask {
|
|||||||
if (unusedKeys.isEmpty()) {
|
if (unusedKeys.isEmpty()) {
|
||||||
System.out.println("No unused MessageKey entries found :)");
|
System.out.println("No unused MessageKey entries found :)");
|
||||||
} else {
|
} else {
|
||||||
System.out.println("Did not find usages for keys:\n- " +
|
System.out.println("Did not find usages for keys:\n- "
|
||||||
String.join("\n- ", Lists.transform(unusedKeys, MessageKey::name)));
|
+ String.join("\n- ", Lists.transform(unusedKeys, MessageKey::name)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,21 +51,6 @@ public class CheckMessageKeyUsages implements AutoToolTask {
|
|||||||
return keys;
|
return keys;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<File> findUsagesOfKey(MessageKey key) {
|
|
||||||
List<File> filesUsingKey = new ArrayList<>();
|
|
||||||
File sourceFolder = new File(ToolsConstants.MAIN_SOURCE_ROOT);
|
|
||||||
|
|
||||||
Consumer<File> usagesCollector = file -> {
|
|
||||||
String source = FileIoUtils.readFromFile(file.toPath());
|
|
||||||
if (source.contains(key.name())) {
|
|
||||||
filesUsingKey.add(file);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
walkJavaFileTree(sourceFolder, usagesCollector);
|
|
||||||
return filesUsingKey;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void walkJavaFileTree(File folder, Consumer<File> javaFileConsumer) {
|
private static void walkJavaFileTree(File folder, Consumer<File> javaFileConsumer) {
|
||||||
for (File file : FileIoUtils.listFilesOrThrow(folder)) {
|
for (File file : FileIoUtils.listFilesOrThrow(folder)) {
|
||||||
if (file.isDirectory()) {
|
if (file.isDirectory()) {
|
||||||
|
|||||||
@ -27,6 +27,12 @@ public final class FileIoUtils {
|
|||||||
writeToFile(Paths.get(outputFile), contents);
|
writeToFile(Paths.get(outputFile), contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the given contents to the file, overriding any existing content.
|
||||||
|
*
|
||||||
|
* @param path the file to write to
|
||||||
|
* @param contents the contents to write
|
||||||
|
*/
|
||||||
public static void writeToFile(Path path, String contents) {
|
public static void writeToFile(Path path, String contents) {
|
||||||
try {
|
try {
|
||||||
Files.write(path, contents.getBytes());
|
Files.write(path, contents.getBytes());
|
||||||
@ -35,6 +41,12 @@ public final class FileIoUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds the given contents to the file while keeping any existing content.
|
||||||
|
*
|
||||||
|
* @param outputFile the file to write to
|
||||||
|
* @param contents the contents to append
|
||||||
|
*/
|
||||||
public static void appendToFile(String outputFile, String contents) {
|
public static void appendToFile(String outputFile, String contents) {
|
||||||
try {
|
try {
|
||||||
Files.write(Paths.get(outputFile), contents.getBytes(), StandardOpenOption.APPEND);
|
Files.write(Paths.get(outputFile), contents.getBytes(), StandardOpenOption.APPEND);
|
||||||
@ -47,6 +59,12 @@ public final class FileIoUtils {
|
|||||||
return readFromFile(Paths.get(file));
|
return readFromFile(Paths.get(file));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the given file's contents as string.
|
||||||
|
*
|
||||||
|
* @param file the file to read
|
||||||
|
* @return the file's contents
|
||||||
|
*/
|
||||||
public static String readFromFile(Path file) {
|
public static String readFromFile(Path file) {
|
||||||
try {
|
try {
|
||||||
return new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
|
return new String(Files.readAllBytes(file), StandardCharsets.UTF_8);
|
||||||
@ -55,6 +73,12 @@ public final class FileIoUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the lines of the given file.
|
||||||
|
*
|
||||||
|
* @param path the path of the file to read
|
||||||
|
* @return the lines of the file
|
||||||
|
*/
|
||||||
public static List<String> readLinesFromFile(Path path) {
|
public static List<String> readLinesFromFile(Path path) {
|
||||||
try {
|
try {
|
||||||
return Files.readAllLines(path, StandardCharsets.UTF_8);
|
return Files.readAllLines(path, StandardCharsets.UTF_8);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user