diff options
author | snowleo <schneeleo@gmail.com> | 2012-11-03 12:44:38 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2012-11-03 12:44:38 +0100 |
commit | 319a3e4deff05d04a544109dbd8755d43dc7abad (patch) | |
tree | d61607f5f2b0f009387e1507a2d2cbf5f48a1b5e /Essentials2Compat/src/com/earth2me/essentials/Essentials.java | |
parent | 488096c1fd00bca61aa7dc1a7721e4a4de55a26d (diff) | |
download | Essentials-319a3e4deff05d04a544109dbd8755d43dc7abad.tar Essentials-319a3e4deff05d04a544109dbd8755d43dc7abad.tar.gz Essentials-319a3e4deff05d04a544109dbd8755d43dc7abad.tar.lz Essentials-319a3e4deff05d04a544109dbd8755d43dc7abad.tar.xz Essentials-319a3e4deff05d04a544109dbd8755d43dc7abad.zip |
Ess2Compat: Settings part 1
Diffstat (limited to 'Essentials2Compat/src/com/earth2me/essentials/Essentials.java')
-rw-r--r-- | Essentials2Compat/src/com/earth2me/essentials/Essentials.java | 39 |
1 files changed, 33 insertions, 6 deletions
diff --git a/Essentials2Compat/src/com/earth2me/essentials/Essentials.java b/Essentials2Compat/src/com/earth2me/essentials/Essentials.java index a483fb365..4d61e6b3d 100644 --- a/Essentials2Compat/src/com/earth2me/essentials/Essentials.java +++ b/Essentials2Compat/src/com/earth2me/essentials/Essentials.java @@ -2,6 +2,7 @@ package com.earth2me.essentials; import java.io.File; import net.ess3.api.IEssentials; +import net.ess3.api.IItemDb; import net.ess3.api.IPlugin; import org.bukkit.Bukkit; import org.bukkit.plugin.java.JavaPlugin; @@ -10,7 +11,7 @@ import org.bukkit.plugin.java.JavaPlugin; public class Essentials extends JavaPlugin { IEssentials ess; - + @Override public void onEnable() { @@ -19,19 +20,45 @@ public class Essentials extends JavaPlugin //TODO: Move Eco Api here IPlugin plugin = (IPlugin)getServer().getPluginManager().getPlugin("Essentials-3"); ess = plugin.getEssentials(); + updateSettings(); updateUserfiles(); } + private void updateSettings() + { + File config = new File(getDataFolder(), "config.yml"); + if (config.isFile()) + { + new UpdateSettings(config, ess); + File fileNew; + do + { + fileNew = new File(getDataFolder(), "config-" + System.currentTimeMillis() + ".yml"); + } + while (fileNew.exists()); + config.renameTo(fileNew); + } + } + private void updateUserfiles() { File folder = new File(getDataFolder(), "userdata"); - - if (folder.isDirectory()) { + + if (folder.isDirectory()) + { new UpdateUserFiles(folder, ess); - File folderNew = new File(getDataFolder(), "userdata-"+System.currentTimeMillis()); - if (!folderNew.exists()) { - folder.renameTo(folderNew); + File folderNew; + do + { + folderNew = new File(getDataFolder(), "userdata-" + System.currentTimeMillis()); } + while (folderNew.exists()); + folder.renameTo(folderNew); } } + + public IItemDb getItemDb() + { + return ess.getItemDb(); + } } |