1 |
package dk.thoerup.bukkit.creativeworld; |
2 |
|
3 |
import java.io.File; |
4 |
import java.io.IOException; |
5 |
|
6 |
import org.bukkit.World; |
7 |
import org.bukkit.WorldCreator; |
8 |
import org.bukkit.configuration.file.FileConfiguration; |
9 |
import org.bukkit.configuration.file.YamlConfiguration; |
10 |
import org.bukkit.plugin.PluginManager; |
11 |
import org.bukkit.plugin.java.JavaPlugin; |
12 |
|
13 |
|
14 |
|
15 |
|
16 |
public class CreativeMain extends JavaPlugin { |
17 |
|
18 |
YamlConfiguration config = new YamlConfiguration(); |
19 |
|
20 |
File configFile; |
21 |
|
22 |
@Override |
23 |
public void onEnable() { |
24 |
configFile = new File( getDataFolder(), "default.yml"); |
25 |
|
26 |
FileConfiguration config = getConfig(); |
27 |
try { |
28 |
if (configFile.exists() ) { |
29 |
config.load(configFile); |
30 |
} else { |
31 |
System.out.println( "CreativeWorld: config file not found" ); |
32 |
} |
33 |
} catch(Exception e) { |
34 |
System.out.println( "CreativeWorld error loading config : " + e.getMessage() ); |
35 |
e.printStackTrace(); |
36 |
return; |
37 |
} |
38 |
|
39 |
|
40 |
TeleportCommand tpcmd = new TeleportCommand(this); |
41 |
getCommand("creative").setExecutor( tpcmd ); |
42 |
getCommand("survival").setExecutor( tpcmd ); |
43 |
|
44 |
getCommand("gamemode").setExecutor( new GamemodeCommand() ); |
45 |
|
46 |
|
47 |
World creative = this.getServer().createWorld( WorldCreator.name("creative") ); |
48 |
creative.setPVP( false ); |
49 |
|
50 |
WorldChanged worldChanged = new WorldChanged(this); |
51 |
|
52 |
|
53 |
PluginManager pm = getServer().getPluginManager(); |
54 |
pm.registerEvents(worldChanged, this); |
55 |
|
56 |
pm.registerEvents( new BlockEnderChests(this), this); |
57 |
|
58 |
|
59 |
} |
60 |
|
61 |
public void onDisable() { |
62 |
} |
63 |
|
64 |
public void saveConfig() { |
65 |
FileConfiguration config = getConfig(); |
66 |
|
67 |
try { |
68 |
config.save( configFile); |
69 |
} catch (IOException e) { |
70 |
System.out.println( "CreativeWorld error saving config : " + e.getMessage() ); |
71 |
e.printStackTrace(); |
72 |
} |
73 |
} |
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
} |