Interface NMSHelper
-
Method Summary
Modifier and TypeMethodDescriptionstatic NMSHelper
get()
Contains API/Helper to access NMS stufffloat
getAttackDamage
(Player player) Returns the amount of damage a player would cause at the exact moment with a generic entity.int
Get the duration that you have to use for infinite potion effects.@Nullable Entity
getEntityById
(World world, int entityId) Returns the entity whoseEntity.getEntityId()
is equal to the given one.@Nullable Sound
getEntityDamageSound
(Entity entity) Returns the sound that the entity would play if it'd receive damage.@Nullable Sound
getEntityDeathSound
(Entity entity) Returns the sound that the entity would play if it'd die.float
getEntityHeight
(Entity entity) Get the height of the entityfloat
getEntityWidth
(Entity entity) Get the width of the entitydouble
Calculates the amount of attack damage this item would theoretically generate.Returns the locale of the player that he has configured within his client.int
Returns the patch version of the running software.int
Returns the revision number that you can find in NMS packages.
Example: If it's running "v1_8_R3" then this method returns 3@Nullable String
getSkullTexture
(Skull skull) Returns the texture of the skull in a base64 format.@Nullable String
getSkullTexture
(SkullMeta skullMeta) Returns the texture of the skull in a base64 format.@Nullable Sound
getSoundByMinecraftName
(String vanillaName) Tries to parse a Minecraft sound given by it's vanilla id (e.g. minecraft:beacon.activate)getVanillaDeathMessage
(Player player) Returns the death message that Minecraft would use by default if the player would die at this momentint
Returns the minor version of the running server software.Hides attributes from the item.boolean
Returns whether or not this server is running paper or a fork of papervoid
playItemPickupAnimation
(Entity entity, Entity item, int amount) Simulates an item, arrow, exp or whatever getting picked up.void
sendPacket
(Player player, Object packet) Will send a message to the player.void
sendWorldTimePacket
(Player player, long time) Sends a world time packet to the given player.void
setEntityFollowRange
(LivingEntity entity, double range) Changes the range in which the entity can follow its target/enemy.void
setEntityMovementSpeed
(LivingEntity entity, double speed) Changes the movement speed of the given entity.void
setEntitySilent
(Entity entity, boolean silent) Changes if an entity is silent, or is allowed to make noise.void
setEntityTarget
(Entity entity, @Nullable Location target) Causes a walkable hologram to walk to a given location.setGlowEffect
(ItemStack is, boolean glowing) Adds or removes a "glow" effect to an item.void
setServerMotd
(String motd) This may sound crazy, but Bukkit's API does not allow the direct change of the server's motd.void
setSkullTexture
(Skull skull, String texture) Applies a custom texture in a base64 format to a skull block.void
setSkullTexture
(SkullMeta skullMeta, String texture) Applies a custom texture in a base64 format to a skull itemvoid
showActionbar
(Player player, String text) Will show a small message above the players hotbarvoid
Shows the "title" to a player.void
Shows the "title" to a player.default void
simulateChestClosing
(Block block) Simulates as if someone would close a container, such as an ender chest, normal chest or a shulker box.void
simulateChestClosing
(World world, int x, int y, int z) Simulates as if someone would close a container, such as an ender chest, normal chest or a shulker box.default void
simulateChestOpening
(Block block) Simulates as if someone would open a container, such as an ender chest, normal chest or a shulker box.void
simulateChestOpening
(World world, int x, int y, int z) Simulates as if someone would open a container, such as an ender chest, normal chest or a shulker box.void
simulatePlayerClickingRespawn
(Player player) Simulates as if the player would click on the "respawn" button while he's dead.void
teleportWithoutEvent
(Entity entity, Location location) Teleports a given entity to a location without callingEntityTeleportEvent
.
-
Method Details
-
getVersion
int getVersion()Returns the minor version of the running server software.Example: If it's running 1.8.6, then this method returns 8
- Returns:
- The minor version of the running server software
-
getPatchVersion
int getPatchVersion()Returns the patch version of the running software.Example: If it's running 1.8.6, then this method returns 6
- Returns:
- The patch version of the running server software
-
getRevision
int getRevision()Returns the revision number that you can find in NMS packages.
Example: If it's running "v1_8_R3" then this method returns 3- Returns:
- The revision number of the running server software
-
isRunningPaper
boolean isRunningPaper()Returns whether or not this server is running paper or a fork of paper- Returns:
true
when the plugin is running PaperMC or a fork of it
-
getLocale
Returns the locale of the player that he has configured within his client.- Parameters:
player
- The given player- Returns:
- The locale of the player
-
setGlowEffect
Adds or removes a "glow" effect to an item.Glow effects basically are simply enchantments added to an item. This method also does some extra little things to improve the glow effect furthermore.
It's possible that the glow effect gets added to the item that's being passed with this method. If it's eventually a new instance that's getting returned depends on the minecraft version that's running and the material of the item.
- Parameters:
is
- The item to which the glow effect shall be added to / removed fromglowing
-true
: Add the effect;false
: Remove the effect- Returns:
- Same or cloned ItemStack instance with or without the glow effect
-
showTitle
Shows the "title" to a player.A title is basically a huge text displayed on the players screen.
- Parameters:
player
- The target to whom the text shall be displayed totitle
- The larger text which is located abovesubtitle
subtitle
- The smaller text which is located belowtitle
fadeIn
- The time in ticks for the "appear" or "fade in" effectstayTime
- The time in ticks in which the title will be shownfadeOut
- The time in ticks for the "disappear" or "fade out" effect
-
showTitle
Shows the "title" to a player.A title is basically a huge text displayed on the players screen.
- Parameters:
player
- The target to whom the text shall be displayed totitle
- The larger text which is located abovesubtitle
subtitle
- The smaller text which is located belowtitle
-
showActionbar
Will show a small message above the players hotbar- Parameters:
player
- The target to whom the text shall be displayed totext
- The string that shall be shown
-
setSkullTexture
Applies a custom texture in a base64 format to a skull block.Make sure to call
BlockState.update()
at some point to actually apply it to the block. This method only applies it to the cloned Skull instance and not to the actual block.- Parameters:
skull
- The skull block to which the texture shall be applied totexture
- The texture in base64 format
-
getSkullTexture
Returns the texture of the skull in a base64 format. Might benull
when the texture hasn't been loaded yet or when simply none has been applied.- Parameters:
skull
- The skull block from which we want to fetch the texture- Returns:
- The texture of the skull. Might be
null
-
setSkullTexture
Applies a custom texture in a base64 format to a skull item- Parameters:
skullMeta
- The ItemMeta of the skull item to which the texture shall be applied totexture
- The texture in base64 format
-
getSkullTexture
Returns the texture of the skull in a base64 format. Might benull
when the texture hasn't been loaded yet or when simply none has been applied.- Parameters:
skullMeta
- The ItemMeta of the skull item from which we want to fetch the texture- Returns:
- The texture of the skull. Might be
null
-
getVanillaDeathMessage
Returns the death message that Minecraft would use by default if the player would die at this moment- Parameters:
player
- The related player- Returns:
- The vanilla death message of the player
-
setEntityTarget
Causes a walkable hologram to walk to a given location. Passnull
to make the hologram stop walking.Keep in mind that there's maximum radius to which the hologram will walk to.
- Parameters:
entity
- The hologram that shall walk to somewheretarget
- The location to which he shall walk to.null
to make him stop
-
sendPacket
Will send a message to the player. The message must be an instance of net.minecraft.v<version>.Packet- Parameters:
player
- The player to who we want to send a message topacket
- The message that shall be send
-
getAttackDamage
Returns the amount of damage a player would cause at the exact moment with a generic entity.Does not consider e.g. the monster damage enchantments as we don't care of the entity type that gets damaged here.
- Parameters:
player
- The player who would deal the damage- Returns:
- The amount of damage he'd deal with a generic entity
-
getEntityById
Returns the entity whoseEntity.getEntityId()
is equal to the given one.Utilizes NBT for best performance
- Parameters:
world
- The world in which the entity is located inentityId
- The id of the entity- Returns:
- The entity with that id.
null
when there's none
-
simulateChestOpening
Simulates as if someone would open a container, such as an ender chest, normal chest or a shulker box.It'll play an animation and updates the redstone signal. Possibly even more is happening.
There's an interal numerical counter that checks how many players have opened the chest. It's being used to determinate when the close animation needs to be played. Make sure to call
simulateChestClosing(World, int, int, int)
equally as often as you called this method and not more or less, as otherwise it'll possibly break. The counter may even reach minus values.- Parameters:
world
- The world in which the container is located atx
- The x position of the container blocky
- The y position of the container blockz
- The z position of the container block
-
simulateChestOpening
Simulates as if someone would open a container, such as an ender chest, normal chest or a shulker box.It'll play an animation and updates the redstone signal. Possibly even more is happening.
There's an interal numerical counter that checks how many players have opened the chest. It's being used to determinate when the close animation needs to be played. Make sure to call
simulateChestClosing(World, int, int, int)
equally as often as you called this method and not more or less, as otherwise it'll possibly break. The counter may even reach minus values.- Parameters:
block
- The block that represents the container
-
simulateChestClosing
Simulates as if someone would close a container, such as an ender chest, normal chest or a shulker box.It'll play an animation and updates the redstone signal. Possibly even more is happening.
There's an interal numerical counter that checks how many players have opened the chest. It's being used to determinate when the close animation needs to be played. Make sure to call
simulateChestOpening(World, int, int, int)
equally as often as you called this method and not more or less, as otherwise it'll possibly break. The counter may even reach minus values.- Parameters:
world
- The world in which the container is located atx
- The x position of the container blocky
- The y position of the container blockz
- The z position of the container block
-
simulateChestClosing
Simulates as if someone would close a container, such as an ender chest, normal chest or a shulker box.It'll play an animation and updates the redstone signal. Possibly even more is happening.
There's an interal numerical counter that checks how many players have opened the chest. It's being used to determinate when the close animation needs to be played. Make sure to call
simulateChestOpening(World, int, int, int)
equally as often as you called this method and not more or less, as otherwise it'll possibly break. The counter may even reach minus values.- Parameters:
block
- The block that represents the container
-
setServerMotd
This may sound crazy, but Bukkit's API does not allow the direct change of the server's motd.- Parameters:
motd
- The new motd
-
playItemPickupAnimation
Simulates an item, arrow, exp or whatever getting picked up.This method does NOT remove the entity from the memory, it only plays the pickup animation.
- Parameters:
entity
- The entity that picked it upitem
- The entity that got picked upamount
- The amount that got picked up. For an item it's for instance its amount, for exp it's the amount it represents
-
simulatePlayerClickingRespawn
Simulates as if the player would click on the "respawn" button while he's dead.- Parameters:
player
- The player for whom we want it to simulate
-
setEntityMovementSpeed
Changes the movement speed of the given entity.Basically only changes the "MOVEMENT_SPEED" attribute. This, however, wasn't possible for all versions in the past and required NMS.
- Parameters:
entity
- The entity for whom the speed shall be changedspeed
- The new movement speed
-
setEntityFollowRange
Changes the range in which the entity can follow its target/enemy.Basically only changes the "FOLLOW_RANGE" attribute. This, however, wasn't possible for all versions in the past and required NMS.
- Parameters:
entity
- The entity for whom the speed shall be changedrange
- The new target range
-
setEntitySilent
Changes if an entity is silent, or is allowed to make noise.- Parameters:
entity
- The entity that will be made silentsilent
- Whether the entity shall be silent or not
-
teleportWithoutEvent
Teleports a given entity to a location without callingEntityTeleportEvent
.Furthermore, it also doesn't check whether the entity is currently being ridden on (unlike Bukkit's API).
- Parameters:
entity
- The entity that shall be teleportedlocation
- The target location
-
getItemDamage
Calculates the amount of attack damage this item would theoretically generate.- Parameters:
is
- The item- Returns:
- The approx amount of damage it'd generate
-
hideAttributes
Hides attributes from the item.This includes e.g. the damage for swords. It's not possible to tell beforehand whether a new instance will be constructed as this greatly depends on the version the user is using.
- Parameters:
is
- The item whose attributes shall be hidden- Returns:
- Possibly the equal or a new instance
-
sendWorldTimePacket
Sends a world time packet to the given player.- Parameters:
player
- Target playertime
- The new world time
-
getEntityDamageSound
Returns the sound that the entity would play if it'd receive damage.- Parameters:
entity
- The involved entity- Returns:
- The sound that it'd play.
null
if it doesn't play any sound in that case
-
getEntityDeathSound
Returns the sound that the entity would play if it'd die.- Parameters:
entity
- The involved entity- Returns:
- The sound that it'd play.
null
if it doesn't play any sound in that case
-
getSoundByMinecraftName
Tries to parse a Minecraft sound given by it's vanilla id (e.g. minecraft:beacon.activate)- Parameters:
vanillaName
- The vanilla id of the sound- Returns:
- The sound that matches to it.
null
if none has been found
-
getEntityWidth
Get the width of the entity- Parameters:
entity
- The involved entity- Returns:
- The width of the entity
-
getEntityHeight
Get the height of the entity- Parameters:
entity
- The involved entity- Returns:
- The height of the entity
-
getEffectInfiniteDuration
int getEffectInfiniteDuration()Get the duration that you have to use for infinite potion effects.While in the past you could just use
Integer.MAX_VALUE
, newer versions instead expect -1. This method automatically handles the differentiation for you.- Returns:
- The duration that you have to use for infinite potion effects
- See Also:
-
get
Contains API/Helper to access NMS stuff- Returns:
- The global NMSHelper instance
-