Common Classes
Player Class
The Player
class represents a player in the game and provides various methods for interaction.
Get Player’s Name:
player_name = player.name
Send a Message:
player.send_message("Hello, {{player.name}}!")
Get Player’s Location:
player_location = player.location
Set Player’s Health:
player.health = 20 // Set health to full
Give Experience:
player.give_experience(100) // Add 100 experience points
Location Class
The Location
class represents a point in the game world, including coordinates and the world itself.
Get Coordinates:
x = location.x y = location.y z = location.z
Set Coordinates:
location.x = 100 location.y += 10 // Move up by 10 blocks location.z = -50
Get World of Location:
world = location.world
Block Class
The Block
class represents a block in the game world.
Get Block Type:
block_type = block.type
Set Block Type:
block.type = :DIAMOND_BLOCK // Change the block to a diamond block
Break a Block:
block.break_naturally() // Break the block
ItemStack Class
The ItemStack
class represents an item in the player's inventory.
Create a New ItemStack: (Soon!)
stone_item = ItemStack(:STONE, 1) // Create a stone item stack of size 1
Get Item Type:
item_type = item_stack.type
Set Amount of Item:
item_stack.amount = 10 // Set the amount to 10
Entity Class
The Entity
class represents any entity in the game, such as players, mobs, and items.
Get Entity Type:
entity_type = entity.type
Remove an Entity:
entity.remove() // Remove the entity from the world
Get Entity Location:
entity_location = entity.location
LivingEntity Class
The LivingEntity
class extends the Entity
class and represents all living creatures in the game, such as players and mobs. It includes additional methods specific to living entities. (Players are also living entities)
Get Health:
health = living_entity.health
Set Health:
living_entity.health = 15 // Set health to 15
Get Max Health:
max_health = living_entity.max_health
Add Potion Effect:
living_entity.add_potion_effect(:SPEED, 60, 1) // Apply Speed effect for 60 seconds
Remove Potion Effect:
living_entity.remove_potion_effect(:SLOWNESS) // Remove the Slowness effect
World Class
The World
class represents a game world, including its properties and methods.
Get All Players in the World:
players_in_world = world.players
Spawn an Entity:
world.spawn_entity(location, :ZOMBIE) // Spawn a zombie at a specific location
Set the Time of Day:
world.time = 1000 // Set the time to day
These methods provide a solid starting point for interacting with various elements within your game. As you explore the Spigot API further, you’ll discover even more methods and capabilities, enabling you to create dynamic and engaging scripts.
Last updated
Was this helpful?