summaryrefslogtreecommitdiff
path: root/src/com/encrox/cplot/Core.java
blob: 4d361c7b999a518437aacc20f6adba75c9662c00 (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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.encrox.cplot;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.Properties;
import java.util.logging.Logger;

import org.bukkit.Bukkit;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.RegisteredServiceProvider;
import org.bukkit.plugin.java.JavaPlugin;

import com.earth2me.essentials.api.Economy;
import com.encrox.cplot.command.Gs;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;

public class Core extends JavaPlugin {
	
	public static Logger logger;
	public static PluginDescriptionFile pdf;
	public static WorldGuardPlugin wg;
	public static WorldEditPlugin we;
	public static Properties p;
	
	public void onEnable() {
		pdf = getDescription();
		logger = Logger.getLogger("Minecraft");
		if(setupMyself() && setupWorldGuard()) {
			getCommand("gs").setExecutor(new Gs());
			logger.info(pdf.getName() + " " + pdf.getVersion() + " has been enabled.");
		} else {
			logger.info(pdf.getName() + " " + pdf.getVersion() + " has been disabled.");
		}
	}
	
	public boolean setupWorldGuard() {
		wg = (WorldGuardPlugin) Bukkit.getPluginManager().getPlugin("WorldGuard");
		we = (WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit");
		return (wg != null) && (we != null);
	}
	
	public boolean setupMyself() {
		if(!this.getDataFolder().exists())
			this.getDataFolder().mkdirs();
		p = new Properties();
		try {
			p.load(new FileReader(new File(this.getDataFolder() + "/config.properties")));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
			return false;
		} catch (IOException e) {
			e.printStackTrace();
			return false;
		}
		return true;
	}
	
	public void onDisable() {
		logger.info(pdf.getName() + " " + pdf.getVersion() + " has been disabled.");
	}

}