mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-08 16:02:47 +01:00
Code clean up
This commit is contained in:
parent
b1a9abc019
commit
e437321f8f
@ -1,20 +1,21 @@
|
||||
package fr.xephi.authme.listener.protocollib;
|
||||
|
||||
import ch.jalu.injector.annotations.NoFieldScan;
|
||||
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.initialization.SettingsDependent;
|
||||
import fr.xephi.authme.listener.ListenerService;
|
||||
import fr.xephi.authme.output.ConsoleLoggerFactory;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@NoFieldScan
|
||||
public class ProtocolLibService implements SettingsDependent {
|
||||
|
||||
|
@ -117,18 +117,9 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
}
|
||||
|
||||
final boolean isAuthAvailable = database.isAuthAvailable(name);
|
||||
RegistrationStatus status = RegistrationStatus.UNREGISTERED;
|
||||
playerCache.addRegistrationStatus(name, isAuthAvailable ? RegistrationStatus.REGISTERED : status);
|
||||
playerCache.addRegistrationStatus(name, isAuthAvailable ? RegistrationStatus.REGISTERED : RegistrationStatus.UNREGISTERED);
|
||||
if (isAuthAvailable) {
|
||||
// Protect inventory
|
||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||
ProtectInventoryEvent ev = bukkitService.createAndCallEvent(
|
||||
isAsync -> new ProtectInventoryEvent(player, isAsync));
|
||||
if (ev.isCancelled()) {
|
||||
player.updateInventory();
|
||||
logger.fine("ProtectInventoryEvent has been cancelled for " + player.getName() + "...");
|
||||
}
|
||||
}
|
||||
protectInventory(player);
|
||||
|
||||
// Session logic
|
||||
if (sessionService.canResumeSession(player)) {
|
||||
@ -160,6 +151,18 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
processJoinSync(player, isAuthAvailable);
|
||||
}
|
||||
|
||||
private void protectInventory(Player player) {
|
||||
// Protect inventory
|
||||
if (service.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||
ProtectInventoryEvent ev = bukkitService.createAndCallEvent(
|
||||
isAsync -> new ProtectInventoryEvent(player, isAsync));
|
||||
if (ev.isCancelled()) {
|
||||
player.updateInventory();
|
||||
logger.fine("ProtectInventoryEvent has been cancelled for " + player.getName() + "...");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handlePlayerWithUnmetNameRestriction(Player player, String ip) {
|
||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
|
||||
player.kickPlayer(service.retrieveSingleMessage(player, MessageKey.NOT_OWNER_ERROR));
|
||||
|
@ -113,7 +113,8 @@ public class TeleportationService implements Reloadable {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!player.hasPlayedBefore() || playerCache.getRegistrationStatus(player.getName()) == RegistrationStatus.UNREGISTERED) {
|
||||
RegistrationStatus registrationStatus = playerCache.getRegistrationStatus(player.getName());
|
||||
if (!player.hasPlayedBefore() || registrationStatus == RegistrationStatus.UNREGISTERED) {
|
||||
logger.debug("Attempting to teleport player `{0}` to first spawn", player.getName());
|
||||
performTeleportation(player, new FirstSpawnTeleportEvent(player, firstSpawn));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user