public abstract class AbstractCommonFunctions extends CommonFunctions implements SelfReference
Modifier and Type | Field and Description |
---|---|
protected TriggerReactorCore |
plugin |
Constructor and Description |
---|
AbstractCommonFunctions(TriggerReactorCore plugin) |
Modifier and Type | Method and Description |
---|---|
void |
addLore(org.bukkit.inventory.ItemStack IS,
String lore)
Append a lore to the specified ItemStack
|
org.bukkit.block.Block |
block(String world,
int x,
int y,
int z)
get Block instance.
|
org.bukkit.Color |
bukkitColor(int red,
int green,
int blue)
creates and returns a bukkit color object using
the RGB values given.
|
void |
clearLore(org.bukkit.inventory.ItemStack IS)
Clear all lores from item.
|
String |
color(String str)
Translate & into minecraft color code
|
String |
currentArea(org.bukkit.entity.Entity entity)
Deprecated.
this returns only one area among the areas where entity is in. Use
currentAreas(Entity)
instead to get all the areas. |
String |
currentAreaAt(org.bukkit.Location location)
Deprecated.
this only return one AreaTrigger's name, yet there could be more
|
String[] |
currentAreas(org.bukkit.entity.Entity entity)
Get the name of area where entity is currently standing on.
|
String[] |
currentAreasAt(org.bukkit.Location location)
Get the name of area triggers containing the given location.
|
String |
formatCurrency(double money)
Translate money into specified country's currency format.
|
String |
formatCurrency(double money,
String locale1,
String locale2)
Translate money into specified country's currency format.
|
List<org.bukkit.entity.Entity> |
getEntitiesInArea(String areaTriggerName)
Get list of entities tracked by this AreaTrigger.
|
String |
getItemTitle(org.bukkit.inventory.ItemStack IS)
Get title of the specified ItemStack.
|
String |
getLore(org.bukkit.inventory.ItemStack IS,
int index)
get Lore at the specified index
|
abstract Collection<? extends org.bukkit.entity.Player> |
getPlayers()
get list of online players online
|
org.bukkit.block.Block |
getTargetBlock(org.bukkit.entity.Player player,
int maxDistance)
Get the block which player is looking at
|
boolean |
hasLore(org.bukkit.inventory.ItemStack IS,
String lore)
Check if the specified ItemStack contains the 'lore.' At least one is contained
in the lore will return true.
|
org.bukkit.inventory.ItemStack |
headForName(String targetName)
Create a player head with given name.
|
abstract org.bukkit.inventory.ItemStack |
headForName(String targetName,
int amount)
Create a player head with given name.
|
abstract org.bukkit.inventory.ItemStack |
headForValue(String textureValue)
Create a player head with given textureValue(base64 encoded).
|
abstract org.bukkit.inventory.ItemStack |
item(int type,
int amount)
Deprecated.
use
item(String, int) instead |
abstract org.bukkit.inventory.ItemStack |
item(int type,
int amount,
int data)
Deprecated.
use
item(String, int, int) instead |
abstract org.bukkit.inventory.ItemStack |
item(String type,
int amount)
Create a new ItemStack
|
abstract org.bukkit.inventory.ItemStack |
item(String type,
int amount,
int data)
Create a new ItemStack
|
org.bukkit.Location |
location(String world,
double x,
double y,
double z)
Create Location instance.
|
org.bukkit.Location |
location(String world,
double x,
double y,
double z,
double yaw,
double pitch)
Create Location instance including pitch and yaw
|
boolean |
locationEqual(org.bukkit.Location loc1,
org.bukkit.Location loc2)
check if two location are equal not considering their decimal points
|
int |
loreSize(org.bukkit.inventory.ItemStack IS)
get size of the lores for the specified ItemStack
|
abstract org.bukkit.potion.PotionEffect |
makePotionEffect(String EffectType,
int duration,
int amplifier,
boolean ambient,
boolean particles,
org.bukkit.Color color)
create a PotionEffect for use in entity.addPotionEffect();
|
org.bukkit.OfflinePlayer |
oplayer(String name)
try to get offline player from name.
|
org.bukkit.entity.Player |
player(String name)
try to get a player from name.
|
org.bukkit.plugin.Plugin |
plugin(String name)
Simply try to get plugin object directly.
|
void |
removeLore(org.bukkit.inventory.ItemStack IS,
int index)
Remove lore at the 'index' of the specified ItemStack.
|
abstract Object |
serializeLocation(org.bukkit.Location loc)
Create a new SerializableLocation, which implements ConfigurationSerializable
|
abstract Object |
serializeLocation(org.bukkit.World world,
double x,
double y,
double z)
Create a new SerializableLocation, which implements ConfigurationSerializable
|
abstract Object |
serializeLocation(org.bukkit.World world,
double x,
double y,
double z,
double yaw,
double pitch)
Create a new SerializableLocation, which implements ConfigurationSerializable
|
void |
setItemTitle(org.bukkit.inventory.ItemStack IS,
String title)
Set title of the specified ItemStack
|
void |
setLore(org.bukkit.inventory.ItemStack IS,
int index,
String lore)
Replace a lore at 'index' for the specified ItemStack.
|
abstract boolean |
takeItem(org.bukkit.entity.Player player,
int id,
int amount)
Deprecated.
use
takeItem(Player, String, int) instead |
abstract boolean |
takeItem(org.bukkit.entity.Player player,
int id,
int amount,
int data)
Deprecated.
use
takeItem(Player, String, int, int) instead |
boolean |
takeItem(org.bukkit.entity.Player player,
org.bukkit.inventory.ItemStack IS,
int amount)
take ItemStack from player.
|
abstract boolean |
takeItem(org.bukkit.entity.Player player,
String id,
int amount)
take item from player.
|
abstract boolean |
takeItem(org.bukkit.entity.Player player,
String id,
int amount,
int data)
take item from player.
|
array, arrayOf, list, listOf, map, matches, mergeArguments, mergeArguments, mergeArguments, newInstance, parseDouble, parseEnum, parseInt, random, random, random, random, random, random, random, random, round, set, set, slocation, sqrt, staticGetFieldValue, staticMethod, staticSetFieldValue, toByte, toDouble, toFloat, toInt, toLong, toShort, typeOf
protected final TriggerReactorCore plugin
public AbstractCommonFunctions(TriggerReactorCore plugin)
public org.bukkit.plugin.Plugin plugin(String name)
Example) #MESSAGE "spawn region info: "+plugin("WorldGuard").getRegionManager(player.getWorld()).getRegion("spawn")
name
- name of the plugin.@Deprecated public abstract boolean takeItem(org.bukkit.entity.Player player, int id, int amount)
takeItem(Player, String, int)
insteadplayer
- id
- amount
- public abstract boolean takeItem(org.bukkit.entity.Player player, String id, int amount)
Example) /trg run IF takeItem(player, "STONE", 1); #MESSAGE "Removed one stone."; ELSE; #MESSAGE "You don't have a stone"; ENDIF;
You can find item names in Materialplayer
- target playerid
- item idamount
- amount@Deprecated public abstract boolean takeItem(org.bukkit.entity.Player player, int id, int amount, int data)
takeItem(Player, String, int, int)
insteadplayer
- id
- amount
- data
- public abstract boolean takeItem(org.bukkit.entity.Player player, String id, int amount, int data)
Example) /trg run IF takeItem(player, "STONE", 1, 1); #MESSAGE "Removed one granite."; ELSE; #MESSAGE "You don't have a granite"; ENDIF;
You can find item names in Materialplayer
- target playerid
- item idamount
- amountdata
- data of itempublic boolean takeItem(org.bukkit.entity.Player player, org.bukkit.inventory.ItemStack IS, int amount)
Example) /trg run IF takeItem(player, {"some.item"}, 1);
You can find item names in Materialplayer
- target playerIS
- item idamount
- amountpublic org.bukkit.Location location(String world, double x, double y, double z)
world
- the name of world.x
- x coordinatey
- y coordinatez
- z coordinatepublic org.bukkit.Location location(String world, double x, double y, double z, double yaw, double pitch)
world
- the name of world.x
- x coordinatey
- y coordinatez
- z coordinateyaw
- yawpitch
- pitchpublic org.bukkit.block.Block block(String world, int x, int y, int z)
world
- name of the worldx
- x coordinatey
- y coordinatez
- z coordinatepublic boolean locationEqual(org.bukkit.Location loc1, org.bukkit.Location loc2)
Example) /trg run IF locationEqual(player.getLocation(), {"otherLocation"}); #MESSAGE "match"; ENDIF;
loc1
- locationloc2
- other locationpublic abstract org.bukkit.potion.PotionEffect makePotionEffect(String EffectType, int duration, int amplifier, boolean ambient, boolean particles, org.bukkit.Color color)
Example) /trg run player.addPotionEffect( makePotionEffect("SPEED", 1000000, 5, false, true, bukkitColor(21,2,24) ))
EffectType
- the name of the PotionEffectType to useduration
- how long the potioneffect should last when applied to an enitityamplifier
- how strong the effect should beambient
- if true particle effects will be more transparentparticles
- if false potion particle effects will not be showncolor
- use bukkitColor() or is no longer available since 1.13public org.bukkit.entity.Player player(String name)
Example) player("wysohn").performCommand("spawn")
name
- name of playerpublic org.bukkit.OfflinePlayer oplayer(String name)
Example) /trg run #MESSAGE "UUID is: "+oplayer("wysohn").getUniqueId()
name
- name of playerpublic abstract Collection<? extends org.bukkit.entity.Player> getPlayers()
Example) /trg run FOR p = getPlayers(); p.performCommand("spawn"); ENDFOR;
public String currentArea(org.bukkit.entity.Entity entity)
currentAreas(Entity)
instead to get all the areas.Example) /trg run #MESSAGE "You are in the AreaTrigger named: "+currentArea(player)
entity
- any entity(including player)public String currentAreaAt(org.bukkit.Location location)
currentAreasAt(Location)
location
- the location to checkpublic String[] currentAreas(org.bukkit.entity.Entity entity)
Example) /trg run #MESSAGE "You are in the AreaTrigger named: "+currentArea(player)
entity
- any entity(including player)public String[] currentAreasAt(org.bukkit.Location location)
location
- the location to checkpublic List<org.bukkit.entity.Entity> getEntitiesInArea(String areaTriggerName)
areaTriggerName
- name of AreaTrigger to get entities frompublic String color(String str)
Example) /trg run player.sendMessage(color("&aGREEN, &cRED"))
str
- unprocessed stringpublic org.bukkit.Color bukkitColor(int red, int green, int blue)
Example) /trg run partColor = bukkitColor(255,255,255)
red
- red the value of red in RGBgreen
- green the value of green in RGBblue
- blue the value of blue in RGB@Deprecated public abstract org.bukkit.inventory.ItemStack item(int type, int amount, int data)
item(String, int, int)
insteadtype
- amount
- data
- public abstract org.bukkit.inventory.ItemStack item(String type, int amount, int data)
Example) /trg run #GIVE item(1, 64, 0)
type
- typeIdamount
- amount of itemdata
- data@Deprecated public abstract org.bukkit.inventory.ItemStack item(int type, int amount)
item(String, int)
insteadtype
- amount
- public abstract org.bukkit.inventory.ItemStack item(String type, int amount)
Example) /trg run #GIVE item(1, 32)
type
- typeIdamount
- amount of itempublic String getItemTitle(org.bukkit.inventory.ItemStack IS)
Example) /trg run #MESSAGE "item name is: "+getItemTitle(player.getItemInHand())
IS
- the target ItemStack to get titlepublic void setItemTitle(org.bukkit.inventory.ItemStack IS, String title)
Example) /trg run myitem = item(1, 1); setItemTitle(myitem, "I'm stone"); #GIVE myitem;
IS
- target ItemStack to change the titletitle
- the titlepublic boolean hasLore(org.bukkit.inventory.ItemStack IS, String lore)
IS
- ItemStack to check lores forelore
- the lorepublic String getLore(org.bukkit.inventory.ItemStack IS, int index)
IS
- the ItemStack to get loreindex
- index of the lorepublic void addLore(org.bukkit.inventory.ItemStack IS, String lore)
IS
- the target ItemStacklore
- the lore to addpublic void setLore(org.bukkit.inventory.ItemStack IS, int index, String lore)
IS
- the target ItemStackindex
- index to replace the lorelore
- the lore to setpublic void removeLore(org.bukkit.inventory.ItemStack IS, int index)
IS
- target ItemStackindex
- index of the lore to deletepublic void clearLore(org.bukkit.inventory.ItemStack IS)
IS
- target ItemStackpublic int loreSize(org.bukkit.inventory.ItemStack IS)
IS
- target ItemStackpublic String formatCurrency(double money, String locale1, String locale2)
formatCurrency
in class CommonFunctions
money
- moneylocale1
- language code (Ex. en)locale2
- country code (Ex. US)public String formatCurrency(double money)
formatCurrency
in class CommonFunctions
money
- moneypublic org.bukkit.block.Block getTargetBlock(org.bukkit.entity.Player player, int maxDistance)
Example) /trg run #MESSAGE "looking at the block: "+getTargetBlock(player, 30);
player
- Player instancemaxDistance
- maximum distance. More distance cause more loads to CPU.public org.bukkit.inventory.ItemStack headForName(String targetName)
Example) /trg run #GIVE headForName("wysohn")
targetName
- name of the owner of headpublic abstract org.bukkit.inventory.ItemStack headForName(String targetName, int amount)
Example) /trg run #GIVE headForName("wysohn")
targetName
- name of the owner of headamount
- amountpublic abstract org.bukkit.inventory.ItemStack headForValue(String textureValue)
Example) /trg run #GIVE headForValue("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlc y5taW5lY3JhZnQubmV0L3RleHR1cmUvN2RjZDdkZjUyNjQ1YzY4Y2RhZDg1NDhlNjFiM2Y3 NjU5NjQwNzcyMjZiYTg3MmI5ZDJiZDQ1YzQzOWQifX19\\")
Notice that there is an extra \ sign as \ is an escape sequence. The final String will be ...OWQifX19\ instead of ...OWQifX19\\"
textureValue
- base64 encoded texture valuepublic abstract Object serializeLocation(org.bukkit.World world, double x, double y, double z)
Example) /trg run serialized = serializeLocation("wildw", 2, 13, 44)
world
- The world instance in which this location residesx
- The x-coordinate of this locationy
- The y-coordinate of this locationz
- The z-coordinate of this locationpublic abstract Object serializeLocation(org.bukkit.World world, double x, double y, double z, double yaw, double pitch)
Example) /trg run serialized = serializeLocation("wildw", 2, 13, 44.6, 13)
world
- The world instance in which this location residesx
- The x-coordinate of this locationy
- The y-coordinate of this locationz
- The z-coordinate of this locationyaw
- The absolute rotation on the x-plane, in degreespitch
- The absolute rotation on the y-plane, in degreespublic abstract Object serializeLocation(org.bukkit.Location loc)
Example) /trg run serialized = serializeLocation("wildw", 2, 13, 44.6, 13)
loc
- The Location value