forked from Upstream/mmocore
Permissions for classes
This commit is contained in:
parent
dc2efdea99
commit
6df4b2e9f7
@ -60,6 +60,8 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
||||
|
||||
private final Map<PlayerResource, ResourceRegeneration> resourceHandlers = new HashMap<>();
|
||||
|
||||
private final boolean needsPermission;
|
||||
|
||||
@Deprecated
|
||||
private final Map<String, EventTrigger> 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();
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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}'
|
||||
|
@ -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}'
|
||||
|
@ -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}'
|
||||
|
@ -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}'
|
||||
|
@ -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}'
|
||||
|
@ -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}'
|
||||
|
@ -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}'
|
||||
|
@ -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.'
|
||||
|
Loading…
Reference in New Issue
Block a user