(update) config/comaptlayer

This commit is contained in:
asofold 2012-06-29 15:44:01 +02:00
parent 218915a702
commit 5312e9573d
4 changed files with 28 additions and 4 deletions

View File

@ -24,5 +24,6 @@ VERSION HISTORY
- (add) List to enable plugins: plugins.ensure-enable [Forces their events to be processed before NoCheatPlus gets them!]
- (bugfix) Remove import of mcMMO-hook (use direct package reference instead).
- (bugfix) Preserve order of entries in the lists read from the configuration.
- (update) config/comaptlayer
(0.0.0) [initial version]

View File

@ -118,17 +118,30 @@ public abstract class AbstractNewConfig extends AbstractConfig {
@Override
public void removeProperty(String path) {
if (path.startsWith(".")) path = path.substring(1);
// VERY EXPENSIVE
MemoryConfiguration temp = new MemoryConfiguration();
setOptions(temp);
Map<String, Object> values = config.getValues(true);
values.remove(path);
for ( String p : values.keySet()){
temp.set(p, values.get(p));
if (values.containsKey(path)) values.remove(path);
else{
final String altPath = "."+path;
if (values.containsKey(altPath)) values.remove(altPath);
}
for ( String _p : values.keySet()){
Object v = values.get(_p);
if (v == null) continue;
else if (v instanceof ConfigurationSection) continue;
String p;
if (_p.startsWith(".")) p = _p.substring(1);
else p = _p;
if (p.startsWith(path)) continue;
temp.set(p, v);
}
config = temp;
}
@Override
public Boolean getBoolean(String path, Boolean defaultValue) {
if (!config.contains(path)) return defaultValue;

View File

@ -60,7 +60,17 @@ public interface CompatConfig {
public Object getProperty(String path, Object defaultValue);
public void set(String path, Object value);
public void setProperty(String path, Object value);
/**
* Remove a path (would also remove sub sections, unless for path naming problems).
* @param path
*/
public void remove(String path);
/**
* Works same as remove(path): removes properties and sections alike.
* @param path
*/
public void removeProperty(String path);
// Contains/has

View File

@ -4,7 +4,7 @@ import java.io.File;
public class CompatConfigFactory {
public static final String version = "0.8.0";
public static final String version = "0.8.1";
/**
* Attempt to get a working file configuration.<br>