mirror of
https://github.com/AuthMe/AuthMeReloaded.git
synced 2025-02-13 02:11:34 +01:00
- Make JsonCache injectable
- Only inject needed field
This commit is contained in:
parent
45d8e24350
commit
ad068ffba0
@ -5,6 +5,7 @@ import fr.xephi.authme.api.API;
|
||||
import fr.xephi.authme.api.NewAPI;
|
||||
import fr.xephi.authme.cache.auth.PlayerAuth;
|
||||
import fr.xephi.authme.cache.auth.PlayerCache;
|
||||
import fr.xephi.authme.cache.backup.JsonCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboCache;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.command.CommandHandler;
|
||||
@ -591,8 +592,11 @@ public class AuthMe extends JavaPlugin {
|
||||
}
|
||||
if (newSettings.getProperty(RestrictionSettings.TELEPORT_UNAUTHED_TO_SPAWN)
|
||||
&& !newSettings.getProperty(RestrictionSettings.NO_TELEPORT)) {
|
||||
limboCache.getJsonCache().writeCache(player);
|
||||
player.teleport(spawnLoader.getSpawnLocation(player));
|
||||
JsonCache jsonCache = initializer.getIfAvailable(JsonCache.class);
|
||||
if (jsonCache != null) {
|
||||
jsonCache.writeCache(player);
|
||||
player.teleport(spawnLoader.getSpawnLocation(player));
|
||||
}
|
||||
}
|
||||
}
|
||||
PlayerCache.getInstance().removePlayer(name);
|
||||
|
@ -10,9 +10,9 @@ import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonSerializationContext;
|
||||
import com.google.gson.JsonSerializer;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
import fr.xephi.authme.cache.limbo.LimboPlayer;
|
||||
import fr.xephi.authme.initialization.DataFolder;
|
||||
import fr.xephi.authme.permission.PermissionsManager;
|
||||
import fr.xephi.authme.settings.SpawnLoader;
|
||||
import fr.xephi.authme.util.BukkitService;
|
||||
@ -32,16 +32,15 @@ public class JsonCache {
|
||||
private final Gson gson;
|
||||
private final File cacheDir;
|
||||
@Inject
|
||||
private AuthMe plugin;
|
||||
@Inject
|
||||
private PermissionsManager permissionsManager;
|
||||
@Inject
|
||||
private SpawnLoader spawnLoader;
|
||||
@Inject
|
||||
private BukkitService bukkitService;
|
||||
|
||||
public JsonCache() {
|
||||
cacheDir = new File(plugin.getDataFolder(), "cache");
|
||||
@Inject
|
||||
public JsonCache(@DataFolder File dataFolder) {
|
||||
cacheDir = new File(dataFolder, "cache");
|
||||
if (!cacheDir.exists() && !cacheDir.isDirectory() && !cacheDir.mkdir()) {
|
||||
ConsoleLogger.showError("Failed to create cache directory.");
|
||||
}
|
||||
|
@ -17,10 +17,13 @@ import static com.google.common.base.Preconditions.checkNotNull;
|
||||
public class LimboCache {
|
||||
|
||||
private final ConcurrentHashMap<String, LimboPlayer> cache = new ConcurrentHashMap<>();
|
||||
private final JsonCache jsonCache = new JsonCache();
|
||||
|
||||
@Inject
|
||||
private JsonCache jsonCache;
|
||||
|
||||
@Inject
|
||||
private PermissionsManager permissionsManager;
|
||||
|
||||
@Inject
|
||||
private SpawnLoader spawnLoader;
|
||||
|
||||
@ -30,10 +33,6 @@ public class LimboCache {
|
||||
this.spawnLoader = spawnLoader;
|
||||
}
|
||||
|
||||
public JsonCache getJsonCache() {
|
||||
return jsonCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a limbo player.
|
||||
*
|
||||
|
Loading…
Reference in New Issue
Block a user