#421 Create SpawnLoader
- Non-static service class which handles the spawnpoints used in AuthMe
This commit is contained in:
@@ -8,6 +8,7 @@ import fr.xephi.authme.output.Messages;
|
||||
import fr.xephi.authme.security.PasswordSecurity;
|
||||
import fr.xephi.authme.security.crypts.HashedPassword;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import fr.xephi.authme.settings.domain.Property;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.event.Event;
|
||||
@@ -24,15 +25,17 @@ public class ProcessService {
|
||||
private final IpAddressManager ipAddressManager;
|
||||
private final PasswordSecurity passwordSecurity;
|
||||
private final PluginHooks pluginHooks;
|
||||
private final SpawnLoader spawnLoader;
|
||||
|
||||
public ProcessService(NewSetting settings, Messages messages, AuthMe authMe, IpAddressManager ipAddressManager,
|
||||
PasswordSecurity passwordSecurity, PluginHooks pluginHooks) {
|
||||
PasswordSecurity passwordSecurity, PluginHooks pluginHooks, SpawnLoader spawnLoader) {
|
||||
this.settings = settings;
|
||||
this.messages = messages;
|
||||
this.authMe = authMe;
|
||||
this.ipAddressManager = ipAddressManager;
|
||||
this.passwordSecurity = passwordSecurity;
|
||||
this.pluginHooks = pluginHooks;
|
||||
this.spawnLoader = spawnLoader;
|
||||
}
|
||||
|
||||
public <T> T getProperty(Property<T> property) {
|
||||
@@ -91,4 +94,8 @@ public class ProcessService {
|
||||
return pluginHooks;
|
||||
}
|
||||
|
||||
public SpawnLoader getSpawnLoader() {
|
||||
return spawnLoader;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,7 +16,6 @@ import fr.xephi.authme.process.Process;
|
||||
import fr.xephi.authme.process.ProcessService;
|
||||
import fr.xephi.authme.settings.NewSetting;
|
||||
import fr.xephi.authme.settings.Settings;
|
||||
import fr.xephi.authme.settings.Spawn;
|
||||
import fr.xephi.authme.settings.properties.HooksSettings;
|
||||
import fr.xephi.authme.settings.properties.PluginSettings;
|
||||
import fr.xephi.authme.settings.properties.RegistrationSettings;
|
||||
@@ -90,7 +89,7 @@ public class AsynchronousJoin implements Process {
|
||||
});
|
||||
return;
|
||||
}
|
||||
final Location spawnLoc = Spawn.getInstance().getSpawnLocation(player);
|
||||
final Location spawnLoc = service.getSpawnLoader().getSpawnLocation(player);
|
||||
final boolean isAuthAvailable = database.isAuthAvailable(name);
|
||||
if (isAuthAvailable) {
|
||||
if (!Settings.noTeleport) {
|
||||
@@ -212,11 +211,14 @@ public class AsynchronousJoin implements Process {
|
||||
}
|
||||
|
||||
private boolean needFirstSpawn() {
|
||||
if (player.hasPlayedBefore())
|
||||
if (player.hasPlayedBefore()) {
|
||||
return false;
|
||||
Location firstSpawn = Spawn.getInstance().getFirstSpawn();
|
||||
if (firstSpawn == null || firstSpawn.getWorld() == null)
|
||||
}
|
||||
Location firstSpawn = service.getSpawnLoader().getFirstSpawn();
|
||||
if (firstSpawn == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
FirstSpawnTeleportEvent tpEvent = new FirstSpawnTeleportEvent(player, player.getLocation(), firstSpawn);
|
||||
plugin.getServer().getPluginManager().callEvent(tpEvent);
|
||||
if (!tpEvent.isCancelled()) {
|
||||
|
||||
Reference in New Issue
Block a user