forked from Upstream/mmocore
Fixed bug when class doesn't have any skills.
This commit is contained in:
parent
c64b88e36d
commit
c6b9372026
@ -11,26 +11,33 @@ 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);
|
||||
}
|
||||
public SkillsCommand(ConfigurationSection config) {
|
||||
super(config, ToggleableCommand.SKILLS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "skills");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if(event.isCancelled()) return true;
|
||||
|
||||
if (data.getProfess().getSkills().size() < 1) {
|
||||
MMOCore.plugin.configManager.getSimpleMessage("no-class-skill").send((Player) sender);
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||
if (sender instanceof Player) {
|
||||
PlayerData data = PlayerData.get((Player) sender);
|
||||
MMOCommandEvent event = new MMOCommandEvent(data, "skills");
|
||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||
if (event.isCancelled()) return true;
|
||||
|
||||
InventoryManager.SKILL_LIST.newInventory(data).open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
InventoryManager.SKILL_LIST.newInventory(data).open();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user