use of org.mozilla.javascript.annotations.JSFunction in project Dragonet-Legacy by DragonetMC.
the class ServerAPI method stop.
@JSFunction
public static void stop(String msg) {
org.dragonet.DragonetServer.instance().getServer().savePlayers();
for (Player plr : org.dragonet.DragonetServer.instance().getServer().getOnlinePlayers()) {
plr.kickPlayer(msg);
}
org.dragonet.DragonetServer.instance().getServer().shutdown();
}
use of org.mozilla.javascript.annotations.JSFunction in project Dragonet-Legacy by DragonetMC.
the class ConfigAPI method readEntry.
@JSFunction
public static String readEntry(String name, String entry) {
File config = new File("plugins/" + name + "/" + name + ".yml");
String content = "EMPTY_NODE";
if (exists(name)) {
try {
for (String s : FileUtils.readLines(config)) {
if (s.contains(new StringBuffer(entry))) {
content = s.replace(new StringBuffer(entry + ": "), new StringBuffer(""));
}
}
} catch (IOException IOe) {
System.err.println(IOe.getMessage());
}
} else {
org.dragonet.DragonetServer.instance().getLogger().warn("[DragonetAPI] Script tried to read a nonexistant config file!");
}
return content;
}
use of org.mozilla.javascript.annotations.JSFunction in project Dragonet-Legacy by DragonetMC.
the class ConfigAPI method addNewEntry.
@JSFunction
public static void addNewEntry(String name, String entry, String value) {
File config = new File("plugins/" + name + "/" + name + ".yml");
String fullEntry = entry + ": " + value;
try {
Files.write(fullEntry.getBytes(), config);
} catch (IOException IOe) {
System.err.print(IOe.getMessage());
}
}
Aggregations