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.configuration.ConfigurationSection;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class SkillsCommand extends RegisteredCommand {
|
public class SkillsCommand extends RegisteredCommand {
|
||||||
public SkillsCommand(ConfigurationSection config) {
|
public SkillsCommand(ConfigurationSection config) {
|
||||||
super(config, ToggleableCommand.SKILLS);
|
super(config, ToggleableCommand.SKILLS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean execute(CommandSender sender, String label, String[] args) {
|
public boolean execute(CommandSender sender, String label, String[] args) {
|
||||||
if (sender instanceof Player) {
|
if (sender instanceof Player) {
|
||||||
PlayerData data = PlayerData.get((Player) sender);
|
PlayerData data = PlayerData.get((Player) sender);
|
||||||
MMOCommandEvent event = new MMOCommandEvent(data, "skills");
|
MMOCommandEvent event = new MMOCommandEvent(data, "skills");
|
||||||
Bukkit.getServer().getPluginManager().callEvent(event);
|
Bukkit.getServer().getPluginManager().callEvent(event);
|
||||||
if(event.isCancelled()) return true;
|
if (event.isCancelled()) return true;
|
||||||
|
|
||||||
if (data.getProfess().getSkills().size() < 1) {
|
if (data.getProfess().getSkills()
|
||||||
MMOCore.plugin.configManager.getSimpleMessage("no-class-skill").send((Player) sender);
|
.stream()
|
||||||
return true;
|
.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();
|
InventoryManager.SKILL_LIST.newInventory(data).open();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user