use of de.Keyle.MyPet.api.entity.MyPetType in project MyPet by xXKeyleXx.
the class CommandPetType method onCommand.
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] args) {
if (args.length < 1) {
return false;
}
String lang = "en";
if (commandSender instanceof Player) {
lang = MyPetApi.getPlatformHelper().getPlayerLanguage((Player) commandSender);
}
try {
MyPetType myPetType = MyPetType.byName(args[0]);
String leashFlagString = "";
for (LeashFlag leashFlag : MyPetApi.getMyPetInfo().getLeashFlags(myPetType)) {
leashFlagString += leashFlag.name() + ", ";
}
leashFlagString = leashFlagString.substring(0, leashFlagString.lastIndexOf(","));
commandSender.sendMessage(Translation.getString("Name.LeashFlag", lang) + ": " + leashFlagString);
String foodString = "";
for (ConfigItem material : MyPetApi.getMyPetInfo().getFood(myPetType)) {
foodString += WordUtils.capitalizeFully(MyPetApi.getPlatformHelper().getMaterialName(material.getItem().getTypeId()).replace("_", " ")) + ", ";
}
foodString = foodString.substring(0, foodString.lastIndexOf(","));
commandSender.sendMessage(Translation.getString("Name.Food", lang) + ": " + foodString);
commandSender.sendMessage(Translation.getString("Name.HP", lang) + ": " + MyPetApi.getMyPetInfo().getStartHP(myPetType));
} catch (MyPetTypeNotFoundException e) {
commandSender.sendMessage(Translation.getString("Message.Command.PetType.Unknown", lang));
}
return true;
}
use of de.Keyle.MyPet.api.entity.MyPetType 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.entity.MyPetType in project MyPet by xXKeyleXx.
the class EntityRegistry method registerEntityTypes.
@Override
@SuppressWarnings("unchecked")
public void registerEntityTypes() {
RegistryMaterials registry = getRegistry();
Object[] backup = backupRegistryID(registry);
for (MyPetType type : entityClasses.keySet()) {
try {
registry.a(type.getTypeID(), null, entityClasses.get(type));
} catch (NullPointerException ignored) {
// NPE means that the entity was registered successfully but the key was not
}
}
restoreRegistryID(registry, backup);
}
Aggregations