mirror of
https://github.com/TotalFreedomMC/TF-EssentialsX.git
synced 2024-11-19 01:40:00 +00:00
Make eco npc methods use proper user config creation and resets.
This commit is contained in:
parent
22e1c14e7e
commit
e8ace54036
1 changed files with 4 additions and 17 deletions
|
@ -1,6 +1,7 @@
|
|||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.EssentialsConf;
|
||||
import com.earth2me.essentials.EssentialsUserConf;
|
||||
import static com.earth2me.essentials.I18n.tl;
|
||||
import com.earth2me.essentials.User;
|
||||
import static com.earth2me.essentials.api.Economy.add;
|
||||
|
@ -52,7 +53,7 @@ public class Economy
|
|||
{
|
||||
folder.mkdirs();
|
||||
}
|
||||
EssentialsConf npcConfig = new EssentialsConf(new File(folder, StringUtil.sanitizeFileName(name) + ".yml"));
|
||||
EssentialsUserConf npcConfig = new EssentialsUserConf(name, null, new File(folder, name + ".yml"));
|
||||
npcConfig.load();
|
||||
npcConfig.setProperty("npc", true);
|
||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||
|
@ -61,22 +62,8 @@ public class Economy
|
|||
|
||||
private static void deleteNPC(String name)
|
||||
{
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
}
|
||||
File config = new File(folder, StringUtil.sanitizeFileName(name) + ".yml");
|
||||
EssentialsConf npcConfig = new EssentialsConf(config);
|
||||
npcConfig.load();
|
||||
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false))
|
||||
{
|
||||
if (!config.delete())
|
||||
{
|
||||
logger.log(Level.WARNING, tl("deleteFileError", config));
|
||||
}
|
||||
ess.getUserMap().removeUser(name);
|
||||
}
|
||||
User user = ess.getUser(name);
|
||||
user.reset();
|
||||
}
|
||||
|
||||
private static User getUserByName(String name)
|
||||
|
|
Loading…
Reference in a new issue