Package wtf.choco.dragoneggdrop.dragon
Class DragonTemplate
java.lang.Object
wtf.choco.dragoneggdrop.dragon.DragonTemplate
- All Implemented Interfaces:
Registerable
public class DragonTemplate extends Object implements Registerable
Represents an immutable template for a custom dragon to be spawned containing information
about its name, the style of its boss bar, as well as the loot table used to generate its
loot after it has been killed.
- Author:
- Parker Hawke - Choco
-
Method Summary
Modifier and Type Method Description void
applyToBattle(org.bukkit.entity.EnderDragon dragon, org.bukkit.boss.DragonBattle battle)
Apply this templates data to an EnderDragonBattle object.static DragonTemplateBuilder
buildCopy(String id, DragonTemplate template)
Get a newDragonTemplateBuilder
to construct an instance ofDragonTemplate
with values copied from an existing template.static DragonTemplateBuilder
builder(String id)
Get a newDragonTemplateBuilder
to construct an instance ofDragonTemplate
.static DragonTemplate
fromFile(File file)
Load and create aDragonTemplate
from a YAMLFile
.double
getAttribute(org.bukkit.attribute.Attribute attribute)
Get the value to be applied for a specific attribute.Map<org.bukkit.attribute.Attribute,Double>
getAttributes()
Get an immutable Map of all attributes and their values according to this template.org.bukkit.boss.BarColor
getBarColor()
Get the colour of the boss bar.org.bukkit.boss.BarStyle
getBarStyle()
Get the style of the boss bar.String
getId()
Get the unique id for this registerable object.DragonLootTable
getLootTable()
Get the loot table used to generate the loot for this dragon once killed.String
getName()
Get the name of the dragon.ParticleShapeDefinition
getParticleShapeDefinition()
Get the particle shape definition to use when this dragon is killed.List<String>
getSpawnAnnouncement()
Get the messages to be announced to all players when this template spawns.double
getSpawnWeight()
Get the weight of this dragon's spawn percentage.boolean
hasAttribute(org.bukkit.attribute.Attribute attribute)
Check whether this template has specified an attribute's value.boolean
shouldAnnounceSpawn()
Check whether this dragon's name should be announced as it spawns.
-
Method Details
-
getId
Description copied from interface:Registerable
Get the unique id for this registerable object.- Specified by:
getId
in interfaceRegisterable
- Returns:
- the unique id
-
getName
Get the name of the dragon.- Returns:
- the dragon's name. null if none
-
getBarStyle
public org.bukkit.boss.BarStyle getBarStyle()Get the style of the boss bar.- Returns:
- the boss bar style
-
getBarColor
public org.bukkit.boss.BarColor getBarColor()Get the colour of the boss bar.- Returns:
- the boss bar colour
-
getParticleShapeDefinition
Get the particle shape definition to use when this dragon is killed.- Returns:
- the shape definition
-
getLootTable
Get the loot table used to generate the loot for this dragon once killed.- Returns:
- the dragon loot table
-
getSpawnWeight
public double getSpawnWeight()Get the weight of this dragon's spawn percentage.- Returns:
- the spawn weight
-
getSpawnAnnouncement
Get the messages to be announced to all players when this template spawns.- Returns:
- the spawn announcement
-
shouldAnnounceSpawn
public boolean shouldAnnounceSpawn()Check whether this dragon's name should be announced as it spawns.- Returns:
- true if it should be announced, false otherwise
-
getAttributes
Get an immutable Map of all attributes and their values according to this template.- Returns:
- the mapped attributes and values
-
getAttribute
public double getAttribute(org.bukkit.attribute.Attribute attribute)Get the value to be applied for a specific attribute. If the provided attribute value is not specified, -1 will be returned.- Parameters:
attribute
- the attribute to check- Returns:
- the value of the attribute, or -1 if non existent
-
hasAttribute
public boolean hasAttribute(org.bukkit.attribute.Attribute attribute)Check whether this template has specified an attribute's value.- Parameters:
attribute
- the attribute to check- Returns:
- true if defined. false otherwise
-
applyToBattle
public void applyToBattle(org.bukkit.entity.EnderDragon dragon, org.bukkit.boss.DragonBattle battle)Apply this templates data to an EnderDragonBattle object.- Parameters:
dragon
- the dragon to modifybattle
- the battle to modify
-
builder
Get a newDragonTemplateBuilder
to construct an instance ofDragonTemplate
.- Parameters:
id
- the template's unique id- Returns:
- the template builder
-
buildCopy
Get a newDragonTemplateBuilder
to construct an instance ofDragonTemplate
with values copied from an existing template.- Parameters:
id
- the template's unique idtemplate
- the template from which to copy values- Returns:
- the template builder
-
fromFile
Load and create aDragonTemplate
from a YAMLFile
.- Parameters:
file
- the file from which to parse a dragon template- Returns:
- the dragon template
-