public class CommonFunctions extends CommonFunctions implements SelfReference
Constructor and Description |
---|
CommonFunctions(TriggerReactorCore plugin) |
Modifier and Type | Method and Description |
---|---|
void |
addLore(org.spongepowered.api.item.inventory.ItemStack IS,
String lore)
Append a lore to the specified ItemStack
|
void |
addLore(org.spongepowered.api.item.inventory.ItemStack IS,
org.spongepowered.api.text.Text lore) |
org.spongepowered.api.boss.BossBarColor |
barColor(String name) |
void |
clearLore(org.spongepowered.api.item.inventory.ItemStack IS)
Clear all lores from item.
|
org.spongepowered.api.text.Text |
color(String str)
Translate & into minecraft color code
|
String |
currentArea(org.spongepowered.api.entity.Entity entity)
Get the name of area where entity is currently standing on.
|
String |
currentAreaAt(org.spongepowered.api.world.Location location)
Deprecated.
this only return one AreaTrigger's name, yet there could be more
|
String[] |
currentAreasAt(org.spongepowered.api.world.Location location)
Get the name of area triggers containing the given location.
|
List<org.spongepowered.api.entity.Entity> |
getEntitiesInArea(String areaTriggerName)
Get list of entities tracked by this AreaTrigger.
|
org.spongepowered.api.text.Text |
getItemTitle(org.spongepowered.api.item.inventory.ItemStack IS)
Get title of the specified ItemStack.
|
org.spongepowered.api.text.Text |
getLore(org.spongepowered.api.item.inventory.ItemStack IS,
int index)
get Lore at the specified index
|
Collection<? extends org.spongepowered.api.entity.living.player.Player> |
getPlayers()
get list of online players online
|
org.spongepowered.api.block.BlockState |
getTargetBlock(org.spongepowered.api.entity.living.player.Player player,
int maxDistance)
Get the block snapshot which player is looking at
|
boolean |
hasLore(org.spongepowered.api.item.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.spongepowered.api.item.inventory.ItemStack |
headForName(String targetName)
Create a player head with given name.
|
org.spongepowered.api.item.inventory.ItemStack |
headForName(String targetName,
int amount) |
org.spongepowered.api.item.inventory.ItemStack |
headForValue(String textureValue)
Create a player head with given textureValue(base64 encoded).
|
org.spongepowered.api.item.inventory.ItemStack |
item(String type,
int amount)
Create a new ItemStack
|
org.spongepowered.api.item.ItemType |
itemType(String name) |
org.spongepowered.api.world.Location<org.spongepowered.api.world.World> |
location(String world,
int x,
int y,
int z) |
boolean |
locationEqual(org.spongepowered.api.world.Location<org.spongepowered.api.world.World> loc1,
org.spongepowered.api.world.Location<org.spongepowered.api.world.World> loc2)
check if two location are equal not considering their decimal points
|
int |
loreSize(org.spongepowered.api.item.inventory.ItemStack IS)
get size of the lores for the specified ItemStack
|
org.spongepowered.api.boss.BossBar |
makeBossBar(String title,
org.spongepowered.api.boss.BossBarColor color,
String style) |
org.spongepowered.api.effect.potion.PotionEffect |
makePotionEffect(String EffectType,
int duration,
int amplifier,
boolean ambient,
boolean particles,
org.spongepowered.api.util.Color color)
create a PotionEffect for use in entity.addPotionEffect();
|
org.spongepowered.api.entity.living.player.User |
oplayer(String name)
try to get offline player from name.
|
org.spongepowered.api.entity.living.player.Player |
player(String name)
try to get a player from name.
|
Object |
plugin(String name)
Simply try to get plugin object directly.
|
void |
removeLore(org.spongepowered.api.item.inventory.ItemStack IS,
int index)
Remove lore at the 'index' of the specified ItemStack
|
void |
setItemTitle(org.spongepowered.api.item.inventory.ItemStack IS,
String title)
Set title of the specified ItemStack
|
void |
setItemTitle(org.spongepowered.api.item.inventory.ItemStack IS,
org.spongepowered.api.text.Text title) |
void |
setLore(org.spongepowered.api.item.inventory.ItemStack IS,
int index,
String lore)
Replace a lore at 'index' for the specified ItemStack
|
void |
setLore(org.spongepowered.api.item.inventory.ItemStack IS,
int index,
org.spongepowered.api.text.Text lore) |
org.spongepowered.api.util.Color |
spongeColor(int red,
int green,
int blue)
creates and returns a bukkit color object using the RGB values given.
|
boolean |
takeItem(org.spongepowered.api.entity.living.player.Player player,
org.spongepowered.api.item.inventory.ItemStack IS,
int amount)
take ItemStack from player.
|
boolean |
takeItem(org.spongepowered.api.entity.living.player.Player player,
String id,
int amount)
take item from player.
|
org.spongepowered.api.text.Text |
text(String str)
convert plain String to Sponge usable Text.
|
array, arrayOf, formatCurrency, formatCurrency, 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
public CommonFunctions(TriggerReactorCore plugin)
public Object plugin(String name)
Example) #MESSAGE "spawn region info: "+plugin("WorldGuard").getRegionManager(player.getWorld()).getRegion("spawn")
name
- name of the plugin.public org.spongepowered.api.item.ItemType itemType(String name)
public boolean takeItem(org.spongepowered.api.entity.living.player.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;
player
- target playerid
- item name. Sponge does not support numerical item id.amount
- amountpublic boolean takeItem(org.spongepowered.api.entity.living.player.Player player, org.spongepowered.api.item.inventory.ItemStack IS, int amount)
Example) /trg run IF takeItem(player, {"some.item"}, 1);
player
- target playerid
- item name. Sponge does not support numerical item id.amount
- amountpublic org.spongepowered.api.world.Location<org.spongepowered.api.world.World> location(String world, int x, int y, int z)
public boolean locationEqual(org.spongepowered.api.world.Location<org.spongepowered.api.world.World> loc1, org.spongepowered.api.world.Location<org.spongepowered.api.world.World> loc2)
Example) /trg run IF locationEqual(player.getLocation(), {"otherLocation"}); #MESSAGE "match"; ENDIF;
loc1
- loc2
- public org.spongepowered.api.effect.potion.PotionEffect makePotionEffect(String EffectType, int duration, int amplifier, boolean ambient, boolean particles, org.spongepowered.api.util.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
- sets the color of the potion particle effects shownpublic org.spongepowered.api.entity.living.player.Player player(String name)
Example) player("wysohn").performCommand("spawn")
name
- name of playerpublic org.spongepowered.api.entity.living.player.User oplayer(String name)
Example) /trg run #MESSAGE "UUID is: "+oplayer("wysohn").getUniqueId()
name
- name of playerpublic Collection<? extends org.spongepowered.api.entity.living.player.Player> getPlayers()
Example) /trg run FOR p = getPlayers(); p.performCommand("spawn"); ENDFOR;
public String currentArea(org.spongepowered.api.entity.Entity entity)
Example) /trg run #MESSAGE "You are in the AreaTrigger named: "+currentArea(player)
entity
- any entity(including player)public String currentAreaAt(org.spongepowered.api.world.Location location)
currentAreasAt(Location)
location
- the location to checkpublic String[] currentAreasAt(org.spongepowered.api.world.Location location)
location
- the location to checkpublic List<org.spongepowered.api.entity.Entity> getEntitiesInArea(String areaTriggerName)
areaTriggerName
- name of AreaTrigger to get entities frompublic org.spongepowered.api.text.Text color(String str)
Example) /trg run player.sendMessage(color("&aGREEN, &cRED"))
str
- unprocessed stringpublic org.spongepowered.api.text.Text text(String str)
str
- String to convertpublic org.spongepowered.api.util.Color spongeColor(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 RGBpublic org.spongepowered.api.item.inventory.ItemStack item(String type, int amount)
Example) /trg run #GIVE item(1, 64, 0)
type
- type name. Sponge does not support numerical item types.amount
- amount of itempublic org.spongepowered.api.text.Text getItemTitle(org.spongepowered.api.item.inventory.ItemStack IS)
Example) /trg run #MESSAGE "item name is: "+getItemTitle(player.getItemInHand())
IS
- public void setItemTitle(org.spongepowered.api.item.inventory.ItemStack IS, String title)
Example) /trg run myitem = item(1, 1); setItemTitle(myitem, "I'm stone"); #GIVE myitem;
IS
- title
- public void setItemTitle(org.spongepowered.api.item.inventory.ItemStack IS, org.spongepowered.api.text.Text title)
public boolean hasLore(org.spongepowered.api.item.inventory.ItemStack IS, String lore)
IS
- lore
- public org.spongepowered.api.text.Text getLore(org.spongepowered.api.item.inventory.ItemStack IS, int index)
IS
- index
- public void addLore(org.spongepowered.api.item.inventory.ItemStack IS, String lore)
IS
- lore
- public void addLore(org.spongepowered.api.item.inventory.ItemStack IS, org.spongepowered.api.text.Text lore)
public void setLore(org.spongepowered.api.item.inventory.ItemStack IS, int index, String lore)
IS
- index
- lore
- public void setLore(org.spongepowered.api.item.inventory.ItemStack IS, int index, org.spongepowered.api.text.Text lore)
public void removeLore(org.spongepowered.api.item.inventory.ItemStack IS, int index)
IS
- index
- public void clearLore(org.spongepowered.api.item.inventory.ItemStack IS)
IS
- public int loreSize(org.spongepowered.api.item.inventory.ItemStack IS)
IS
- public org.spongepowered.api.block.BlockState getTargetBlock(org.spongepowered.api.entity.living.player.Player player, int maxDistance)
Example) /trg run #MESSAGE "looking at the block: "+getTargetBlock(player, 30);
player
- maxDistance
- public org.spongepowered.api.item.inventory.ItemStack headForName(String targetName)
Example) /trg run #GIVE headForName("wysohn")
targetName
- name of the owner of headpublic org.spongepowered.api.item.inventory.ItemStack headForName(String targetName, int amount)
public org.spongepowered.api.item.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 org.spongepowered.api.boss.BossBarColor barColor(String name) throws IllegalArgumentException, NoSuchFieldException