Remove stands on plugin shutdown
This commit is contained in:
parent
37dd1b05b1
commit
7cd7bdb8b9
|
@ -24,6 +24,7 @@ import fr.xephi.authme.security.crypts.Sha256;
|
|||
import fr.xephi.authme.service.BackupService;
|
||||
import fr.xephi.authme.service.BukkitService;
|
||||
import fr.xephi.authme.service.MigrationService;
|
||||
import fr.xephi.authme.service.SpectateLoginService;
|
||||
import fr.xephi.authme.service.bungeecord.BungeeReceiver;
|
||||
import fr.xephi.authme.service.yaml.YamlParseException;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
|
@ -69,6 +70,7 @@ public class AuthMe extends JavaPlugin {
|
|||
private Injector injector;
|
||||
private BackupService backupService;
|
||||
private ConsoleLogger logger;
|
||||
private SpectateLoginService spectateLoginService;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
|
@ -246,6 +248,7 @@ public class AuthMe extends JavaPlugin {
|
|||
bukkitService = injector.getSingleton(BukkitService.class);
|
||||
commandHandler = injector.getSingleton(CommandHandler.class);
|
||||
backupService = injector.getSingleton(BackupService.class);
|
||||
spectateLoginService = injector.getSingleton(SpectateLoginService.class);
|
||||
|
||||
// Trigger instantiation (class not used elsewhere)
|
||||
injector.getSingleton(BungeeReceiver.class);
|
||||
|
@ -316,6 +319,9 @@ public class AuthMe extends JavaPlugin {
|
|||
// Wait for tasks and close data source
|
||||
new TaskCloser(this, database).run();
|
||||
|
||||
// Remove all armorstands so that the players do not get Spectator gamemode
|
||||
spectateLoginService.removeArmorstands();
|
||||
|
||||
// Disabled correctly
|
||||
Consumer<String> infoLogMethod = logger == null ? getLogger()::info : logger::info;
|
||||
infoLogMethod.accept("AuthMe " + this.getDescription().getVersion() + " disabled!");
|
||||
|
|
|
@ -40,16 +40,6 @@ public class SpectateLoginService {
|
|||
player.setSpectatorTarget(stand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the stand is used when authorizing the player
|
||||
*
|
||||
* @param stand the stand
|
||||
* @return true if the stand is used for authorization, false otherwise
|
||||
*/
|
||||
public boolean isStandReserved(ArmorStand stand) {
|
||||
return armorStands.containsValue(stand);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates spectator target for the player
|
||||
*
|
||||
|
@ -80,6 +70,18 @@ public class SpectateLoginService {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes all armorstands and restores player gamemode
|
||||
*/
|
||||
public void removeArmorstands() {
|
||||
for (Player player : armorStands.keySet()) {
|
||||
removeStand(player);
|
||||
}
|
||||
|
||||
gameModeMap.clear();
|
||||
armorStands.clear();
|
||||
}
|
||||
|
||||
public boolean hasStand(Player player) {
|
||||
return armorStands.containsKey(player);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue