Package fr.royalpha.sheepwars.api
Class SheepWarsSheep
- java.lang.Object
-
- fr.royalpha.sheepwars.api.SheepWarsSheep
-
public abstract class SheepWarsSheep extends java.lang.Object
-
-
Field Summary
Fields Modifier and Type Field Description private static java.util.List<SheepWarsSheep>
availableSheeps
private org.bukkit.DyeColor
color
private static org.bukkit.configuration.file.FileConfiguration
config
private static java.io.File
configFile
private java.lang.String
configPath
private boolean
drop
private int
duration
private boolean
friendly
private double
health
private fr.royalpha.sheepwars.core.message.Message
msgName
private float
random
private java.util.List<fr.royalpha.sheepwars.core.handler.SheepAbility>
sheepAbilities
private static java.util.List<SheepWarsSheep>
waitingSheeps
-
Constructor Summary
Constructors Constructor Description SheepWarsSheep(fr.royalpha.sheepwars.core.message.Message.Messages name, org.bukkit.DyeColor color, int duration, boolean friendly, boolean drop, float random, fr.royalpha.sheepwars.core.handler.SheepAbility... sheepAbilities)
Usethis constructor
instead.SheepWarsSheep(fr.royalpha.sheepwars.core.message.Message.Messages name, org.bukkit.DyeColor color, int duration, boolean friendly, boolean drop, fr.royalpha.sheepwars.core.handler.SheepAbility... sheepAbilities)
Usethis constructor
instead.SheepWarsSheep(fr.royalpha.sheepwars.core.message.Message name, java.lang.String configPath, org.bukkit.DyeColor color, int duration, boolean friendly, double health, boolean drop, float random, fr.royalpha.sheepwars.core.handler.SheepAbility... sheepAbilities)
Usethis constructor
instead.SheepWarsSheep(java.lang.String name, org.bukkit.DyeColor color, int duration, boolean friendly, double health, boolean drop, float random, fr.royalpha.sheepwars.core.handler.SheepAbility... sheepAbilities)
Initialize a new sheep !
-
Method Summary
Modifier and Type Method Description boolean
equals(java.lang.Object obj)
java.util.List<fr.royalpha.sheepwars.core.handler.SheepAbility>
getAbilities()
Get the sheep abilities.static java.util.List<SheepWarsSheep>
getAvailableSheeps()
Get registered sheeps.org.bukkit.DyeColor
getColor()
Get sheep color.private java.lang.String
getConfigFieldPath(java.lang.String field)
No need to use this method.static SheepWarsSheep
getCorrespondingSheep(org.bukkit.inventory.ItemStack item, org.bukkit.entity.Player player)
int
getDuration()
Get the sheep duration.double
getHealth()
Get the sheep health.org.bukkit.inventory.ItemStack
getIcon(org.bukkit.entity.Player player)
Get the sheep icon according to the player's language.int
getId()
Get the sheep id managed by the plugin.java.lang.String
getName(org.bukkit.entity.Player player)
Get the sheep name according to the player's language.float
getRandom()
Get the luck to get this sheep (between 0.0 and 1.0).static void
giveRandomSheep(org.bukkit.entity.Player player)
static void
giveSheep(org.bukkit.entity.Player player, SheepWarsSheep sheep)
static void
giveSheep(org.bukkit.entity.Player player, SheepWarsSheep sheep, int amount)
boolean
hasAbility(fr.royalpha.sheepwars.core.handler.SheepAbility... abilities)
Test if the sheep has the ability.boolean
isDropAllowed()
Get if the sheep is allowed to drop its wool on death.boolean
isFriendly()
Get if this sheep is friendly or aggressive.abstract void
onFinish(org.bukkit.entity.Player player, org.bukkit.entity.Sheep bukkitSheep, boolean death, org.bukkit.plugin.Plugin plugin)
Called before the sheep disappear.abstract boolean
onGive(org.bukkit.entity.Player player)
Useful to cancel the give of a sheep under certain conditions.abstract void
onSpawn(org.bukkit.entity.Player player, org.bukkit.entity.Sheep bukkitSheep, org.bukkit.plugin.Plugin plugin)
Useful to do something when the sheep gets launched.abstract boolean
onTicking(org.bukkit.entity.Player player, long ticks, org.bukkit.entity.Sheep bukkitSheep, org.bukkit.plugin.Plugin plugin)
Most important method called every tick.static boolean
registerSheep(SheepWarsSheep sheep)
UseUltimateSheepWarsAPI
methods instead.static void
setupConfig(java.io.File file, fr.royalpha.sheepwars.core.SheepWarsPlugin plugin)
No need to use this method.private org.bukkit.entity.Sheep
spawnSheep(org.bukkit.Location location, org.bukkit.entity.Player player, org.bukkit.plugin.Plugin plugin)
boolean
throwSheep(org.bukkit.entity.Player launcher, org.bukkit.plugin.Plugin plugin)
Throw this sheep from a player.static boolean
unregisterSheep(SheepWarsSheep sheep)
UseUltimateSheepWarsAPI
methods instead.
-
-
-
Field Detail
-
availableSheeps
private static java.util.List<SheepWarsSheep> availableSheeps
-
waitingSheeps
private static java.util.List<SheepWarsSheep> waitingSheeps
-
configFile
private static java.io.File configFile
-
config
private static org.bukkit.configuration.file.FileConfiguration config
-
msgName
private fr.royalpha.sheepwars.core.message.Message msgName
-
configPath
private java.lang.String configPath
-
color
private org.bukkit.DyeColor color
-
duration
private int duration
-
friendly
private boolean friendly
-
health
private double health
-
drop
private boolean drop
-
random
private float random
-
sheepAbilities
private java.util.List<fr.royalpha.sheepwars.core.handler.SheepAbility> sheepAbilities
-
-
Constructor Detail
-
SheepWarsSheep
public SheepWarsSheep(java.lang.String name, org.bukkit.DyeColor color, int duration, boolean friendly, double health, boolean drop, float random, fr.royalpha.sheepwars.core.handler.SheepAbility... sheepAbilities)
Initialize a new sheep !- Parameters:
name
- Define the sheep's name. It will be automatically add to the language files.color
- Color of the sheep.duration
- Life time (in seconds) of the sheep, 0 will cause the sheep not to be automatically killed.friendly
- Is this sheep friendly ? If yes, it will not be launched but just appear at the player position.health
- Sheep's health.drop
- Will the sheep drop its wool if killed ?random
- Specify the luck to get this sheep (1 = maximum luck, 0 = you will never get this sheep).sheepAbilities
- (Optional) Sheep ability such as "FIRE_PROOF" or "SEEK_PLAYERS".
-
SheepWarsSheep
public SheepWarsSheep(fr.royalpha.sheepwars.core.message.Message.Messages name, org.bukkit.DyeColor color, int duration, boolean friendly, boolean drop, float random, fr.royalpha.sheepwars.core.handler.SheepAbility... sheepAbilities)
Usethis constructor
instead.
-
SheepWarsSheep
public SheepWarsSheep(fr.royalpha.sheepwars.core.message.Message.Messages name, org.bukkit.DyeColor color, int duration, boolean friendly, boolean drop, fr.royalpha.sheepwars.core.handler.SheepAbility... sheepAbilities)
Usethis constructor
instead.
-
SheepWarsSheep
public SheepWarsSheep(fr.royalpha.sheepwars.core.message.Message name, java.lang.String configPath, org.bukkit.DyeColor color, int duration, boolean friendly, double health, boolean drop, float random, fr.royalpha.sheepwars.core.handler.SheepAbility... sheepAbilities)
Usethis constructor
instead.
-
-
Method Detail
-
giveRandomSheep
public static void giveRandomSheep(org.bukkit.entity.Player player)
-
giveSheep
public static void giveSheep(org.bukkit.entity.Player player, SheepWarsSheep sheep)
-
giveSheep
public static void giveSheep(org.bukkit.entity.Player player, SheepWarsSheep sheep, int amount)
-
spawnSheep
private org.bukkit.entity.Sheep spawnSheep(org.bukkit.Location location, org.bukkit.entity.Player player, org.bukkit.plugin.Plugin plugin)
-
getId
public int getId()
Get the sheep id managed by the plugin.
-
getName
public java.lang.String getName(org.bukkit.entity.Player player)
Get the sheep name according to the player's language.
-
getColor
public org.bukkit.DyeColor getColor()
Get sheep color.- Returns:
- The color of the sheep.
-
getIcon
public org.bukkit.inventory.ItemStack getIcon(org.bukkit.entity.Player player)
Get the sheep icon according to the player's language.
-
getDuration
public int getDuration()
Get the sheep duration.
-
isFriendly
public boolean isFriendly()
Get if this sheep is friendly or aggressive.
-
getHealth
public double getHealth()
Get the sheep health.
-
isDropAllowed
public boolean isDropAllowed()
Get if the sheep is allowed to drop its wool on death.
-
getRandom
public float getRandom()
Get the luck to get this sheep (between 0.0 and 1.0).
-
getAbilities
public java.util.List<fr.royalpha.sheepwars.core.handler.SheepAbility> getAbilities()
Get the sheep abilities.
-
hasAbility
public boolean hasAbility(fr.royalpha.sheepwars.core.handler.SheepAbility... abilities)
Test if the sheep has the ability.
-
getConfigFieldPath
private java.lang.String getConfigFieldPath(java.lang.String field)
No need to use this method.
-
onGive
public abstract boolean onGive(org.bukkit.entity.Player player)
Useful to cancel the give of a sheep under certain conditions.- Parameters:
player
- Player who will receive the sheep in his inventory- Returns:
- true if there's no problem giving that sheep to that player. false otherwise and the sheep won't be given.
-
onSpawn
public abstract void onSpawn(org.bukkit.entity.Player player, org.bukkit.entity.Sheep bukkitSheep, org.bukkit.plugin.Plugin plugin)
Useful to do something when the sheep gets launched.
For example : the Intergalactic Sheep broadcast a message.- Parameters:
player
-bukkitSheep
- The sheep's bukkit entity.plugin
- UltimateSheepWars plugin instance (useful to launch runnables).
-
onTicking
public abstract boolean onTicking(org.bukkit.entity.Player player, long ticks, org.bukkit.entity.Sheep bukkitSheep, org.bukkit.plugin.Plugin plugin)
Most important method called every tick.- Parameters:
player
- Player who has launched the sheep.ticks
- Sheep's ticks (number decremented every twentieth of a second starting from (sheep.getDuration*20
) at the moment the sheep appeared).bukkitSheep
- The sheep's bukkit entity.plugin
- UltimateSheepWars plugin instance (useful to launch runnables).- Returns:
- true if you want to stop the sheep and directly go to the onFinish([...]); method, false if you want to continue ticking.
-
onFinish
public abstract void onFinish(org.bukkit.entity.Player player, org.bukkit.entity.Sheep bukkitSheep, boolean death, org.bukkit.plugin.Plugin plugin)
Called before the sheep disappear.- Parameters:
player
- Player who has launched the sheep.bukkitSheep
- The sheep's bukkit entity.death
- Was the sheep killed by a player and is already dead ?plugin
- UltimateSheepWars plugin instance (useful to launch runnables).
-
throwSheep
public boolean throwSheep(org.bukkit.entity.Player launcher, org.bukkit.plugin.Plugin plugin)
Throw this sheep from a player.
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equals
in classjava.lang.Object
-
getCorrespondingSheep
public static SheepWarsSheep getCorrespondingSheep(org.bukkit.inventory.ItemStack item, org.bukkit.entity.Player player)
-
getAvailableSheeps
public static java.util.List<SheepWarsSheep> getAvailableSheeps()
Get registered sheeps.
-
registerSheep
public static boolean registerSheep(SheepWarsSheep sheep) throws java.io.IOException
UseUltimateSheepWarsAPI
methods instead.- Throws:
java.io.IOException
-
unregisterSheep
public static boolean unregisterSheep(SheepWarsSheep sheep)
UseUltimateSheepWarsAPI
methods instead.
-
setupConfig
public static void setupConfig(java.io.File file, fr.royalpha.sheepwars.core.SheepWarsPlugin plugin)
No need to use this method.
-
-