public final class Util
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private static double[] |
COS_TABLE
An array storing the cosine of each index, i.e.
|
(package private) static org.bukkit.ChatColor |
CYAN
Convenience reference to the
ChatColor "DARK_AQUA," aka cyan. |
(package private) static org.bukkit.ChatColor |
GRAY
Convenience reference to the
ChatColor "GRAY," aka light gray. |
private static org.bukkit.attribute.AttributeModifier |
LARGE_MODIFIER
Represents a large attribute modifier, specifically a 90% decrease.
|
(package private) static java.util.Set<org.bukkit.entity.EntityType> |
PASSIVE_MOBS
A set of
EntityType s considered livestock, whose natural spawns should be blocked. |
private static double |
RADICAL_TWO_OVER_TWO
Holds the constant sqrt(2)/2.
|
private static double[] |
SIN_TABLE
An array storing the sine of each index, i.e.
|
private static org.bukkit.attribute.AttributeModifier |
SMALL_MODIFIER
Represents a small attribute modifier, specifically a 40% decrease.
|
private static java.text.DecimalFormat |
TENTHS
Formats decimal values (specifically mob health nametag values) to the tenths place.
|
static int |
TPS
Represents the number of ticks per second on a Minecraft server.
|
Constructor and Description |
---|
Util() |
Modifier and Type | Method and Description |
---|---|
private static void |
applyModifier(org.bukkit.entity.LivingEntity livingEntity,
org.bukkit.attribute.Attribute attribute,
org.bukkit.attribute.AttributeModifier modifier)
Applies a given attribute modifier to the entity's attribute.
|
static void |
configureReinforcement(org.bukkit.entity.LivingEntity livingEntity)
Configures the given entity to be a reinforcement by weakening it, clearing equipment, and tagging
its metadata.
|
private static double |
cos(int degrees)
Returns the cosine of the input as a double.
|
(package private) static java.lang.String |
formatEntityType(org.bukkit.entity.EntityType entityType)
Formats the given EntityType to be UpperCamelCase, and replaces underscores with a space.
|
private static java.lang.String |
getOriginalCustomName(org.bukkit.entity.LivingEntity livingEntity)
Retrieves the entity's original name.
|
(package private) static org.bukkit.inventory.ItemStack |
getPlayerHead(java.lang.String playerName)
Returns the skull of the given player as an
ItemStack . |
(package private) static java.lang.Object |
getRandomElement(java.util.Collection collection)
Returns a random element from the given collection, or null if the collection is empty.
|
static boolean |
isReinforcement(org.bukkit.entity.LivingEntity livingEntity)
Returns true if the given entity is a reinforcement.
|
static org.bukkit.entity.LivingEntity |
parseEntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent event)
Parses an EntityDamageByEntityEvent for any mobs, specifically an Entity that is a
LivingEntity but not a Player.
|
static double |
random(double min,
double max)
Generates a random double between min and max.
|
static int |
random(int min,
int max)
Generates a random integer between min and max.
|
private static double |
sin(int degrees)
Returns the sine of the input as a double.
|
static org.bukkit.entity.Entity |
summonEntityWithVelocity(org.bukkit.Location origin,
org.bukkit.entity.EntityType entityType)
Summons an entity and applies a random velocity vector.
|
(package private) static void |
updateMobHealthNametag(org.bukkit.entity.LivingEntity livingEntity)
Updates a mob's custom name (nametag) to show its current health, max health, and custom name.
|
private static final java.text.DecimalFormat TENTHS
private static final double[] SIN_TABLE
private static final double[] COS_TABLE
private static final double RADICAL_TWO_OVER_TWO
public static final int TPS
static final org.bukkit.ChatColor CYAN
ChatColor
"DARK_AQUA," aka cyan.static final org.bukkit.ChatColor GRAY
ChatColor
"GRAY," aka light gray.static final java.util.Set<org.bukkit.entity.EntityType> PASSIVE_MOBS
EntityType
s considered livestock, whose natural spawns should be blocked.
TODO : make dynamic in Configurationprivate static final org.bukkit.attribute.AttributeModifier SMALL_MODIFIER
private static final org.bukkit.attribute.AttributeModifier LARGE_MODIFIER
private static double sin(int degrees)
degrees
- the degree argument as an integer.private static double cos(int degrees)
degrees
- the degree argument as an integer.public static int random(int min, int max)
min
- the lower bound.max
- the upper bound.public static double random(double min, double max)
min
- the lower bound.max
- the upper bound.static org.bukkit.inventory.ItemStack getPlayerHead(java.lang.String playerName)
ItemStack
.playerName
- the name of the player.public static org.bukkit.entity.LivingEntity parseEntityDamageByEntityEvent(org.bukkit.event.entity.EntityDamageByEntityEvent event)
event
- the event to parse.private static java.lang.String getOriginalCustomName(org.bukkit.entity.LivingEntity livingEntity)
livingEntity
- the entity.static java.lang.String formatEntityType(org.bukkit.entity.EntityType entityType)
entityType
- the entity type.static void updateMobHealthNametag(org.bukkit.entity.LivingEntity livingEntity)
livingEntity
- the entity to update.public static void configureReinforcement(org.bukkit.entity.LivingEntity livingEntity)
livingEntity
- the entity to configure as a reinforcement.public static boolean isReinforcement(org.bukkit.entity.LivingEntity livingEntity)
livingEntity
- the entity.private static void applyModifier(org.bukkit.entity.LivingEntity livingEntity, org.bukkit.attribute.Attribute attribute, org.bukkit.attribute.AttributeModifier modifier)
livingEntity
- the entity.attribute
- the attribute.modifier
- the modifier.static java.lang.Object getRandomElement(java.util.Collection collection)
collection
- the collection.public static org.bukkit.entity.Entity summonEntityWithVelocity(org.bukkit.Location origin, org.bukkit.entity.EntityType entityType)
origin
- the location to spawn the entity.entityType
- the entity type.