Search in sources :

Example 21 with Permission

use of org.bukkit.permissions.Permission in project Bukkit by Bukkit.

the class DefaultPermissions method registerPermission.

public static Permission registerPermission(String name, String desc, PermissionDefault def, Permission parent) {
    Permission perm = registerPermission(name, desc, def);
    parent.getChildren().put(perm.getName(), true);
    return perm;
}
Also used : Permission(org.bukkit.permissions.Permission)

Example 22 with Permission

use of org.bukkit.permissions.Permission in project Bukkit by Bukkit.

the class PluginManagerTest method testRemovePermissionByPermission.

private void testRemovePermissionByPermission(final String name) {
    final Permission perm = new Permission(name);
    pm.addPermission(perm);
    assertThat("Permission \"" + name + "\" was not added", pm.getPermission(name), is(perm));
    pm.removePermission(perm);
    assertThat("Permission \"" + name + "\" was not removed", pm.getPermission(name), is(nullValue()));
}
Also used : Permission(org.bukkit.permissions.Permission)

Example 23 with Permission

use of org.bukkit.permissions.Permission in project MyPet by xXKeyleXx.

the class CommandOptionReloadSkilltrees method onCommandOption.

@Override
public boolean onCommandOption(CommandSender sender, String[] args) {
    SkillTreeMobType.clearMobTypes();
    String[] petTypes = new String[MyPetType.values().length + 1];
    petTypes[0] = "default";
    for (int i = 1; i <= MyPetType.values().length; i++) {
        petTypes[i] = MyPetType.values()[i - 1].name();
    }
    for (MyPet myPet : MyPetApi.getMyPetManager().getAllActiveMyPets()) {
        myPet.getSkills().reset();
    }
    SkillTreeMobType.clearMobTypes();
    SkillTreeLoaderNBT.getSkilltreeLoader().loadSkillTrees(MyPetApi.getPlugin().getDataFolder().getPath() + File.separator + "skilltrees", petTypes);
    Set<String> skilltreeNames = new LinkedHashSet<>();
    for (MyPetType mobType : MyPetType.values()) {
        SkillTreeMobType skillTreeMobType = SkillTreeMobType.byPetType(mobType);
        SkillTreeLoader.addDefault(skillTreeMobType);
        SkillTreeLoader.manageInheritance(skillTreeMobType);
        skilltreeNames.addAll(skillTreeMobType.getSkillTreeNames());
    }
    // register skilltree permissions
    for (String skilltreeName : skilltreeNames) {
        try {
            Bukkit.getPluginManager().addPermission(new Permission("MyPet.custom.skilltree." + skilltreeName));
        } catch (Exception ignored) {
        }
    }
    for (MyPet myPet : MyPetApi.getMyPetManager().getAllActiveMyPets()) {
        myPet.getSkills().reset();
        SkillTree skillTree = myPet.getSkilltree();
        if (skillTree != null) {
            String skilltreeName = skillTree.getName();
            if (SkillTreeMobType.hasMobType(myPet.getPetType())) {
                SkillTreeMobType mobType = SkillTreeMobType.byPetType(myPet.getPetType());
                if (mobType.hasSkillTree(skilltreeName)) {
                    skillTree = mobType.getSkillTree(skilltreeName);
                } else {
                    skillTree = null;
                }
            } else {
                skillTree = null;
            }
        }
        myPet.setSkilltree(skillTree);
        if (skillTree != null) {
            sender.sendMessage(Util.formatText(Translation.getString("Message.Command.Skills.Show", myPet.getOwner()), myPet.getPetName(), (myPet.getSkilltree() == null ? "-" : myPet.getSkilltree().getDisplayName())));
            for (SkillInstance skill : myPet.getSkills().getSkills()) {
                if (skill.isActive()) {
                    myPet.getOwner().sendMessage("  " + ChatColor.GREEN + skill.getName(myPet.getOwner().getLanguage()) + ChatColor.RESET + " " + skill.getFormattedValue());
                }
            }
        }
    }
    sender.sendMessage("[" + ChatColor.AQUA + "MyPet" + ChatColor.RESET + "] skilltrees loaded!");
    return true;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) SkillInstance(de.Keyle.MyPet.api.skill.SkillInstance) MyPet(de.Keyle.MyPet.api.entity.MyPet) MyPetType(de.Keyle.MyPet.api.entity.MyPetType) SkillTreeMobType(de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType) Permission(org.bukkit.permissions.Permission) SkillTree(de.Keyle.MyPet.api.skill.skilltree.SkillTree)

Aggregations

Permission (org.bukkit.permissions.Permission)23 SkillTreeMobType (de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType)2 MyPetLogger (de.Keyle.MyPet.util.logger.MyPetLogger)2 Player (org.bukkit.entity.Player)2 ConfigurationNode (com.bergerkiller.bukkit.common.config.ConfigurationNode)1 IPermissionDefault (com.bergerkiller.bukkit.common.permissions.IPermissionDefault)1 Job (com.gamingmesh.jobs.container.Job)1 JobPermission (com.gamingmesh.jobs.container.JobPermission)1 JobProgression (com.gamingmesh.jobs.container.JobProgression)1 JobsPlayer (com.gamingmesh.jobs.container.JobsPlayer)1 MyPet (de.Keyle.MyPet.api.entity.MyPet)1 MyPetType (de.Keyle.MyPet.api.entity.MyPetType)1 MyPetPlayer (de.Keyle.MyPet.api.player.MyPetPlayer)1 SkillInstance (de.Keyle.MyPet.api.skill.SkillInstance)1 SkillTree (de.Keyle.MyPet.api.skill.skilltree.SkillTree)1 SqLiteRepository (de.Keyle.MyPet.repository.types.SqLiteRepository)1 Updater (de.Keyle.MyPet.util.Updater)1 MyPetPlayerImpl (de.Keyle.MyPet.util.player.MyPetPlayerImpl)1 File (java.io.File)1 HashMap (java.util.HashMap)1