mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2025-07-03 04:21:37 +00:00
Add a method to write to the userdata to UserData.java and IUser.java.
This commit is contained in:
parent
44a6f4d562
commit
f16907412d
2 changed files with 64 additions and 0 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue