mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2025-02-16 20:41:59 +01:00
Config now volatile instead of using thread lock.
This commit is contained in:
parent
d40e67b47d
commit
a778d353c4
@ -104,7 +104,6 @@ import java.util.LinkedHashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
@ -119,8 +118,8 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
|
|
||||||
private AnchorManager anchorManager = new AnchorManager(this);
|
private AnchorManager anchorManager = new AnchorManager(this);
|
||||||
// TODO please let's make this non-static
|
// TODO please let's make this non-static
|
||||||
private MultiverseCoreConfiguration config;
|
private volatile MultiverseCoreConfiguration config;
|
||||||
private final ReentrantLock configLock = new ReentrantLock();
|
//private final ReentrantLock configLock = new ReentrantLock();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method is used to find out who is teleporting a player.
|
* This method is used to find out who is teleporting a player.
|
||||||
@ -469,12 +468,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
|
wantedConfig = (MultiverseCoreConfiguration) multiverseConfig.get("multiverse-configuration");
|
||||||
} catch (Exception ignore) {
|
} catch (Exception ignore) {
|
||||||
} finally {
|
} finally {
|
||||||
configLock.lock();
|
|
||||||
try {
|
|
||||||
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
config = ((wantedConfig == null) ? new MultiverseCoreConfiguration() : wantedConfig);
|
||||||
} finally {
|
|
||||||
configLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
this.migrateWorldConfig();
|
this.migrateWorldConfig();
|
||||||
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
this.worldManager.loadWorldConfig(new File(getDataFolder(), "worlds.yml"));
|
||||||
@ -1246,17 +1240,7 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public MultiverseCoreConfig getMVConfig() {
|
public MultiverseCoreConfig getMVConfig() {
|
||||||
Thread thread = Thread.currentThread();
|
|
||||||
if (configLock.isLocked()) {
|
|
||||||
log(Level.FINEST, "configLock is locked when attempting to get config on thread: " + thread);
|
|
||||||
}
|
|
||||||
configLock.lock();
|
|
||||||
try {
|
|
||||||
log(Level.FINEST, "Getting config on thread: " + thread);
|
|
||||||
return config;
|
return config;
|
||||||
} finally {
|
|
||||||
configLock.unlock();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user