Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ You can set the max level for each enchantment, and add XP cost in levels.
>
> Example: `enchantbookplus.enchant.*` or `enchantbookplus.enchant.unbreaking`

| Permission | Description |
|-----------------------------------------|----------------------------------------------------------------------------------------|
| `enchantbookplus.enchant.<enchantment>` | Allow enchanting `<enchantment>` above the vanilla level, as configured in the plugin. |
| `enchantbookplus.reload` | Reload plugin config using `/enchantbookplus reload` |
| Permission | Description | Default |
|-----------------------------------------|----------------------------------------------------------------------------------------|----------|
| `enchantbookplus.enchant.<enchantment>` | Allow enchanting `<enchantment>` above the vanilla level, as configured in the plugin. | Everyone |
| `enchantbookplus.reload` | Reload plugin config using `/enchantbookplus reload` | OP |

## Reporting issues
Fixing bugs is the utmost priority for this project.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ public void reload() {

@Override
public void onEnable() {
Permissions.init();
Objects.requireNonNull(getCommand("enchantbookplus")).setExecutor(new MainCommand());

registerEvents();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package pro.cloudnode.smp.enchantbookplus;

import org.bukkit.Registry;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager;
import org.jetbrains.annotations.NotNull;

public final class Permissions {
Expand All @@ -9,4 +13,21 @@ public final class Permissions {
}

public static @NotNull String RELOAD = "enchantbookplus.reload";

public static void init() {
final @NotNull PluginManager pm = EnchantBookPlus.getInstance().getServer().getPluginManager();
pm.addPermission(new Permission(
RELOAD,
"Reload plugin config using `/enchantbookplus reload`",
PermissionDefault.OP
));
for (Enchantment enchantment : Registry.ENCHANTMENT) {
EnchantBookPlus.getInstance().getLogger().info("Registering permission for " + enchantment.getKey());
pm.addPermission(new Permission(
enchant(enchantment),
"Allow enchanting " + enchantment.getKey() + "above the vanilla level, as configured in the plugin",
PermissionDefault.TRUE
));
}
}
}
Loading