Skip to content
Tad Hardesty edited this page Jun 16, 2014 · 3 revisions

Importing

To import Java classes, such as Bukkit classes, the following is possible:

# use 'World' to refer to the World interface
from org.bukkit import World
# use 'Player', 'Creeper', and 'Zombie' to refer to the entity classes
from org.bukkit.entity import Player, Creeper, Zombie

# access Java's System class
from java.lang import System

Note that most of the time you don't need to import classes unless you plan to construct instances or use static methods or variables.

Accessing properties

Many objects have getters and setters - methods with signatures like int getThing() and void setThing(int thing). In Python, it's still possible to access these methods directly, but they also act as properties:

server = Bukkit.getServer()
maxPlayers = server.getMaxPlayers()  # works as normal
maxPlayers = server.maxPlayers       # also works
server.setWhitelist(True)            # works as normal
server.whitelist = True              # also works

Clone this wiki locally