mirror of
https://github.com/Xiao-MoMi/Custom-Fishing.git
synced 2025-12-19 15:09:24 +00:00
Fixed redis reloading
This commit is contained in:
@@ -81,7 +81,11 @@ public class BukkitStorageManager implements StorageManager, Listener {
|
|||||||
public void reload() {
|
public void reload() {
|
||||||
YamlDocument config = plugin.getConfigManager().loadConfig("database.yml");
|
YamlDocument config = plugin.getConfigManager().loadConfig("database.yml");
|
||||||
this.serverID = config.getString("unique-server-id", "default");
|
this.serverID = config.getString("unique-server-id", "default");
|
||||||
|
try {
|
||||||
|
config.save(new File(plugin.getBoostrap().getDataFolder(), "database.yml"));
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
// Check if storage type has changed and reinitialize if necessary
|
// Check if storage type has changed and reinitialize if necessary
|
||||||
StorageType storageType = StorageType.valueOf(config.getString("data-storage-method", "H2"));
|
StorageType storageType = StorageType.valueOf(config.getString("data-storage-method", "H2"));
|
||||||
if (storageType != previousType) {
|
if (storageType != previousType) {
|
||||||
@@ -102,13 +106,14 @@ public class BukkitStorageManager implements StorageManager, Listener {
|
|||||||
|
|
||||||
// Handle Redis configuration
|
// Handle Redis configuration
|
||||||
if (!this.hasRedis && config.getBoolean("Redis.enable", false)) {
|
if (!this.hasRedis && config.getBoolean("Redis.enable", false)) {
|
||||||
this.hasRedis = true;
|
|
||||||
this.redisManager = new RedisManager(plugin);
|
this.redisManager = new RedisManager(plugin);
|
||||||
this.redisManager.initialize(config);
|
this.redisManager.initialize(config);
|
||||||
|
this.hasRedis = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Disable Redis if it was enabled but is now disabled
|
// Disable Redis if it was enabled but is now disabled
|
||||||
if (this.hasRedis && !config.getBoolean("Redis.enable", false) && this.redisManager != null) {
|
if (this.hasRedis && !config.getBoolean("Redis.enable", false) && this.redisManager != null) {
|
||||||
|
this.hasRedis = false;
|
||||||
this.redisManager.disable();
|
this.redisManager.disable();
|
||||||
this.redisManager = null;
|
this.redisManager = null;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user