#1113 Handle LimboPlayers within LimboService (remove LimboCache) (work in progress)
- Delete LimboCache and LimboPlayerStorage: LimboService now handles all LimboPlayer actions - Revoke player rights when creating a LimboPlayer, within the LimboService - Various fixes and improvements
This commit is contained in:
@@ -111,7 +111,6 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
final boolean isAuthAvailable = database.isAuthAvailable(name);
|
||||
|
||||
if (isAuthAvailable) {
|
||||
limboService.createLimboPlayer(player);
|
||||
service.setGroup(player, AuthGroupType.REGISTERED_UNAUTHENTICATED);
|
||||
|
||||
// Protect inventory
|
||||
@@ -141,11 +140,6 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// TODO #1113: Why delete and add LimboPlayer again?
|
||||
// Not Registered. Delete old data, load default one.
|
||||
// limboCache.deletePlayerData(player);
|
||||
// limboCache.addPlayerData(player);
|
||||
|
||||
// Groups logic
|
||||
service.setGroup(player, AuthGroupType.UNREGISTERED);
|
||||
|
||||
@@ -158,12 +152,11 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
final int registrationTimeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||
|
||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
|
||||
player.setOp(false);
|
||||
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
|
||||
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
|
||||
player.setFlySpeed(0.0f);
|
||||
player.setWalkSpeed(0.0f);
|
||||
}
|
||||
// TODO #1113: Find an elegant way to deop unregistered players (and disable fly status etc.?)
|
||||
limboService.createLimboPlayer(player);
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, isAuthAvailable);
|
||||
|
||||
player.setNoDamageTicks(registrationTimeout);
|
||||
if (pluginHookService.isEssentialsAvailable() && service.getProperty(HooksSettings.USE_ESSENTIALS_MOTD)) {
|
||||
player.performCommand("motd");
|
||||
@@ -175,10 +168,6 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
}
|
||||
commandManager.runCommandsOnJoin(player);
|
||||
});
|
||||
|
||||
// Timeout and message task
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, isAuthAvailable);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -189,7 +178,7 @@ public class AsynchronousJoin implements AsynchronousProcess {
|
||||
* @param domain The hostname of the IP address
|
||||
*
|
||||
* @return True if the name is restricted (IP/domain is not allowed for the given name),
|
||||
* false if the restrictions are met or if the name has no restrictions to it
|
||||
* false if the restrictions are met or if the name has no restrictions to it
|
||||
*/
|
||||
private boolean isNameRestricted(String name, String ip, String domain) {
|
||||
if (!service.getProperty(RestrictionSettings.ENABLE_RESTRICTED_USERS)) {
|
||||
|
||||
@@ -65,15 +65,12 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
public void processPlayerLogin(Player player) {
|
||||
final String name = player.getName().toLowerCase();
|
||||
|
||||
commonService.setGroup(player, AuthGroupType.LOGGED_IN);
|
||||
final LimboPlayer limbo = limboService.getLimboPlayer(name);
|
||||
// Limbo contains the State of the Player before /login
|
||||
if (limbo != null) {
|
||||
limboService.restoreData(player);
|
||||
// do we really need to use location from database for now?
|
||||
// because LimboCache#restoreData teleport player to last location.
|
||||
}
|
||||
// TODO #1113: Need to set group before deleting limboPlayer??
|
||||
commonService.setGroup(player, AuthGroupType.LOGGED_IN);
|
||||
|
||||
if (commonService.getProperty(PROTECT_INVENTORY_BEFORE_LOGIN)) {
|
||||
restoreInventory(player);
|
||||
|
||||
@@ -2,12 +2,11 @@ package fr.xephi.authme.process.logout;
|
||||
|
||||
import fr.xephi.authme.data.auth.PlayerAuth;
|
||||
import fr.xephi.authme.data.auth.PlayerCache;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
import fr.xephi.authme.process.AsynchronousProcess;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.process.SyncProcessManager;
|
||||
import fr.xephi.authme.service.CommonService;
|
||||
import fr.xephi.authme.settings.properties.RestrictionSettings;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -24,9 +23,6 @@ public class AsynchronousLogout implements AsynchronousProcess {
|
||||
@Inject
|
||||
private PlayerCache playerCache;
|
||||
|
||||
@Inject
|
||||
private LimboService limboService;
|
||||
|
||||
@Inject
|
||||
private SyncProcessManager syncProcessManager;
|
||||
|
||||
@@ -47,8 +43,6 @@ public class AsynchronousLogout implements AsynchronousProcess {
|
||||
database.updateQuitLoc(auth);
|
||||
}
|
||||
|
||||
// TODO #1113: Would we not have to RESTORE the limbo player here?
|
||||
limboService.createLimboPlayer(player);
|
||||
playerCache.removePlayer(name);
|
||||
database.setUnlogged(name);
|
||||
syncProcessManager.processSyncPlayerLogout(player);
|
||||
|
||||
@@ -2,6 +2,7 @@ package fr.xephi.authme.process.logout;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.data.SessionManager;
|
||||
import fr.xephi.authme.data.limbo.LimboService;
|
||||
import fr.xephi.authme.events.LogoutEvent;
|
||||
import fr.xephi.authme.listener.protocollib.ProtocolLibService;
|
||||
import fr.xephi.authme.message.MessageKey;
|
||||
@@ -36,6 +37,9 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
@Inject
|
||||
private LimboPlayerTaskManager limboPlayerTaskManager;
|
||||
|
||||
@Inject
|
||||
private LimboService limboService;
|
||||
|
||||
@Inject
|
||||
private SessionManager sessionManager;
|
||||
|
||||
@@ -53,11 +57,11 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
protocolLibService.sendBlankInventoryPacket(player);
|
||||
}
|
||||
|
||||
applyLogoutEffect(player);
|
||||
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, true);
|
||||
|
||||
applyLogoutEffect(player);
|
||||
|
||||
// Player is now logout... Time to fire event !
|
||||
bukkitService.callEvent(new LogoutEvent(player));
|
||||
|
||||
@@ -77,15 +81,8 @@ public class ProcessSynchronousPlayerLogout implements SynchronousProcess {
|
||||
}
|
||||
|
||||
// Set player's data to unauthenticated
|
||||
limboService.createLimboPlayer(player);
|
||||
service.setGroup(player, AuthGroupType.REGISTERED_UNAUTHENTICATED);
|
||||
player.setOp(false);
|
||||
player.setAllowFlight(false);
|
||||
// Remove speed
|
||||
if (!service.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)
|
||||
&& service.getProperty(RestrictionSettings.REMOVE_SPEED)) {
|
||||
player.setFlySpeed(0.0f);
|
||||
player.setWalkSpeed(0.0f);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -111,12 +111,13 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
teleportationService.teleportOnJoin(player);
|
||||
player.saveData();
|
||||
|
||||
// TODO #1113: Why delete? limboCache.deletePlayerData(player);
|
||||
limboService.createLimboPlayer(player);
|
||||
bukkitService.scheduleSyncTaskFromOptionallyAsyncTask(() -> {
|
||||
limboService.createLimboPlayer(player);
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, false);
|
||||
|
||||
limboPlayerTaskManager.registerTimeoutTask(player);
|
||||
limboPlayerTaskManager.registerMessageTask(name, false);
|
||||
applyBlindEffect(player);
|
||||
applyBlindEffect(player);
|
||||
});
|
||||
}
|
||||
authGroupHandler.setGroup(player, AuthGroupType.UNREGISTERED);
|
||||
service.send(player, MessageKey.UNREGISTERED_SUCCESS);
|
||||
@@ -124,13 +125,8 @@ public class AsynchronousUnregister implements AsynchronousProcess {
|
||||
|
||||
private void applyBlindEffect(final Player player) {
|
||||
if (service.getProperty(RegistrationSettings.APPLY_BLIND_EFFECT)) {
|
||||
final int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||
bukkitService.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
|
||||
}
|
||||
});
|
||||
int timeout = service.getProperty(RestrictionSettings.TIMEOUT) * TICKS_PER_SECOND;
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.BLINDNESS, timeout, 2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user