Merge branch 'master' of https://github.com/AuthMe-Team/AuthMeReloaded into 293-translate-help-messages

Conflicts:
	src/main/java/fr/xephi/authme/command/help/HelpProvider.java
This commit is contained in:
ljacqu 2016-10-07 19:11:41 +02:00
commit c30e7acdc5
208 changed files with 1444 additions and 1400 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Wed Jun 22 17:39:14 EDT 2016. See commands/commands.tpl.md -->
<!-- File auto-generated on Sat Oct 01 23:33:39 CEST 2016. See commands/commands.tpl.md -->
## AuthMe Commands
You can use the following commands to use the features of AuthMe. Mandatory arguments are marked with `< >`
@ -32,7 +32,7 @@ brackets; optional arguments are enclosed in square brackets (`[ ]`).
<br />Requires `authme.admin.firstspawn`
- **/authme setfirstspawn**: Change the first player's spawn to your current position.
<br />Requires `authme.admin.setfirstspawn`
- **/authme purge** &lt;days>: Purge old AuthMeReloaded data longer than the specified amount of days ago.
- **/authme purge** &lt;days> [all]: Purge old AuthMeReloaded data longer than the specified amount of days ago.
<br />Requires `authme.admin.purge`
- **/authme resetpos** &lt;player/*>: Purge the last know position of the specified player or all of them.
<br />Requires `authme.admin.purgelastpos`
@ -66,7 +66,7 @@ brackets; optional arguments are enclosed in square brackets (`[ ]`).
<br />Requires `authme.player.email.add`
- **/email change** &lt;oldEmail> &lt;newEmail>: Change an email address of your account.
<br />Requires `authme.player.email.change`
- **/email recover** &lt;email>: Recover your account using an Email address by sending a mail containing a new password.
- **/email recover** &lt;email> [code]: Recover your account using an Email address by sending a mail containing a new password.
<br />Requires `authme.player.email.recover`
- **/email help** [query]: View detailed help for /email commands.
- **/captcha** &lt;captcha>: Captcha command for AuthMeReloaded.
@ -76,4 +76,4 @@ brackets; optional arguments are enclosed in square brackets (`[ ]`).
---
This page was automatically generated on the [AuthMe-Team/AuthMeReloaded repository](https://github.com/AuthMe-Team/AuthMeReloaded/tree/master/docs/) on Wed Jun 22 17:39:14 EDT 2016
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Oct 01 23:33:39 CEST 2016

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Wed Jun 22 17:39:16 EDT 2016. See hashmethods/hash_algorithms.tpl.md -->
<!-- File auto-generated on Sat Oct 01 23:42:20 CEST 2016. See hashmethods/hash_algorithms.tpl.md -->
## Hash Algorithms
AuthMe supports the following hash algorithms for storing your passwords safely.
@ -17,7 +17,7 @@ JOOMLA | Recommended | 65 | | | Text | 32 |
MD5 | Do not use | 32 | | | None | |
MD5VB | Acceptable | 56 | | | Text | 16 |
MYBB | Acceptable | 32 | | | Text | 8 | Y
PBKDF2 | Does not work | 328 | | | Text | 12 |
PBKDF2 | Does not work | 332 | | | Text | 12 |
PBKDF2DJANGO | Acceptable | 77 | Y | | Text | 12 |
PHPBB | Acceptable | 34 | | | Text | 16 |
PHPFUSION | Do not use | 64 | Y | | | | Y
@ -82,4 +82,4 @@ or bad.
---
This page was automatically generated on the [AuthMe-Team/AuthMeReloaded repository](https://github.com/AuthMe-Team/AuthMeReloaded/tree/master/docs/) on Wed Jun 22 17:39:16 EDT 2016
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Oct 01 23:42:20 CEST 2016

View File

@ -1,11 +1,12 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Wed Jun 22 17:39:29 EDT 2016. See permissions/permission_nodes.tpl.md -->
<!-- File auto-generated on Sun Oct 02 10:47:16 CEST 2016. See permissions/permission_nodes.tpl.md -->
## AuthMe Permission Nodes
The following are the permission nodes that are currently supported by the latest dev builds.
- **authme.admin.*** Give access to all admin commands.
- **authme.admin.accounts** Administrator command to see all accounts associated with a user.
- **authme.admin.antibotmessages** Permission to see Antibot messages.
- **authme.admin.changemail** Administrator command to set or change the email address of a user.
- **authme.admin.changepassword** Administrator command to change the password of a user.
- **authme.admin.converter** Administrator command to convert old or other data to AuthMe data.
@ -46,4 +47,4 @@ The following are the permission nodes that are currently supported by the lates
---
This page was automatically generated on the [AuthMe-Team/AuthMeReloaded repository](https://github.com/AuthMe-Team/AuthMeReloaded/tree/master/docs/) on Wed Jun 22 17:39:29 EDT 2016
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sun Oct 02 10:47:16 CEST 2016

View File

@ -367,7 +367,7 @@
<plugin>
<groupId>org.eluder.coveralls</groupId>
<artifactId>coveralls-maven-plugin</artifactId>
<version>4.2.0</version>
<version>4.3.0</version>
<configuration>
<failOnServiceError>false</failOnServiceError>
</configuration>
@ -505,7 +505,7 @@
<dependency>
<groupId>com.zaxxer</groupId>
<artifactId>HikariCP</artifactId>
<version>2.5.1-SNAPSHOT</version>
<version>2.5.1</version>
<scope>compile</scope>
<exclusions>
<exclusion>

View File

@ -1,142 +0,0 @@
package fr.xephi.authme;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
import fr.xephi.authme.util.BukkitService;
import org.bukkit.entity.Player;
import javax.inject.Inject;
import java.util.concurrent.CopyOnWriteArrayList;
import static fr.xephi.authme.util.BukkitService.TICKS_PER_MINUTE;
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
/**
* The AntiBot Service Management class.
*/
public class AntiBot {
private final Settings settings;
private final Messages messages;
private final PermissionsManager permissionsManager;
private final BukkitService bukkitService;
private final CopyOnWriteArrayList<String> antibotKicked = new CopyOnWriteArrayList<String>();
private final CopyOnWriteArrayList<String> antibotPlayers = new CopyOnWriteArrayList<String>();
private AntiBotStatus antiBotStatus = AntiBotStatus.DISABLED;
@Inject
AntiBot(Settings settings, Messages messages, PermissionsManager permissionsManager,
BukkitService bukkitService) {
this.settings = settings;
this.messages = messages;
this.permissionsManager = permissionsManager;
this.bukkitService = bukkitService;
setupAntiBotService();
}
private void setupAntiBotService() {
if (settings.getProperty(ProtectionSettings.ENABLE_ANTIBOT)) {
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
antiBotStatus = AntiBotStatus.LISTENING;
}
}, 2 * TICKS_PER_MINUTE);
}
}
public void overrideAntiBotStatus(boolean activated) {
if (antiBotStatus != AntiBotStatus.DISABLED) {
if (activated) {
antiBotStatus = AntiBotStatus.ACTIVE;
} else {
antiBotStatus = AntiBotStatus.LISTENING;
}
}
}
public AntiBotStatus getAntiBotStatus() {
return antiBotStatus;
}
public void activateAntiBot() {
antiBotStatus = AntiBotStatus.ACTIVE;
for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_ENABLED_MESSAGE)) {
bukkitService.broadcastMessage(s);
}
final int duration = settings.getProperty(ProtectionSettings.ANTIBOT_DURATION);
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
if (antiBotStatus == AntiBotStatus.ACTIVE) {
antiBotStatus = AntiBotStatus.LISTENING;
antibotPlayers.clear();
antibotKicked.clear();
for (String s : messages.retrieve(MessageKey.ANTIBOT_AUTO_DISABLED_MESSAGE)) {
bukkitService.broadcastMessage(s.replace("%m", Integer.toString(duration)));
}
}
}
}, duration * TICKS_PER_MINUTE);
}
/**
* Handles a player joining the server and checks if AntiBot needs to be activated.
*
* @param player the player who joined the server
*/
public void handlePlayerJoin(final Player player) {
if (antiBotStatus == AntiBotStatus.ACTIVE || antiBotStatus == AntiBotStatus.DISABLED) {
return;
}
if (permissionsManager.hasPermission(player, PlayerStatePermission.BYPASS_ANTIBOT)) {
return;
}
antibotPlayers.add(player.getName().toLowerCase());
if (antibotPlayers.size() > settings.getProperty(ProtectionSettings.ANTIBOT_SENSIBILITY)) {
activateAntiBot();
return;
}
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
antibotPlayers.remove(player.getName().toLowerCase());
}
}, 15 * TICKS_PER_SECOND);
}
/**
* Returns whether the player was kicked because of activated antibot. The list is reset
* when antibot is deactivated.
*
* @param name the name to check
* @return true if the given name has been kicked because of Antibot
*/
public boolean wasPlayerKicked(String name) {
return antibotKicked.contains(name.toLowerCase());
}
/**
* Adds a name to the list of players kicked by antibot. Should only be used when a player
* is determined to be kicked because of failed antibot verification.
*
* @param name the name to add
*/
public void addPlayerKick(String name) {
antibotKicked.addIfAbsent(name.toLowerCase());
}
public enum AntiBotStatus {
LISTENING,
DISABLED,
ACTIVE
}
}

View File

@ -5,8 +5,8 @@ import ch.jalu.injector.InjectorBuilder;
import com.google.common.annotations.VisibleForTesting;
import fr.xephi.authme.api.API;
import fr.xephi.authme.api.NewAPI;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.command.CommandHandler;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
@ -21,20 +21,21 @@ import fr.xephi.authme.listener.PlayerListener16;
import fr.xephi.authme.listener.PlayerListener18;
import fr.xephi.authme.listener.PlayerListener19;
import fr.xephi.authme.listener.ServerListener;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PermissionsSystemType;
import fr.xephi.authme.security.crypts.SHA256;
import fr.xephi.authme.service.BackupService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.task.CleanupTask;
import fr.xephi.authme.task.purge.PurgeService;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.GeoLiteAPI;
import fr.xephi.authme.util.MigrationService;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.geoip.GeoIpManager;
import fr.xephi.authme.service.MigrationService;
import fr.xephi.authme.util.PlayerUtils;
import org.bukkit.Server;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -48,7 +49,7 @@ import org.bukkit.scheduler.BukkitScheduler;
import java.io.File;
import java.util.Date;
import static fr.xephi.authme.util.BukkitService.TICKS_PER_MINUTE;
import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE;
import static fr.xephi.authme.util.Utils.isClassLoaded;
/**
@ -73,7 +74,7 @@ public class AuthMe extends JavaPlugin {
private DataSource database;
private BukkitService bukkitService;
private Injector injector;
private GeoLiteAPI geoLiteApi;
private GeoIpManager geoIpManager;
private PlayerCache playerCache;
/**
@ -150,7 +151,7 @@ public class AuthMe extends JavaPlugin {
}
// Do a backup on start
new PerformBackup(this, settings).doBackup(PerformBackup.BackupCause.START);
new BackupService(this, settings).doBackup(BackupService.BackupCause.START);
// Set up Metrics
MetricsManager.sendMetrics(this, settings);
@ -247,7 +248,7 @@ public class AuthMe extends JavaPlugin {
permsMan = injector.getSingleton(PermissionsManager.class);
bukkitService = injector.getSingleton(BukkitService.class);
commandHandler = injector.getSingleton(CommandHandler.class);
geoLiteApi = injector.getSingleton(GeoLiteAPI.class);
geoIpManager = injector.getSingleton(GeoIpManager.class);
// Trigger construction of API classes; they will keep track of the singleton
injector.getSingleton(NewAPI.class);
@ -344,7 +345,7 @@ public class AuthMe extends JavaPlugin {
// Do backup on stop if enabled
if (settings != null) {
new PerformBackup(this, settings).doBackup(PerformBackup.BackupCause.STOP);
new BackupService(this, settings).doBackup(BackupService.BackupCause.STOP);
}
// Wait for tasks and close data source
@ -360,7 +361,7 @@ public class AuthMe extends JavaPlugin {
public String replaceAllInfo(String message, Player player) {
String playersOnline = Integer.toString(bukkitService.getOnlinePlayers().size());
String ipAddress = Utils.getPlayerIp(player);
String ipAddress = PlayerUtils.getPlayerIp(player);
Server server = getServer();
return message
.replace("&", "\u00a7")
@ -373,7 +374,7 @@ public class AuthMe extends JavaPlugin {
.replace("{SERVER}", server.getServerName())
.replace("{VERSION}", server.getBukkitVersion())
// TODO: We should cache info like this, maybe with a class that extends Player?
.replace("{COUNTRY}", geoLiteApi.getCountryName(ipAddress));
.replace("{COUNTRY}", geoIpManager.getCountryName(ipAddress));
}

View File

@ -1,14 +1,14 @@
package fr.xephi.authme.api;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;

View File

@ -1,14 +1,14 @@
package fr.xephi.authme.api;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.entity.Player;

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.command;
import com.github.authme.configme.properties.Property;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;

View File

@ -1,7 +1,6 @@
package fr.xephi.authme.command;
import com.google.common.collect.Lists;
import fr.xephi.authme.util.StringUtils;
import java.util.ArrayList;
import java.util.List;
@ -25,18 +24,6 @@ public final class CommandUtils {
return command.getArguments().size();
}
/**
* Provide a textual representation of a list of labels to show it as a command. For example, a list containing
* the items ["authme", "register", "player"] will return "authme register player".
*
* @param labels The labels to format
*
* @return The space-separated labels
*/
public static String labelsToString(Iterable<String> labels) {
return StringUtils.join(" ", labels);
}
public static String constructCommandPath(CommandDescription command) {
StringBuilder sb = new StringBuilder();
String prefix = "/";

View File

@ -1,12 +1,11 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;
@ -70,7 +69,7 @@ public class AccountsCommand implements ExecutableCommand {
private static void outputAccountsList(CommandSender sender, String playerName, List<String> accountList) {
sender.sendMessage("[AuthMe] " + playerName + " has " + accountList.size() + " accounts.");
String message = "[AuthMe] " + StringUtils.join(", ", accountList) + ".";
String message = "[AuthMe] " + String.join(", ", accountList) + ".";
sender.sendMessage(message);
}
}

View File

@ -1,17 +1,17 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.util.ValidationService.ValidationResult;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.service.ValidationService.ValidationResult;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;

View File

@ -6,16 +6,16 @@ import com.google.common.collect.ImmutableMap;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.converter.Converter;
import fr.xephi.authme.converter.CrazyLoginConverter;
import fr.xephi.authme.converter.MySqlToSqlite;
import fr.xephi.authme.converter.RakamakConverter;
import fr.xephi.authme.converter.RoyalAuthConverter;
import fr.xephi.authme.converter.SqliteToSql;
import fr.xephi.authme.converter.vAuthConverter;
import fr.xephi.authme.converter.xAuthConverter;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.datasource.converter.Converter;
import fr.xephi.authme.datasource.converter.CrazyLoginConverter;
import fr.xephi.authme.datasource.converter.MySqlToSqlite;
import fr.xephi.authme.datasource.converter.RakamakConverter;
import fr.xephi.authme.datasource.converter.RoyalAuthConverter;
import fr.xephi.authme.datasource.converter.SqliteToSql;
import fr.xephi.authme.datasource.converter.vAuthConverter;
import fr.xephi.authme.datasource.converter.xAuthConverter;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;

View File

@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.task.purge.PurgeService;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;

View File

@ -1,17 +1,17 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.util.ValidationService.ValidationResult;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.service.ValidationService.ValidationResult;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -8,7 +8,7 @@ import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import org.bukkit.command.CommandSender;

View File

@ -1,12 +1,12 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.command.CommandSender;
import javax.inject.Inject;

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.AntiBot;
import fr.xephi.authme.service.AntiBotService;
import fr.xephi.authme.command.CommandMapper;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.command.FoundCommandResult;
@ -18,7 +18,7 @@ import java.util.List;
public class SwitchAntiBotCommand implements ExecutableCommand {
@Inject
private AntiBot antiBot;
private AntiBotService antiBotService;
@Inject
private CommandMapper commandMapper;
@ -29,7 +29,7 @@ public class SwitchAntiBotCommand implements ExecutableCommand {
@Override
public void executeCommand(final CommandSender sender, List<String> arguments) {
if (arguments.isEmpty()) {
sender.sendMessage("[AuthMe] AntiBot status: " + antiBot.getAntiBotStatus().name());
sender.sendMessage("[AuthMe] AntiBot status: " + antiBotService.getAntiBotStatus().name());
return;
}
@ -37,10 +37,10 @@ public class SwitchAntiBotCommand implements ExecutableCommand {
// Enable or disable the mod
if ("ON".equalsIgnoreCase(newState)) {
antiBot.overrideAntiBotStatus(true);
antiBotService.overrideAntiBotStatus(true);
sender.sendMessage("[AuthMe] AntiBot Manual Override: enabled!");
} else if ("OFF".equalsIgnoreCase(newState)) {
antiBot.overrideAntiBotStatus(false);
antiBotService.overrideAntiBotStatus(false);
sender.sendMessage("[AuthMe] AntiBot Manual Override: disabled!");
} else {
sender.sendMessage(ChatColor.DARK_RED + "Invalid AntiBot mode!");

View File

@ -3,9 +3,9 @@ package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.ExecutableCommand;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.command.executable.captcha;
import fr.xephi.authme.cache.CaptchaManager;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.CaptchaManager;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import org.bukkit.entity.Player;
import javax.inject.Inject;

View File

@ -1,12 +1,12 @@
package fr.xephi.authme.command.executable.changepassword;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.util.ValidationService.ValidationResult;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.service.ValidationService.ValidationResult;
import org.bukkit.entity.Player;
import javax.inject.Inject;

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.command.executable.email;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.Management;
import org.bukkit.entity.Player;

View File

@ -1,17 +1,17 @@
package fr.xephi.authme.command.executable.email;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.mail.SendMailSSL;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.service.RecoveryCodeManager;
import fr.xephi.authme.service.RecoveryCodeService;
import org.bukkit.entity.Player;
import javax.inject.Inject;
@ -40,7 +40,7 @@ public class RecoverEmailCommand extends PlayerCommand {
private SendMailSSL sendMailSsl;
@Inject
private RecoveryCodeManager recoveryCodeManager;
private RecoveryCodeService recoveryCodeService;
@Override
public void runCommand(Player player, List<String> arguments) {
@ -69,7 +69,7 @@ public class RecoverEmailCommand extends PlayerCommand {
return;
}
if (recoveryCodeManager.isRecoveryCodeNeeded()) {
if (recoveryCodeService.isRecoveryCodeNeeded()) {
// Process /email recovery addr@example.com
if (arguments.size() == 1) {
createAndSendRecoveryCode(player, email);
@ -83,25 +83,25 @@ public class RecoverEmailCommand extends PlayerCommand {
}
private void createAndSendRecoveryCode(Player player, String email) {
String recoveryCode = recoveryCodeManager.generateCode(player.getName());
String recoveryCode = recoveryCodeService.generateCode(player.getName());
sendMailSsl.sendRecoveryCode(player.getName(), email, recoveryCode);
commandService.send(player, MessageKey.RECOVERY_CODE_SENT);
}
private void processRecoveryCode(Player player, String code, String email) {
final String name = player.getName();
if (!recoveryCodeManager.isCodeValid(name, code)) {
if (!recoveryCodeService.isCodeValid(name, code)) {
commandService.send(player, MessageKey.INCORRECT_RECOVERY_CODE);
return;
}
generateAndSendNewPassword(player, email);
recoveryCodeManager.removeCode(name);
recoveryCodeService.removeCode(name);
}
private void generateAndSendNewPassword(Player player, String email) {
String name = player.getName();
String thePass = RandomString.generate(commandService.getProperty(RECOVERY_PASSWORD_LENGTH));
String thePass = RandomStringUtils.generate(commandService.getProperty(RECOVERY_PASSWORD_LENGTH));
HashedPassword hashNew = passwordSecurity.computeHash(thePass, name);
dataSource.updatePassword(name, hashNew);

View File

@ -4,10 +4,10 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.mail.SendMailSSL;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import org.bukkit.entity.Player;
@ -80,7 +80,7 @@ public class RegisterCommand extends PlayerCommand {
} else if (commandService.getProperty(ENABLE_CONFIRM_EMAIL) && !email.equals(arguments.get(1))) {
commandService.send(player, MessageKey.USAGE_REGISTER);
} else {
String thePass = RandomString.generate(commandService.getProperty(RECOVERY_PASSWORD_LENGTH));
String thePass = RandomStringUtils.generate(commandService.getProperty(RECOVERY_PASSWORD_LENGTH));
management.performRegister(player, thePass, email, true);
}
}

View File

@ -1,9 +1,9 @@
package fr.xephi.authme.command.executable.unregister;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.command.CommandService;
import fr.xephi.authme.command.PlayerCommand;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.Management;
import org.bukkit.entity.Player;

View File

@ -203,7 +203,7 @@ public class HelpProvider implements SettingsDependent {
}
lines.add(ChatColor.GOLD + helpMessagesService.getMessage(HelpMessageKey.COMMANDS) + ":");
String parentCommandPath = CommandUtils.labelsToString(parentLabels);
String parentCommandPath = String.join(" ", parentLabels);
for (CommandDescription child : command.getChildren()) {
lines.add(" /" + parentCommandPath + " " + child.getLabels().get(0)
+ ChatColor.GRAY + ChatColor.ITALIC + ": " + child.getDescription());

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.cache;
package fr.xephi.authme.data;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
@ -86,7 +86,7 @@ public class CaptchaManager implements SettingsDependent {
* @return the generated code
*/
public String generateCode(String name) {
String code = RandomString.generate(captchaLength);
String code = RandomStringUtils.generate(captchaLength);
captchaCodes.put(name.toLowerCase(), code);
return code;
}

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.cache;
package fr.xephi.authme.data;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.HasCleanup;

View File

@ -1,14 +1,14 @@
package fr.xephi.authme.cache;
package fr.xephi.authme.data;
import com.google.common.annotations.VisibleForTesting;
import fr.xephi.authme.initialization.HasCleanup;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.PlayerUtils;
import org.bukkit.entity.Player;
import javax.inject.Inject;
@ -108,7 +108,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
*/
public void tempbanPlayer(final Player player) {
if (isEnabled) {
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
final String reason = messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS);
final Date expires = new Date();

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.cache.auth;
package fr.xephi.authme.data.auth;
import fr.xephi.authme.security.crypts.HashedPassword;
import org.bukkit.Location;

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.cache.auth;
package fr.xephi.authme.data.auth;
import java.util.concurrent.ConcurrentHashMap;

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.cache.backup;
package fr.xephi.authme.data.backup;
import com.google.common.io.Files;
import com.google.gson.Gson;
@ -10,13 +10,13 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.data.limbo.LimboPlayer;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.FileUtils;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.PlayerUtils;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
@ -30,7 +30,7 @@ import java.nio.charset.StandardCharsets;
/**
* Class used to store player's data (OP, flying, speed, position) to disk.
*/
public class PlayerDataStorage {
public class LimboPlayerStorage {
private final Gson gson;
private final File cacheDir;
@ -39,7 +39,7 @@ public class PlayerDataStorage {
private BukkitService bukkitService;
@Inject
PlayerDataStorage(@DataFolder File dataFolder, PermissionsManager permsMan,
LimboPlayerStorage(@DataFolder File dataFolder, PermissionsManager permsMan,
SpawnLoader spawnLoader, BukkitService bukkitService) {
this.permissionsManager = permsMan;
this.spawnLoader = spawnLoader;
@ -50,8 +50,8 @@ public class PlayerDataStorage {
ConsoleLogger.warning("Failed to create userdata directory.");
}
gson = new GsonBuilder()
.registerTypeAdapter(PlayerData.class, new PlayerDataSerializer())
.registerTypeAdapter(PlayerData.class, new PlayerDataDeserializer())
.registerTypeAdapter(LimboPlayer.class, new LimboPlayerSerializer())
.registerTypeAdapter(LimboPlayer.class, new LimboPlayerDeserializer())
.setPrettyPrinting()
.create();
}
@ -63,8 +63,8 @@ public class PlayerDataStorage {
*
* @return PlayerData object if the data is exist, null otherwise.
*/
public PlayerData readData(Player player) {
String id = Utils.getUUIDorName(player);
public LimboPlayer readData(Player player) {
String id = PlayerUtils.getUUIDorName(player);
File file = new File(cacheDir, id + File.separator + "data.json");
if (!file.exists()) {
return null;
@ -72,7 +72,7 @@ public class PlayerDataStorage {
try {
String str = Files.toString(file, StandardCharsets.UTF_8);
return gson.fromJson(str, PlayerData.class);
return gson.fromJson(str, LimboPlayer.class);
} catch (IOException e) {
ConsoleLogger.logException("Could not read player data on disk for '" + player.getName() + "'", e);
return null;
@ -85,7 +85,7 @@ public class PlayerDataStorage {
* @param player player to save
*/
public void saveData(Player player) {
String id = Utils.getUUIDorName(player);
String id = PlayerUtils.getUUIDorName(player);
Location location = spawnLoader.getPlayerLocationOrSpawn(player);
String group = "";
if (permissionsManager.hasGroupSupport()) {
@ -95,12 +95,12 @@ public class PlayerDataStorage {
boolean canFly = player.getAllowFlight();
float walkSpeed = player.getWalkSpeed();
float flySpeed = player.getFlySpeed();
PlayerData playerData = new PlayerData(location, operator, group, canFly, walkSpeed, flySpeed);
LimboPlayer limboPlayer = new LimboPlayer(location, operator, group, canFly, walkSpeed, flySpeed);
try {
File file = new File(cacheDir, id + File.separator + "data.json");
Files.createParentDirs(file);
Files.touch(file);
Files.write(gson.toJson(playerData), file, StandardCharsets.UTF_8);
Files.write(gson.toJson(limboPlayer), file, StandardCharsets.UTF_8);
} catch (IOException e) {
ConsoleLogger.logException("Failed to write " + player.getName() + " data.", e);
}
@ -113,7 +113,7 @@ public class PlayerDataStorage {
* @param player player to remove
*/
public void removeData(Player player) {
String id = Utils.getUUIDorName(player);
String id = PlayerUtils.getUUIDorName(player);
File file = new File(cacheDir, id);
if (file.exists()) {
FileUtils.purgeDirectory(file);
@ -131,14 +131,14 @@ public class PlayerDataStorage {
* @return true if data exist, false otherwise.
*/
public boolean hasData(Player player) {
String id = Utils.getUUIDorName(player);
String id = PlayerUtils.getUUIDorName(player);
File file = new File(cacheDir, id + File.separator + "data.json");
return file.exists();
}
private class PlayerDataDeserializer implements JsonDeserializer<PlayerData> {
private class LimboPlayerDeserializer implements JsonDeserializer<LimboPlayer> {
@Override
public PlayerData deserialize(JsonElement jsonElement, Type type,
public LimboPlayer deserialize(JsonElement jsonElement, Type type,
JsonDeserializationContext context) {
JsonObject jsonObject = jsonElement.getAsJsonObject();
if (jsonObject == null) {
@ -181,18 +181,18 @@ public class PlayerDataStorage {
flySpeed = e.getAsFloat();
}
return new PlayerData(loc, operator, group, canFly, walkSpeed, flySpeed);
return new LimboPlayer(loc, operator, group, canFly, walkSpeed, flySpeed);
}
}
private class PlayerDataSerializer implements JsonSerializer<PlayerData> {
private class LimboPlayerSerializer implements JsonSerializer<LimboPlayer> {
@Override
public JsonElement serialize(PlayerData playerData, Type type,
public JsonElement serialize(LimboPlayer limboPlayer, Type type,
JsonSerializationContext context) {
JsonObject obj = new JsonObject();
obj.addProperty("group", playerData.getGroup());
obj.addProperty("group", limboPlayer.getGroup());
Location loc = playerData.getLocation();
Location loc = limboPlayer.getLocation();
JsonObject obj2 = new JsonObject();
obj2.addProperty("world", loc.getWorld().getName());
obj2.addProperty("x", loc.getX());
@ -202,10 +202,10 @@ public class PlayerDataStorage {
obj2.addProperty("pitch", loc.getPitch());
obj.add("location", obj2);
obj.addProperty("operator", playerData.isOperator());
obj.addProperty("can-fly", playerData.isCanFly());
obj.addProperty("walk-speed", playerData.getWalkSpeed());
obj.addProperty("fly-speed", playerData.getFlySpeed());
obj.addProperty("operator", limboPlayer.isOperator());
obj.addProperty("can-fly", limboPlayer.isCanFly());
obj.addProperty("walk-speed", limboPlayer.getWalkSpeed());
obj.addProperty("fly-speed", limboPlayer.getFlySpeed());
return obj;
}
}

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.cache.limbo;
package fr.xephi.authme.data.limbo;
import fr.xephi.authme.cache.backup.PlayerDataStorage;
import fr.xephi.authme.data.backup.LimboPlayerStorage;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
@ -16,24 +16,24 @@ import java.util.concurrent.ConcurrentHashMap;
import static com.google.common.base.Preconditions.checkNotNull;
/**
* Manages all {@link PlayerData} instances.
* Manages all {@link LimboPlayer} instances.
*/
public class LimboCache {
private final Map<String, PlayerData> cache = new ConcurrentHashMap<>();
private final Map<String, LimboPlayer> cache = new ConcurrentHashMap<>();
private PlayerDataStorage playerDataStorage;
private LimboPlayerStorage limboPlayerStorage;
private Settings settings;
private PermissionsManager permissionsManager;
private SpawnLoader spawnLoader;
@Inject
LimboCache(Settings settings, PermissionsManager permissionsManager,
SpawnLoader spawnLoader, PlayerDataStorage playerDataStorage) {
SpawnLoader spawnLoader, LimboPlayerStorage limboPlayerStorage) {
this.settings = settings;
this.permissionsManager = permissionsManager;
this.spawnLoader = spawnLoader;
this.playerDataStorage = playerDataStorage;
this.limboPlayerStorage = limboPlayerStorage;
}
/**
@ -53,8 +53,8 @@ public class LimboCache {
playerGroup = permissionsManager.getPrimaryGroup(player);
}
if (playerDataStorage.hasData(player)) {
PlayerData cache = playerDataStorage.readData(player);
if (limboPlayerStorage.hasData(player)) {
LimboPlayer cache = limboPlayerStorage.readData(player);
if (cache != null) {
location = cache.getLocation();
playerGroup = cache.getGroup();
@ -64,10 +64,10 @@ public class LimboCache {
flySpeed = cache.getFlySpeed();
}
} else {
playerDataStorage.saveData(player);
limboPlayerStorage.saveData(player);
}
cache.put(name, new PlayerData(location, operator, playerGroup, flyEnabled, walkSpeed, flySpeed));
cache.put(name, new LimboPlayer(location, operator, playerGroup, flyEnabled, walkSpeed, flySpeed));
}
/**
@ -78,7 +78,7 @@ public class LimboCache {
public void restoreData(Player player) {
String lowerName = player.getName().toLowerCase();
if (cache.containsKey(lowerName)) {
PlayerData data = cache.get(lowerName);
LimboPlayer data = cache.get(lowerName);
player.setOp(data.isOperator());
player.setAllowFlight(data.isCanFly());
float walkSpeed = data.getWalkSpeed();
@ -104,7 +104,7 @@ public class LimboCache {
*/
public void deletePlayerData(Player player) {
removeFromCache(player);
playerDataStorage.removeData(player);
limboPlayerStorage.removeData(player);
}
/**
@ -114,7 +114,7 @@ public class LimboCache {
*/
public void removeFromCache(Player player) {
String name = player.getName().toLowerCase();
PlayerData cachedPlayer = cache.remove(name);
LimboPlayer cachedPlayer = cache.remove(name);
if (cachedPlayer != null) {
cachedPlayer.clearTasks();
}
@ -127,7 +127,7 @@ public class LimboCache {
*
* @return PlayerData
*/
public PlayerData getPlayerData(String name) {
public LimboPlayer getPlayerData(String name) {
checkNotNull(name);
return cache.get(name.toLowerCase());
}

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.cache.limbo;
package fr.xephi.authme.data.limbo;
import org.bukkit.Location;
import org.bukkit.scheduler.BukkitTask;
@ -7,7 +7,7 @@ import org.bukkit.scheduler.BukkitTask;
* Represents a player which is not logged in and keeps track of certain states (like OP status, flying)
* which may be revoked from the player until he has logged in or registered.
*/
public class PlayerData {
public class LimboPlayer {
private final boolean canFly;
private final boolean operator;
@ -18,8 +18,7 @@ public class PlayerData {
private BukkitTask timeoutTask = null;
private BukkitTask messageTask = null;
public PlayerData(Location loc, boolean operator,
String group, boolean fly, float walkSpeed, float flySpeed) {
public LimboPlayer(Location loc, boolean operator, String group, boolean fly, float walkSpeed, float flySpeed) {
this.loc = loc;
this.operator = operator;
this.group = group;

View File

@ -9,8 +9,10 @@ import com.google.common.util.concurrent.ListeningExecutorService;
import com.google.common.util.concurrent.MoreExecutors;
import com.google.common.util.concurrent.ThreadFactoryBuilder;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.security.crypts.HashedPassword;
import java.util.ArrayList;

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.datasource;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.security.crypts.HashedPassword;

View File

@ -7,9 +7,9 @@ public enum DataSourceType {
MYSQL,
@Deprecated
FILE,
SQLITE,
SQLITE
@Deprecated
FILE
}

View File

@ -1,8 +1,8 @@
package fr.xephi.authme.datasource;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.security.crypts.HashedPassword;
import java.io.BufferedReader;

View File

@ -4,7 +4,10 @@ import com.google.common.annotations.VisibleForTesting;
import com.zaxxer.hikari.HikariDataSource;
import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.Columns;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.security.HashAlgorithm;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.security.crypts.XFBCRYPT;

View File

@ -2,7 +2,10 @@ package fr.xephi.authme.datasource;
import com.google.common.annotations.VisibleForTesting;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.Columns;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.security.crypts.HashedPassword;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.DatabaseSettings;

View File

@ -1,10 +1,9 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.util.StringUtils;
import org.bukkit.command.CommandSender;
import org.bukkit.command.ConsoleCommandSender;
@ -67,7 +66,7 @@ public abstract class AbstractDataSourceConverter<S extends DataSource> implemen
if (!skippedPlayers.isEmpty()) {
logAndSendMessage(sender, "Skipped conversion for players which were already in "
+ destinationType + ": " + StringUtils.join(", ", skippedPlayers));
+ destinationType + ": " + String.join(", ", skippedPlayers));
}
logAndSendMessage(sender, "Database successfully converted from " + source.getType()
+ " to " + destinationType);

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import org.bukkit.command.CommandSender;

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.settings.Settings;

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.FlatFile;

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.security.PasswordSecurity;

View File

@ -1,8 +1,8 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender;
@ -12,7 +12,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
import javax.inject.Inject;
import java.io.File;
import static fr.xephi.authme.util.StringUtils.makePath;
import static fr.xephi.authme.util.FileUtils.makePath;
public class RoyalAuthConverter implements Converter {

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
import org.bukkit.Bukkit;
@ -14,7 +14,7 @@ import java.io.IOException;
import java.util.Scanner;
import java.util.UUID;
import static fr.xephi.authme.util.StringUtils.makePath;
import static fr.xephi.authme.util.FileUtils.makePath;
public class vAuthConverter implements Converter {

View File

@ -1,9 +1,9 @@
package fr.xephi.authme.converter;
package fr.xephi.authme.datasource.converter;
import de.luricos.bukkit.xAuth.database.DatabaseTables;
import de.luricos.bukkit.xAuth.utils.xAuthLog;
import de.luricos.bukkit.xAuth.xAuth;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.util.CollectionUtils;
@ -19,7 +19,7 @@ import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;
import static fr.xephi.authme.util.StringUtils.makePath;
import static fr.xephi.authme.util.FileUtils.makePath;
public class xAuthConverter implements Converter {

View File

@ -1,9 +1,10 @@
package fr.xephi.authme.util;
package fr.xephi.authme.geoip;
import com.google.common.annotations.VisibleForTesting;
import com.maxmind.geoip.LookupService;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.DataFolder;
import fr.xephi.authme.util.FileUtils;
import javax.inject.Inject;
import java.io.File;
@ -16,7 +17,7 @@ import java.net.URLConnection;
import java.util.concurrent.TimeUnit;
import java.util.zip.GZIPInputStream;
public class GeoLiteAPI {
public class GeoIpManager {
private static final String LICENSE =
"[LICENSE] This product uses data from the GeoLite API created by MaxMind, available at http://www.maxmind.com";
private static final String GEOIP_URL =
@ -27,14 +28,14 @@ public class GeoLiteAPI {
private final File dataFile;
@Inject
GeoLiteAPI(@DataFolder File dataFolder) {
GeoIpManager(@DataFolder File dataFolder) {
this.dataFile = new File(dataFolder, "GeoIP.dat");
// Fires download of recent data or the initialization of the look up service
isDataAvailable();
}
@VisibleForTesting
GeoLiteAPI(@DataFolder File dataFolder, LookupService lookupService) {
GeoIpManager(@DataFolder File dataFolder, LookupService lookupService) {
this.dataFile = dataFolder;
this.lookupService = lookupService;
}

View File

@ -5,7 +5,7 @@ import com.github.authme.configme.resource.PropertyResource;
import com.github.authme.configme.resource.YamlFileResource;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.CacheDataSource;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
@ -14,17 +14,17 @@ import fr.xephi.authme.datasource.MySQL;
import fr.xephi.authme.datasource.SQLite;
import fr.xephi.authme.output.ConsoleFilter;
import fr.xephi.authme.output.Log4JFilter;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SettingsMigrationService;
import fr.xephi.authme.settings.properties.AuthMeSettingsRetriever;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.FileUtils;
import fr.xephi.authme.util.MigrationService;
import fr.xephi.authme.service.MigrationService;
import fr.xephi.authme.util.StringUtils;
import org.apache.logging.log4j.LogManager;
import org.bukkit.Bukkit;
@ -37,7 +37,7 @@ import java.util.List;
import java.util.logging.Logger;
import static fr.xephi.authme.settings.properties.EmailSettings.RECALL_PLAYERS;
import static fr.xephi.authme.util.BukkitService.TICKS_PER_MINUTE;
import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE;
/**
* Initializes various services.

View File

@ -1,16 +1,16 @@
package fr.xephi.authme.initialization;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.backup.PlayerDataStorage;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.backup.LimboPlayerStorage;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -32,7 +32,7 @@ public class OnShutdownPlayerSaver {
@Inject
private DataSource dataSource;
@Inject
private PlayerDataStorage playerDataStorage;
private LimboPlayerStorage limboPlayerStorage;
@Inject
private SpawnLoader spawnLoader;
@Inject
@ -77,8 +77,8 @@ public class OnShutdownPlayerSaver {
}
if (settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
&& !settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
if (!playerDataStorage.hasData(player)) {
playerDataStorage.saveData(player);
if (!limboPlayerStorage.hasData(player)) {
limboPlayerStorage.saveData(player);
}
}
}

View File

@ -1,7 +1,6 @@
package fr.xephi.authme.listener;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.message.MessageKey;
/**
* Exception thrown when a verification has failed.
@ -27,7 +26,7 @@ public class FailedVerificationException extends Exception {
@Override
public String toString() {
return getClass().getSimpleName() + ": reason=" + (reason == null ? "null" : reason)
+ ";args=" + (args == null ? "null" : StringUtils.join(", ", args));
return getClass().getSimpleName() + ": reason=" + reason
+ ";args=" + (args == null ? "null" : String.join(", ", args));
}
}

View File

@ -1,12 +1,12 @@
package fr.xephi.authme.listener;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityEvent;

View File

@ -1,22 +1,22 @@
package fr.xephi.authme.listener;
import fr.xephi.authme.AntiBot;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.service.AntiBotService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.Server;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerLoginEvent;
@ -40,7 +40,7 @@ class OnJoinVerifier implements Reloadable {
@Inject
private PermissionsManager permissionsManager;
@Inject
private AntiBot antiBot;
private AntiBotService antiBotService;
@Inject
private ValidationService validationService;
@Inject
@ -50,7 +50,8 @@ class OnJoinVerifier implements Reloadable {
private Pattern nicknamePattern;
OnJoinVerifier() { }
OnJoinVerifier() {
}
@PostConstruct
@ -63,12 +64,15 @@ class OnJoinVerifier implements Reloadable {
/**
* Checks if Antibot is enabled.
*
* @param playerName the name of the player (lowercase)
* @param player the player
* @param isAuthAvailable whether or not the player is registered
*/
public void checkAntibot(String playerName, boolean isAuthAvailable) throws FailedVerificationException {
if (antiBot.getAntiBotStatus() == AntiBot.AntiBotStatus.ACTIVE && !isAuthAvailable) {
antiBot.addPlayerKick(playerName);
public void checkAntibot(Player player, boolean isAuthAvailable) throws FailedVerificationException {
if (permissionsManager.hasPermission(player, PlayerStatePermission.BYPASS_ANTIBOT)) {
return;
}
if (antiBotService.shouldKick(isAuthAvailable)) {
antiBotService.addPlayerKick(player.getName());
throw new FailedVerificationException(MessageKey.KICK_ANTIBOT);
}
}
@ -105,6 +109,7 @@ class OnJoinVerifier implements Reloadable {
* joining player is a VIP.
*
* @param event the login event to verify
*
* @return true if the player's connection should be refused (i.e. the event does not need to be processed
* further), false if the player is not refused
*/
@ -193,6 +198,7 @@ class OnJoinVerifier implements Reloadable {
* Selects a non-VIP player to kick when a VIP player joins the server when full.
*
* @param onlinePlayers list of online players
*
* @return the player to kick, or null if none applicable
*/
private Player generateKickPlayer(Collection<? extends Player> onlinePlayers) {

View File

@ -1,19 +1,19 @@
package fr.xephi.authme.listener;
import fr.xephi.authme.AntiBot;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.process.Management;
import fr.xephi.authme.service.AntiBotService;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.TeleportationService;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -62,7 +62,7 @@ public class PlayerListener implements Listener {
@Inject
private DataSource dataSource;
@Inject
private AntiBot antiBot;
private AntiBotService antiBotService;
@Inject
private Management management;
@Inject
@ -223,8 +223,7 @@ public class PlayerListener implements Listener {
// Slow stuff
final PlayerAuth auth = dataSource.getAuth(name);
final boolean isAuthAvailable = (auth != null);
final String lowerName = name.toLowerCase();
onJoinVerifier.checkAntibot(lowerName, isAuthAvailable);
onJoinVerifier.checkAntibot(player, isAuthAvailable);
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
onJoinVerifier.checkNameCasing(player, auth);
onJoinVerifier.checkPlayerCountry(isAuthAvailable, event.getAddress().getHostAddress());
@ -234,7 +233,7 @@ public class PlayerListener implements Listener {
return;
}
antiBot.handlePlayerJoin(player);
antiBotService.handlePlayerJoin();
teleportationService.teleportOnJoin(player);
}
@ -250,7 +249,7 @@ public class PlayerListener implements Listener {
}
}
if (antiBot.wasPlayerKicked(player.getName())) {
if (antiBotService.wasPlayerKicked(player.getName())) {
return;
}
@ -268,7 +267,7 @@ public class PlayerListener implements Listener {
}
final Player player = event.getPlayer();
if (!antiBot.wasPlayerKicked(player.getName())) {
if (!antiBotService.wasPlayerKicked(player.getName())) {
management.performQuit(player);
}
}

View File

@ -23,7 +23,7 @@ import com.comphenix.protocol.events.PacketAdapter;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.events.PacketEvent;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerCache;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;

View File

@ -3,11 +3,11 @@ package fr.xephi.authme.listener.protocollib;
import ch.jalu.injector.annotations.NoFieldScan;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.entity.Player;
import javax.inject.Inject;

View File

@ -8,7 +8,7 @@ import com.comphenix.protocol.events.PacketEvent;
import com.comphenix.protocol.reflect.FieldAccessException;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerCache;
class TabCompletePacketAdapter extends PacketAdapter {

View File

@ -5,7 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.FileUtils;
import fr.xephi.authme.util.StringUtils;
import org.apache.commons.mail.EmailConstants;

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.output;
package fr.xephi.authme.message;
/**
* Keys for translatable messages managed by {@link Messages}.

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.output;
package fr.xephi.authme.message;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.initialization.SettingsDependent;

View File

@ -100,6 +100,11 @@ public enum AdminPermission implements PermissionNode {
*/
RELOAD("authme.admin.reload", DefaultPermission.OP_ONLY),
/**
* Permission to see Antibot messages.
*/
ANTIBOT_MESSAGES("authme.admin.antibotmessages", DefaultPermission.OP_ONLY),
/**
* Permission to see the other accounts of the players that log in.
*/

View File

@ -1,8 +1,8 @@
package fr.xephi.authme.permission;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.data.limbo.LimboPlayer;
import fr.xephi.authme.initialization.Reloadable;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.HooksSettings;
@ -72,7 +72,7 @@ public class AuthGroupHandler implements Reloadable {
case LOGGED_IN:
// Get the player data
PlayerData data = limboCache.getPlayerData(player.getName().toLowerCase());
LimboPlayer data = limboCache.getPlayerData(player.getName().toLowerCase());
if (data == null) {
return false;
}

View File

@ -9,7 +9,7 @@ import fr.xephi.authme.process.logout.AsynchronousLogout;
import fr.xephi.authme.process.quit.AsynchronousQuit;
import fr.xephi.authme.process.register.AsyncRegister;
import fr.xephi.authme.process.unregister.AsynchronousUnregister;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -1,14 +1,14 @@
package fr.xephi.authme.process;
import com.github.authme.configme.properties.Property;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.output.Messages;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.permission.AuthGroupHandler;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.permission.PermissionNode;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

View File

@ -5,7 +5,7 @@ import fr.xephi.authme.process.logout.ProcessSynchronousPlayerLogout;
import fr.xephi.authme.process.quit.ProcessSyncronousPlayerQuit;
import fr.xephi.authme.process.register.ProcessSyncEmailRegister;
import fr.xephi.authme.process.register.ProcessSyncPasswordRegister;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import org.bukkit.entity.Player;
import javax.inject.Inject;

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.process.changepassword;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.security.PasswordSecurity;

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.process.email;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.settings.properties.RegistrationSettings;

View File

@ -1,9 +1,9 @@
package fr.xephi.authme.process.email;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.settings.properties.RegistrationSettings;

View File

@ -2,14 +2,14 @@ package fr.xephi.authme.process.join;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.SessionManager;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.data.SessionManager;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.ProtectInventoryEvent;
import fr.xephi.authme.hooks.PluginHooks;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.permission.PlayerStatePermission;
import fr.xephi.authme.process.AsynchronousProcess;
@ -19,9 +19,9 @@ import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.PlayerUtils;
import org.apache.commons.lang.reflect.MethodUtils;
import org.bukkit.GameMode;
import org.bukkit.entity.LivingEntity;
@ -32,7 +32,7 @@ import org.bukkit.potion.PotionEffectType;
import javax.inject.Inject;
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
/**
* Asynchronous process for when a player joins.
@ -67,7 +67,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
private BukkitService bukkitService;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Inject
private AsynchronousLogin asynchronousLogin;
@ -78,7 +78,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
public void processJoin(final Player player) {
final String name = player.getName().toLowerCase();
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
if (isPlayerUnrestricted(name)) {
return;
@ -185,8 +185,8 @@ public class AsynchronousJoin implements AsynchronousProcess {
});
// Timeout and message task
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, isAuthAvailable);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, isAuthAvailable);
}
private boolean isPlayerUnrestricted(String name) {
@ -249,7 +249,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
private int countOnlinePlayersByIp(String ip) {
int count = 0;
for (Player player : bukkitService.getOnlinePlayers()) {
if (ip.equalsIgnoreCase(Utils.getPlayerIp(player))) {
if (ip.equalsIgnoreCase(PlayerUtils.getPlayerIp(player))) {
++count;
}
}

View File

@ -2,15 +2,15 @@ package fr.xephi.authme.process.login;
import com.google.common.annotations.VisibleForTesting;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.CaptchaManager;
import fr.xephi.authme.cache.TempbanManager;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.data.CaptchaManager;
import fr.xephi.authme.data.TempbanManager;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.data.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AdminPermission;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.permission.PlayerPermission;
@ -24,10 +24,10 @@ import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.PlayerUtils;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
@ -71,7 +71,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
private TempbanManager tempbanManager;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
AsynchronousLogin() {
}
@ -120,7 +120,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
service.send(player, MessageKey.USER_NOT_REGISTERED);
// Recreate the message task to immediately send the message again as response
// and to make sure we send the right register message (password vs. email registration)
playerDataTaskManager.registerMessageTask(name, false);
limboPlayerTaskManager.registerMessageTask(name, false);
return null;
}
@ -130,7 +130,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
return null;
}
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
if (hasReachedMaxLoggedInPlayersForIp(player, ip)) {
service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
return null;
@ -163,7 +163,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
return false;
}
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
// Increase the counts here before knowing the result of the login.
captchaManager.increaseCount(name);
@ -210,7 +210,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
private void performLogin(Player player, PlayerAuth auth) {
if (player.isOnline()) {
// Update auth to reflect this new login
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
auth.setRealName(player.getName());
auth.setLastLogin(System.currentTimeMillis());
auth.setIp(ip);
@ -241,9 +241,9 @@ public class AsynchronousLogin implements AsynchronousProcess {
// task, we schedule it in the end
// so that we can be sure, and have not to care if it might be
// processed in other order.
PlayerData playerData = limboCache.getPlayerData(name);
if (playerData != null) {
playerData.clearTasks();
LimboPlayer limboPlayer = limboCache.getPlayerData(name);
if (limboPlayer != null) {
limboPlayer.clearTasks();
}
syncProcessManager.processSyncPlayerLogin(player);
} else {
@ -311,7 +311,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
final String name = player.getName();
int count = 0;
for (Player onlinePlayer : bukkitService.getOnlinePlayers()) {
if (ip.equalsIgnoreCase(Utils.getPlayerIp(onlinePlayer))
if (ip.equalsIgnoreCase(PlayerUtils.getPlayerIp(onlinePlayer))
&& !onlinePlayer.getName().equals(name)
&& dataSource.isLogged(onlinePlayer.getName().toLowerCase())) {
++count;

View File

@ -1,9 +1,9 @@
package fr.xephi.authme.process.login;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.cache.limbo.PlayerData;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.data.limbo.LimboPlayer;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.events.LoginEvent;
import fr.xephi.authme.events.RestoreInventoryEvent;
@ -12,8 +12,8 @@ import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.service.BungeeService;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.TeleportationService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import org.apache.commons.lang.reflect.MethodUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity;
@ -79,7 +79,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
public void processPlayerLogin(Player player) {
final String name = player.getName().toLowerCase();
final PlayerData limbo = limboCache.getPlayerData(name);
final LimboPlayer limbo = limboCache.getPlayerData(name);
// Limbo contains the State of the Player before /login
if (limbo != null) {
limboCache.restoreData(player);

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.process.logout;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SyncProcessManager;

View File

@ -1,25 +1,25 @@
package fr.xephi.authme.process.logout;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.SessionManager;
import fr.xephi.authme.data.SessionManager;
import fr.xephi.authme.events.LogoutEvent;
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.TeleportationService;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
import javax.inject.Inject;
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
@ -34,7 +34,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
private ProtocolLibService protocolLibService;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Inject
private SessionManager sessionManager;
@ -53,8 +53,8 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
protocolLibService.sendBlankInventoryPacket(player);
}
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, true);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, true);
applyLogoutEffect(player);

View File

@ -1,9 +1,9 @@
package fr.xephi.authme.process.quit;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.cache.SessionManager;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.SessionManager;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.CacheDataSource;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.process.AsynchronousProcess;
@ -11,8 +11,8 @@ import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SyncProcessManager;
import fr.xephi.authme.settings.SpawnLoader;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.util.PlayerUtils;
import fr.xephi.authme.service.ValidationService;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@ -63,7 +63,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
database.updateQuitLoc(auth);
}
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
PlayerAuth auth = PlayerAuth.builder()
.name(name)
.realName(player.getName())

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.process.quit;
import fr.xephi.authme.cache.backup.PlayerDataStorage;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.data.backup.LimboPlayerStorage;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.process.SynchronousProcess;
import org.bukkit.entity.Player;
@ -11,7 +11,7 @@ import javax.inject.Inject;
public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
@Inject
private PlayerDataStorage playerDataStorage;
private LimboPlayerStorage limboPlayerStorage;
@Inject
private LimboCache limboCache;
@ -22,8 +22,8 @@ public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
limboCache.removeFromCache(player);
} else {
// Save player's data, so we could retrieve it later on player next join
if (!playerDataStorage.hasData(player)) {
playerDataStorage.saveData(player);
if (!limboPlayerStorage.hasData(player)) {
limboPlayerStorage.saveData(player);
}
}

View File

@ -1,10 +1,10 @@
package fr.xephi.authme.process.register;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.mail.SendMailSSL;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.process.AsynchronousProcess;
import fr.xephi.authme.process.ProcessService;
@ -19,11 +19,11 @@ import fr.xephi.authme.settings.properties.PluginSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.settings.properties.SecuritySettings;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.util.PlayerUtils;
import fr.xephi.authme.util.StringUtils;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.util.ValidationService;
import fr.xephi.authme.util.ValidationService.ValidationResult;
import fr.xephi.authme.service.ValidationService;
import fr.xephi.authme.service.ValidationService.ValidationResult;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -94,7 +94,7 @@ public class AsyncRegister implements AsynchronousProcess {
}
final int maxRegPerIp = service.getProperty(RestrictionSettings.MAX_REGISTRATION_PER_IP);
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
if (maxRegPerIp > 0
&& !"127.0.0.1".equalsIgnoreCase(ip)
&& !"localhost".equalsIgnoreCase(ip)
@ -102,7 +102,7 @@ public class AsyncRegister implements AsynchronousProcess {
List<String> otherAccounts = database.getAllAuthsByIp(ip);
if (otherAccounts.size() >= maxRegPerIp) {
service.send(player, MessageKey.MAX_REGISTER_EXCEEDED, Integer.toString(maxRegPerIp),
Integer.toString(otherAccounts.size()), StringUtils.join(", ", otherAccounts));
Integer.toString(otherAccounts.size()), String.join(", ", otherAccounts));
return false;
}
}
@ -132,7 +132,7 @@ public class AsyncRegister implements AsynchronousProcess {
}
final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name);
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
PlayerAuth auth = PlayerAuth.builder()
.name(name)
.realName(player.getName())
@ -154,7 +154,7 @@ public class AsyncRegister implements AsynchronousProcess {
private void passwordRegister(final Player player, String password, boolean autoLogin) {
final String name = player.getName().toLowerCase();
final String ip = Utils.getPlayerIp(player);
final String ip = PlayerUtils.getPlayerIp(player);
final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name);
PlayerAuth auth = PlayerAuth.builder()
.name(name)

View File

@ -1,13 +1,13 @@
package fr.xephi.authme.process.register;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.util.PlayerUtils;
import org.bukkit.entity.Player;
import javax.inject.Inject;
@ -19,7 +19,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
private ProcessService service;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
ProcessSyncEmailRegister() { }
@ -31,11 +31,11 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
}
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, true);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, true);
player.saveData();
ConsoleLogger.fine(player.getName() + " registered " + Utils.getPlayerIp(player));
ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));
}
}

View File

@ -1,8 +1,8 @@
package fr.xephi.authme.process.register;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.process.SynchronousProcess;
@ -10,8 +10,8 @@ import fr.xephi.authme.service.BungeeService;
import fr.xephi.authme.settings.properties.EmailSettings;
import fr.xephi.authme.settings.properties.HooksSettings;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.util.Utils;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.util.PlayerUtils;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@ -31,7 +31,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
private LimboCache limboCache;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
ProcessSyncPasswordRegister() {
}
@ -54,8 +54,8 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
private void requestLogin(Player player) {
final String name = player.getName().toLowerCase();
limboCache.updatePlayerData(player);
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, true);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, true);
if (player.isInsideVehicle() && player.getVehicle() != null) {
player.getVehicle().eject();
@ -74,7 +74,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
}
player.saveData();
ConsoleLogger.fine(player.getName() + " registered " + Utils.getPlayerIp(player));
ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));
// Kick Player after Registration is enabled, kick the player
if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) {

View File

@ -1,11 +1,11 @@
package fr.xephi.authme.process.unregister;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.cache.auth.PlayerCache;
import fr.xephi.authme.cache.limbo.LimboCache;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.data.auth.PlayerCache;
import fr.xephi.authme.data.limbo.LimboCache;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.output.MessageKey;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.permission.AuthGroupHandler;
import fr.xephi.authme.permission.AuthGroupType;
import fr.xephi.authme.process.AsynchronousProcess;
@ -13,9 +13,9 @@ import fr.xephi.authme.process.ProcessService;
import fr.xephi.authme.security.PasswordSecurity;
import fr.xephi.authme.settings.properties.RegistrationSettings;
import fr.xephi.authme.settings.properties.RestrictionSettings;
import fr.xephi.authme.task.PlayerDataTaskManager;
import fr.xephi.authme.util.BukkitService;
import fr.xephi.authme.util.TeleportationService;
import fr.xephi.authme.task.LimboPlayerTaskManager;
import fr.xephi.authme.service.BukkitService;
import fr.xephi.authme.service.TeleportationService;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
@ -23,7 +23,7 @@ import org.bukkit.potion.PotionEffectType;
import javax.inject.Inject;
import static fr.xephi.authme.util.BukkitService.TICKS_PER_SECOND;
import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
public class AsynchronousUnregister implements AsynchronousProcess {
@ -46,7 +46,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
private LimboCache limboCache;
@Inject
private PlayerDataTaskManager playerDataTaskManager;
private LimboPlayerTaskManager limboPlayerTaskManager;
@Inject
private TeleportationService teleportationService;
@ -114,8 +114,8 @@ public class AsynchronousUnregister implements AsynchronousProcess {
limboCache.deletePlayerData(player);
limboCache.addPlayerData(player);
playerDataTaskManager.registerTimeoutTask(player);
playerDataTaskManager.registerMessageTask(name, false);
limboPlayerTaskManager.registerTimeoutTask(player);
limboPlayerTaskManager.registerMessageTask(name, false);
applyBlindEffect(player);
}
authGroupHandler.setGroup(player, AuthGroupType.UNREGISTERED);

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
@ -30,7 +30,7 @@ public abstract class HexSaltedMethod implements EncryptionMethod {
@Override
public String generateSalt() {
return RandomString.generateHex(getSaltLength());
return RandomStringUtils.generateHex(getSaltLength());
}
@Override

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
@ -19,7 +19,7 @@ public class IPB3 extends SeparateSaltMethod {
@Override
public String generateSalt() {
return RandomString.generateHex(5);
return RandomStringUtils.generateHex(5);
}
}

View File

@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.security.HashUtils;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
@ -44,7 +44,7 @@ public class IPB4 implements EncryptionMethod {
@Override
public String generateSalt() {
return RandomString.generateLowerUpper(22);
return RandomStringUtils.generateLowerUpper(22);
}
@Override

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
@ -19,7 +19,7 @@ public class MYBB extends SeparateSaltMethod {
@Override
public String generateSalt() {
return RandomString.generateLowerUpper(8);
return RandomStringUtils.generateLowerUpper(8);
}
}

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.description.AsciiRestricted;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@ -41,7 +41,7 @@ public class PHPFUSION extends SeparateSaltMethod {
@Override
public String generateSalt() {
return RandomString.generateHex(12);
return RandomStringUtils.generateHex(12);
}

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
@ -30,7 +30,7 @@ public class SALTED2MD5 extends SeparateSaltMethod {
@Override
public String generateSalt() {
return RandomString.generateHex(saltLength);
return RandomStringUtils.generateHex(saltLength);
}

View File

@ -1,7 +1,7 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.HashUtils;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.Usage;
@ -15,6 +15,6 @@ public class SALTEDSHA512 extends SeparateSaltMethod {
@Override
public String generateSalt() {
return RandomString.generateHex(32);
return RandomStringUtils.generateHex(32);
}
}

View File

@ -1,6 +1,6 @@
package fr.xephi.authme.security.crypts;
import fr.xephi.authme.security.RandomString;
import fr.xephi.authme.util.RandomStringUtils;
import fr.xephi.authme.security.crypts.description.HasSalt;
import fr.xephi.authme.security.crypts.description.Recommendation;
import fr.xephi.authme.security.crypts.description.SaltType;
@ -19,7 +19,7 @@ public class WBB3 extends SeparateSaltMethod {
@Override
public String generateSalt() {
return RandomString.generateHex(40);
return RandomStringUtils.generateHex(40);
}
}

View File

@ -0,0 +1,218 @@
package fr.xephi.authme.service;
import fr.xephi.authme.initialization.SettingsDependent;
import fr.xephi.authme.message.MessageKey;
import fr.xephi.authme.message.Messages;
import fr.xephi.authme.permission.AdminPermission;
import fr.xephi.authme.permission.PermissionsManager;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.ProtectionSettings;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import javax.inject.Inject;
import java.util.concurrent.CopyOnWriteArrayList;
import static fr.xephi.authme.service.BukkitService.TICKS_PER_MINUTE;
import static fr.xephi.authme.service.BukkitService.TICKS_PER_SECOND;
/**
* The AntiBot Service Management class.
*/
public class AntiBotService implements SettingsDependent {
// Instances
private final Messages messages;
private final PermissionsManager permissionsManager;
private final BukkitService bukkitService;
// Settings
private int duration;
private int sensibility;
private int delay;
// Service status
private AntiBotStatus antiBotStatus;
private boolean startup;
private BukkitTask disableTask;
private int antibotPlayers;
private final CopyOnWriteArrayList<String> antibotKicked = new CopyOnWriteArrayList<>();
@Inject
AntiBotService(Settings settings, Messages messages, PermissionsManager permissionsManager,
BukkitService bukkitService) {
// Instances
this.messages = messages;
this.permissionsManager = permissionsManager;
this.bukkitService = bukkitService;
// Initial status
disableTask = null;
antibotPlayers = 0;
antiBotStatus = AntiBotStatus.DISABLED;
startup = true;
// Load settings and start if required
reload(settings);
}
@Override
public void reload(Settings settings) {
// Load settings
duration = settings.getProperty(ProtectionSettings.ANTIBOT_DURATION);
sensibility = settings.getProperty(ProtectionSettings.ANTIBOT_SENSIBILITY);
delay = settings.getProperty(ProtectionSettings.ANTIBOT_DELAY);
// Stop existing protection
stopProtection();
antiBotStatus = AntiBotStatus.DISABLED;
// If antibot is disabled, just stop
if (!settings.getProperty(ProtectionSettings.ENABLE_ANTIBOT)) {
return;
}
// Bot activation task
Runnable enableTask = new Runnable() {
@Override
public void run() {
antiBotStatus = AntiBotStatus.LISTENING;
}
};
// Delay the schedule on first start
if(startup) {
bukkitService.scheduleSyncDelayedTask(enableTask, delay * TICKS_PER_SECOND);
startup = false;
} else {
enableTask.run();
}
}
private void startProtection() {
// Disable existing antibot session
stopProtection();
// Enable the new session
antiBotStatus = AntiBotStatus.ACTIVE;
// Inform admins
for (Player player : bukkitService.getOnlinePlayers()) {
if (permissionsManager.hasPermission(player, AdminPermission.ANTIBOT_MESSAGES)) {
messages.send(player, MessageKey.ANTIBOT_AUTO_ENABLED_MESSAGE);
}
}
// Schedule auto-disable
disableTask = bukkitService.runTaskLater(new Runnable() {
@Override
public void run() {
stopProtection();
}
}, duration * TICKS_PER_MINUTE);
}
private void stopProtection() {
if (antiBotStatus != AntiBotStatus.ACTIVE) {
return;
}
// Change status
antiBotStatus = AntiBotStatus.LISTENING;
antibotPlayers = 0;
antibotKicked.clear();
// Cancel auto-disable task
disableTask.cancel();
disableTask = null;
// Inform admins
for (Player player : bukkitService.getOnlinePlayers()) {
if (permissionsManager.hasPermission(player, AdminPermission.ANTIBOT_MESSAGES)) {
messages.send(player, MessageKey.ANTIBOT_AUTO_DISABLED_MESSAGE, Integer.toString(duration));
}
}
}
/**
* Returns the status of the AntiBot service.
*
* @return status of the antibot service
*/
public AntiBotStatus getAntiBotStatus() {
return antiBotStatus;
}
/**
* Allows to override the status of the protection.
*
* @param started the new protection status
*/
public void overrideAntiBotStatus(boolean started) {
if (antiBotStatus != AntiBotStatus.DISABLED) {
if (started) {
startProtection();
} else {
stopProtection();
}
}
}
/**
* Handles a player joining the server and checks if AntiBot needs to be activated.
*/
public void handlePlayerJoin() {
if (antiBotStatus != AntiBotStatus.LISTENING) {
return;
}
antibotPlayers++;
if (antibotPlayers > sensibility) {
startProtection();
return;
}
bukkitService.scheduleSyncDelayedTask(new Runnable() {
@Override
public void run() {
antibotPlayers--;
}
}, 5 * TICKS_PER_SECOND);
}
/**
* Returns if a player should be kicked due to antibot service.
*
* @param isAuthAvailable if the player is registered
* @return if the player should be kicked
*/
public boolean shouldKick(boolean isAuthAvailable) {
return !isAuthAvailable && (antiBotStatus == AntiBotStatus.ACTIVE);
}
/**
* Returns whether the player was kicked because of activated antibot. The list is reset
* when antibot is deactivated.
*
* @param name the name to check
*
* @return true if the given name has been kicked because of Antibot
*/
public boolean wasPlayerKicked(String name) {
return antibotKicked.contains(name.toLowerCase());
}
/**
* Adds a name to the list of players kicked by antibot. Should only be used when a player
* is determined to be kicked because of failed antibot verification.
*
* @param name the name to add
*/
public void addPlayerKick(String name) {
antibotKicked.addIfAbsent(name.toLowerCase());
}
public enum AntiBotStatus {
LISTENING,
DISABLED,
ACTIVE
}
}

View File

@ -1,10 +1,11 @@
package fr.xephi.authme;
package fr.xephi.authme.service;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.settings.Settings;
import fr.xephi.authme.settings.properties.BackupSettings;
import fr.xephi.authme.settings.properties.DatabaseSettings;
import fr.xephi.authme.util.StringUtils;
import java.io.File;
import java.io.FileInputStream;
@ -20,7 +21,7 @@ import java.util.Date;
*
* @author stefano
*/
public class PerformBackup {
public class BackupService {
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
@ -38,7 +39,7 @@ public class PerformBackup {
* @param instance AuthMe
* @param settings The plugin settings
*/
public PerformBackup(AuthMe instance, Settings settings) {
public BackupService(AuthMe instance, Settings settings) {
this.dataFolder = instance.getDataFolder();
this.settings = settings;
this.dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
@ -47,7 +48,7 @@ public class PerformBackup {
this.tblname = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
String dateString = DATE_FORMAT.format(new Date());
this.path = StringUtils.join(File.separator,
this.path = String.join(File.separator,
instance.getDataFolder().getPath(), "backups", "backup" + dateString);
}

View File

@ -1,4 +1,4 @@
package fr.xephi.authme.util;
package fr.xephi.authme.service;
import fr.xephi.authme.AuthMe;
import fr.xephi.authme.ConsoleLogger;

View File

@ -1,8 +1,8 @@
package fr.xephi.authme.util;
package fr.xephi.authme.service;
import fr.xephi.authme.ConsoleLogger;
import fr.xephi.authme.cache.auth.PlayerAuth;
import fr.xephi.authme.converter.ForceFlatToSqlite;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.converter.ForceFlatToSqlite;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.datasource.DataSourceType;
import fr.xephi.authme.datasource.FlatFile;

Some files were not shown because too many files have changed in this diff Show More