use of org.mozilla.javascript.annotations.JSFunction in project Dragonet-Legacy by DragonetMC.
the class ConfigAPI method create.
@JSFunction
public static void create(String name) {
File configDir = new File("plugins/" + name);
File configFile = new File(configDir.getPath() + "/" + name + ".yml");
try {
if (!configDir.exists()) {
if (configDir.mkdir()) {
if (configFile.createNewFile()) {
}
}
}
} catch (IOException IOe) {
System.err.println(IOe.getMessage());
}
}
use of org.mozilla.javascript.annotations.JSFunction in project Dragonet-Legacy by DragonetMC.
the class PlayerAPI method addPotionEffect.
@JSFunction
public static void addPotionEffect(Object player, int effectID, int duration, int amp, boolean areParticles) {
if (player instanceof DragonetPlayer) {
// TODO for MC:PE
} else {
PotionEffect effectPC = new PotionEffect(PotionEffectType.getById(effectID), duration, amp, !areParticles);
Player plr = (Player) player;
plr.addPotionEffect(effectPC);
}
}
use of org.mozilla.javascript.annotations.JSFunction in project Dragonet-Legacy by DragonetMC.
the class PlayerAPI method setHelth.
@JSFunction
public static void setHelth(Object player, double Health) {
Player plr = ((Player) player);
plr.setHealth(Health);
}
use of org.mozilla.javascript.annotations.JSFunction in project Dragonet-Legacy by DragonetMC.
the class PlayerAPI method addItemInventory.
@JSFunction
public static void addItemInventory(Object player, String MaterialName, int Count) {
Player plr = (Player) player;
Material mat = Material.getMaterial(MaterialName);
if ((plr != null) && (mat != null)) {
plr.getInventory().addItem(new ItemStack(mat, Count));
} else if (plr == null) {
org.dragonet.DragonetServer.instance().getLogger().warn("[DragonetAPI] Script tried to add item to non-existent player! Please alert the script author.");
} else if (mat == null) {
org.dragonet.DragonetServer.instance().getLogger().warn("[DragonetAPI] Script tried to add non-existent item to player! Please alret the script author.");
}
}
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();
}
Aggregations