Difference between revisions of "Commands"

From SupaHam
Jump to: navigation, search
(Initial page creation. phew)
(No difference)

Revision as of 07:01, 18 January 2014

A command in Minecraft starts with a forward slash (/).

Example:
/seed

The seed command is a vanilla command, meaning it comes with Minecraft without any modifications.

Permissions

Some commands require permissions. If a player does not have the appropriate permissions for a command an error message is sent to the player. Vanilla commands that require permissions are acquired by becoming an Operator.

Though Minecraft server modifications such as Bukkit have a permissions implementation that allow you to apply permission nodes (String) to players, this allows for maximum flexibility.

Example:
Imagine a scenario where you, as a server admin, want to give a player permission to only mute other players, to help keep the chat clean. Without Bukkit this is not possible. You would have to give that player op status which gives them permission to all other commands on the server. You might not be able to trust someone with that many permissions, this is where Bukkit's SuperPerms implementation comes in. SuperPerms is a Bukkit implementation that allows for plugins to hook into Bukkit and check player permissions and with a permissions management plugin such as PermissionsEx you are able to manage player permissions and do much more.

A permission node is a String (text) usually seperated with fullstops/periods (.) instead of whitespaces.

Example:
"my.command.permission"

Arguments

There are commands such as /seed which are simple that tell you the seed of the current world you're in, but commands do much more than that. As a developer, you can implement commands with arguments to allow your users to insert their own values and the rest is done behind the scenes (in the code).

Example:
/tp [target player] <destination player>
/tp [target player] <x> <y> <z>

The example above is copied straight out of the vanilla Minecraft which allows you to teleport around the world. Now, you might get confused since you see square brackets ([]) and angle brackets (<>), those are the arguments. Any developer can implement their syntax just the way they want so don't base the following information on all plugins, though I (SupaHam) tend to make mine similar to how Minecraft and many Bukkit plugins do theirs. So with the tp command the square brackets are optional and the angle brackets are required. Usually between these brackets are a descriptive one/two words.

So, the tp command has the [target player] and the <destination player> argument for one of the usages. If you understood well then you should know that the [target player] is not required but the <destination player> is.

Example:
A. SupaHam executes /tp Steve

Minecraft then takes that 'Steve' argument and checks if it's valid
Case: Steve is online

  • Minecraft checks if Steve is online on the same server as SupaHam. If Steve is online, SupaHam will get teleported to him.

Case: Steve is offline

  • Minecraft outputs an error to the command sender saying 'Steve' is not a valid player.

B. SupaHam executes /tp Steve SupaHam

Notice the difference between command A and command B? Command B is making use of the optional argument ([target player]).

Minecraft then takes both 'Steve' and 'SupaHam' and check if they are both valid players, as shown with the cases above. If they are both valid Minecraft then teleports 'Steve' to 'SupaHam'.