1 |
torben |
1657 |
package dk.thoerup.bukkit.creativeworld; |
2 |
|
|
|
3 |
torben |
3238 |
import java.io.File; |
4 |
|
|
import java.io.IOException; |
5 |
torben |
1657 |
|
6 |
|
|
import org.bukkit.World; |
7 |
|
|
import org.bukkit.WorldCreator; |
8 |
torben |
3238 |
import org.bukkit.configuration.file.FileConfiguration; |
9 |
|
|
import org.bukkit.configuration.file.YamlConfiguration; |
10 |
|
|
import org.bukkit.plugin.PluginManager; |
11 |
torben |
1657 |
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 |
torben |
1681 |
pm.registerEvents(worldChanged, this); |
55 |
torben |
1657 |
|
56 |
torben |
2038 |
pm.registerEvents( new BlockEnderChests(this), this); |
57 |
torben |
1657 |
|
58 |
torben |
2038 |
|
59 |
torben |
1657 |
} |
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 |
|
|
} |