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;
}
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()));
}
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;
}
Aggregations