mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2024-11-23 10:45:23 +01:00
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:
commit
c30e7acdc5
@ -1,5 +1,5 @@
|
|||||||
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
<!-- 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
|
## AuthMe Commands
|
||||||
You can use the following commands to use the features of AuthMe. Mandatory arguments are marked with `< >`
|
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`
|
<br />Requires `authme.admin.firstspawn`
|
||||||
- **/authme setfirstspawn**: Change the first player's spawn to your current position.
|
- **/authme setfirstspawn**: Change the first player's spawn to your current position.
|
||||||
<br />Requires `authme.admin.setfirstspawn`
|
<br />Requires `authme.admin.setfirstspawn`
|
||||||
- **/authme purge** <days>: Purge old AuthMeReloaded data longer than the specified amount of days ago.
|
- **/authme purge** <days> [all]: Purge old AuthMeReloaded data longer than the specified amount of days ago.
|
||||||
<br />Requires `authme.admin.purge`
|
<br />Requires `authme.admin.purge`
|
||||||
- **/authme resetpos** <player/*>: Purge the last know position of the specified player or all of them.
|
- **/authme resetpos** <player/*>: Purge the last know position of the specified player or all of them.
|
||||||
<br />Requires `authme.admin.purgelastpos`
|
<br />Requires `authme.admin.purgelastpos`
|
||||||
@ -66,7 +66,7 @@ brackets; optional arguments are enclosed in square brackets (`[ ]`).
|
|||||||
<br />Requires `authme.player.email.add`
|
<br />Requires `authme.player.email.add`
|
||||||
- **/email change** <oldEmail> <newEmail>: Change an email address of your account.
|
- **/email change** <oldEmail> <newEmail>: Change an email address of your account.
|
||||||
<br />Requires `authme.player.email.change`
|
<br />Requires `authme.player.email.change`
|
||||||
- **/email recover** <email>: Recover your account using an Email address by sending a mail containing a new password.
|
- **/email recover** <email> [code]: Recover your account using an Email address by sending a mail containing a new password.
|
||||||
<br />Requires `authme.player.email.recover`
|
<br />Requires `authme.player.email.recover`
|
||||||
- **/email help** [query]: View detailed help for /email commands.
|
- **/email help** [query]: View detailed help for /email commands.
|
||||||
- **/captcha** <captcha>: Captcha command for AuthMeReloaded.
|
- **/captcha** <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
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
<!-- 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
|
## Hash Algorithms
|
||||||
AuthMe supports the following hash algorithms for storing your passwords safely.
|
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 | |
|
MD5 | Do not use | 32 | | | None | |
|
||||||
MD5VB | Acceptable | 56 | | | Text | 16 |
|
MD5VB | Acceptable | 56 | | | Text | 16 |
|
||||||
MYBB | Acceptable | 32 | | | Text | 8 | Y
|
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 |
|
PBKDF2DJANGO | Acceptable | 77 | Y | | Text | 12 |
|
||||||
PHPBB | Acceptable | 34 | | | Text | 16 |
|
PHPBB | Acceptable | 34 | | | Text | 16 |
|
||||||
PHPFUSION | Do not use | 64 | Y | | | | Y
|
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
|
||||||
|
@ -1,11 +1,12 @@
|
|||||||
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
|
<!-- 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
|
## AuthMe Permission Nodes
|
||||||
The following are the permission nodes that are currently supported by the latest dev builds.
|
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.*** – Give access to all admin commands.
|
||||||
- **authme.admin.accounts** – Administrator command to see all accounts associated with a user.
|
- **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.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.changepassword** – Administrator command to change the password of a user.
|
||||||
- **authme.admin.converter** – Administrator command to convert old or other data to AuthMe data.
|
- **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
|
||||||
|
4
pom.xml
4
pom.xml
@ -367,7 +367,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.eluder.coveralls</groupId>
|
<groupId>org.eluder.coveralls</groupId>
|
||||||
<artifactId>coveralls-maven-plugin</artifactId>
|
<artifactId>coveralls-maven-plugin</artifactId>
|
||||||
<version>4.2.0</version>
|
<version>4.3.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<failOnServiceError>false</failOnServiceError>
|
<failOnServiceError>false</failOnServiceError>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -505,7 +505,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.zaxxer</groupId>
|
<groupId>com.zaxxer</groupId>
|
||||||
<artifactId>HikariCP</artifactId>
|
<artifactId>HikariCP</artifactId>
|
||||||
<version>2.5.1-SNAPSHOT</version>
|
<version>2.5.1</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
<exclusions>
|
<exclusions>
|
||||||
<exclusion>
|
<exclusion>
|
||||||
|
@ -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
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -5,8 +5,8 @@ import ch.jalu.injector.InjectorBuilder;
|
|||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import fr.xephi.authme.api.API;
|
import fr.xephi.authme.api.API;
|
||||||
import fr.xephi.authme.api.NewAPI;
|
import fr.xephi.authme.api.NewAPI;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandHandler;
|
import fr.xephi.authme.command.CommandHandler;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
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.PlayerListener18;
|
||||||
import fr.xephi.authme.listener.PlayerListener19;
|
import fr.xephi.authme.listener.PlayerListener19;
|
||||||
import fr.xephi.authme.listener.ServerListener;
|
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.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PermissionsSystemType;
|
import fr.xephi.authme.permission.PermissionsSystemType;
|
||||||
import fr.xephi.authme.security.crypts.SHA256;
|
import fr.xephi.authme.security.crypts.SHA256;
|
||||||
|
import fr.xephi.authme.service.BackupService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.task.CleanupTask;
|
import fr.xephi.authme.task.CleanupTask;
|
||||||
import fr.xephi.authme.task.purge.PurgeService;
|
import fr.xephi.authme.task.purge.PurgeService;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.GeoLiteAPI;
|
import fr.xephi.authme.geoip.GeoIpManager;
|
||||||
import fr.xephi.authme.util.MigrationService;
|
import fr.xephi.authme.service.MigrationService;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import org.bukkit.Server;
|
import org.bukkit.Server;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -48,7 +49,7 @@ import org.bukkit.scheduler.BukkitScheduler;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Date;
|
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;
|
import static fr.xephi.authme.util.Utils.isClassLoaded;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -73,7 +74,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
private DataSource database;
|
private DataSource database;
|
||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
private Injector injector;
|
private Injector injector;
|
||||||
private GeoLiteAPI geoLiteApi;
|
private GeoIpManager geoIpManager;
|
||||||
private PlayerCache playerCache;
|
private PlayerCache playerCache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -150,7 +151,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Do a backup on start
|
// Do a backup on start
|
||||||
new PerformBackup(this, settings).doBackup(PerformBackup.BackupCause.START);
|
new BackupService(this, settings).doBackup(BackupService.BackupCause.START);
|
||||||
|
|
||||||
// Set up Metrics
|
// Set up Metrics
|
||||||
MetricsManager.sendMetrics(this, settings);
|
MetricsManager.sendMetrics(this, settings);
|
||||||
@ -247,7 +248,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
permsMan = injector.getSingleton(PermissionsManager.class);
|
permsMan = injector.getSingleton(PermissionsManager.class);
|
||||||
bukkitService = injector.getSingleton(BukkitService.class);
|
bukkitService = injector.getSingleton(BukkitService.class);
|
||||||
commandHandler = injector.getSingleton(CommandHandler.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
|
// Trigger construction of API classes; they will keep track of the singleton
|
||||||
injector.getSingleton(NewAPI.class);
|
injector.getSingleton(NewAPI.class);
|
||||||
@ -344,7 +345,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
// Do backup on stop if enabled
|
// Do backup on stop if enabled
|
||||||
if (settings != null) {
|
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
|
// Wait for tasks and close data source
|
||||||
@ -360,7 +361,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
|
|
||||||
public String replaceAllInfo(String message, Player player) {
|
public String replaceAllInfo(String message, Player player) {
|
||||||
String playersOnline = Integer.toString(bukkitService.getOnlinePlayers().size());
|
String playersOnline = Integer.toString(bukkitService.getOnlinePlayers().size());
|
||||||
String ipAddress = Utils.getPlayerIp(player);
|
String ipAddress = PlayerUtils.getPlayerIp(player);
|
||||||
Server server = getServer();
|
Server server = getServer();
|
||||||
return message
|
return message
|
||||||
.replace("&", "\u00a7")
|
.replace("&", "\u00a7")
|
||||||
@ -373,7 +374,7 @@ public class AuthMe extends JavaPlugin {
|
|||||||
.replace("{SERVER}", server.getServerName())
|
.replace("{SERVER}", server.getServerName())
|
||||||
.replace("{VERSION}", server.getBukkitVersion())
|
.replace("{VERSION}", server.getBukkitVersion())
|
||||||
// TODO: We should cache info like this, maybe with a class that extends Player?
|
// TODO: We should cache info like this, maybe with a class that extends Player?
|
||||||
.replace("{COUNTRY}", geoLiteApi.getCountryName(ipAddress));
|
.replace("{COUNTRY}", geoIpManager.getCountryName(ipAddress));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package fr.xephi.authme.api;
|
package fr.xephi.authme.api;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.hooks.PluginHooks;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package fr.xephi.authme.api;
|
package fr.xephi.authme.api;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.hooks.PluginHooks;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.command;
|
package fr.xephi.authme.command;
|
||||||
|
|
||||||
import com.github.authme.configme.properties.Property;
|
import com.github.authme.configme.properties.Property;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.message.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
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.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.command;
|
package fr.xephi.authme.command;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -25,18 +24,6 @@ public final class CommandUtils {
|
|||||||
return command.getArguments().size();
|
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) {
|
public static String constructCommandPath(CommandDescription command) {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
String prefix = "/";
|
String prefix = "/";
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
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.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -70,7 +69,7 @@ public class AccountsCommand implements ExecutableCommand {
|
|||||||
|
|
||||||
private static void outputAccountsList(CommandSender sender, String playerName, List<String> accountList) {
|
private static void outputAccountsList(CommandSender sender, String playerName, List<String> accountList) {
|
||||||
sender.sendMessage("[AuthMe] " + playerName + " has " + accountList.size() + " accounts.");
|
sender.sendMessage("[AuthMe] " + playerName + " has " + accountList.size() + " accounts.");
|
||||||
String message = "[AuthMe] " + StringUtils.join(", ", accountList) + ".";
|
String message = "[AuthMe] " + String.join(", ", accountList) + ".";
|
||||||
sender.sendMessage(message);
|
sender.sendMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
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.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
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.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import fr.xephi.authme.util.ValidationService.ValidationResult;
|
import fr.xephi.authme.service.ValidationService.ValidationResult;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -6,16 +6,16 @@ import com.google.common.collect.ImmutableMap;
|
|||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.converter.Converter;
|
import fr.xephi.authme.datasource.converter.Converter;
|
||||||
import fr.xephi.authme.converter.CrazyLoginConverter;
|
import fr.xephi.authme.datasource.converter.CrazyLoginConverter;
|
||||||
import fr.xephi.authme.converter.MySqlToSqlite;
|
import fr.xephi.authme.datasource.converter.MySqlToSqlite;
|
||||||
import fr.xephi.authme.converter.RakamakConverter;
|
import fr.xephi.authme.datasource.converter.RakamakConverter;
|
||||||
import fr.xephi.authme.converter.RoyalAuthConverter;
|
import fr.xephi.authme.datasource.converter.RoyalAuthConverter;
|
||||||
import fr.xephi.authme.converter.SqliteToSql;
|
import fr.xephi.authme.datasource.converter.SqliteToSql;
|
||||||
import fr.xephi.authme.converter.vAuthConverter;
|
import fr.xephi.authme.datasource.converter.vAuthConverter;
|
||||||
import fr.xephi.authme.converter.xAuthConverter;
|
import fr.xephi.authme.datasource.converter.xAuthConverter;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.process.Management;
|
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.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
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.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
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.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
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.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
|
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.task.purge.PurgeService;
|
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.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
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.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
package fr.xephi.authme.command.executable.authme;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
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.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import fr.xephi.authme.util.ValidationService.ValidationResult;
|
import fr.xephi.authme.service.ValidationService.ValidationResult;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@ import fr.xephi.authme.command.ExecutableCommand;
|
|||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
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.Settings;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
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.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.command.executable.authme;
|
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.CommandMapper;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.command.FoundCommandResult;
|
import fr.xephi.authme.command.FoundCommandResult;
|
||||||
@ -18,7 +18,7 @@ import java.util.List;
|
|||||||
public class SwitchAntiBotCommand implements ExecutableCommand {
|
public class SwitchAntiBotCommand implements ExecutableCommand {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AntiBot antiBot;
|
private AntiBotService antiBotService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private CommandMapper commandMapper;
|
private CommandMapper commandMapper;
|
||||||
@ -29,7 +29,7 @@ public class SwitchAntiBotCommand implements ExecutableCommand {
|
|||||||
@Override
|
@Override
|
||||||
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
public void executeCommand(final CommandSender sender, List<String> arguments) {
|
||||||
if (arguments.isEmpty()) {
|
if (arguments.isEmpty()) {
|
||||||
sender.sendMessage("[AuthMe] AntiBot status: " + antiBot.getAntiBotStatus().name());
|
sender.sendMessage("[AuthMe] AntiBot status: " + antiBotService.getAntiBotStatus().name());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,10 +37,10 @@ public class SwitchAntiBotCommand implements ExecutableCommand {
|
|||||||
|
|
||||||
// Enable or disable the mod
|
// Enable or disable the mod
|
||||||
if ("ON".equalsIgnoreCase(newState)) {
|
if ("ON".equalsIgnoreCase(newState)) {
|
||||||
antiBot.overrideAntiBotStatus(true);
|
antiBotService.overrideAntiBotStatus(true);
|
||||||
sender.sendMessage("[AuthMe] AntiBot Manual Override: enabled!");
|
sender.sendMessage("[AuthMe] AntiBot Manual Override: enabled!");
|
||||||
} else if ("OFF".equalsIgnoreCase(newState)) {
|
} else if ("OFF".equalsIgnoreCase(newState)) {
|
||||||
antiBot.overrideAntiBotStatus(false);
|
antiBotService.overrideAntiBotStatus(false);
|
||||||
sender.sendMessage("[AuthMe] AntiBot Manual Override: disabled!");
|
sender.sendMessage("[AuthMe] AntiBot Manual Override: disabled!");
|
||||||
} else {
|
} else {
|
||||||
sender.sendMessage(ChatColor.DARK_RED + "Invalid AntiBot mode!");
|
sender.sendMessage(ChatColor.DARK_RED + "Invalid AntiBot mode!");
|
||||||
|
@ -3,9 +3,9 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
import fr.xephi.authme.command.ExecutableCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
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.process.Management;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package fr.xephi.authme.command.executable.authme;
|
|||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.ExecutableCommand;
|
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.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.command.executable.captcha;
|
package fr.xephi.authme.command.executable.captcha;
|
||||||
|
|
||||||
import fr.xephi.authme.cache.CaptchaManager;
|
import fr.xephi.authme.data.CaptchaManager;
|
||||||
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.CommandService;
|
||||||
import fr.xephi.authme.command.PlayerCommand;
|
import fr.xephi.authme.command.PlayerCommand;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package fr.xephi.authme.command.executable.changepassword;
|
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.CommandService;
|
||||||
import fr.xephi.authme.command.PlayerCommand;
|
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.process.Management;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import fr.xephi.authme.util.ValidationService.ValidationResult;
|
import fr.xephi.authme.service.ValidationService.ValidationResult;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.command.executable.email;
|
|||||||
|
|
||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.PlayerCommand;
|
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.process.Management;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package fr.xephi.authme.command.executable.email;
|
package fr.xephi.authme.command.executable.email;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
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.CommandService;
|
||||||
import fr.xephi.authme.command.PlayerCommand;
|
import fr.xephi.authme.command.PlayerCommand;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.mail.SendMailSSL;
|
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.PasswordSecurity;
|
||||||
import fr.xephi.authme.security.RandomString;
|
import fr.xephi.authme.util.RandomStringUtils;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -40,7 +40,7 @@ public class RecoverEmailCommand extends PlayerCommand {
|
|||||||
private SendMailSSL sendMailSsl;
|
private SendMailSSL sendMailSsl;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private RecoveryCodeManager recoveryCodeManager;
|
private RecoveryCodeService recoveryCodeService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void runCommand(Player player, List<String> arguments) {
|
public void runCommand(Player player, List<String> arguments) {
|
||||||
@ -69,7 +69,7 @@ public class RecoverEmailCommand extends PlayerCommand {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (recoveryCodeManager.isRecoveryCodeNeeded()) {
|
if (recoveryCodeService.isRecoveryCodeNeeded()) {
|
||||||
// Process /email recovery addr@example.com
|
// Process /email recovery addr@example.com
|
||||||
if (arguments.size() == 1) {
|
if (arguments.size() == 1) {
|
||||||
createAndSendRecoveryCode(player, email);
|
createAndSendRecoveryCode(player, email);
|
||||||
@ -83,25 +83,25 @@ public class RecoverEmailCommand extends PlayerCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void createAndSendRecoveryCode(Player player, String email) {
|
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);
|
sendMailSsl.sendRecoveryCode(player.getName(), email, recoveryCode);
|
||||||
commandService.send(player, MessageKey.RECOVERY_CODE_SENT);
|
commandService.send(player, MessageKey.RECOVERY_CODE_SENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processRecoveryCode(Player player, String code, String email) {
|
private void processRecoveryCode(Player player, String code, String email) {
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
if (!recoveryCodeManager.isCodeValid(name, code)) {
|
if (!recoveryCodeService.isCodeValid(name, code)) {
|
||||||
commandService.send(player, MessageKey.INCORRECT_RECOVERY_CODE);
|
commandService.send(player, MessageKey.INCORRECT_RECOVERY_CODE);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
generateAndSendNewPassword(player, email);
|
generateAndSendNewPassword(player, email);
|
||||||
recoveryCodeManager.removeCode(name);
|
recoveryCodeService.removeCode(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void generateAndSendNewPassword(Player player, String email) {
|
private void generateAndSendNewPassword(Player player, String email) {
|
||||||
String name = player.getName();
|
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);
|
HashedPassword hashNew = passwordSecurity.computeHash(thePass, name);
|
||||||
|
|
||||||
dataSource.updatePassword(name, hashNew);
|
dataSource.updatePassword(name, hashNew);
|
||||||
|
@ -4,10 +4,10 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.command.CommandService;
|
import fr.xephi.authme.command.CommandService;
|
||||||
import fr.xephi.authme.command.PlayerCommand;
|
import fr.xephi.authme.command.PlayerCommand;
|
||||||
import fr.xephi.authme.mail.SendMailSSL;
|
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.process.Management;
|
||||||
import fr.xephi.authme.security.HashAlgorithm;
|
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.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import org.bukkit.entity.Player;
|
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))) {
|
} else if (commandService.getProperty(ENABLE_CONFIRM_EMAIL) && !email.equals(arguments.get(1))) {
|
||||||
commandService.send(player, MessageKey.USAGE_REGISTER);
|
commandService.send(player, MessageKey.USAGE_REGISTER);
|
||||||
} else {
|
} 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);
|
management.performRegister(player, thePass, email, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package fr.xephi.authme.command.executable.unregister;
|
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.CommandService;
|
||||||
import fr.xephi.authme.command.PlayerCommand;
|
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.process.Management;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -203,7 +203,7 @@ public class HelpProvider implements SettingsDependent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
lines.add(ChatColor.GOLD + helpMessagesService.getMessage(HelpMessageKey.COMMANDS) + ":");
|
lines.add(ChatColor.GOLD + helpMessagesService.getMessage(HelpMessageKey.COMMANDS) + ":");
|
||||||
String parentCommandPath = CommandUtils.labelsToString(parentLabels);
|
String parentCommandPath = String.join(" ", parentLabels);
|
||||||
for (CommandDescription child : command.getChildren()) {
|
for (CommandDescription child : command.getChildren()) {
|
||||||
lines.add(" /" + parentCommandPath + " " + child.getLabels().get(0)
|
lines.add(" /" + parentCommandPath + " " + child.getLabels().get(0)
|
||||||
+ ChatColor.GRAY + ChatColor.ITALIC + ": " + child.getDescription());
|
+ ChatColor.GRAY + ChatColor.ITALIC + ": " + child.getDescription());
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.cache;
|
package fr.xephi.authme.data;
|
||||||
|
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
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.Settings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
|
|
||||||
@ -86,7 +86,7 @@ public class CaptchaManager implements SettingsDependent {
|
|||||||
* @return the generated code
|
* @return the generated code
|
||||||
*/
|
*/
|
||||||
public String generateCode(String name) {
|
public String generateCode(String name) {
|
||||||
String code = RandomString.generate(captchaLength);
|
String code = RandomStringUtils.generate(captchaLength);
|
||||||
captchaCodes.put(name.toLowerCase(), code);
|
captchaCodes.put(name.toLowerCase(), code);
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.cache;
|
package fr.xephi.authme.data;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.initialization.HasCleanup;
|
import fr.xephi.authme.initialization.HasCleanup;
|
@ -1,14 +1,14 @@
|
|||||||
package fr.xephi.authme.cache;
|
package fr.xephi.authme.data;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import fr.xephi.authme.initialization.HasCleanup;
|
import fr.xephi.authme.initialization.HasCleanup;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.message.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
import fr.xephi.authme.settings.properties.SecuritySettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -108,7 +108,7 @@ public class TempbanManager implements SettingsDependent, HasCleanup {
|
|||||||
*/
|
*/
|
||||||
public void tempbanPlayer(final Player player) {
|
public void tempbanPlayer(final Player player) {
|
||||||
if (isEnabled) {
|
if (isEnabled) {
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
final String reason = messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS);
|
final String reason = messages.retrieveSingle(MessageKey.TEMPBAN_MAX_LOGINS);
|
||||||
|
|
||||||
final Date expires = new Date();
|
final Date expires = new Date();
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.cache.auth;
|
package fr.xephi.authme.data.auth;
|
||||||
|
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.cache.auth;
|
package fr.xephi.authme.data.auth;
|
||||||
|
|
||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
@ -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.common.io.Files;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
@ -10,13 +10,13 @@ import com.google.gson.JsonObject;
|
|||||||
import com.google.gson.JsonSerializationContext;
|
import com.google.gson.JsonSerializationContext;
|
||||||
import com.google.gson.JsonSerializer;
|
import com.google.gson.JsonSerializer;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.initialization.DataFolder;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
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.FileUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Player;
|
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.
|
* 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 Gson gson;
|
||||||
private final File cacheDir;
|
private final File cacheDir;
|
||||||
@ -39,7 +39,7 @@ public class PlayerDataStorage {
|
|||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
PlayerDataStorage(@DataFolder File dataFolder, PermissionsManager permsMan,
|
LimboPlayerStorage(@DataFolder File dataFolder, PermissionsManager permsMan,
|
||||||
SpawnLoader spawnLoader, BukkitService bukkitService) {
|
SpawnLoader spawnLoader, BukkitService bukkitService) {
|
||||||
this.permissionsManager = permsMan;
|
this.permissionsManager = permsMan;
|
||||||
this.spawnLoader = spawnLoader;
|
this.spawnLoader = spawnLoader;
|
||||||
@ -50,8 +50,8 @@ public class PlayerDataStorage {
|
|||||||
ConsoleLogger.warning("Failed to create userdata directory.");
|
ConsoleLogger.warning("Failed to create userdata directory.");
|
||||||
}
|
}
|
||||||
gson = new GsonBuilder()
|
gson = new GsonBuilder()
|
||||||
.registerTypeAdapter(PlayerData.class, new PlayerDataSerializer())
|
.registerTypeAdapter(LimboPlayer.class, new LimboPlayerSerializer())
|
||||||
.registerTypeAdapter(PlayerData.class, new PlayerDataDeserializer())
|
.registerTypeAdapter(LimboPlayer.class, new LimboPlayerDeserializer())
|
||||||
.setPrettyPrinting()
|
.setPrettyPrinting()
|
||||||
.create();
|
.create();
|
||||||
}
|
}
|
||||||
@ -63,8 +63,8 @@ public class PlayerDataStorage {
|
|||||||
*
|
*
|
||||||
* @return PlayerData object if the data is exist, null otherwise.
|
* @return PlayerData object if the data is exist, null otherwise.
|
||||||
*/
|
*/
|
||||||
public PlayerData readData(Player player) {
|
public LimboPlayer readData(Player player) {
|
||||||
String id = Utils.getUUIDorName(player);
|
String id = PlayerUtils.getUUIDorName(player);
|
||||||
File file = new File(cacheDir, id + File.separator + "data.json");
|
File file = new File(cacheDir, id + File.separator + "data.json");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
return null;
|
return null;
|
||||||
@ -72,7 +72,7 @@ public class PlayerDataStorage {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
String str = Files.toString(file, StandardCharsets.UTF_8);
|
String str = Files.toString(file, StandardCharsets.UTF_8);
|
||||||
return gson.fromJson(str, PlayerData.class);
|
return gson.fromJson(str, LimboPlayer.class);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ConsoleLogger.logException("Could not read player data on disk for '" + player.getName() + "'", e);
|
ConsoleLogger.logException("Could not read player data on disk for '" + player.getName() + "'", e);
|
||||||
return null;
|
return null;
|
||||||
@ -85,7 +85,7 @@ public class PlayerDataStorage {
|
|||||||
* @param player player to save
|
* @param player player to save
|
||||||
*/
|
*/
|
||||||
public void saveData(Player player) {
|
public void saveData(Player player) {
|
||||||
String id = Utils.getUUIDorName(player);
|
String id = PlayerUtils.getUUIDorName(player);
|
||||||
Location location = spawnLoader.getPlayerLocationOrSpawn(player);
|
Location location = spawnLoader.getPlayerLocationOrSpawn(player);
|
||||||
String group = "";
|
String group = "";
|
||||||
if (permissionsManager.hasGroupSupport()) {
|
if (permissionsManager.hasGroupSupport()) {
|
||||||
@ -95,12 +95,12 @@ public class PlayerDataStorage {
|
|||||||
boolean canFly = player.getAllowFlight();
|
boolean canFly = player.getAllowFlight();
|
||||||
float walkSpeed = player.getWalkSpeed();
|
float walkSpeed = player.getWalkSpeed();
|
||||||
float flySpeed = player.getFlySpeed();
|
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 {
|
try {
|
||||||
File file = new File(cacheDir, id + File.separator + "data.json");
|
File file = new File(cacheDir, id + File.separator + "data.json");
|
||||||
Files.createParentDirs(file);
|
Files.createParentDirs(file);
|
||||||
Files.touch(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) {
|
} catch (IOException e) {
|
||||||
ConsoleLogger.logException("Failed to write " + player.getName() + " data.", e);
|
ConsoleLogger.logException("Failed to write " + player.getName() + " data.", e);
|
||||||
}
|
}
|
||||||
@ -113,7 +113,7 @@ public class PlayerDataStorage {
|
|||||||
* @param player player to remove
|
* @param player player to remove
|
||||||
*/
|
*/
|
||||||
public void removeData(Player player) {
|
public void removeData(Player player) {
|
||||||
String id = Utils.getUUIDorName(player);
|
String id = PlayerUtils.getUUIDorName(player);
|
||||||
File file = new File(cacheDir, id);
|
File file = new File(cacheDir, id);
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
FileUtils.purgeDirectory(file);
|
FileUtils.purgeDirectory(file);
|
||||||
@ -131,14 +131,14 @@ public class PlayerDataStorage {
|
|||||||
* @return true if data exist, false otherwise.
|
* @return true if data exist, false otherwise.
|
||||||
*/
|
*/
|
||||||
public boolean hasData(Player player) {
|
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");
|
File file = new File(cacheDir, id + File.separator + "data.json");
|
||||||
return file.exists();
|
return file.exists();
|
||||||
}
|
}
|
||||||
|
|
||||||
private class PlayerDataDeserializer implements JsonDeserializer<PlayerData> {
|
private class LimboPlayerDeserializer implements JsonDeserializer<LimboPlayer> {
|
||||||
@Override
|
@Override
|
||||||
public PlayerData deserialize(JsonElement jsonElement, Type type,
|
public LimboPlayer deserialize(JsonElement jsonElement, Type type,
|
||||||
JsonDeserializationContext context) {
|
JsonDeserializationContext context) {
|
||||||
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
JsonObject jsonObject = jsonElement.getAsJsonObject();
|
||||||
if (jsonObject == null) {
|
if (jsonObject == null) {
|
||||||
@ -181,18 +181,18 @@ public class PlayerDataStorage {
|
|||||||
flySpeed = e.getAsFloat();
|
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
|
@Override
|
||||||
public JsonElement serialize(PlayerData playerData, Type type,
|
public JsonElement serialize(LimboPlayer limboPlayer, Type type,
|
||||||
JsonSerializationContext context) {
|
JsonSerializationContext context) {
|
||||||
JsonObject obj = new JsonObject();
|
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();
|
JsonObject obj2 = new JsonObject();
|
||||||
obj2.addProperty("world", loc.getWorld().getName());
|
obj2.addProperty("world", loc.getWorld().getName());
|
||||||
obj2.addProperty("x", loc.getX());
|
obj2.addProperty("x", loc.getX());
|
||||||
@ -202,10 +202,10 @@ public class PlayerDataStorage {
|
|||||||
obj2.addProperty("pitch", loc.getPitch());
|
obj2.addProperty("pitch", loc.getPitch());
|
||||||
obj.add("location", obj2);
|
obj.add("location", obj2);
|
||||||
|
|
||||||
obj.addProperty("operator", playerData.isOperator());
|
obj.addProperty("operator", limboPlayer.isOperator());
|
||||||
obj.addProperty("can-fly", playerData.isCanFly());
|
obj.addProperty("can-fly", limboPlayer.isCanFly());
|
||||||
obj.addProperty("walk-speed", playerData.getWalkSpeed());
|
obj.addProperty("walk-speed", limboPlayer.getWalkSpeed());
|
||||||
obj.addProperty("fly-speed", playerData.getFlySpeed());
|
obj.addProperty("fly-speed", limboPlayer.getFlySpeed());
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -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.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
@ -16,24 +16,24 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
import static com.google.common.base.Preconditions.checkNotNull;
|
import static com.google.common.base.Preconditions.checkNotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages all {@link PlayerData} instances.
|
* Manages all {@link LimboPlayer} instances.
|
||||||
*/
|
*/
|
||||||
public class LimboCache {
|
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 Settings settings;
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
private SpawnLoader spawnLoader;
|
private SpawnLoader spawnLoader;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
LimboCache(Settings settings, PermissionsManager permissionsManager,
|
LimboCache(Settings settings, PermissionsManager permissionsManager,
|
||||||
SpawnLoader spawnLoader, PlayerDataStorage playerDataStorage) {
|
SpawnLoader spawnLoader, LimboPlayerStorage limboPlayerStorage) {
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.permissionsManager = permissionsManager;
|
this.permissionsManager = permissionsManager;
|
||||||
this.spawnLoader = spawnLoader;
|
this.spawnLoader = spawnLoader;
|
||||||
this.playerDataStorage = playerDataStorage;
|
this.limboPlayerStorage = limboPlayerStorage;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -53,8 +53,8 @@ public class LimboCache {
|
|||||||
playerGroup = permissionsManager.getPrimaryGroup(player);
|
playerGroup = permissionsManager.getPrimaryGroup(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerDataStorage.hasData(player)) {
|
if (limboPlayerStorage.hasData(player)) {
|
||||||
PlayerData cache = playerDataStorage.readData(player);
|
LimboPlayer cache = limboPlayerStorage.readData(player);
|
||||||
if (cache != null) {
|
if (cache != null) {
|
||||||
location = cache.getLocation();
|
location = cache.getLocation();
|
||||||
playerGroup = cache.getGroup();
|
playerGroup = cache.getGroup();
|
||||||
@ -64,10 +64,10 @@ public class LimboCache {
|
|||||||
flySpeed = cache.getFlySpeed();
|
flySpeed = cache.getFlySpeed();
|
||||||
}
|
}
|
||||||
} else {
|
} 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) {
|
public void restoreData(Player player) {
|
||||||
String lowerName = player.getName().toLowerCase();
|
String lowerName = player.getName().toLowerCase();
|
||||||
if (cache.containsKey(lowerName)) {
|
if (cache.containsKey(lowerName)) {
|
||||||
PlayerData data = cache.get(lowerName);
|
LimboPlayer data = cache.get(lowerName);
|
||||||
player.setOp(data.isOperator());
|
player.setOp(data.isOperator());
|
||||||
player.setAllowFlight(data.isCanFly());
|
player.setAllowFlight(data.isCanFly());
|
||||||
float walkSpeed = data.getWalkSpeed();
|
float walkSpeed = data.getWalkSpeed();
|
||||||
@ -104,7 +104,7 @@ public class LimboCache {
|
|||||||
*/
|
*/
|
||||||
public void deletePlayerData(Player player) {
|
public void deletePlayerData(Player player) {
|
||||||
removeFromCache(player);
|
removeFromCache(player);
|
||||||
playerDataStorage.removeData(player);
|
limboPlayerStorage.removeData(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -114,7 +114,7 @@ public class LimboCache {
|
|||||||
*/
|
*/
|
||||||
public void removeFromCache(Player player) {
|
public void removeFromCache(Player player) {
|
||||||
String name = player.getName().toLowerCase();
|
String name = player.getName().toLowerCase();
|
||||||
PlayerData cachedPlayer = cache.remove(name);
|
LimboPlayer cachedPlayer = cache.remove(name);
|
||||||
if (cachedPlayer != null) {
|
if (cachedPlayer != null) {
|
||||||
cachedPlayer.clearTasks();
|
cachedPlayer.clearTasks();
|
||||||
}
|
}
|
||||||
@ -127,7 +127,7 @@ public class LimboCache {
|
|||||||
*
|
*
|
||||||
* @return PlayerData
|
* @return PlayerData
|
||||||
*/
|
*/
|
||||||
public PlayerData getPlayerData(String name) {
|
public LimboPlayer getPlayerData(String name) {
|
||||||
checkNotNull(name);
|
checkNotNull(name);
|
||||||
return cache.get(name.toLowerCase());
|
return cache.get(name.toLowerCase());
|
||||||
}
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.cache.limbo;
|
package fr.xephi.authme.data.limbo;
|
||||||
|
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
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)
|
* 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.
|
* 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 canFly;
|
||||||
private final boolean operator;
|
private final boolean operator;
|
||||||
@ -18,8 +18,7 @@ public class PlayerData {
|
|||||||
private BukkitTask timeoutTask = null;
|
private BukkitTask timeoutTask = null;
|
||||||
private BukkitTask messageTask = null;
|
private BukkitTask messageTask = null;
|
||||||
|
|
||||||
public PlayerData(Location loc, boolean operator,
|
public LimboPlayer(Location loc, boolean operator, String group, boolean fly, float walkSpeed, float flySpeed) {
|
||||||
String group, boolean fly, float walkSpeed, float flySpeed) {
|
|
||||||
this.loc = loc;
|
this.loc = loc;
|
||||||
this.operator = operator;
|
this.operator = operator;
|
||||||
this.group = group;
|
this.group = group;
|
@ -9,8 +9,10 @@ import com.google.common.util.concurrent.ListeningExecutorService;
|
|||||||
import com.google.common.util.concurrent.MoreExecutors;
|
import com.google.common.util.concurrent.MoreExecutors;
|
||||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
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 fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.datasource;
|
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.initialization.Reloadable;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@ public enum DataSourceType {
|
|||||||
|
|
||||||
MYSQL,
|
MYSQL,
|
||||||
|
|
||||||
@Deprecated
|
SQLITE,
|
||||||
FILE,
|
|
||||||
|
|
||||||
SQLITE
|
@Deprecated
|
||||||
|
FILE
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package fr.xephi.authme.datasource;
|
package fr.xephi.authme.datasource;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
|
@ -4,7 +4,10 @@ import com.google.common.annotations.VisibleForTesting;
|
|||||||
import com.zaxxer.hikari.HikariDataSource;
|
import com.zaxxer.hikari.HikariDataSource;
|
||||||
import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException;
|
import com.zaxxer.hikari.pool.HikariPool.PoolInitializationException;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.HashAlgorithm;
|
||||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.security.crypts.XFBCRYPT;
|
import fr.xephi.authme.security.crypts.XFBCRYPT;
|
||||||
|
@ -2,7 +2,10 @@ package fr.xephi.authme.datasource;
|
|||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.security.crypts.HashedPassword;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.datasource.converter;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.DataSource;
|
||||||
import fr.xephi.authme.datasource.DataSourceType;
|
import fr.xephi.authme.datasource.DataSourceType;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
|
||||||
@ -67,7 +66,7 @@ public abstract class AbstractDataSourceConverter<S extends DataSource> implemen
|
|||||||
|
|
||||||
if (!skippedPlayers.isEmpty()) {
|
if (!skippedPlayers.isEmpty()) {
|
||||||
logAndSendMessage(sender, "Skipped conversion for players which were already in "
|
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()
|
logAndSendMessage(sender, "Database successfully converted from " + source.getType()
|
||||||
+ " to " + destinationType);
|
+ " to " + destinationType);
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.datasource.converter;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.datasource.converter;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.DataSource;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
@ -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.DataSource;
|
||||||
import fr.xephi.authme.datasource.FlatFile;
|
import fr.xephi.authme.datasource.FlatFile;
|
@ -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.DataSource;
|
||||||
import fr.xephi.authme.datasource.DataSourceType;
|
import fr.xephi.authme.datasource.DataSourceType;
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.datasource.converter;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.DataSource;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
@ -1,8 +1,8 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.datasource.converter;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.DataSource;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -12,7 +12,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.io.File;
|
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 {
|
public class RoyalAuthConverter implements Converter {
|
||||||
|
|
@ -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.DataSource;
|
||||||
import fr.xephi.authme.datasource.DataSourceType;
|
import fr.xephi.authme.datasource.DataSourceType;
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.converter;
|
package fr.xephi.authme.datasource.converter;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.DataSource;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -14,7 +14,7 @@ import java.io.IOException;
|
|||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import java.util.UUID;
|
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 {
|
public class vAuthConverter implements Converter {
|
||||||
|
|
@ -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.database.DatabaseTables;
|
||||||
import de.luricos.bukkit.xAuth.utils.xAuthLog;
|
import de.luricos.bukkit.xAuth.utils.xAuthLog;
|
||||||
import de.luricos.bukkit.xAuth.xAuth;
|
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.datasource.DataSource;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
import fr.xephi.authme.util.CollectionUtils;
|
import fr.xephi.authme.util.CollectionUtils;
|
||||||
@ -19,7 +19,7 @@ import java.sql.SQLException;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
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 {
|
public class xAuthConverter implements Converter {
|
||||||
|
|
@ -1,9 +1,10 @@
|
|||||||
package fr.xephi.authme.util;
|
package fr.xephi.authme.geoip;
|
||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import com.maxmind.geoip.LookupService;
|
import com.maxmind.geoip.LookupService;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.initialization.DataFolder;
|
import fr.xephi.authme.initialization.DataFolder;
|
||||||
|
import fr.xephi.authme.util.FileUtils;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -16,7 +17,7 @@ import java.net.URLConnection;
|
|||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
|
|
||||||
public class GeoLiteAPI {
|
public class GeoIpManager {
|
||||||
private static final String LICENSE =
|
private static final String LICENSE =
|
||||||
"[LICENSE] This product uses data from the GeoLite API created by MaxMind, available at http://www.maxmind.com";
|
"[LICENSE] This product uses data from the GeoLite API created by MaxMind, available at http://www.maxmind.com";
|
||||||
private static final String GEOIP_URL =
|
private static final String GEOIP_URL =
|
||||||
@ -27,14 +28,14 @@ public class GeoLiteAPI {
|
|||||||
private final File dataFile;
|
private final File dataFile;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
GeoLiteAPI(@DataFolder File dataFolder) {
|
GeoIpManager(@DataFolder File dataFolder) {
|
||||||
this.dataFile = new File(dataFolder, "GeoIP.dat");
|
this.dataFile = new File(dataFolder, "GeoIP.dat");
|
||||||
// Fires download of recent data or the initialization of the look up service
|
// Fires download of recent data or the initialization of the look up service
|
||||||
isDataAvailable();
|
isDataAvailable();
|
||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
GeoLiteAPI(@DataFolder File dataFolder, LookupService lookupService) {
|
GeoIpManager(@DataFolder File dataFolder, LookupService lookupService) {
|
||||||
this.dataFile = dataFolder;
|
this.dataFile = dataFolder;
|
||||||
this.lookupService = lookupService;
|
this.lookupService = lookupService;
|
||||||
}
|
}
|
@ -5,7 +5,7 @@ import com.github.authme.configme.resource.PropertyResource;
|
|||||||
import com.github.authme.configme.resource.YamlFileResource;
|
import com.github.authme.configme.resource.YamlFileResource;
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.CacheDataSource;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.datasource.DataSourceType;
|
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.datasource.SQLite;
|
||||||
import fr.xephi.authme.output.ConsoleFilter;
|
import fr.xephi.authme.output.ConsoleFilter;
|
||||||
import fr.xephi.authme.output.Log4JFilter;
|
import fr.xephi.authme.output.Log4JFilter;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.message.Messages;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SettingsMigrationService;
|
import fr.xephi.authme.settings.SettingsMigrationService;
|
||||||
import fr.xephi.authme.settings.properties.AuthMeSettingsRetriever;
|
import fr.xephi.authme.settings.properties.AuthMeSettingsRetriever;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
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.FileUtils;
|
||||||
import fr.xephi.authme.util.MigrationService;
|
import fr.xephi.authme.service.MigrationService;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -37,7 +37,7 @@ import java.util.List;
|
|||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
import static fr.xephi.authme.settings.properties.EmailSettings.RECALL_PLAYERS;
|
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.
|
* Initializes various services.
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
package fr.xephi.authme.initialization;
|
package fr.xephi.authme.initialization;
|
||||||
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.backup.PlayerDataStorage;
|
import fr.xephi.authme.data.backup.LimboPlayerStorage;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.hooks.PluginHooks;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -32,7 +32,7 @@ public class OnShutdownPlayerSaver {
|
|||||||
@Inject
|
@Inject
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerDataStorage playerDataStorage;
|
private LimboPlayerStorage limboPlayerStorage;
|
||||||
@Inject
|
@Inject
|
||||||
private SpawnLoader spawnLoader;
|
private SpawnLoader spawnLoader;
|
||||||
@Inject
|
@Inject
|
||||||
@ -77,8 +77,8 @@ public class OnShutdownPlayerSaver {
|
|||||||
}
|
}
|
||||||
if (settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
|
if (settings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
|
||||||
&& !settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
|
&& !settings.getProperty(RestrictionSettings.NO_TELEPORT)) {
|
||||||
if (!playerDataStorage.hasData(player)) {
|
if (!limboPlayerStorage.hasData(player)) {
|
||||||
playerDataStorage.saveData(player);
|
limboPlayerStorage.saveData(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exception thrown when a verification has failed.
|
* Exception thrown when a verification has failed.
|
||||||
@ -27,7 +26,7 @@ public class FailedVerificationException extends Exception {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getClass().getSimpleName() + ": reason=" + (reason == null ? "null" : reason)
|
return getClass().getSimpleName() + ": reason=" + reason
|
||||||
+ ";args=" + (args == null ? "null" : StringUtils.join(", ", args));
|
+ ";args=" + (args == null ? "null" : String.join(", ", args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
package fr.xephi.authme.listener;
|
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.datasource.DataSource;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
import fr.xephi.authme.hooks.PluginHooks;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
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.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.entity.EntityEvent;
|
import org.bukkit.event.entity.EntityEvent;
|
||||||
|
@ -1,22 +1,22 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
import fr.xephi.authme.AntiBot;
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.DataSource;
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.message.Messages;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
|
import fr.xephi.authme.service.AntiBotService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.ProtectionSettings;
|
import fr.xephi.authme.settings.properties.ProtectionSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
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.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
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.Server;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
@ -40,7 +40,7 @@ class OnJoinVerifier implements Reloadable {
|
|||||||
@Inject
|
@Inject
|
||||||
private PermissionsManager permissionsManager;
|
private PermissionsManager permissionsManager;
|
||||||
@Inject
|
@Inject
|
||||||
private AntiBot antiBot;
|
private AntiBotService antiBotService;
|
||||||
@Inject
|
@Inject
|
||||||
private ValidationService validationService;
|
private ValidationService validationService;
|
||||||
@Inject
|
@Inject
|
||||||
@ -50,7 +50,8 @@ class OnJoinVerifier implements Reloadable {
|
|||||||
|
|
||||||
private Pattern nicknamePattern;
|
private Pattern nicknamePattern;
|
||||||
|
|
||||||
OnJoinVerifier() { }
|
OnJoinVerifier() {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
@ -63,12 +64,15 @@ class OnJoinVerifier implements Reloadable {
|
|||||||
/**
|
/**
|
||||||
* Checks if Antibot is enabled.
|
* 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
|
* @param isAuthAvailable whether or not the player is registered
|
||||||
*/
|
*/
|
||||||
public void checkAntibot(String playerName, boolean isAuthAvailable) throws FailedVerificationException {
|
public void checkAntibot(Player player, boolean isAuthAvailable) throws FailedVerificationException {
|
||||||
if (antiBot.getAntiBotStatus() == AntiBot.AntiBotStatus.ACTIVE && !isAuthAvailable) {
|
if (permissionsManager.hasPermission(player, PlayerStatePermission.BYPASS_ANTIBOT)) {
|
||||||
antiBot.addPlayerKick(playerName);
|
return;
|
||||||
|
}
|
||||||
|
if (antiBotService.shouldKick(isAuthAvailable)) {
|
||||||
|
antiBotService.addPlayerKick(player.getName());
|
||||||
throw new FailedVerificationException(MessageKey.KICK_ANTIBOT);
|
throw new FailedVerificationException(MessageKey.KICK_ANTIBOT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -105,6 +109,7 @@ class OnJoinVerifier implements Reloadable {
|
|||||||
* joining player is a VIP.
|
* joining player is a VIP.
|
||||||
*
|
*
|
||||||
* @param event the login event to verify
|
* @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
|
* @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
|
* 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.
|
* Selects a non-VIP player to kick when a VIP player joins the server when full.
|
||||||
*
|
*
|
||||||
* @param onlinePlayers list of online players
|
* @param onlinePlayers list of online players
|
||||||
|
*
|
||||||
* @return the player to kick, or null if none applicable
|
* @return the player to kick, or null if none applicable
|
||||||
*/
|
*/
|
||||||
private Player generateKickPlayer(Collection<? extends Player> onlinePlayers) {
|
private Player generateKickPlayer(Collection<? extends Player> onlinePlayers) {
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
package fr.xephi.authme.listener;
|
package fr.xephi.authme.listener;
|
||||||
|
|
||||||
import fr.xephi.authme.AntiBot;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.message.Messages;
|
||||||
import fr.xephi.authme.process.Management;
|
import fr.xephi.authme.process.Management;
|
||||||
|
import fr.xephi.authme.service.AntiBotService;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.TeleportationService;
|
import fr.xephi.authme.service.TeleportationService;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -62,7 +62,7 @@ public class PlayerListener implements Listener {
|
|||||||
@Inject
|
@Inject
|
||||||
private DataSource dataSource;
|
private DataSource dataSource;
|
||||||
@Inject
|
@Inject
|
||||||
private AntiBot antiBot;
|
private AntiBotService antiBotService;
|
||||||
@Inject
|
@Inject
|
||||||
private Management management;
|
private Management management;
|
||||||
@Inject
|
@Inject
|
||||||
@ -223,8 +223,7 @@ public class PlayerListener implements Listener {
|
|||||||
// Slow stuff
|
// Slow stuff
|
||||||
final PlayerAuth auth = dataSource.getAuth(name);
|
final PlayerAuth auth = dataSource.getAuth(name);
|
||||||
final boolean isAuthAvailable = (auth != null);
|
final boolean isAuthAvailable = (auth != null);
|
||||||
final String lowerName = name.toLowerCase();
|
onJoinVerifier.checkAntibot(player, isAuthAvailable);
|
||||||
onJoinVerifier.checkAntibot(lowerName, isAuthAvailable);
|
|
||||||
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
|
onJoinVerifier.checkKickNonRegistered(isAuthAvailable);
|
||||||
onJoinVerifier.checkNameCasing(player, auth);
|
onJoinVerifier.checkNameCasing(player, auth);
|
||||||
onJoinVerifier.checkPlayerCountry(isAuthAvailable, event.getAddress().getHostAddress());
|
onJoinVerifier.checkPlayerCountry(isAuthAvailable, event.getAddress().getHostAddress());
|
||||||
@ -234,7 +233,7 @@ public class PlayerListener implements Listener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
antiBot.handlePlayerJoin(player);
|
antiBotService.handlePlayerJoin();
|
||||||
teleportationService.teleportOnJoin(player);
|
teleportationService.teleportOnJoin(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,12 +244,12 @@ public class PlayerListener implements Listener {
|
|||||||
if (settings.getProperty(RegistrationSettings.REMOVE_LEAVE_MESSAGE)) {
|
if (settings.getProperty(RegistrationSettings.REMOVE_LEAVE_MESSAGE)) {
|
||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
} else if (settings.getProperty(RegistrationSettings.REMOVE_UNLOGGED_LEAVE_MESSAGE)) {
|
} else if (settings.getProperty(RegistrationSettings.REMOVE_UNLOGGED_LEAVE_MESSAGE)) {
|
||||||
if(listenerService.shouldCancelEvent(event)) {
|
if (listenerService.shouldCancelEvent(event)) {
|
||||||
event.setQuitMessage(null);
|
event.setQuitMessage(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (antiBot.wasPlayerKicked(player.getName())) {
|
if (antiBotService.wasPlayerKicked(player.getName())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -268,7 +267,7 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
if (!antiBot.wasPlayerKicked(player.getName())) {
|
if (!antiBotService.wasPlayerKicked(player.getName())) {
|
||||||
management.performQuit(player);
|
management.performQuit(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ import com.comphenix.protocol.events.PacketAdapter;
|
|||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.events.PacketEvent;
|
import com.comphenix.protocol.events.PacketEvent;
|
||||||
import fr.xephi.authme.AuthMe;
|
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.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
@ -3,11 +3,11 @@ package fr.xephi.authme.listener.protocollib;
|
|||||||
import ch.jalu.injector.annotations.NoFieldScan;
|
import ch.jalu.injector.annotations.NoFieldScan;
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.initialization.SettingsDependent;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -8,7 +8,7 @@ import com.comphenix.protocol.events.PacketEvent;
|
|||||||
import com.comphenix.protocol.reflect.FieldAccessException;
|
import com.comphenix.protocol.reflect.FieldAccessException;
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
|
|
||||||
class TabCompletePacketAdapter extends PacketAdapter {
|
class TabCompletePacketAdapter extends PacketAdapter {
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.ConsoleLogger;
|
|||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.EmailSettings;
|
import fr.xephi.authme.settings.properties.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
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.FileUtils;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
import fr.xephi.authme.util.StringUtils;
|
||||||
import org.apache.commons.mail.EmailConstants;
|
import org.apache.commons.mail.EmailConstants;
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.output;
|
package fr.xephi.authme.message;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Keys for translatable messages managed by {@link Messages}.
|
* Keys for translatable messages managed by {@link Messages}.
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.output;
|
package fr.xephi.authme.message;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.initialization.SettingsDependent;
|
import fr.xephi.authme.initialization.SettingsDependent;
|
@ -100,6 +100,11 @@ public enum AdminPermission implements PermissionNode {
|
|||||||
*/
|
*/
|
||||||
RELOAD("authme.admin.reload", DefaultPermission.OP_ONLY),
|
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.
|
* Permission to see the other accounts of the players that log in.
|
||||||
*/
|
*/
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package fr.xephi.authme.permission;
|
package fr.xephi.authme.permission;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.PlayerData;
|
import fr.xephi.authme.data.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.initialization.Reloadable;
|
import fr.xephi.authme.initialization.Reloadable;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
@ -72,7 +72,7 @@ public class AuthGroupHandler implements Reloadable {
|
|||||||
|
|
||||||
case LOGGED_IN:
|
case LOGGED_IN:
|
||||||
// Get the player data
|
// Get the player data
|
||||||
PlayerData data = limboCache.getPlayerData(player.getName().toLowerCase());
|
LimboPlayer data = limboCache.getPlayerData(player.getName().toLowerCase());
|
||||||
if (data == null) {
|
if (data == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import fr.xephi.authme.process.logout.AsynchronousLogout;
|
|||||||
import fr.xephi.authme.process.quit.AsynchronousQuit;
|
import fr.xephi.authme.process.quit.AsynchronousQuit;
|
||||||
import fr.xephi.authme.process.register.AsyncRegister;
|
import fr.xephi.authme.process.register.AsyncRegister;
|
||||||
import fr.xephi.authme.process.unregister.AsynchronousUnregister;
|
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.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -1,14 +1,14 @@
|
|||||||
package fr.xephi.authme.process;
|
package fr.xephi.authme.process;
|
||||||
|
|
||||||
import com.github.authme.configme.properties.Property;
|
import com.github.authme.configme.properties.Property;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.output.Messages;
|
import fr.xephi.authme.message.Messages;
|
||||||
import fr.xephi.authme.permission.AuthGroupHandler;
|
import fr.xephi.authme.permission.AuthGroupHandler;
|
||||||
import fr.xephi.authme.permission.AuthGroupType;
|
import fr.xephi.authme.permission.AuthGroupType;
|
||||||
import fr.xephi.authme.permission.PermissionNode;
|
import fr.xephi.authme.permission.PermissionNode;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.settings.Settings;
|
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.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ import fr.xephi.authme.process.logout.ProcessSynchronousPlayerLogout;
|
|||||||
import fr.xephi.authme.process.quit.ProcessSyncronousPlayerQuit;
|
import fr.xephi.authme.process.quit.ProcessSyncronousPlayerQuit;
|
||||||
import fr.xephi.authme.process.register.ProcessSyncEmailRegister;
|
import fr.xephi.authme.process.register.ProcessSyncEmailRegister;
|
||||||
import fr.xephi.authme.process.register.ProcessSyncPasswordRegister;
|
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 org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.process.changepassword;
|
package fr.xephi.authme.process.changepassword;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
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.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.security.PasswordSecurity;
|
import fr.xephi.authme.security.PasswordSecurity;
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.process.email;
|
package fr.xephi.authme.process.email;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
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.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package fr.xephi.authme.process.email;
|
package fr.xephi.authme.process.email;
|
||||||
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
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.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
|
@ -2,14 +2,14 @@ package fr.xephi.authme.process.join;
|
|||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.SessionManager;
|
import fr.xephi.authme.data.SessionManager;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.events.ProtectInventoryEvent;
|
import fr.xephi.authme.events.ProtectInventoryEvent;
|
||||||
import fr.xephi.authme.hooks.PluginHooks;
|
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.AuthGroupType;
|
||||||
import fr.xephi.authme.permission.PlayerStatePermission;
|
import fr.xephi.authme.permission.PlayerStatePermission;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
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.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.task.PlayerDataTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import org.apache.commons.lang.reflect.MethodUtils;
|
import org.apache.commons.lang.reflect.MethodUtils;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -32,7 +32,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static fr.xephi.authme.settings.properties.RestrictionSettings.PROTECT_INVENTORY_BEFORE_LOGIN;
|
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.
|
* Asynchronous process for when a player joins.
|
||||||
@ -67,7 +67,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
private BukkitService bukkitService;
|
private BukkitService bukkitService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerDataTaskManager playerDataTaskManager;
|
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private AsynchronousLogin asynchronousLogin;
|
private AsynchronousLogin asynchronousLogin;
|
||||||
@ -78,7 +78,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
|
|
||||||
public void processJoin(final Player player) {
|
public void processJoin(final Player player) {
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
|
|
||||||
if (isPlayerUnrestricted(name)) {
|
if (isPlayerUnrestricted(name)) {
|
||||||
return;
|
return;
|
||||||
@ -185,8 +185,8 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Timeout and message task
|
// Timeout and message task
|
||||||
playerDataTaskManager.registerTimeoutTask(player);
|
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||||
playerDataTaskManager.registerMessageTask(name, isAuthAvailable);
|
limboPlayerTaskManager.registerMessageTask(name, isAuthAvailable);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isPlayerUnrestricted(String name) {
|
private boolean isPlayerUnrestricted(String name) {
|
||||||
@ -249,7 +249,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
|||||||
private int countOnlinePlayersByIp(String ip) {
|
private int countOnlinePlayersByIp(String ip) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Player player : bukkitService.getOnlinePlayers()) {
|
for (Player player : bukkitService.getOnlinePlayers()) {
|
||||||
if (ip.equalsIgnoreCase(Utils.getPlayerIp(player))) {
|
if (ip.equalsIgnoreCase(PlayerUtils.getPlayerIp(player))) {
|
||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,15 @@ package fr.xephi.authme.process.login;
|
|||||||
|
|
||||||
import com.google.common.annotations.VisibleForTesting;
|
import com.google.common.annotations.VisibleForTesting;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.CaptchaManager;
|
import fr.xephi.authme.data.CaptchaManager;
|
||||||
import fr.xephi.authme.cache.TempbanManager;
|
import fr.xephi.authme.data.TempbanManager;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.PlayerData;
|
import fr.xephi.authme.data.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.events.AuthMeAsyncPreLoginEvent;
|
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.AdminPermission;
|
||||||
import fr.xephi.authme.permission.PermissionsManager;
|
import fr.xephi.authme.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.permission.PlayerPermission;
|
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.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.task.PlayerDataTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
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.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
private TempbanManager tempbanManager;
|
private TempbanManager tempbanManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerDataTaskManager playerDataTaskManager;
|
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||||
|
|
||||||
AsynchronousLogin() {
|
AsynchronousLogin() {
|
||||||
}
|
}
|
||||||
@ -120,7 +120,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
service.send(player, MessageKey.USER_NOT_REGISTERED);
|
service.send(player, MessageKey.USER_NOT_REGISTERED);
|
||||||
// Recreate the message task to immediately send the message again as response
|
// 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)
|
// and to make sure we send the right register message (password vs. email registration)
|
||||||
playerDataTaskManager.registerMessageTask(name, false);
|
limboPlayerTaskManager.registerMessageTask(name, false);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
if (hasReachedMaxLoggedInPlayersForIp(player, ip)) {
|
if (hasReachedMaxLoggedInPlayersForIp(player, ip)) {
|
||||||
service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
service.send(player, MessageKey.ALREADY_LOGGED_IN_ERROR);
|
||||||
return null;
|
return null;
|
||||||
@ -163,7 +163,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
return false;
|
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.
|
// Increase the counts here before knowing the result of the login.
|
||||||
captchaManager.increaseCount(name);
|
captchaManager.increaseCount(name);
|
||||||
@ -210,7 +210,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
private void performLogin(Player player, PlayerAuth auth) {
|
private void performLogin(Player player, PlayerAuth auth) {
|
||||||
if (player.isOnline()) {
|
if (player.isOnline()) {
|
||||||
// Update auth to reflect this new login
|
// Update auth to reflect this new login
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
auth.setRealName(player.getName());
|
auth.setRealName(player.getName());
|
||||||
auth.setLastLogin(System.currentTimeMillis());
|
auth.setLastLogin(System.currentTimeMillis());
|
||||||
auth.setIp(ip);
|
auth.setIp(ip);
|
||||||
@ -241,9 +241,9 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
// task, we schedule it in the end
|
// task, we schedule it in the end
|
||||||
// so that we can be sure, and have not to care if it might be
|
// so that we can be sure, and have not to care if it might be
|
||||||
// processed in other order.
|
// processed in other order.
|
||||||
PlayerData playerData = limboCache.getPlayerData(name);
|
LimboPlayer limboPlayer = limboCache.getPlayerData(name);
|
||||||
if (playerData != null) {
|
if (limboPlayer != null) {
|
||||||
playerData.clearTasks();
|
limboPlayer.clearTasks();
|
||||||
}
|
}
|
||||||
syncProcessManager.processSyncPlayerLogin(player);
|
syncProcessManager.processSyncPlayerLogin(player);
|
||||||
} else {
|
} else {
|
||||||
@ -311,7 +311,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
|||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Player onlinePlayer : bukkitService.getOnlinePlayers()) {
|
for (Player onlinePlayer : bukkitService.getOnlinePlayers()) {
|
||||||
if (ip.equalsIgnoreCase(Utils.getPlayerIp(onlinePlayer))
|
if (ip.equalsIgnoreCase(PlayerUtils.getPlayerIp(onlinePlayer))
|
||||||
&& !onlinePlayer.getName().equals(name)
|
&& !onlinePlayer.getName().equals(name)
|
||||||
&& dataSource.isLogged(onlinePlayer.getName().toLowerCase())) {
|
&& dataSource.isLogged(onlinePlayer.getName().toLowerCase())) {
|
||||||
++count;
|
++count;
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package fr.xephi.authme.process.login;
|
package fr.xephi.authme.process.login;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.cache.limbo.PlayerData;
|
import fr.xephi.authme.data.limbo.LimboPlayer;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.events.LoginEvent;
|
import fr.xephi.authme.events.LoginEvent;
|
||||||
import fr.xephi.authme.events.RestoreInventoryEvent;
|
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.process.SynchronousProcess;
|
||||||
import fr.xephi.authme.service.BungeeService;
|
import fr.xephi.authme.service.BungeeService;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.TeleportationService;
|
import fr.xephi.authme.service.TeleportationService;
|
||||||
import org.apache.commons.lang.reflect.MethodUtils;
|
import org.apache.commons.lang.reflect.MethodUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -79,7 +79,7 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
|||||||
public void processPlayerLogin(Player player) {
|
public void processPlayerLogin(Player player) {
|
||||||
final String name = player.getName().toLowerCase();
|
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
|
// Limbo contains the State of the Player before /login
|
||||||
if (limbo != null) {
|
if (limbo != null) {
|
||||||
limboCache.restoreData(player);
|
limboCache.restoreData(player);
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.process.logout;
|
package fr.xephi.authme.process.logout;
|
||||||
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
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.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.process.SyncProcessManager;
|
import fr.xephi.authme.process.SyncProcessManager;
|
||||||
|
@ -1,25 +1,25 @@
|
|||||||
package fr.xephi.authme.process.logout;
|
package fr.xephi.authme.process.logout;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.events.LogoutEvent;
|
||||||
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
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.permission.AuthGroupType;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.process.SynchronousProcess;
|
import fr.xephi.authme.process.SynchronousProcess;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.task.PlayerDataTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.TeleportationService;
|
import fr.xephi.authme.service.TeleportationService;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
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 {
|
public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||||
@ -34,7 +34,7 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
|||||||
private ProtocolLibService protocolLibService;
|
private ProtocolLibService protocolLibService;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerDataTaskManager playerDataTaskManager;
|
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private SessionManager sessionManager;
|
private SessionManager sessionManager;
|
||||||
@ -53,8 +53,8 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
|||||||
protocolLibService.sendBlankInventoryPacket(player);
|
protocolLibService.sendBlankInventoryPacket(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerDataTaskManager.registerTimeoutTask(player);
|
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||||
playerDataTaskManager.registerMessageTask(name, true);
|
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||||
|
|
||||||
applyLogoutEffect(player);
|
applyLogoutEffect(player);
|
||||||
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package fr.xephi.authme.process.quit;
|
package fr.xephi.authme.process.quit;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.cache.SessionManager;
|
import fr.xephi.authme.data.SessionManager;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.CacheDataSource;
|
import fr.xephi.authme.datasource.CacheDataSource;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
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.process.SyncProcessManager;
|
||||||
import fr.xephi.authme.settings.SpawnLoader;
|
import fr.xephi.authme.settings.SpawnLoader;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -63,7 +63,7 @@ public class AsynchronousQuit implements AsynchronousProcess {
|
|||||||
database.updateQuitLoc(auth);
|
database.updateQuitLoc(auth);
|
||||||
}
|
}
|
||||||
|
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.process.quit;
|
package fr.xephi.authme.process.quit;
|
||||||
|
|
||||||
import fr.xephi.authme.cache.backup.PlayerDataStorage;
|
import fr.xephi.authme.data.backup.LimboPlayerStorage;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.process.SynchronousProcess;
|
import fr.xephi.authme.process.SynchronousProcess;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ import javax.inject.Inject;
|
|||||||
public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
|
public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerDataStorage playerDataStorage;
|
private LimboPlayerStorage limboPlayerStorage;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
@ -22,8 +22,8 @@ public class ProcessSyncronousPlayerQuit implements SynchronousProcess {
|
|||||||
limboCache.removeFromCache(player);
|
limboCache.removeFromCache(player);
|
||||||
} else {
|
} else {
|
||||||
// Save player's data, so we could retrieve it later on player next join
|
// Save player's data, so we could retrieve it later on player next join
|
||||||
if (!playerDataStorage.hasData(player)) {
|
if (!limboPlayerStorage.hasData(player)) {
|
||||||
playerDataStorage.saveData(player);
|
limboPlayerStorage.saveData(player);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package fr.xephi.authme.process.register;
|
package fr.xephi.authme.process.register;
|
||||||
|
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.mail.SendMailSSL;
|
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.permission.PermissionsManager;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
import fr.xephi.authme.process.AsynchronousProcess;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
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.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.settings.properties.SecuritySettings;
|
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.StringUtils;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.service.ValidationService;
|
||||||
import fr.xephi.authme.util.ValidationService;
|
import fr.xephi.authme.service.ValidationService.ValidationResult;
|
||||||
import fr.xephi.authme.util.ValidationService.ValidationResult;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
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 int maxRegPerIp = service.getProperty(RestrictionSettings.MAX_REGISTRATION_PER_IP);
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
if (maxRegPerIp > 0
|
if (maxRegPerIp > 0
|
||||||
&& !"127.0.0.1".equalsIgnoreCase(ip)
|
&& !"127.0.0.1".equalsIgnoreCase(ip)
|
||||||
&& !"localhost".equalsIgnoreCase(ip)
|
&& !"localhost".equalsIgnoreCase(ip)
|
||||||
@ -102,7 +102,7 @@ public class AsyncRegister implements AsynchronousProcess {
|
|||||||
List<String> otherAccounts = database.getAllAuthsByIp(ip);
|
List<String> otherAccounts = database.getAllAuthsByIp(ip);
|
||||||
if (otherAccounts.size() >= maxRegPerIp) {
|
if (otherAccounts.size() >= maxRegPerIp) {
|
||||||
service.send(player, MessageKey.MAX_REGISTER_EXCEEDED, Integer.toString(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;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -132,7 +132,7 @@ public class AsyncRegister implements AsynchronousProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name);
|
final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name);
|
||||||
final String ip = Utils.getPlayerIp(player);
|
final String ip = PlayerUtils.getPlayerIp(player);
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
.realName(player.getName())
|
.realName(player.getName())
|
||||||
@ -154,7 +154,7 @@ public class AsyncRegister implements AsynchronousProcess {
|
|||||||
|
|
||||||
private void passwordRegister(final Player player, String password, boolean autoLogin) {
|
private void passwordRegister(final Player player, String password, boolean autoLogin) {
|
||||||
final String name = player.getName().toLowerCase();
|
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);
|
final HashedPassword hashedPassword = passwordSecurity.computeHash(password, name);
|
||||||
PlayerAuth auth = PlayerAuth.builder()
|
PlayerAuth auth = PlayerAuth.builder()
|
||||||
.name(name)
|
.name(name)
|
||||||
|
@ -1,13 +1,13 @@
|
|||||||
package fr.xephi.authme.process.register;
|
package fr.xephi.authme.process.register;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
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.permission.AuthGroupType;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.process.SynchronousProcess;
|
import fr.xephi.authme.process.SynchronousProcess;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.task.PlayerDataTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -19,7 +19,7 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
|
|||||||
private ProcessService service;
|
private ProcessService service;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerDataTaskManager playerDataTaskManager;
|
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||||
|
|
||||||
ProcessSyncEmailRegister() { }
|
ProcessSyncEmailRegister() { }
|
||||||
|
|
||||||
@ -31,11 +31,11 @@ public class ProcessSyncEmailRegister implements SynchronousProcess {
|
|||||||
}
|
}
|
||||||
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
service.send(player, MessageKey.ACCOUNT_NOT_ACTIVATED);
|
||||||
|
|
||||||
playerDataTaskManager.registerTimeoutTask(player);
|
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||||
playerDataTaskManager.registerMessageTask(name, true);
|
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||||
|
|
||||||
player.saveData();
|
player.saveData();
|
||||||
ConsoleLogger.fine(player.getName() + " registered " + Utils.getPlayerIp(player));
|
ConsoleLogger.fine(player.getName() + " registered " + PlayerUtils.getPlayerIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package fr.xephi.authme.process.register;
|
package fr.xephi.authme.process.register;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.output.MessageKey;
|
import fr.xephi.authme.message.MessageKey;
|
||||||
import fr.xephi.authme.permission.AuthGroupType;
|
import fr.xephi.authme.permission.AuthGroupType;
|
||||||
import fr.xephi.authme.process.ProcessService;
|
import fr.xephi.authme.process.ProcessService;
|
||||||
import fr.xephi.authme.process.SynchronousProcess;
|
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.EmailSettings;
|
||||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.task.PlayerDataTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.Utils;
|
import fr.xephi.authme.util.PlayerUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -31,7 +31,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
|||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerDataTaskManager playerDataTaskManager;
|
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||||
|
|
||||||
ProcessSyncPasswordRegister() {
|
ProcessSyncPasswordRegister() {
|
||||||
}
|
}
|
||||||
@ -54,8 +54,8 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
|||||||
private void requestLogin(Player player) {
|
private void requestLogin(Player player) {
|
||||||
final String name = player.getName().toLowerCase();
|
final String name = player.getName().toLowerCase();
|
||||||
limboCache.updatePlayerData(player);
|
limboCache.updatePlayerData(player);
|
||||||
playerDataTaskManager.registerTimeoutTask(player);
|
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||||
playerDataTaskManager.registerMessageTask(name, true);
|
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||||
|
|
||||||
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
if (player.isInsideVehicle() && player.getVehicle() != null) {
|
||||||
player.getVehicle().eject();
|
player.getVehicle().eject();
|
||||||
@ -74,7 +74,7 @@ public class ProcessSyncPasswordRegister implements SynchronousProcess {
|
|||||||
}
|
}
|
||||||
|
|
||||||
player.saveData();
|
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
|
// Kick Player after Registration is enabled, kick the player
|
||||||
if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) {
|
if (service.getProperty(RegistrationSettings.FORCE_KICK_AFTER_REGISTER)) {
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
package fr.xephi.authme.process.unregister;
|
package fr.xephi.authme.process.unregister;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
import fr.xephi.authme.data.auth.PlayerCache;
|
||||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
import fr.xephi.authme.data.limbo.LimboCache;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
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.AuthGroupHandler;
|
||||||
import fr.xephi.authme.permission.AuthGroupType;
|
import fr.xephi.authme.permission.AuthGroupType;
|
||||||
import fr.xephi.authme.process.AsynchronousProcess;
|
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.security.PasswordSecurity;
|
||||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||||
import fr.xephi.authme.task.PlayerDataTaskManager;
|
import fr.xephi.authme.task.LimboPlayerTaskManager;
|
||||||
import fr.xephi.authme.util.BukkitService;
|
import fr.xephi.authme.service.BukkitService;
|
||||||
import fr.xephi.authme.util.TeleportationService;
|
import fr.xephi.authme.service.TeleportationService;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
@ -23,7 +23,7 @@ import org.bukkit.potion.PotionEffectType;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
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 {
|
public class AsynchronousUnregister implements AsynchronousProcess {
|
||||||
|
|
||||||
@ -46,7 +46,7 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
|||||||
private LimboCache limboCache;
|
private LimboCache limboCache;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private PlayerDataTaskManager playerDataTaskManager;
|
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private TeleportationService teleportationService;
|
private TeleportationService teleportationService;
|
||||||
@ -114,8 +114,8 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
|||||||
limboCache.deletePlayerData(player);
|
limboCache.deletePlayerData(player);
|
||||||
limboCache.addPlayerData(player);
|
limboCache.addPlayerData(player);
|
||||||
|
|
||||||
playerDataTaskManager.registerTimeoutTask(player);
|
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||||
playerDataTaskManager.registerMessageTask(name, false);
|
limboPlayerTaskManager.registerMessageTask(name, false);
|
||||||
applyBlindEffect(player);
|
applyBlindEffect(player);
|
||||||
}
|
}
|
||||||
authGroupHandler.setGroup(player, AuthGroupType.UNREGISTERED);
|
authGroupHandler.setGroup(player, AuthGroupType.UNREGISTERED);
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
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.HasSalt;
|
||||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||||
@ -30,7 +30,7 @@ public abstract class HexSaltedMethod implements EncryptionMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSalt() {
|
public String generateSalt() {
|
||||||
return RandomString.generateHex(getSaltLength());
|
return RandomStringUtils.generateHex(getSaltLength());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
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.HasSalt;
|
||||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||||
@ -19,7 +19,7 @@ public class IPB3 extends SeparateSaltMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSalt() {
|
public String generateSalt() {
|
||||||
return RandomString.generateHex(5);
|
return RandomStringUtils.generateHex(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package fr.xephi.authme.security.crypts;
|
|||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.security.HashUtils;
|
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.HasSalt;
|
||||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||||
@ -44,7 +44,7 @@ public class IPB4 implements EncryptionMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSalt() {
|
public String generateSalt() {
|
||||||
return RandomString.generateLowerUpper(22);
|
return RandomStringUtils.generateLowerUpper(22);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
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.HasSalt;
|
||||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||||
@ -19,7 +19,7 @@ public class MYBB extends SeparateSaltMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSalt() {
|
public String generateSalt() {
|
||||||
return RandomString.generateLowerUpper(8);
|
return RandomStringUtils.generateLowerUpper(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
package fr.xephi.authme.security.crypts;
|
||||||
|
|
||||||
import fr.xephi.authme.security.HashUtils;
|
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.AsciiRestricted;
|
||||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.Usage;
|
import fr.xephi.authme.security.crypts.description.Usage;
|
||||||
@ -41,7 +41,7 @@ public class PHPFUSION extends SeparateSaltMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSalt() {
|
public String generateSalt() {
|
||||||
return RandomString.generateHex(12);
|
return RandomStringUtils.generateHex(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
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.HasSalt;
|
||||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||||
@ -30,7 +30,7 @@ public class SALTED2MD5 extends SeparateSaltMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSalt() {
|
public String generateSalt() {
|
||||||
return RandomString.generateHex(saltLength);
|
return RandomStringUtils.generateHex(saltLength);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
package fr.xephi.authme.security.crypts;
|
||||||
|
|
||||||
import fr.xephi.authme.security.HashUtils;
|
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.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.Usage;
|
import fr.xephi.authme.security.crypts.description.Usage;
|
||||||
|
|
||||||
@ -15,6 +15,6 @@ public class SALTEDSHA512 extends SeparateSaltMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSalt() {
|
public String generateSalt() {
|
||||||
return RandomString.generateHex(32);
|
return RandomStringUtils.generateHex(32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package fr.xephi.authme.security.crypts;
|
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.HasSalt;
|
||||||
import fr.xephi.authme.security.crypts.description.Recommendation;
|
import fr.xephi.authme.security.crypts.description.Recommendation;
|
||||||
import fr.xephi.authme.security.crypts.description.SaltType;
|
import fr.xephi.authme.security.crypts.description.SaltType;
|
||||||
@ -19,7 +19,7 @@ public class WBB3 extends SeparateSaltMethod {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateSalt() {
|
public String generateSalt() {
|
||||||
return RandomString.generateHex(40);
|
return RandomStringUtils.generateHex(40);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
218
src/main/java/fr/xephi/authme/service/AntiBotService.java
Normal file
218
src/main/java/fr/xephi/authme/service/AntiBotService.java
Normal 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
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -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.datasource.DataSourceType;
|
||||||
import fr.xephi.authme.settings.Settings;
|
import fr.xephi.authme.settings.Settings;
|
||||||
import fr.xephi.authme.settings.properties.BackupSettings;
|
import fr.xephi.authme.settings.properties.BackupSettings;
|
||||||
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
import fr.xephi.authme.settings.properties.DatabaseSettings;
|
||||||
import fr.xephi.authme.util.StringUtils;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
@ -20,7 +21,7 @@ import java.util.Date;
|
|||||||
*
|
*
|
||||||
* @author stefano
|
* @author stefano
|
||||||
*/
|
*/
|
||||||
public class PerformBackup {
|
public class BackupService {
|
||||||
|
|
||||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
|
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd_HH-mm");
|
||||||
|
|
||||||
@ -38,7 +39,7 @@ public class PerformBackup {
|
|||||||
* @param instance AuthMe
|
* @param instance AuthMe
|
||||||
* @param settings The plugin settings
|
* @param settings The plugin settings
|
||||||
*/
|
*/
|
||||||
public PerformBackup(AuthMe instance, Settings settings) {
|
public BackupService(AuthMe instance, Settings settings) {
|
||||||
this.dataFolder = instance.getDataFolder();
|
this.dataFolder = instance.getDataFolder();
|
||||||
this.settings = settings;
|
this.settings = settings;
|
||||||
this.dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
this.dbName = settings.getProperty(DatabaseSettings.MYSQL_DATABASE);
|
||||||
@ -47,7 +48,7 @@ public class PerformBackup {
|
|||||||
this.tblname = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
this.tblname = settings.getProperty(DatabaseSettings.MYSQL_TABLE);
|
||||||
|
|
||||||
String dateString = DATE_FORMAT.format(new Date());
|
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);
|
instance.getDataFolder().getPath(), "backups", "backup" + dateString);
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package fr.xephi.authme.util;
|
package fr.xephi.authme.service;
|
||||||
|
|
||||||
import fr.xephi.authme.AuthMe;
|
import fr.xephi.authme.AuthMe;
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
@ -1,8 +1,8 @@
|
|||||||
package fr.xephi.authme.util;
|
package fr.xephi.authme.service;
|
||||||
|
|
||||||
import fr.xephi.authme.ConsoleLogger;
|
import fr.xephi.authme.ConsoleLogger;
|
||||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||||
import fr.xephi.authme.converter.ForceFlatToSqlite;
|
import fr.xephi.authme.datasource.converter.ForceFlatToSqlite;
|
||||||
import fr.xephi.authme.datasource.DataSource;
|
import fr.xephi.authme.datasource.DataSource;
|
||||||
import fr.xephi.authme.datasource.DataSourceType;
|
import fr.xephi.authme.datasource.DataSourceType;
|
||||||
import fr.xephi.authme.datasource.FlatFile;
|
import fr.xephi.authme.datasource.FlatFile;
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user