Package dev.selena.luacore.utils.lua
Class ScriptHelper
java.lang.Object
dev.selena.luacore.utils.lua.ScriptHelper
A useful tool for script assistance
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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 applyPotionEffectAsyncvoid
applyPotionEffectAsync
(org.bukkit.entity.Player player, String effectType, int duration, int amplifier) Used for when you cant seem to bind the class in luavoid
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 threadvoid
dropItem
(org.bukkit.inventory.ItemStack item, org.bukkit.Location loc) Used for dropping an ItemStack at a location in the worldstatic org.luaj.vm2.LuaValue
extractConstantValue
(String path, String constantName) Used for getting a LuaValue from a scriptorg.bukkit.block.Block
getBlockAtLocation
(org.bukkit.Location loc) Used for getting the Block at a locationorg.bukkit.Location
getBlockLocation
(org.bukkit.block.Block block) Used for getting the location of a blockstatic int
getIntFromLuaValue
(org.luaj.vm2.LuaValue content) Used for getting an Integer from a LuaValueorg.bukkit.inventory.ItemStack
getItem
(org.bukkit.Material type, int amount) Used for getting an ItemStack in luastatic String[]
getStringArrayFromLuaValue
(org.luaj.vm2.LuaValue content) Used for getting a string array from a LuaValuestatic String
getStringFromLuaValue
(org.luaj.vm2.LuaValue content) Used for getting a string from a LuaValuevoid
giveItem
(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack item) User for giving a player an ItemStackstatic boolean
hasDebuff
(org.bukkit.entity.Player player) Checks if the player has a debuff potion effectstatic boolean
hasPotionEffect
(org.bukkit.entity.Player player, String potionEffect) Used for checking if the player has a potion effectstatic String
intToRoman
(int num) Used for converting an Int to roman numeralsstatic boolean
isDebuff
(org.bukkit.potion.PotionEffectType effectType) Used for checking of a potion effect is a debuffstatic 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 easilystatic void
removeDebuffs
(org.bukkit.entity.Player player) Removes all debuffs from the playerstatic void
removeEffects
(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType... effects) Used for removing potion effects from a playerstatic void
removeEffectsAsync
(org.bukkit.entity.Player player, org.bukkit.potion.PotionEffectType effects) Used for removing potion effects when on a different thread
-
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 effecteffectType
- The potion effect typeduration
- 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 effecteffectType
- The potion effect typeduration
- The duration of the effectamplifier
- 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 effecteffectType
- The String Name of the potion effectduration
- The durationamplifier
- 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 typeamount
- 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 droploc
- 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 toitem
- The ItemStack you want to give
-
extractConstantValue
Used for getting a LuaValue from a script- Parameters:
path
- The script name and pathconstantName
- The variable you want to get- Returns:
- Returns a LuaValue object from the script
- See Also:
-
intToRoman
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
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
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
Used for checking if the player has a potion effect- Parameters:
player
- The player you want to checkpotionEffect
- 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 fromeffects
- 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 fromeffects
- The potion effect you want to remove from the player
-
multiplyArray
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 duplicateamount
- The amount of duplicates that should go into the array- Returns:
- The new array
-