#1046 Add onFirstLogin to commands.yml
- Allow to configure commands run on player's first login (login of player with a previously null lastlogin date)
This commit is contained in:
@@ -47,8 +47,8 @@ public class SyncProcessManager {
|
||||
runTask(() -> processSyncPlayerLogout.processSyncLogout(player));
|
||||
}
|
||||
|
||||
public void processSyncPlayerLogin(Player player) {
|
||||
runTask(() -> processSyncPlayerLogin.processPlayerLogin(player));
|
||||
public void processSyncPlayerLogin(Player player, boolean isFirstLogin) {
|
||||
runTask(() -> processSyncPlayerLogin.processPlayerLogin(player, isFirstLogin));
|
||||
}
|
||||
|
||||
public void processSyncPlayerQuit(Player player, boolean wasLoggedIn) {
|
||||
|
||||
@@ -220,6 +220,8 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
*/
|
||||
private void performLogin(Player player, PlayerAuth auth) {
|
||||
if (player.isOnline()) {
|
||||
final boolean isFirstLogin = (auth.getLastLogin() == null);
|
||||
|
||||
// Update auth to reflect this new login
|
||||
final String ip = PlayerUtils.getPlayerIp(player);
|
||||
auth.setRealName(player.getName());
|
||||
@@ -258,7 +260,7 @@ public class AsynchronousLogin implements AsynchronousProcess {
|
||||
// task, we schedule it in the end
|
||||
// so that we can be sure, and have not to care if it might be
|
||||
// processed in other order.
|
||||
syncProcessManager.processSyncPlayerLogin(player);
|
||||
syncProcessManager.processSyncPlayerLogin(player, isFirstLogin);
|
||||
} else {
|
||||
ConsoleLogger.warning("Player '" + player.getName() + "' wasn't online during login process, aborted...");
|
||||
}
|
||||
|
||||
@@ -62,7 +62,13 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
}
|
||||
}
|
||||
|
||||
public void processPlayerLogin(Player player) {
|
||||
/**
|
||||
* Performs operations in sync mode for a player that has just logged in.
|
||||
*
|
||||
* @param player the player that was logged in
|
||||
* @param isFirstLogin true if this is the first time the player logged in
|
||||
*/
|
||||
public void processPlayerLogin(Player player, boolean isFirstLogin) {
|
||||
final String name = player.getName().toLowerCase();
|
||||
final LimboPlayer limbo = limboService.getLimboPlayer(name);
|
||||
|
||||
@@ -93,6 +99,9 @@ public class ProcessSyncPlayerLogin implements SynchronousProcess {
|
||||
welcomeMessageConfiguration.sendWelcomeMessage(player);
|
||||
|
||||
// Login is now finished; we can force all commands
|
||||
if (isFirstLogin) {
|
||||
commandManager.runCommandsOnFirstLogin(player);
|
||||
}
|
||||
commandManager.runCommandsOnLogin(player);
|
||||
|
||||
// Send Bungee stuff. The service will check if it is enabled or not.
|
||||
|
||||
Reference in New Issue
Block a user