Fixed bug when class doesn't have any skills.

This commit is contained in:
Ka0rX 2023-04-02 20:20:55 +01:00
parent c64b88e36d
commit c6b9372026

View File

@ -11,6 +11,8 @@ import org.bukkit.command.CommandSender;
import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.entity.Player;
import java.util.stream.Collectors;
public class SkillsCommand extends RegisteredCommand {
public SkillsCommand(ConfigurationSection config) {
super(config, ToggleableCommand.SKILLS);
@ -24,7 +26,12 @@ public class SkillsCommand extends RegisteredCommand {
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) return true;
if (data.getProfess().getSkills().size() < 1) {
if (data.getProfess().getSkills()
.stream()
.filter((classSkill) -> data.hasUnlocked(classSkill.getSkill()))
.sorted((classSkill1,classSkill2)->classSkill1.getUnlockLevel()-classSkill1.getUnlockLevel())
.collect(Collectors.toList())
.size() < 1) {
MMOCore.plugin.configManager.getSimpleMessage("no-class-skill").send((Player) sender);
return true;
}