mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-08-21 10:52:01 +00:00
Change to our own Yaml parsing for globalgroups instead of using the
YAMLConfiguration class in bukkit.
This commit is contained in:
parent
1eac05799f
commit
b71a6ac5e1
|
@ -188,4 +188,5 @@ v 2.0:
|
||||||
- Fix loading users with only numerals in their names to be seen as strings.
|
- Fix loading users with only numerals in their names to be seen as strings.
|
||||||
- Ignore any sub folders in the Worlds folder which start with a period (fix for storing data in svn respoitories).
|
- Ignore any sub folders in the Worlds folder which start with a period (fix for storing data in svn respoitories).
|
||||||
- Throw a better error than 'null' when someone removes all groups from a yml.
|
- Throw a better error than 'null' when someone removes all groups from a yml.
|
||||||
- Stop force removing attachments and let Bukkit handle it's own mess.
|
- Stop force removing attachments and let Bukkit handle it's own mess.
|
||||||
|
- Change to our own Yaml parsing for globalgroups instead of using the YAMLConfiguration class in bukkit.
|
|
@ -1,6 +1,7 @@
|
||||||
package org.anjocaido.groupmanager;
|
package org.anjocaido.groupmanager;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -20,9 +21,10 @@ import org.anjocaido.groupmanager.events.GroupManagerEventHandler;
|
||||||
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
import org.anjocaido.groupmanager.utils.PermissionCheckResult;
|
||||||
import org.anjocaido.groupmanager.utils.Tasks;
|
import org.anjocaido.groupmanager.utils.Tasks;
|
||||||
import org.bukkit.configuration.MemorySection;
|
import org.bukkit.configuration.MemorySection;
|
||||||
import org.bukkit.configuration.file.YamlConfiguration;
|
|
||||||
import org.yaml.snakeyaml.DumperOptions;
|
import org.yaml.snakeyaml.DumperOptions;
|
||||||
import org.yaml.snakeyaml.Yaml;
|
import org.yaml.snakeyaml.Yaml;
|
||||||
|
import org.yaml.snakeyaml.constructor.SafeConstructor;
|
||||||
|
import org.yaml.snakeyaml.reader.UnicodeReader;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ElgarL
|
* @author ElgarL
|
||||||
|
@ -31,7 +33,7 @@ import org.yaml.snakeyaml.Yaml;
|
||||||
public class GlobalGroups {
|
public class GlobalGroups {
|
||||||
|
|
||||||
private GroupManager plugin;
|
private GroupManager plugin;
|
||||||
private YamlConfiguration GGroups;
|
//private Yaml GGroups;
|
||||||
|
|
||||||
private Map<String, Group> groups;
|
private Map<String, Group> groups;
|
||||||
|
|
||||||
|
@ -89,8 +91,9 @@ public class GlobalGroups {
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load() {
|
public void load() {
|
||||||
|
|
||||||
GGroups = new YamlConfiguration();
|
Yaml GGroupYAML = new Yaml(new SafeConstructor());
|
||||||
|
Map<String, Object> GGroups;
|
||||||
|
|
||||||
GroupManager.setLoaded(false);
|
GroupManager.setLoaded(false);
|
||||||
|
|
||||||
// READ globalGroups FILE
|
// READ globalGroups FILE
|
||||||
|
@ -106,8 +109,13 @@ public class GlobalGroups {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Load the YAML file.
|
||||||
|
*/
|
||||||
try {
|
try {
|
||||||
GGroups.load(GlobalGroupsFile);
|
FileInputStream groupsInputStream = new FileInputStream(GlobalGroupsFile);
|
||||||
|
GGroups = (Map<String, Object>) GGroupYAML.load(new UnicodeReader(groupsInputStream));
|
||||||
|
groupsInputStream.close();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + GlobalGroupsFile.getPath(), ex);
|
throw new IllegalArgumentException("The following file couldn't pass on Parser.\n" + GlobalGroupsFile.getPath(), ex);
|
||||||
}
|
}
|
||||||
|
@ -115,12 +123,12 @@ public class GlobalGroups {
|
||||||
// Clear out old groups
|
// Clear out old groups
|
||||||
resetGlobalGroups();
|
resetGlobalGroups();
|
||||||
|
|
||||||
if (!GGroups.getKeys(false).isEmpty()) {
|
if (!GGroups.keySet().isEmpty()) {
|
||||||
// Read all global groups
|
// Read all global groups
|
||||||
Map<String, Object> allGroups = new HashMap<String, Object>();
|
Map<String, Object> allGroups = new HashMap<String, Object>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
allGroups = (Map<String, Object>) GGroups.getConfigurationSection("groups").getValues(false);
|
allGroups = (Map<String, Object>) GGroups.get("groups");
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// ex.printStackTrace();
|
// ex.printStackTrace();
|
||||||
throw new IllegalArgumentException("Your " + GlobalGroupsFile.getPath() + " file is invalid. See console for details.", ex);
|
throw new IllegalArgumentException("Your " + GlobalGroupsFile.getPath() + " file is invalid. See console for details.", ex);
|
||||||
|
|
Loading…
Reference in a new issue