Fixed issue #788.

This commit is contained in:
Ka0rX 2023-04-16 20:09:35 +01:00
parent 4de49070a0
commit 048ed1364d

View File

@ -4,6 +4,7 @@ import io.lumine.mythic.lib.MythicLib;
import io.lumine.mythic.lib.UtilityMethods; import io.lumine.mythic.lib.UtilityMethods;
import net.Indyuce.mmocore.MMOCore; import net.Indyuce.mmocore.MMOCore;
import net.Indyuce.mmocore.api.player.PlayerData; import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.profess.ClassOption;
import net.Indyuce.mmocore.gui.api.EditableInventory; import net.Indyuce.mmocore.gui.api.EditableInventory;
import net.Indyuce.mmocore.gui.api.GeneratedInventory; import net.Indyuce.mmocore.gui.api.GeneratedInventory;
import net.Indyuce.mmocore.gui.api.InventoryClickContext; import net.Indyuce.mmocore.gui.api.InventoryClickContext;
@ -112,13 +113,18 @@ public class SubclassSelect extends EditableInventory {
if (item.getFunction().startsWith("sub-class")) { if (item.getFunction().startsWith("sub-class")) {
String classId = item.getFunction().substring(10); String classId = item.getFunction().substring(10);
PlayerClass profess = MMOCore.plugin.classManager.get(classId);
if (playerData.getClassPoints() < 1) { if (playerData.getClassPoints() < 1) {
player.closeInventory(); player.closeInventory();
MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(getPlayer()); MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(getPlayer());
new ConfigMessage("cant-choose-new-class").send(player); new ConfigMessage("cant-choose-new-class").send(player);
return; return;
} }
if (profess.hasOption(ClassOption.NEEDS_PERMISSION) && !player.hasPermission("mmocore.class." + profess.getId().toLowerCase())) {
MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(player);
new ConfigMessage("no-permission-for-class").send(player);
return;
}
InventoryManager.CLASS_CONFIRM.get(classId).newInventory(playerData, this, true).open(); InventoryManager.CLASS_CONFIRM.get(classId).newInventory(playerData, this, true).open();
} }