Merge branches 'master' and 'passwd_recovery_process' of https://github.com/AuthMe/AuthMeReloaded into passwd_recovery_process
# Conflicts: # docs/config.md # src/main/resources/messages/messages_bg.yml # src/main/resources/messages/messages_es.yml # src/main/resources/messages/messages_pt.yml # src/main/resources/messages/messages_zhcn.yml
This commit is contained in:
@@ -24,7 +24,7 @@ public final class RandomStringUtils {
|
||||
* @return The random string
|
||||
*/
|
||||
public static String generate(int length) {
|
||||
return generate(length, LOWER_ALPHANUMERIC_INDEX);
|
||||
return generateString(length, LOWER_ALPHANUMERIC_INDEX);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ public final class RandomStringUtils {
|
||||
* @return The random hexadecimal string
|
||||
*/
|
||||
public static String generateHex(int length) {
|
||||
return generate(length, HEX_MAX_INDEX);
|
||||
return generateString(length, HEX_MAX_INDEX);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -46,10 +46,10 @@ public final class RandomStringUtils {
|
||||
* @return The random string
|
||||
*/
|
||||
public static String generateLowerUpper(int length) {
|
||||
return generate(length, CHARS.length);
|
||||
return generateString(length, CHARS.length);
|
||||
}
|
||||
|
||||
private static String generate(int length, int maxIndex) {
|
||||
private static String generateString(int length, int maxIndex) {
|
||||
if (length < 0) {
|
||||
throw new IllegalArgumentException("Length must be positive but was " + length);
|
||||
}
|
||||
|
||||
@@ -76,4 +76,20 @@ public final class StringUtils {
|
||||
public static String formatException(Throwable th) {
|
||||
return "[" + th.getClass().getSimpleName() + "]: " + th.getMessage();
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the given needle is in the middle of the haystack, i.e. that the haystack
|
||||
* contains the needle and that it is not at the very start or end.
|
||||
*
|
||||
* @param needle the needle to search for
|
||||
* @param haystack the haystack to search in
|
||||
*
|
||||
* @return true if the needle is in the middle of the word, false otherwise
|
||||
*/
|
||||
// Note ljacqu 20170314: `needle` is restricted to char type intentionally because something like
|
||||
// isInsideString("11", "2211") would unexpectedly return true...
|
||||
public static boolean isInsideString(char needle, String haystack) {
|
||||
int index = haystack.indexOf(needle);
|
||||
return index > 0 && index < haystack.length() - 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package fr.xephi.authme.util;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -51,6 +53,22 @@ public final class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a message to the given sender (null safe), and logs the message to the console.
|
||||
* This method is aware that the command sender might be the console sender and avoids
|
||||
* displaying the message twice in this case.
|
||||
*
|
||||
* @param sender the sender to inform
|
||||
* @param message the message to log and send
|
||||
*/
|
||||
public static void logAndSendMessage(CommandSender sender, String message) {
|
||||
ConsoleLogger.info(message);
|
||||
// Make sure sender is not console user, which will see the message from ConsoleLogger already
|
||||
if (sender != null && !(sender instanceof ConsoleCommandSender)) {
|
||||
sender.sendMessage(message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Null-safe way to check whether a collection is empty or not.
|
||||
*
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.util.stream.Collectors;
|
||||
*
|
||||
* @param <A> the argument type
|
||||
*/
|
||||
public class TagReplacer<A> {
|
||||
public final class TagReplacer<A> {
|
||||
|
||||
private final List<Tag<A>> tags;
|
||||
private final Collection<String> messages;
|
||||
|
||||
Reference in New Issue
Block a user