mirror of
https://gitlab.com/phoenix-dvpmt/mmocore.git
synced 2025-01-11 07:57:45 +01:00
Class option for class permission
This commit is contained in:
parent
0121c5d106
commit
7d2d8a59b2
@ -2,51 +2,57 @@ package net.Indyuce.mmocore.api.player.profess;
|
||||
|
||||
public enum ClassOption {
|
||||
|
||||
/**
|
||||
* If the class should be applied to newcomers
|
||||
*/
|
||||
DEFAULT,
|
||||
/**
|
||||
* If the class should be applied to newcomers
|
||||
*/
|
||||
DEFAULT,
|
||||
|
||||
/**
|
||||
* If the class should in the /class GUI
|
||||
*/
|
||||
DISPLAY(true),
|
||||
/**
|
||||
* When set to true any player has to have the
|
||||
* mmocore.class.lower_case_name permission to use the class
|
||||
*/
|
||||
NEEDS_PERMISSION,
|
||||
|
||||
/**
|
||||
* Health only regens when out of combat
|
||||
*/
|
||||
OFF_COMBAT_HEALTH_REGEN,
|
||||
/**
|
||||
* If the class should in the /class GUI
|
||||
*/
|
||||
DISPLAY(true),
|
||||
|
||||
/**
|
||||
* Mana only regens when out of combat
|
||||
*/
|
||||
OFF_COMBAT_MANA_REGEN,
|
||||
/**
|
||||
* Health only regens when out of combat
|
||||
*/
|
||||
OFF_COMBAT_HEALTH_REGEN,
|
||||
|
||||
/**
|
||||
* Stamina only regens when out of combat
|
||||
*/
|
||||
OFF_COMBAT_STAMINA_REGEN,
|
||||
/**
|
||||
* Mana only regens when out of combat
|
||||
*/
|
||||
OFF_COMBAT_MANA_REGEN,
|
||||
|
||||
/**
|
||||
* Stellium only regens when out of combat
|
||||
*/
|
||||
OFF_COMBAT_STELLIUM_REGEN;
|
||||
/**
|
||||
* Stamina only regens when out of combat
|
||||
*/
|
||||
OFF_COMBAT_STAMINA_REGEN,
|
||||
|
||||
private final boolean def;
|
||||
/**
|
||||
* Stellium only regens when out of combat
|
||||
*/
|
||||
OFF_COMBAT_STELLIUM_REGEN;
|
||||
|
||||
ClassOption() {
|
||||
this(false);
|
||||
}
|
||||
private final boolean def;
|
||||
|
||||
ClassOption(boolean def) {
|
||||
this.def = def;
|
||||
}
|
||||
ClassOption() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
public boolean getDefault() {
|
||||
return def;
|
||||
}
|
||||
ClassOption(boolean def) {
|
||||
this.def = def;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return name().toLowerCase().replace("_", "-");
|
||||
}
|
||||
public boolean getDefault() {
|
||||
return def;
|
||||
}
|
||||
|
||||
public String getPath() {
|
||||
return name().toLowerCase().replace("_", "-");
|
||||
}
|
||||
}
|
@ -60,8 +60,6 @@ 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<>();
|
||||
|
||||
@ -168,8 +166,6 @@ 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.
|
||||
@ -209,7 +205,6 @@ 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);
|
||||
@ -279,10 +274,6 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
||||
return expTable != null;
|
||||
}
|
||||
|
||||
public boolean needsPermission() {
|
||||
return needsPermission;
|
||||
}
|
||||
|
||||
public ItemStack getIcon() {
|
||||
return icon.clone();
|
||||
}
|
||||
@ -304,7 +295,7 @@ public class PlayerClass extends PostLoadObject implements ExperienceObject {
|
||||
}
|
||||
|
||||
public boolean hasOption(ClassOption option) {
|
||||
return options.containsKey(option) ? options.get(option) : option.getDefault();
|
||||
return options.getOrDefault(option, option.getDefault());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -4,16 +4,16 @@ import io.lumine.mythic.lib.MythicLib;
|
||||
import io.lumine.mythic.lib.api.item.ItemTag;
|
||||
import io.lumine.mythic.lib.api.item.NBTItem;
|
||||
import net.Indyuce.mmocore.MMOCore;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
||||
import net.Indyuce.mmocore.api.player.profess.PlayerClass;
|
||||
import net.Indyuce.mmocore.gui.api.EditableInventory;
|
||||
import net.Indyuce.mmocore.gui.api.GeneratedInventory;
|
||||
import net.Indyuce.mmocore.gui.api.item.InventoryItem;
|
||||
import net.Indyuce.mmocore.gui.api.item.SimplePlaceholderItem;
|
||||
import net.Indyuce.mmocore.manager.InventoryManager;
|
||||
import net.Indyuce.mmocore.api.ConfigMessage;
|
||||
import net.Indyuce.mmocore.api.SoundEvent;
|
||||
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||
import net.Indyuce.mmocore.api.player.profess.ClassOption;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
@ -116,7 +116,7 @@ public class ClassSelect extends EditableInventory {
|
||||
}
|
||||
|
||||
PlayerClass profess = MMOCore.plugin.classManager.get(tag);
|
||||
if(profess.needsPermission()&&!player.hasPermission("mmocore.class."+profess.getName().toLowerCase())) {
|
||||
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;
|
||||
|
Loading…
Reference in New Issue
Block a user