use of org.bukkit.configuration.Configuration in project Dragonet-Legacy by DragonetMC.
the class DragonetServer method initialize.
/**
* Initialize the server, DO NOT CALL IT YOURSELF. Only called by Glowstone
* main class.
*/
public void initialize() {
this.logger.info("Starting Dragonet Server version " + (RELEASE ? "Release " : "") + DragonetVersioning.DRAGONET_VERSION + "... ");
if (!RELEASE) {
this.logger.warn("** This is a snapshot or an un-official build of Dragonet, you may expirence bugs and errors! ");
}
File fileConfig = new File(this.server.getConfigDir() + File.separator + "dragonet.yml");
if (!fileConfig.exists()) {
try {
InputStream inp = DragonetServer.class.getResourceAsStream("/defaults/dragonet.yml");
try {
FileOutputStream oup = new FileOutputStream(fileConfig);
try {
int data = -1;
while ((data = inp.read()) != -1) {
oup.write(data);
}
} finally {
oup.close();
}
} finally {
if (inp != null) {
inp.close();
}
}
} catch (IOException e) {
}
}
Configuration config = YamlConfiguration.loadConfiguration(fileConfig);
enabledJs = config.getBoolean("plugin-support.dapis", true);
enabledPhp = config.getBoolean("plugin-support.php", true);
enabledDragonPortal = config.getBoolean("dragonportal.enabled", false);
if (RELEASE) {
try {
metrics = new DragonetMetrics(this);
metrics.start();
} catch (IOException ex) {
this.logger.error("Faild to send statistics! ");
}
}
this.logger.info("Current Minecraft PC Version: " + DragonetVersioning.MINECRAFT_PC_VERSION);
this.logger.info("Current Minecraft: PE Version: " + DragonetVersioning.MINECRAFT_PE_VERSION);
this.threadPool = Executors.newFixedThreadPool(64);
String ip = config.getString("server-ip", "0.0.0.0");
int port = config.getInt("server-port", 19132);
this.logger.info("Trying to bind on UDP address " + ip + ":" + port + "... ");
try {
this.network = new RakNetInterface(sessionManager, ip, port);
} catch (Exception ex) {
this.getLogger().error("FAILD TO BIND ON THE Minecraft: Pocket Edition PORT " + port + "(UDP)! ");
this.getLogger().error("CLOSE THE PROGRAM USING THAT PORT OR CHANGE THE PORT TO SOLVE THIS PROBLEM! ");
this.getLogger().error("ERROR MESSAGE: " + ex.getMessage());
ex.printStackTrace();
this.getServer().shutdown();
return;
}
this.rhino = new Rhino(this.getServer());
if (enabledJs) {
this.logger.info("Loading DAPIS scripts... ");
this.rhino.loadScripts();
} else {
this.logger.info("DAPIS Javascript plugins disabled! ");
}
this.php = new PHPManager(this);
if (enabledPhp) {
this.logger.info("Loading PHP scripts");
this.php.loadScripts();
} else {
this.logger.info("PHP plugins disabled! ");
}
//DragonPortal server
if (enabledDragonPortal) {
this.getLogger().info("Enabling DragonPortal server... ");
try {
this.portalServer = new DragonPortalServer(this, config.getString("dragonportal.bind-address", "127.0.0.1"), config.getInt("dragonportal.bind-port", 25590), config.getString("dragonportal.password", "NOT_SET"));
this.portalServer.initialize();
} catch (UnknownHostException ex) {
this.getLogger().error("Faild to create DragonPoral server. ", ex);
} catch (IOException ex) {
this.getLogger().error("Faild to bind DragonPoral server on [" + config.getString("dragonportal.bind-address", "127.0.0.1") + ":" + config.getInt("dragonportal.bind-port", 25590) + "]. ", ex);
} catch (PasswordNotSetException ex) {
this.getLogger().error(ex.getMessage());
}
enabledDragonPortal = true;
} else {
enabledDragonPortal = false;
}
//This exists because ScriptAPI.addMethod() must be called AFTER Dragonet initialization
for (Script s : rhino.getScripts()) {
this.getLogger().info("[DragonetAPI] Loading script " + s.getUID());
s.runFunction("onLoad", new Object[] { s });
}
this.playerSpawnThreshold = config.getInt("player-spawn-chunk-threshold", 36);
this.logger.info("Dragonet successfully initialized! ");
}
use of org.bukkit.configuration.Configuration in project Bukkit by Bukkit.
the class YamlConfiguration method buildHeader.
@Override
protected String buildHeader() {
String header = options().header();
if (options().copyHeader()) {
Configuration def = getDefaults();
if ((def != null) && (def instanceof FileConfiguration)) {
FileConfiguration filedefaults = (FileConfiguration) def;
String defaultsHeader = filedefaults.buildHeader();
if ((defaultsHeader != null) && (defaultsHeader.length() > 0)) {
return defaultsHeader;
}
}
}
if (header == null) {
return "";
}
StringBuilder builder = new StringBuilder();
String[] lines = header.split("\r?\n", -1);
boolean startedHeader = false;
for (int i = lines.length - 1; i >= 0; i--) {
builder.insert(0, "\n");
if ((startedHeader) || (lines[i].length() != 0)) {
builder.insert(0, lines[i]);
builder.insert(0, COMMENT_PREFIX);
startedHeader = true;
}
}
return builder.toString();
}
Aggregations