Add missing party chat permission check to the party chat command

This commit is contained in:
nossr50 2020-10-29 12:20:52 -07:00
parent ca93dc02df
commit 4bac586253

View File

@ -11,6 +11,7 @@ import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.player.UserManager; import com.gmail.nossr50.util.player.UserManager;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.permissions.Permissible;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
/* /*
@ -32,6 +33,11 @@ public class CommandManager {
registerCommands(); registerCommands();
} }
private void registerCommands() {
bukkitCommandManager.registerCommand(new AdminChatCommand(pluginRef));
bukkitCommandManager.registerCommand(new PartyChatCommand(pluginRef));
}
public void registerConditions() { public void registerConditions() {
// Method or Class based - Can only be used on methods // Method or Class based - Can only be used on methods
bukkitCommandManager.getCommandConditions().addCondition(ADMIN_CONDITION, (context) -> { bukkitCommandManager.getCommandConditions().addCondition(ADMIN_CONDITION, (context) -> {
@ -56,13 +62,15 @@ public class CommandManager {
if(bukkitCommandIssuer.getIssuer() instanceof Player) { if(bukkitCommandIssuer.getIssuer() instanceof Player) {
validateLoadedData(bukkitCommandIssuer.getPlayer()); validateLoadedData(bukkitCommandIssuer.getPlayer());
validatePlayerParty(bukkitCommandIssuer.getPlayer()); validatePlayerParty(bukkitCommandIssuer.getPlayer());
validatePermission("mcmmo.chat.partychat", bukkitCommandIssuer.getPlayer());
} }
}); });
} }
private void registerCommands() { private void validatePermission(@NotNull String permissionNode, @NotNull Permissible permissible) {
bukkitCommandManager.registerCommand(new AdminChatCommand(pluginRef)); if(!permissible.hasPermission(permissionNode)) {
bukkitCommandManager.registerCommand(new PartyChatCommand(pluginRef)); throw new ConditionFailedException("You do not have the appropriate permission to use this command.");
}
} }