Plugin: PlayerStuff

Let’s play around with a Player a bit more.

We’re going to install the PlayerStuff plugin and change some of the object properties for players in the Minecraft world.

In the Player object, there are all kinds of interesting functions to get information about a player, and to set those values as well. Here are a few we’ll look at:

chat()

getWorld()

getDisplayName() (can set it too)

getExperience() (can set it too)

getHunger() (can set it too)

getHealth() (can set it too)

isSleeping()

getLocation()

We can send a message to a player, get some values, and more. Here’s code for a full plugin that demonstrates some of these features. It provides the command "/whoami". For more advanced plugins, this approach could be a great ...

Get Learn to Program with Minecraft Plugins, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.