Saving user join and check on command

This commit is contained in:
HexelDev 2018-03-10 19:13:23 +01:00
parent 844bd24221
commit fe4d5e7c0d
2 changed files with 16 additions and 0 deletions

View File

@ -1,5 +1,6 @@
package fr.xephi.authme.listener;
import fr.xephi.authme.data.QuickCommandsProtectionManager;
import fr.xephi.authme.data.auth.PlayerAuth;
import fr.xephi.authme.datasource.DataSource;
import fr.xephi.authme.message.MessageKey;
@ -86,6 +87,8 @@ public class PlayerListener implements Listener {
@Inject
private PermissionsManager permissionsManager;
@Inject
private QuickCommandsProtectionManager quickCommandsProtectionManager;
@Inject
private BungeeSender bungeeSender;
private boolean isAsyncPlayerPreLoginEventCalled = false;
@ -100,6 +103,11 @@ public class PlayerListener implements Listener {
return;
}
final Player player = event.getPlayer();
if (!quickCommandsProtectionManager.isAllowed(player.getName())) {
event.setCancelled(true);
player.kickPlayer(m.retrieveSingle(MessageKey.QUICK_COMMAND_PROTECTION_KICK));
return;
}
if (listenerService.shouldCancelEvent(player)) {
event.setCancelled(true);
m.send(player, MessageKey.DENIED_COMMAND);
@ -207,6 +215,11 @@ public class PlayerListener implements Listener {
if (!PlayerListener19Spigot.isPlayerSpawnLocationEventCalled()) {
teleportationService.teleportOnJoin(player);
}
if (quickCommandsProtectionManager.shouldSaveLogin(player)) {
quickCommandsProtectionManager.setLogin(player.getName());
}
management.performJoin(player);
teleportationService.teleportNewPlayerToFirstSpawn(player);

View File

@ -275,6 +275,9 @@ public enum MessageKey {
/** To verify your identity you need to link an email address with your account! */
VERIFICATION_CODE_EMAIL_NEEDED("verification.email_needed"),
/** You used a command too fast! Please, join the server again and wait more before using any command. */
QUICK_COMMAND_PROTECTION_KICK("quick_command.kick"),
/** second */
SECOND("time.second"),