summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/settings/SettingsHolder.java
blob: 22a398a3c5799929ba2c896110f56cbe17204a8a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.earth2me.essentials.settings;

import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.ISettings;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
import java.io.File;
import java.util.concurrent.atomic.AtomicBoolean;


public class SettingsHolder extends AsyncStorageObjectHolder<Settings> implements ISettings
{
	private final transient AtomicBoolean debug = new AtomicBoolean(false);
	public SettingsHolder(final IEssentials ess)
	{
		super(ess, Settings.class);
		onReload();
	}

	@Override
	public final void onReload()
	{
		super.onReload();
		acquireReadLock();
		try {
			debug.set(getData().getGeneral().isDebug());
		} finally {
			unlock();
		}
	}

	@Override
	public File getStorageFile()
	{
		return new File(ess.getPlugin().getDataFolder(), "settings.yml");
	}

	@Override
	public String getLocale()
	{
		acquireReadLock();
		try {
			return getData().getGeneral().getLocale();
		} finally {
			unlock();
		}
	}

	@Override
	public boolean isDebug()
	{
		return debug.get();
	}
	
	public void setDebug(final boolean set)
	{
		debug.set(set);
		acquireWriteLock();
		try {
			getData().getGeneral().setDebug(set);
		} finally {
			unlock();
		}
	}
}