Search in sources :

Example 1 with JSFunction

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());
    }
}
Also used : IOException(java.io.IOException) File(java.io.File) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 2 with JSFunction

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);
    }
}
Also used : DragonetPlayer(org.dragonet.entity.DragonetPlayer) DragonetPlayer(org.dragonet.entity.DragonetPlayer) Player(org.bukkit.entity.Player) PotionEffect(org.bukkit.potion.PotionEffect) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 3 with JSFunction

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);
}
Also used : DragonetPlayer(org.dragonet.entity.DragonetPlayer) Player(org.bukkit.entity.Player) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 4 with JSFunction

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.");
    }
}
Also used : DragonetPlayer(org.dragonet.entity.DragonetPlayer) Player(org.bukkit.entity.Player) Material(org.bukkit.Material) ItemStack(org.bukkit.inventory.ItemStack) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Example 5 with JSFunction

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();
}
Also used : Player(org.bukkit.entity.Player) JSFunction(org.mozilla.javascript.annotations.JSFunction)

Aggregations

JSFunction (org.mozilla.javascript.annotations.JSFunction)8 Player (org.bukkit.entity.Player)4 File (java.io.File)3 IOException (java.io.IOException)3 DragonetPlayer (org.dragonet.entity.DragonetPlayer)3 Material (org.bukkit.Material)1 ItemStack (org.bukkit.inventory.ItemStack)1 PotionEffect (org.bukkit.potion.PotionEffect)1 CustomMethod (org.dragonet.rhino.CustomMethod)1 Script (org.dragonet.rhino.Script)1 WrappedException (org.mozilla.javascript.WrappedException)1