package dk.thoerup.bukkit.creativeworld; import java.io.*; import org.bukkit.World; import org.bukkit.WorldCreator; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.generator.ChunkGenerator; import org.bukkit.event.entity.*; import org.bukkit.plugin.*; import org.bukkit.configuration.*; import org.bukkit.configuration.file.*; import org.bukkit.event.Event; import org.bukkit.event.Event.Priority; public class CreativeMain extends JavaPlugin { YamlConfiguration config = new YamlConfiguration(); File configFile; @Override public void onEnable() { configFile = new File( getDataFolder(), "default.yml"); FileConfiguration config = getConfig(); try { if (configFile.exists() ) { config.load(configFile); } else { System.out.println( "CreativeWorld: config file not found" ); } } catch(Exception e) { System.out.println( "CreativeWorld error loading config : " + e.getMessage() ); e.printStackTrace(); return; } TeleportCommand tpcmd = new TeleportCommand(this); getCommand("creative").setExecutor( tpcmd ); getCommand("survival").setExecutor( tpcmd ); getCommand("gamemode").setExecutor( new GamemodeCommand() ); World creative = this.getServer().createWorld( WorldCreator.name("creative") ); creative.setPVP( false ); WorldChanged worldChanged = new WorldChanged(this); PluginManager pm = getServer().getPluginManager(); pm.registerEvent(Event.Type.PLAYER_CHANGED_WORLD, worldChanged, Priority.Normal, this); } public void onDisable() { } public void saveConfig() { FileConfiguration config = getConfig(); try { config.save( configFile); } catch (IOException e) { System.out.println( "CreativeWorld error saving config : " + e.getMessage() ); e.printStackTrace(); } } }