summaryrefslogtreecommitdiffstats
path: root/Essentials2Compat/src/com/earth2me/essentials/Essentials.java
blob: a483fb365ff26fd052efb7e4f1fe9d966085d0b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package com.earth2me.essentials;

import java.io.File;
import net.ess3.api.IEssentials;
import net.ess3.api.IPlugin;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;


public class Essentials extends JavaPlugin
{
	IEssentials ess;
	
	@Override
	public void onEnable()
	{
		Bukkit.getLogger().info("You can remove this compatibility plugin, when all plugins are updated to Essentials-3");
		//TODO: Update files to new 3.0 format
		//TODO: Move Eco Api here
		IPlugin plugin = (IPlugin)getServer().getPluginManager().getPlugin("Essentials-3");
		ess = plugin.getEssentials();
		updateUserfiles();
	}

	private void updateUserfiles()
	{
		File folder = new File(getDataFolder(), "userdata");
		
		if (folder.isDirectory()) {
			new UpdateUserFiles(folder, ess);
			File folderNew = new File(getDataFolder(), "userdata-"+System.currentTimeMillis());
			if (!folderNew.exists()) {
				folder.renameTo(folderNew);
			}
		}
	}
}