Wrapper.py Plugin API Reference

class api.API(wrapper, name='', id=None)[source]

The API class contains methods for basic plugin functionality, such as handling events, registering commands, and more.

Most methods aren’t related to gameplay, aside from commands, but for core stuff. See the Minecraft class (accessible at self.api.minecraft) for more gameplay-related methods.

blockForEvent(eventType)[source]

Blocks until the specified event is called.

callEvent(event, payload)[source]

Invokes the specific event. Payload is extra information relating to the event. Errors may occur if you don’t specify the right payload information.

getPluginContext(id)[source]

Returns the content of another plugin with the specified ID.

i.e. api.getPluginContext(“com.benbaptist.plugins.essentials”)

getStorage(name, world=False)[source]

Return a storage object for storing configurations, player data, and any other data your plugin will need to remember across reboots.

Setting world=True will store the data inside the current world folder, for world-specific data.

registerCommand(name, callback, permission=None)[source]

This registers a command that, when executed in Minecraft, will execute callback(player, args). permission is an optional attribute if you want your command to only be executable if the player has a specified permission node.

registerEvent(eventType, callback)[source]

Register an event and a callback. See [doc link needed here] for a list of events. callback(payload) when an event occurs, and the contents of payload varies between events.

registerPermission(permission=None, value=False)[source]

Used to set a default for a specific permission node.

Note: You do not need to run this function unless you want certain permission nodes to be granted by default. i.e. essentials.list should be on by default, so players can run /list without having any permissions.

class api.Minecraft(wrapper)[source]

This class contains functions related to in-game features directly. These methods are located at self.api.minecraft.

broadcast(message='', irc=False)[source]

Broadcasts the specified message to all clients connected. message can be a JSON chat object, or a string with formatting codes using the & as a prefix.

Setting irc=True will also broadcast the specified message on IRC channels that Wrapper.py is connected to. Formatting might not work properly.

console(string)[source]

Run a command in the Minecraft server’s console.

getLevelInfo(worldName=False)[source]

Return an NBT object of the world’s level.dat.

getPlayer(username='')[source]

Returns the player object of the specified logged-in player. Will raise an exception if the player is not logged in.

getPlayers()[source]

Returns a list of the currently connected players.

getServer()[source]

Returns the server object.

getSpawnPoint()[source]

Returns the spawn point of the current world.

getTime()[source]

Returns the time of the world in ticks.

getWorldName()[source]

Returns the world’s name.

giveStatusEffect(player, effect, duration=30, amplifier=30)[source]

Gives the specified status effect to the specified target.

isServerStarted()[source]

Returns a boolean if the server is fully booted or not.

lookupUUID(uuid)[source]

Returns the username from the specified UUID. If the player has never logged in before and isn’t in the user cache, it will poll Mojang’s API. The function will raise an exception if the UUID is invalid.

message(destination='', json_message={})[source]

THIS METHOD WILL BE CHANGED. Used to message some specific target.

processColorCodes(message)[source]

Used internally to process old-style color-codes with the & symbol, and returns a JSON chat object.

setBlock(x, y, z, tileName, dataValue=0, oldBlockHandling='replace', dataTag={})[source]

Sets a block at the specified coordinates with the specific details. Will fail if the chunk is not loaded.

summonEntity(entity, x=0, y=0, z=0, dataTag={})[source]

Summons an entity at the specified coordinates with the specified data tag.

teleportAllEntities(entity, x, y, z)[source]

Teleports all of the specific entity type to the specified coordinates.

class api.Player(username, wrapper)[source]

Player objects contains methods and data of a currently logged-in player. This object is destroyed upon logging off.

actionMessage(message='')[source]
connect(ip, address)[source]

Upon calling, the player object will become defunct and the client will be transferred to another server (provided it has offline-mode turned on).

getDimension()[source]

Returns the player’s current dimension. -1 for Nether, 0 for Overworld, and 1 for End.

getFirstLogin()[source]

Returns a tuple containing the timestamp of when the user first logged in for the first time, and the timezone (same as time.tzname).

getGamemode()[source]

Returns the player’s current gamemode.

getGroups()[source]

Returns a list of permission groups that the player is in.

getHeldItem()[source]

Returns the item object of an item currently being held.

getItemInSlot(slot)[source]
getPosition()[source]

Returns a tuple of the player’s current position.

hasGroup(group)[source]

Returns a boolean of whether or not the player is in the specified permission group.

hasPermission(node)[source]

If the player has the specified permission node (either directly, or inherited from a group that the player is in), it will return the value (usually True) of the node. Otherwise, it returns False.

isOp()[source]

Returns whether or not the player is currently a server operator.

message(message='')[source]
openWindow(type, title, slots)[source]
processColorCodes(message)[source]

Used internally to process old-style color-codes with the & symbol, and returns a JSON chat object.

setBlock(position)[source]
setGamemode(gm=0)[source]

Sets the user’s gamemode.

setPlayerFlying(fly)[source]
setResourcePack(url)[source]

Sets the player’s resource pack to a different URL. If the user hasn’t already allowed resource packs, the user will be prompted to change to the specified resource pack. Probably broken right now.

setVisualXP(progress, level, total)[source]

This Page