diff --git a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java index 765b54e5..5be54c20 100644 --- a/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java +++ b/src/main/java/net/Indyuce/mmocore/api/player/profess/PlayerClass.java @@ -60,6 +60,8 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { private final Map resourceHandlers = new HashMap<>(); + private final boolean needsPermission; + @Deprecated private final Map eventTriggers = new HashMap<>(); @@ -166,6 +168,8 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { } } + needsPermission =config.contains("needs-permission")?config.getBoolean("needs-permission"):false; + /* * Must make sure all the resourceHandlers are registered * when the placer class is initialized. @@ -205,7 +209,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { expTable = null; castParticle = new CastingParticle(Particle.SPELL_INSTANT); actionBarFormat = ""; - + needsPermission =false; this.icon = new ItemStack(material); setOption(ClassOption.DISPLAY, false); setOption(ClassOption.DEFAULT, false); @@ -275,6 +279,10 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject { return expTable != null; } + public boolean needsPermission() { + return needsPermission; + } + public ItemStack getIcon() { return icon.clone(); } diff --git a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java index da5d505a..80ffed86 100644 --- a/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java +++ b/src/main/java/net/Indyuce/mmocore/gui/ClassSelect.java @@ -82,6 +82,7 @@ public class ClassSelect extends EditableInventory { lore.add(index + j, profess.getAttributeDescription().get(j)); } + meta.setLore(lore); item.setItemMeta(meta); return NBTItem.get(item).addTag(new ItemTag("classId", profess.getId())).toItem(); @@ -115,6 +116,12 @@ public class ClassSelect extends EditableInventory { } PlayerClass profess = MMOCore.plugin.classManager.get(tag); + if(profess.needsPermission()&&!player.hasPermission("mmocore.class."+profess.getName().toLowerCase())) { + MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(player); + new ConfigMessage("no-permission-for-class").send(player); + return; + } + if (profess.equals(playerData.getProfess())) { MMOCore.plugin.soundManager.getSound(SoundEvent.CANT_SELECT_CLASS).playTo(player); MMOCore.plugin.configManager.getSimpleMessage("already-on-class", "class", profess.getName()).send(player); diff --git a/src/main/resources/default/classes/arcane-mage.yml b/src/main/resources/default/classes/arcane-mage.yml index 2ecd420a..1236f2c5 100644 --- a/src/main/resources/default/classes/arcane-mage.yml +++ b/src/main/resources/default/classes/arcane-mage.yml @@ -99,6 +99,9 @@ skills: level: 15 max-level: 30 +#If true the player will need to have the mmocore.class.{class_name} permission +needs-permission: false + # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/human.yml b/src/main/resources/default/classes/human.yml index dc27e6d8..a570a890 100644 --- a/src/main/resources/default/classes/human.yml +++ b/src/main/resources/default/classes/human.yml @@ -19,6 +19,11 @@ options: # Must match an existing exp curve filename from the 'expcurves' folder exp-curve: levels + +#If true the player will need to have the mmocore.class.{class_name} permission +needs-permission: false + + # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/mage.yml b/src/main/resources/default/classes/mage.yml index 40de28fa..25448b53 100644 --- a/src/main/resources/default/classes/mage.yml +++ b/src/main/resources/default/classes/mage.yml @@ -139,6 +139,11 @@ skills: level: 15 max-level: 30 + +#If true the player will need to have the mmocore.class.{class_name} permission +needs-permission: false + + # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/marksman.yml b/src/main/resources/default/classes/marksman.yml index 53c174bb..6839af0f 100644 --- a/src/main/resources/default/classes/marksman.yml +++ b/src/main/resources/default/classes/marksman.yml @@ -85,6 +85,11 @@ attributes: base: .105 per-level: 0 + +#If true the player will need to have the mmocore.class.{class_name} permission +needs-permission: false + + # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/paladin.yml b/src/main/resources/default/classes/paladin.yml index 1914e23b..b60418f6 100644 --- a/src/main/resources/default/classes/paladin.yml +++ b/src/main/resources/default/classes/paladin.yml @@ -75,6 +75,11 @@ attributes: base: .095 per-level: 0 + +#If true the player will need to have the mmocore.class.{class_name} permission +needs-permission: false + + # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/rogue.yml b/src/main/resources/default/classes/rogue.yml index d22d3ce1..62f23276 100644 --- a/src/main/resources/default/classes/rogue.yml +++ b/src/main/resources/default/classes/rogue.yml @@ -78,6 +78,11 @@ attributes: base: .105 per-level: 0 + + +#If true the player will need to have the mmocore.class.{class_name} permission +needs-permission: false + # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/classes/warrior.yml b/src/main/resources/default/classes/warrior.yml index bf127b0f..12e8a92d 100644 --- a/src/main/resources/default/classes/warrior.yml +++ b/src/main/resources/default/classes/warrior.yml @@ -115,6 +115,10 @@ attributes: base: 4.2 per-level: 0.05 + +#If true the player will need to have the mmocore.class.{class_name} permission +needs-permission: false + # Experience sources for main class experience. main-exp-sources: - 'killmob{type=ZOMBIE;amount=1-3}' diff --git a/src/main/resources/default/messages.yml b/src/main/resources/default/messages.yml index ee0499a6..0da94fa8 100644 --- a/src/main/resources/default/messages.yml +++ b/src/main/resources/default/messages.yml @@ -152,7 +152,8 @@ start-quest: '&eYou successfully started &6{quest}&e.' cant-choose-new-class: - '&cYou need one class point to perform this action.' - +no-permission-for-class: +- "&cYou don't have the permission to choose this class." # Attributes no-attribute-points-spent: '&cYou have not spent any attribute points.' not-attribute-reallocation-point: '&cYou do not have 1 reallocation point.'