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