Added permission associated with every MMOCore command.

This commit is contained in:
Ka0rX 2023-04-04 07:11:16 +01:00
parent 8f2da7a865
commit a54bfc03a0
10 changed files with 42 additions and 1 deletions

View File

@ -18,6 +18,9 @@ public class AttributesCommand extends RegisteredCommand {
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if (!sender.hasPermission("mmocore.attributes"))
return false;
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is for players only.");
return true;

View File

@ -25,6 +25,8 @@ public class FriendsCommand extends RegisteredCommand {
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if (!sender.hasPermission("mmocore.friends"))
return false;
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is for players only.");
return true;

View File

@ -26,6 +26,8 @@ public class GuildCommand extends RegisteredCommand {
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if (!sender.hasPermission("mmocore.guild"))
return false;
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is for players only.");
return true;

View File

@ -27,6 +27,8 @@ public class PartyCommand extends RegisteredCommand {
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if (!sender.hasPermission("mmocore.party"))
return false;
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is for players only.");
return true;

View File

@ -18,6 +18,8 @@ public class PlayerStatsCommand extends RegisteredCommand {
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if (!sender.hasPermission("mmocore.profile"))
return false;
if (!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command is for players only.");
return true;

View File

@ -17,6 +17,8 @@ public class QuestsCommand extends RegisteredCommand {
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if (!sender.hasPermission("mmocore.quests"))
return false;
if (sender instanceof Player) {
PlayerData data = PlayerData.get((Player) sender);
MMOCommandEvent event = new MMOCommandEvent(data, "quests");

View File

@ -19,6 +19,8 @@ public class SkillTreesCommand extends RegisteredCommand {
@Override
public boolean execute(@NotNull CommandSender sender, String s, String[] args) {
if (!sender.hasPermission("mmocore.skilltrees"))
return false;
if (!(sender instanceof Player player))
return false;
PlayerData data = PlayerData.get(player);

View File

@ -18,6 +18,8 @@ public class SkillsCommand extends RegisteredCommand {
@Override
public boolean execute(CommandSender sender, String label, String[] args) {
if (!sender.hasPermission("mmocore.skills"))
return false;
if (sender instanceof Player) {
PlayerData data = PlayerData.get((Player) sender);
MMOCommandEvent event = new MMOCommandEvent(data, "skills");

View File

@ -32,7 +32,7 @@ public enum ToggleableCommand {
PARTY("party", "Invite players in a party to split exp", config -> new PartyCommand(config)),
GUILD("guild", "Show players in current guild", config -> new GuildCommand(config)),
WITHDRAW("withdraw", "Withdraw money into coins and notes", config -> new WithdrawCommand(config), v -> MMOCore.plugin.hasEconomy() && MMOCore.plugin.economy.isValid(), "w"),
SKILL_TREES("skiltrees", "Open up the skill tree menu", config -> new SkillTreesCommand(config), "st", "trees", "tree"),
SKILL_TREES("skilltrees", "Open up the skill tree menu", config -> new SkillTreesCommand(config), "st", "trees", "tree"),
DEPOSIT("deposit", "Open the currency deposit menu", config -> new DepositCommand(config), "d"),
PVP_MODE("pvpmode", "Toggle on/off PVP mode.", config -> new PvpModeCommand(config), "pvp");

View File

@ -27,3 +27,27 @@ permissions:
mmocore.class-select:
description: Access to /class
default: op
mmocore.attributes:
description: Access to /attributes
default: true
mmocore.skills:
description: Access to /skills
default: true
mmocore.profile:
description: Access to /profile
default: true
mmocore.friends:
description: Access to /friends
default: true
mmocore.guild:
description: Access to /guild
default: true
mmocore.party:
description: Access to /party
default: true
mmocore.skilltrees:
description: Access to /skilltrees
default: true
mmocore.quests:
description: Access to /quests
default: true