Class ScriptHelper

java.lang.Object
dev.selena.luacore.utils.lua.ScriptHelper

public class ScriptHelper extends Object
A useful tool for script assistance
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    applyPotionEffect(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType effectType, int duration, int amplifier)
    applies a potion effect to the player Note: if you are running the script on a different thread you will need to use applyPotionEffectAsync
    void
    applyPotionEffectAsync(org.bukkit.entity.Player player, String effectType, int duration, int amplifier)
    Used for when you cant seem to bind the class in lua
    void
    applyPotionEffectAsync(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType effectType, int duration, int amplifier)
    Used for applying potion effects when the Lua script isn't on the main thread
    void
    dropItem(org.bukkit.inventory.ItemStack item, org.bukkit.Location loc)
    Used for dropping an ItemStack at a location in the world
    static org.luaj.vm2.LuaValue
    extractConstantValue(String path, String constantName)
    Used for getting a LuaValue from a script
    org.bukkit.block.Block
    getBlockAtLocation(org.bukkit.Location loc)
    Used for getting the Block at a location
    org.bukkit.Location
    getBlockLocation(org.bukkit.block.Block block)
    Used for getting the location of a block
    static int
    getIntFromLuaValue(org.luaj.vm2.LuaValue content)
    Used for getting an Integer from a LuaValue
    org.bukkit.inventory.ItemStack
    getItem(org.bukkit.Material type, int amount)
    Used for getting an ItemStack in lua
    static String[]
    getStringArrayFromLuaValue(org.luaj.vm2.LuaValue content)
    Used for getting a string array from a LuaValue
    static String
    getStringFromLuaValue(org.luaj.vm2.LuaValue content)
    Used for getting a string from a LuaValue
    void
    giveItem(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item)
    User for giving a player an ItemStack
    static boolean
    hasDebuff(org.bukkit.entity.Player player)
    Checks if the player has a debuff potion effect
    static boolean
    hasPotionEffect(org.bukkit.entity.Player player, String potionEffect)
    Used for checking if the player has a potion effect
    static String
    intToRoman(int num)
    Used for converting an Int to roman numerals
    static boolean
    isDebuff(org.bukkit.potion.PotionEffectType effectType)
    Used for checking of a potion effect is a debuff
    static Object[]
    multiplyArray(Object[] array, int amount)
    Used for duplicating the array x times Example of use, I had a mask plugin and one of the maks gave 2x the rewards from fishing Using this method you can double the rewards easily
    static void
    removeDebuffs(org.bukkit.entity.Player player)
    Removes all debuffs from the player
    static void
    removeEffects(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType... effects)
    Used for removing potion effects from a player
    static void
    removeEffectsAsync(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType effects)
    Used for removing potion effects when on a different thread

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ScriptHelper

      public ScriptHelper()
  • Method Details

    • applyPotionEffect

      public void applyPotionEffect(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType effectType, int duration, int amplifier)
      applies a potion effect to the player Note: if you are running the script on a different thread you will need to use applyPotionEffectAsync
      Parameters:
      player - The player you want to effect
      effectType - The potion effect type
      duration - Duration of the effect (-1 for infinite)
      amplifier - The amplifier of the effect
      See Also:
    • applyPotionEffectAsync

      public void applyPotionEffectAsync(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType effectType, int duration, int amplifier)
      Used for applying potion effects when the Lua script isn't on the main thread
      Parameters:
      player - The player you want to effect
      effectType - The potion effect type
      duration - The duration of the effect
      amplifier - The amplifier of the effect
    • applyPotionEffectAsync

      public void applyPotionEffectAsync(org.bukkit.entity.Player player, String effectType, int duration, int amplifier)
      Used for when you cant seem to bind the class in lua
      Parameters:
      player - The player you want to effect
      effectType - The String Name of the potion effect
      duration - The duration
      amplifier - The amplifier
    • getItem

      public org.bukkit.inventory.ItemStack getItem(org.bukkit.Material type, int amount)
      Used for getting an ItemStack in lua
      Parameters:
      type - The Material type
      amount - The ItemStack size
      Returns:
      The requested ItemStack
    • getBlockLocation

      public org.bukkit.Location getBlockLocation(org.bukkit.block.Block block)
      Used for getting the location of a block
      Parameters:
      block - The block you want the location of
      Returns:
      Location of the block
    • getBlockAtLocation

      public org.bukkit.block.Block getBlockAtLocation(org.bukkit.Location loc)
      Used for getting the Block at a location
      Parameters:
      loc - The location you want the block of
      Returns:
      The block at the requested location
    • dropItem

      public void dropItem(org.bukkit.inventory.ItemStack item, org.bukkit.Location loc)
      Used for dropping an ItemStack at a location in the world
      Parameters:
      item - The Item you want to drop
      loc - The location you want to drop it
    • giveItem

      public void giveItem(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item)
      User for giving a player an ItemStack
      Parameters:
      player - The player you want to give the Item to
      item - The ItemStack you want to give
    • extractConstantValue

      public static org.luaj.vm2.LuaValue extractConstantValue(String path, String constantName)
      Used for getting a LuaValue from a script
      Parameters:
      path - The script name and path
      constantName - The variable you want to get
      Returns:
      Returns a LuaValue object from the script
      See Also:
    • intToRoman

      public static String intToRoman(int num)
      Used for converting an Int to roman numerals
      Parameters:
      num - The number you want to convert
      Returns:
      The roman numeral value for the int
    • getStringFromLuaValue

      public static String getStringFromLuaValue(org.luaj.vm2.LuaValue content)
      Used for getting a string from a LuaValue
      Parameters:
      content - The LuaValue you want to convert to a string
      Returns:
      String from the LuaValue
      See Also:
    • getStringArrayFromLuaValue

      public static String[] getStringArrayFromLuaValue(org.luaj.vm2.LuaValue content)
      Used for getting a string array from a LuaValue
      Parameters:
      content - The LuaValue you want to convert
      Returns:
      String[] of the LuaValue parsed in
      See Also:
    • getIntFromLuaValue

      public static int getIntFromLuaValue(org.luaj.vm2.LuaValue content)
      Used for getting an Integer from a LuaValue
      Parameters:
      content - The LuaValue you want to convert
      Returns:
      int of the LuaValue parsed in
      See Also:
    • isDebuff

      public static boolean isDebuff(org.bukkit.potion.PotionEffectType effectType)
      Used for checking of a potion effect is a debuff
      Parameters:
      effectType - The potion effect you want to check
      Returns:
      True if the effect is a debuff
    • hasDebuff

      public static boolean hasDebuff(org.bukkit.entity.Player player)
      Checks if the player has a debuff potion effect
      Parameters:
      player - The player you want to check
      Returns:
      True if the player has a debuff
    • hasPotionEffect

      public static boolean hasPotionEffect(org.bukkit.entity.Player player, String potionEffect)
      Used for checking if the player has a potion effect
      Parameters:
      player - The player you want to check
      potionEffect - The name of the potion effect
      Returns:
      True if the player has the effect (False if the effect doesn't exist)
    • removeDebuffs

      public static void removeDebuffs(org.bukkit.entity.Player player)
      Removes all debuffs from the player
      Parameters:
      player - The player you want to remove the debuffs from
    • removeEffects

      public static void removeEffects(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType... effects)
      Used for removing potion effects from a player
      Parameters:
      player - The player you want to remove the effects from
      effects - The potion effects you want to remove
    • removeEffectsAsync

      public static void removeEffectsAsync(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType effects)
      Used for removing potion effects when on a different thread
      Parameters:
      player - The player you want to remove potion effects from
      effects - The potion effect you want to remove from the player
    • multiplyArray

      public static Object[] multiplyArray(Object[] array, int amount)
      Used for duplicating the array x times Example of use, I had a mask plugin and one of the maks gave 2x the rewards from fishing Using this method you can double the rewards easily
      Parameters:
      array - The array you want to duplicate
      amount - The amount of duplicates that should go into the array
      Returns:
      The new array