use of de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType 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;
}
use of de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType in project MyPet by xXKeyleXx.
the class CommandOptionSkilltree method onCommandOption.
@Override
public boolean onCommandOption(CommandSender sender, String[] args) {
if (args.length < 2) {
return false;
}
String lang = MyPetApi.getPlatformHelper().getCommandSenderLanguage(sender);
Player petOwner = Bukkit.getServer().getPlayer(args[0]);
if (petOwner == null || !petOwner.isOnline()) {
sender.sendMessage("[" + ChatColor.AQUA + "MyPet" + ChatColor.RESET + "] " + Translation.getString("Message.No.PlayerOnline", lang));
return true;
} else if (!MyPetApi.getMyPetManager().hasActiveMyPet(petOwner)) {
sender.sendMessage("[" + ChatColor.AQUA + "MyPet" + ChatColor.RESET + "] " + Util.formatText(Translation.getString("Message.No.UserHavePet", lang), petOwner.getName()));
return true;
}
MyPet myPet = MyPetApi.getMyPetManager().getMyPet(petOwner);
SkillTreeMobType skillTreeMobType = SkillTreeMobType.byPetType(myPet.getPetType());
if (skillTreeMobType.hasSkillTree(args[1])) {
SkillTree skillTree = skillTreeMobType.getSkillTree(args[1]);
if (myPet.setSkilltree(skillTree)) {
sender.sendMessage("[" + ChatColor.AQUA + "MyPet" + ChatColor.RESET + "] " + Util.formatText(Translation.getString("Message.Skilltree.SwitchedToFor", lang), petOwner.getName(), skillTree.getName()));
} else {
sender.sendMessage("[" + ChatColor.AQUA + "MyPet" + ChatColor.RESET + "] " + Translation.getString("Message.Skilltree.NotSwitched", lang));
}
} else {
sender.sendMessage("[" + ChatColor.AQUA + "MyPet" + ChatColor.RESET + "] " + Util.formatText(Translation.getString("Message.Command.Skilltree.CantFindSkilltree", lang), args[1]));
}
return true;
}
use of de.Keyle.MyPet.api.skill.skilltree.SkillTreeMobType in project MyPet by xXKeyleXx.
the class InactiveMyPet method load.
@Override
public void load(TagCompound myPetNBT) {
if (myPetNBT.getCompoundData().containsKey("UUID")) {
uuid = UUID.fromString(myPetNBT.getAs("UUID", TagString.class).getStringData());
}
exp = myPetNBT.getAs("Exp", TagDouble.class).getDoubleData();
if (myPetNBT.containsKeyAs("Health", TagInt.class)) {
health = myPetNBT.getAs("Health", TagInt.class).getIntData();
} else if (myPetNBT.containsKeyAs("Health", TagDouble.class)) {
health = myPetNBT.getAs("Health", TagDouble.class).getDoubleData();
}
respawnTime = myPetNBT.getAs("Respawntime", TagInt.class).getIntData();
petName = myPetNBT.getAs("Name", TagString.class).getStringData();
if (myPetNBT.getCompoundData().containsKey("Type")) {
petType = MyPetType.valueOf(myPetNBT.getAs("Type", TagString.class).getStringData());
}
if (myPetNBT.getCompoundData().containsKey("LastUsed")) {
lastUsed = myPetNBT.getAs("LastUsed", TagLong.class).getLongData();
}
if (myPetNBT.getCompoundData().containsKey("Skilltree")) {
String skillTreeName = myPetNBT.getAs("Skilltree", TagString.class).getStringData();
if (skillTreeName != null) {
if (SkillTreeMobType.byPetType(petType) != null) {
SkillTreeMobType mobType = SkillTreeMobType.byPetType(petType);
if (mobType.hasSkillTree(skillTreeName)) {
this.skillTree = mobType.getSkillTree(skillTreeName);
}
}
}
}
if (myPetNBT.containsKeyAs("Hunger", TagInt.class)) {
saturation = myPetNBT.getAs("Hunger", TagInt.class).getIntData();
} else if (myPetNBT.containsKeyAs("Hunger", TagDouble.class)) {
saturation = myPetNBT.getAs("Hunger", TagDouble.class).getDoubleData();
}
if (myPetNBT.getCompoundData().containsKey("WorldGroup")) {
worldGroup = myPetNBT.getAs("WorldGroup", TagString.class).getStringData();
}
if (myPetNBT.getCompoundData().containsKey("Wants-To-Respawn")) {
wantsToRespawn = myPetNBT.getAs("Wants-To-Respawn", TagByte.class).getBooleanData();
}
setSkills(myPetNBT.getAs("Skills", TagCompound.class));
setInfo(myPetNBT.getAs("Info", TagCompound.class));
}
Aggregations