Interface NMSHelper
- 
Method SummaryModifier and TypeMethodDescriptionstatic NMSHelperget()Contains API/Helper to access NMS stufffloatgetAttackDamage(Player player) Returns the amount of damage a player would cause at the exact moment with a generic entity.intGet the duration that you have to use for infinite potion effects.@Nullable EntitygetEntityById(World world, int entityId) Returns the entity whoseEntity.getEntityId()is equal to the given one.@Nullable SoundgetEntityDamageSound(Entity entity) Returns the sound that the entity would play if it'd receive damage.@Nullable SoundgetEntityDeathSound(Entity entity) Returns the sound that the entity would play if it'd die.floatgetEntityHeight(Entity entity) Get the height of the entityfloatgetEntityWidth(Entity entity) Get the width of the entitydoubleCalculates the amount of attack damage this item would theoretically generate.Returns the locale of the player that he has configured within his client.intReturns the patch version of the running software.intReturns the revision number that you can find in NMS packages.
 Example: If it's running "v1_8_R3" then this method returns 3@Nullable StringgetSkullTexture(Skull skull) Returns the texture of the skull in a base64 format.@Nullable StringgetSkullTexture(SkullMeta skullMeta) Returns the texture of the skull in a base64 format.@Nullable SoundgetSoundByMinecraftName(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 momentintReturns the minor version of the running server software.Hides attributes from the item.booleanReturns whether or not this server is running paper or a fork of papervoidplayItemPickupAnimation(Entity entity, Entity item, int amount) Simulates an item, arrow, exp or whatever getting picked up.voidsendPacket(Player player, Object packet) Will send a message to the player.voidsendWorldTimePacket(Player player, long time) Sends a world time packet to the given player.voidsetEntityFollowRange(LivingEntity entity, double range) Changes the range in which the entity can follow its target/enemy.voidsetEntityMovementSpeed(LivingEntity entity, double speed) Changes the movement speed of the given entity.voidsetEntitySilent(Entity entity, boolean silent) Changes if an entity is silent, or is allowed to make noise.voidsetEntityTarget(Entity entity, @Nullable Location target) Causes a walkable hologram to walk to a given location.voidsetFireballDirection(Entity fireball, Vector direction, double speed) Sets the fireball direction and speed.setGlowEffect(ItemStack is, boolean glowing) Adds or removes a "glow" effect to an item.voidsetServerMotd(String motd) This may sound crazy, but Bukkit's API does not allow the direct change of the server's motd.voidsetSkullTexture(Skull skull, String texture) Applies a custom texture in a base64 format to a skull block.voidsetSkullTexture(SkullMeta skullMeta, String texture) Applies a custom texture in a base64 format to a skull itemvoidshowActionbar(Player player, String text) Will show a small message above the players hotbarvoidShows the "title" to a player.voidShows the "title" to a player.default voidsimulateChestClosing(Block block) Simulates as if someone would close a container, such as an ender chest, normal chest or a shulker box.voidsimulateChestClosing(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 voidsimulateChestOpening(Block block) Simulates as if someone would open a container, such as an ender chest, normal chest or a shulker box.voidsimulateChestOpening(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.voidsimulatePlayerClickingRespawn(Player player) Simulates as if the player would click on the "respawn" button while he's dead.voidteleportWithoutEvent(Entity entity, Location location) Teleports a given entity to a location without callingEntityTeleportEvent.
- 
Method Details- 
getVersionint 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
 
- 
getPatchVersionint 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
 
- 
getRevisionint 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
 
- 
isRunningPaperboolean isRunningPaper()Returns whether or not this server is running paper or a fork of paper- Returns:
- truewhen the plugin is running PaperMC or a fork of it
 
- 
getLocaleReturns the locale of the player that he has configured within his client.- Parameters:
- player- The given player
- Returns:
- The locale of the player
 
- 
setGlowEffectAdds 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 from
- glowing-- true: Add the effect;- false: Remove the effect
- Returns:
- Same or cloned ItemStack instance with or without the glow effect
 
- 
showTitleShows 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 to
- title- The larger text which is located above- subtitle
- subtitle- The smaller text which is located below- title
- fadeIn- The time in ticks for the "appear" or "fade in" effect
- stayTime- The time in ticks in which the title will be shown
- fadeOut- The time in ticks for the "disappear" or "fade out" effect
 
- 
showTitleShows 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 to
- title- The larger text which is located above- subtitle
- subtitle- The smaller text which is located below- title
 
- 
showActionbarWill show a small message above the players hotbar- Parameters:
- player- The target to whom the text shall be displayed to
- text- The string that shall be shown
 
- 
setSkullTextureApplies 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 to
- texture- The texture in base64 format
 
- 
getSkullTextureReturns the texture of the skull in a base64 format. Might benullwhen 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
 
- 
setSkullTextureApplies 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 to
- texture- The texture in base64 format
 
- 
getSkullTextureReturns the texture of the skull in a base64 format. Might benullwhen 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
 
- 
getVanillaDeathMessageReturns 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
 
- 
setEntityTargetCauses a walkable hologram to walk to a given location. Passnullto 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 somewhere
- target- The location to which he shall walk to.- nullto make him stop
 
- 
sendPacketWill 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 to
- packet- The message that shall be send
 
- 
getAttackDamageReturns 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
 
- 
getEntityByIdReturns 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 in
- entityId- The id of the entity
- Returns:
- The entity with that id. nullwhen there's none
 
- 
simulateChestOpeningSimulates 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 at
- x- The x position of the container block
- y- The y position of the container block
- z- The z position of the container block
 
- 
simulateChestOpeningSimulates 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
 
- 
simulateChestClosingSimulates 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 at
- x- The x position of the container block
- y- The y position of the container block
- z- The z position of the container block
 
- 
simulateChestClosingSimulates 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
 
- 
setServerMotdThis may sound crazy, but Bukkit's API does not allow the direct change of the server's motd.- Parameters:
- motd- The new motd
 
- 
playItemPickupAnimationSimulates 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 up
- item- The entity that got picked up
- amount- The amount that got picked up. For an item it's for instance its amount, for exp it's the amount it represents
 
- 
simulatePlayerClickingRespawnSimulates 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
 
- 
setEntityMovementSpeedChanges 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 changed
- speed- The new movement speed
 
- 
setEntityFollowRangeChanges 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 changed
- range- The new target range
 
- 
setEntitySilentChanges if an entity is silent, or is allowed to make noise.- Parameters:
- entity- The entity that will be made silent
- silent- Whether the entity shall be silent or not
 
- 
teleportWithoutEventTeleports 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 teleported
- location- The target location
 
- 
getItemDamageCalculates the amount of attack damage this item would theoretically generate.- Parameters:
- is- The item
- Returns:
- The approx amount of damage it'd generate
 
- 
hideAttributesHides 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
 
- 
sendWorldTimePacketSends a world time packet to the given player.- Parameters:
- player- Target player
- time- The new world time
 
- 
getEntityDamageSoundReturns the sound that the entity would play if it'd receive damage.- Parameters:
- entity- The involved entity
- Returns:
- The sound that it'd play. nullif it doesn't play any sound in that case
 
- 
getEntityDeathSoundReturns the sound that the entity would play if it'd die.- Parameters:
- entity- The involved entity
- Returns:
- The sound that it'd play. nullif it doesn't play any sound in that case
 
- 
getSoundByMinecraftNameTries 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. nullif none has been found
 
- 
getEntityWidthGet the width of the entity- Parameters:
- entity- The involved entity
- Returns:
- The width of the entity
 
- 
getEntityHeightGet the height of the entity- Parameters:
- entity- The involved entity
- Returns:
- The height of the entity
 
- 
getEffectInfiniteDurationint 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:
 
- 
setFireballDirectionSets the fireball direction and speed.This method aims to be consistent across all versions, even though they were significant changes in the fireball in how it behaves. - Parameters:
- fireball- The fireball entity
- direction- The direction in which the fireball shall fly
- speed- The speed at which the fireball shall fly
- Throws:
- RuntimeException- If the entity is not a valid fireball
- IllegalArgumentException- If the direction's length is exactly 0.0
 
- 
getContains API/Helper to access NMS stuff- Returns:
- The global NMSHelper instance
 
 
-