Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into playerjoin-listener-cleanup
This commit is contained in:
@@ -29,7 +29,21 @@ public class AccountsCommand implements ExecutableCommand {
|
||||
final String playerName = arguments.isEmpty() ? sender.getName() : arguments.get(0);
|
||||
|
||||
// Assumption: a player name cannot contain '.'
|
||||
if (!playerName.contains(".")) {
|
||||
if (playerName.contains(".")) {
|
||||
bukkitService.runTaskAsynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<String> accountList = dataSource.getAllAuthsByIp(playerName);
|
||||
if (accountList.isEmpty()) {
|
||||
sender.sendMessage("[AuthMe] This IP does not exist in the database.");
|
||||
} else if (accountList.size() == 1) {
|
||||
sender.sendMessage("[AuthMe] " + playerName + " is a single account player");
|
||||
} else {
|
||||
outputAccountsList(sender, playerName, accountList);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
bukkitService.runTaskAsynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -49,20 +63,6 @@ public class AccountsCommand implements ExecutableCommand {
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
bukkitService.runTaskAsynchronously(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
List<String> accountList = dataSource.getAllAuthsByIp(playerName);
|
||||
if (accountList.isEmpty()) {
|
||||
sender.sendMessage("[AuthMe] This IP does not exist in the database.");
|
||||
} else if (accountList.size() == 1) {
|
||||
sender.sendMessage("[AuthMe] " + playerName + " is a single account player");
|
||||
} else {
|
||||
outputAccountsList(sender, playerName, accountList);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -66,11 +66,11 @@ public class ChangePasswordAdminCommand implements ExecutableCommand {
|
||||
HashedPassword hashedPassword = passwordSecurity.computeHash(playerPass, playerNameLowerCase);
|
||||
auth.setPassword(hashedPassword);
|
||||
|
||||
if (!dataSource.updatePassword(auth)) {
|
||||
commandService.send(sender, MessageKey.ERROR);
|
||||
} else {
|
||||
if (dataSource.updatePassword(auth)) {
|
||||
commandService.send(sender, MessageKey.PASSWORD_CHANGED_SUCCESS);
|
||||
ConsoleLogger.info(playerNameLowerCase + "'s password changed");
|
||||
} else {
|
||||
commandService.send(sender, MessageKey.ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -18,10 +18,10 @@ public class FirstSpawnCommand extends PlayerCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
if (spawnLoader.getFirstSpawn() != null) {
|
||||
player.teleport(spawnLoader.getFirstSpawn());
|
||||
} else {
|
||||
if (spawnLoader.getFirstSpawn() == null) {
|
||||
player.sendMessage("[AuthMe] First spawn has failed, please try to define the first spawn");
|
||||
} else {
|
||||
player.teleport(spawnLoader.getFirstSpawn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,10 @@ public class SpawnCommand extends PlayerCommand {
|
||||
|
||||
@Override
|
||||
public void runCommand(Player player, List<String> arguments, CommandService commandService) {
|
||||
if (spawnLoader.getSpawn() != null) {
|
||||
player.teleport(spawnLoader.getSpawn());
|
||||
} else {
|
||||
if (spawnLoader.getSpawn() == null) {
|
||||
player.sendMessage("[AuthMe] Spawn has failed, please try to define the spawn");
|
||||
} else {
|
||||
player.teleport(spawnLoader.getSpawn());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -181,15 +181,15 @@ public class AuthMeServiceInitializer {
|
||||
Class<?>[] annotations = injection.getDependencyAnnotations();
|
||||
Object[] values = new Object[dependencies.length];
|
||||
for (int i = 0; i < dependencies.length; ++i) {
|
||||
if (annotations[i] != null) {
|
||||
if (annotations[i] == null) {
|
||||
values[i] = get(dependencies[i], traversedClasses);
|
||||
} else {
|
||||
Object value = objects.get(annotations[i]);
|
||||
if (value == null) {
|
||||
throw new IllegalStateException("Value for field with @" + annotations[i].getSimpleName()
|
||||
+ " must be registered beforehand");
|
||||
}
|
||||
values[i] = value;
|
||||
} else {
|
||||
values[i] = get(dependencies[i], traversedClasses);
|
||||
}
|
||||
}
|
||||
return values;
|
||||
|
||||
@@ -68,12 +68,12 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
private boolean needsCaptcha(Player player) {
|
||||
final String name = player.getName().toLowerCase();
|
||||
if (service.getProperty(SecuritySettings.USE_CAPTCHA)) {
|
||||
if (!plugin.captcha.containsKey(name)) {
|
||||
plugin.captcha.putIfAbsent(name, 1);
|
||||
} else {
|
||||
if (plugin.captcha.containsKey(name)) {
|
||||
int i = plugin.captcha.get(name) + 1;
|
||||
plugin.captcha.remove(name);
|
||||
plugin.captcha.putIfAbsent(name, i);
|
||||
} else {
|
||||
plugin.captcha.putIfAbsent(name, 1);
|
||||
}
|
||||
if (plugin.captcha.containsKey(name) && plugin.captcha.get(name) > Settings.maxLoginTry) {
|
||||
plugin.cap.putIfAbsent(name, RandomString.generate(Settings.captchaLength));
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/*
|
||||
* To change this template, choose Tools | Templates and open the template in
|
||||
* the editor.
|
||||
*/
|
||||
package fr.xephi.authme.security.crypts;
|
||||
|
||||
import fr.xephi.authme.security.HashUtils;
|
||||
@@ -24,7 +20,7 @@ public class PHPBB extends HexSaltedMethod {
|
||||
byte[] hash = md5er.digest(bytes);
|
||||
return bytes2hex(hash);
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new RuntimeException(e);
|
||||
throw new UnsupportedOperationException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class EnumProperty<E extends Enum<E>> extends Property<E> {
|
||||
return getDefaultValue();
|
||||
}
|
||||
E mappedValue = mapToEnum(textValue);
|
||||
return mappedValue != null ? mappedValue : getDefaultValue();
|
||||
return mappedValue == null ? getDefaultValue() : mappedValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -3,6 +3,7 @@ package fr.xephi.authme.settings.domain;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.yaml.snakeyaml.Yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -33,6 +34,17 @@ public abstract class Property<T> {
|
||||
return new StringListProperty(path, defaultValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new String list property where all values are lowercase.
|
||||
*
|
||||
* @param path The property's path
|
||||
* @param defaultValues The items in the default list
|
||||
* @return The created list property
|
||||
*/
|
||||
public static Property<List<String>> newLowercaseListProperty(String path, String... defaultValues) {
|
||||
return new LowercaseStringListProperty(path, defaultValues);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new enum property.
|
||||
*
|
||||
@@ -165,7 +177,7 @@ public abstract class Property<T> {
|
||||
/**
|
||||
* String list property.
|
||||
*/
|
||||
private static final class StringListProperty extends Property<List<String>> {
|
||||
private static class StringListProperty extends Property<List<String>> {
|
||||
|
||||
public StringListProperty(String path, String[] defaultValues) {
|
||||
super(path, Arrays.asList(defaultValues));
|
||||
@@ -196,4 +208,28 @@ public abstract class Property<T> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Lowercase String list property.
|
||||
*/
|
||||
private static final class LowercaseStringListProperty extends StringListProperty {
|
||||
|
||||
public LowercaseStringListProperty(String path, String[] defaultValues) {
|
||||
super(path, defaultValues);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getFromFile(FileConfiguration configuration) {
|
||||
if (!configuration.isList(getPath())) {
|
||||
return getDefaultValue();
|
||||
}
|
||||
|
||||
// make sure all elements are lowercase
|
||||
List<String> lowercaseList = new ArrayList<>();
|
||||
for (String element : configuration.getStringList(getPath())) {
|
||||
lowercaseList.add(element.toLowerCase());
|
||||
}
|
||||
|
||||
return lowercaseList;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.settings.domain.Property.newListProperty;
|
||||
import static fr.xephi.authme.settings.domain.Property.newLowercaseListProperty;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
|
||||
public class RestrictionSettings implements SettingsClass {
|
||||
@@ -24,7 +25,7 @@ public class RestrictionSettings implements SettingsClass {
|
||||
|
||||
@Comment("Allowed commands for unauthenticated players")
|
||||
public static final Property<List<String>> ALLOW_COMMANDS =
|
||||
newListProperty("settings.restrictions.allowCommands",
|
||||
newLowercaseListProperty("settings.restrictions.allowCommands",
|
||||
"/login", "/register", "/l", "/reg", "/email", "/captcha");
|
||||
|
||||
@Comment({
|
||||
@@ -81,7 +82,7 @@ public class RestrictionSettings implements SettingsClass {
|
||||
" AllowedRestrictedUser:",
|
||||
" - playername;127.0.0.1"})
|
||||
public static final Property<List<String>> ALLOWED_RESTRICTED_USERS =
|
||||
newListProperty("settings.restrictions.AllowedRestrictedUser");
|
||||
newLowercaseListProperty("settings.restrictions.AllowedRestrictedUser");
|
||||
|
||||
@Comment("Should unregistered players be kicked immediately?")
|
||||
public static final Property<Boolean> KICK_NON_REGISTERED =
|
||||
@@ -188,7 +189,7 @@ public class RestrictionSettings implements SettingsClass {
|
||||
"It is case-sensitive!"
|
||||
})
|
||||
public static final Property<List<String>> UNRESTRICTED_NAMES =
|
||||
newListProperty("settings.unrestrictions.UnrestrictedName");
|
||||
newLowercaseListProperty("settings.unrestrictions.UnrestrictedName");
|
||||
|
||||
|
||||
private RestrictionSettings() {
|
||||
|
||||
@@ -8,6 +8,7 @@ import fr.xephi.authme.settings.domain.SettingsClass;
|
||||
import java.util.List;
|
||||
|
||||
import static fr.xephi.authme.settings.domain.Property.newListProperty;
|
||||
import static fr.xephi.authme.settings.domain.Property.newLowercaseListProperty;
|
||||
import static fr.xephi.authme.settings.domain.Property.newProperty;
|
||||
|
||||
public class SecuritySettings implements SettingsClass {
|
||||
@@ -98,7 +99,7 @@ public class SecuritySettings implements SettingsClass {
|
||||
"- '123456'",
|
||||
"- 'password'"})
|
||||
public static final Property<List<String>> UNSAFE_PASSWORDS =
|
||||
newListProperty("settings.security.unsafePasswords", "123456", "password", "qwerty", "12345", "54321");
|
||||
newLowercaseListProperty("settings.security.unsafePasswords", "123456", "password", "qwerty", "12345", "54321");
|
||||
|
||||
private SecuritySettings() {
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public class BukkitService {
|
||||
} else if (obj instanceof Player[]) {
|
||||
return Arrays.asList((Player[]) obj);
|
||||
} else {
|
||||
String type = (obj != null) ? obj.getClass().getName() : "null";
|
||||
String type = (obj == null) ? "null" : obj.getClass().getName();
|
||||
ConsoleLogger.showError("Unknown list of online players of type " + type);
|
||||
}
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
|
||||
|
||||
Reference in New Issue
Block a user