Using a third-party permissions plugin

You will most likely have trusted players on your server with whom you wish to share the use of the /enchant command. However, these players are not trusted enough to be an OP. In order to share the use of this command, you will need to use a permissions plugin. The permissions plugin will allow you to create multiple groups of players. Each group will have different permissions assigned to it. Each player that plays on your server can then be assigned to a specific group. As an example, you can have four permission groups, namely default, trusted, mod, and admin. The default group will have the basic permissions. A new player who joins the server will be put into the default group. The trusted group will have a few more privileges. They will have access to specific commands, such as setting the time of day in the server world and teleporting players. The mod group stands for "moderator", and it will have access to many other commands, such as kicking or banning a player. Finally, the admin group, which stands for "administrator", will have the /give command and the /enchant command.

There are several permission plugins available at dev.bukkit.org. Each permission plugin is created by a different developer. They have various features depending on how the developer decided to program it. Most of the popular permissions plugins that are used today were actually created before permissions were added to the API. Because of this, they may not utilize all of Bukkit's features. They also include additional features that are no longer needed, such as permission groups. The plugin that we will use is the one that I have developed myself, and it is called CodsPerms. CodsPerms is a simple and basic permissions plugin. Because CodsPerms follows the rules of the Bukkit API, the group configuration that you will learn in this chapter can also be utilized for other permission plugins. Instructions on where to download CodsPerms can be found at http://codisimus.com/codsperms.

Once you have the jar file of the plugin, install it on your server as you would install one of your own plugins. With the plugin installed, the permission command will be available to you. Executing the /perm command will inform you of the various commands that are now at your disposal.

Tip

You need to have the permissions.manage node in order to use the permission command. Until we fully set up the permission plugin, you can either run these commands from the console, or give yourself the OP status.

You will see that there are commands that can be used to give permission nodes to players as well as remove them. This is useful if you want to add single nodes, such as giving yourself the permissions.manage node, but you will not want to use those commands for everyone who joins your server. To resolve this, we will configure the groups that were presented earlier.

These groups will be created as a permission node that contains several other child permission nodes. This will allow us to give a player a single group node, and they will then inherit all of its children. We can create these parent nodes within the permissions.yml file located in the root directory (the same folder in which you placed spigot.jar). The permissions.yml file is a YAML file like plugin.yml. Therefore, you should be familiar with the formatting. You can edit this file with a text editor. If you wish to use NetBeans, you can open the file by navigating to File | Open Fileā€¦ or by dragging and dropping the file in the NetBeans window.

Tip

Editing a YAML file incorrectly will cause it to not load completely. The issue that you will most likely face with the YAML files is having a tab in your document rather than spaces. This will cause your file to not load properly.

The following code is a sample of how permissions.yml might look after creating the groups that were specified earlier:

group.default:
  description: New Players who may have joined for the first time
  default: true
  children:
    minecraft.command.kill: true
    minecraft.command.list: true
group.trusted:
  description: Players who often play on the server
  default: false
  children:
    group.default: true
    minecraft.command.weather: true
    minecraft.command.time: true
    minecraft.command.teleport: true
group.mod:
  description: Players who moderate the server
  default: false
  children:
    group.trusted: true
    minecraft.command.ban: true
    minecraft.command.pardon: true
    minecraft.command.kick: true
group.admin:
  description: Players who administer on the server
  default: false
  children:
    group.mod: true
    minecraft.command.ban-ip: true
    minecraft.command.pardon-ip: true
    minecraft.command.gamerule: true
    minecraft.command.give: true
    minecraft.command.say: true
    permissions.manage: true
    enchanter.enchant: true

Every group can inherit the permission nodes of another group by simply adding that group permission node as one of their children. In this example, the admin group inherits all the permissions from the mod group, the mod group inherits all the permissions from the trusted group, and the trusted group inherits all the permissions from the default group. Therefore, the admin group also inherits the default group's permissions through parentage. In this sample file, we have default set to true for the group.default parent node. This means that each player on the server will automatically have the group.default permission node. Because of the child nodes, each player will also have minecraft.command.kill and minecraft.command.list. Adding permissions to the default group will eliminate the need to hand out permissions to each player who joins your server.

As you can see, the permission nodes earlier included permissions for some Minecraft commands as well as the permission for the Enchanter plugin. There are many more permissions than have already been listed. These are a few that are commonly used. The rest of the permissions for the Minecraft and Bukkit commands can be found at wiki.bukkit.org/CraftBukkit_commands.

Once you have populated the permissions YAML file, you will have to reload the server in order for the changes to take effect. Now, you can assign players to different groups. Use the following command with your own username to add yourself to the trusted group:

>perm give Codisimus group.trusted

You will have the permissions defined in group.trusted within the permissions.yml file. Try putting yourself in various groups and using the /enchant commands and various other commands. Ensure that you are not an OP, as it will give you all the permissions regardless of which group you are in. Also, keep in mind that you must manually remove yourself from groups. If a player in the admin group is added to the trusted group, they will still have administrator privileges until they are removed from the admin group.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.51.3