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