summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2013-02-14 03:05:41 -0800
committerKHobbits <rob@khobbits.co.uk>2013-02-14 03:05:41 -0800
commit5840c02efce3d937cfaaf8dbb7dfdb1fa5f85e28 (patch)
treed1dfdaec7802da21c6df00daff69672553c83f1a
parent44a6f4d56280d9dd0f07d3147478236455b170b7 (diff)
parentf16907412db441c7efe69712ee8f3e109ce1af0f (diff)
downloadEssentials-5840c02efce3d937cfaaf8dbb7dfdb1fa5f85e28.tar
Essentials-5840c02efce3d937cfaaf8dbb7dfdb1fa5f85e28.tar.gz
Essentials-5840c02efce3d937cfaaf8dbb7dfdb1fa5f85e28.tar.lz
Essentials-5840c02efce3d937cfaaf8dbb7dfdb1fa5f85e28.tar.xz
Essentials-5840c02efce3d937cfaaf8dbb7dfdb1fa5f85e28.zip
Merge pull request #331 from kukelekuuk00/2.9
Add methods to UserData and IUser for accessing and writing of data from other plugins.
-rw-r--r--Essentials/src/com/earth2me/essentials/IUser.java10
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java54
2 files changed, 64 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/IUser.java b/Essentials/src/com/earth2me/essentials/IUser.java
index 972165a39..00c4f328f 100644
--- a/Essentials/src/com/earth2me/essentials/IUser.java
+++ b/Essentials/src/com/earth2me/essentials/IUser.java
@@ -1,6 +1,8 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
+import java.util.Map;
+import java.util.Set;
import org.bukkit.Location;
import org.bukkit.entity.Player;
@@ -52,4 +54,12 @@ public interface IUser extends Player
void setLogoutLocation();
Location getLogoutLocation();
+
+ void setConfigProperty(String node, Object object);
+
+ Set<String> getConfigKeys();
+
+ Map<String, Object> getConfigMap();
+
+ Map<String, Object> getConfigMap(String node);
}
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
index 023214a13..13a8a9eb5 100644
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ b/Essentials/src/com/earth2me/essentials/UserData.java
@@ -867,6 +867,60 @@ public abstract class UserData extends PlayerExtension implements IConf
config.save();
}
+ public void setConfigProperty(String node, Object object)
+ {
+ final String prefix = "info.";
+ node = prefix+node;
+ if (object instanceof Map)
+ {
+ config.setProperty(node, (Map) object);
+ }
+ else if (object instanceof List)
+ {
+ config.setProperty(node, (List<String>) object);
+ }
+ else if (object instanceof Location)
+ {
+ config.setProperty(node, (Location) object);
+ }
+ else if (object instanceof ItemStack)
+ {
+ config.setProperty(node, (ItemStack) object);
+ }
+ else
+ {
+ config.setProperty(node, object);
+ }
+ config.save();
+ }
+
+ public Set<String> getConfigKeys()
+ {
+ if (config.isConfigurationSection("info"))
+ {
+ return config.getConfigurationSection("info").getKeys(true);
+ }
+ return new HashSet<String>();
+ }
+
+ public Map<String, Object> getConfigMap()
+ {
+ if (config.isConfigurationSection("info"))
+ {
+ return config.getConfigurationSection("info").getValues(true);
+ }
+ return new HashMap<String, Object>();
+ }
+
+ public Map<String, Object> getConfigMap(String node)
+ {
+ if (config.isConfigurationSection("info."+node))
+ {
+ return config.getConfigurationSection("info."+node).getValues(true);
+ }
+ return new HashMap<String, Object>();
+ }
+
public void save()
{
config.save();