use of de.Keyle.MyPet.api.gui.IconMenu in project MyPet by xXKeyleXx.
the class Beacon method activate.
public boolean activate() {
final Player owner = myPet.getOwner().getPlayer();
final Beacon beacon = this;
String title = RESET + Translation.getString("Name.Skill.Beacon", myPet.getOwner());
IconMenu menu = new IconMenu(title, new IconMenu.OptionClickEventHandler() {
List<Integer> selectedBuffs = new ArrayList<>(beacon.selectedBuffs);
boolean active = beacon.active;
private BeaconReceiver receiver = beacon.receiver;
@Override
public void onOptionClick(IconMenu.OptionClickEvent event) {
event.setWillClose(false);
event.setWillDestroy(false);
if (getMyPet().getStatus() != MyPet.PetState.Here) {
return;
}
IconMenu menu = event.getMenu();
switch(event.getPosition()) {
case 5:
event.setWillClose(true);
event.setWillDestroy(true);
return;
case 4:
if (active) {
menu.getOption(4).setMaterial(REDSTONE_BLOCK).setTitle(Util.formatText(Translation.getString("Message.Skill.Beacon.Effect", myPet.getOwner().getLanguage()), RED + Translation.getString("Name.Off", myPet.getOwner().getLanguage()))).setLore(RESET + Translation.getString("Message.Skill.Beacon.ClickOn", myPet.getOwner().getLanguage()));
active = false;
} else {
menu.getOption(4).setMaterial(EMERALD_BLOCK).setTitle(Util.formatText(Translation.getString("Message.Skill.Beacon.Effect", myPet.getOwner().getLanguage()), GREEN + Translation.getString("Name.On", myPet.getOwner().getLanguage()))).setLore(RESET + Translation.getString("Message.Skill.Beacon.ClickOff", myPet.getOwner().getLanguage()));
active = true;
}
menu.update();
break;
case 3:
beacon.active = active;
beacon.selectedBuffs.clear();
beacon.selectedBuffs.addAll(selectedBuffs);
beacon.receiver = receiver;
event.setWillClose(true);
event.setWillDestroy(true);
break;
case 21:
if (receiver != BeaconReceiver.Owner) {
menu.getOption(21).setMeta(ownerMeta, false, false);
if (menu.getOption(22) != null) {
menu.getOption(22).setMeta(partyMeta);
}
menu.getOption(23).setMeta(disabledMeta);
receiver = BeaconReceiver.Owner;
menu.update();
}
break;
case 22:
if (receiver != BeaconReceiver.Party) {
menu.getOption(21).setMeta(disabledMeta);
menu.getOption(22).setMeta(partyMeta);
menu.getOption(23).setMeta(disabledMeta);
receiver = BeaconReceiver.Party;
menu.update();
}
break;
case 23:
if (receiver != BeaconReceiver.Everyone) {
menu.getOption(21).setMeta(disabledMeta);
if (menu.getOption(22) != null) {
menu.getOption(22).setMeta(disabledMeta);
}
menu.getOption(23).setMeta(everyoneMeta);
receiver = BeaconReceiver.Everyone;
menu.update();
}
break;
default:
if (buffPositionItems.containsKey(event.getPosition())) {
int selectedBuff = buffPositionItems.get(event.getPosition());
if (selectableBuffs > 1) {
if (selectedBuffs.indexOf(selectedBuff) != -1) {
selectedBuffs.remove(selectedBuffs.indexOf(selectedBuff));
menu.getOption(buffItemPositions.get(selectedBuff)).setGlowing(false);
if (selectableBuffs > selectedBuffs.size()) {
menu.setOption(13, new IconMenuItem().setMaterial(POTION).setTitle(BLUE + Util.formatText(Translation.getString("Message.Skill.Beacon.RemainingBuffs", myPet.getOwner().getLanguage()), selectableBuffs - selectedBuffs.size())).setAmount(selectableBuffs - selectedBuffs.size()));
} else {
menu.setOption(13, new IconMenuItem().setMaterial(GLASS_BOTTLE).setTitle(GRAY + Util.formatText(Translation.getString("Message.Skill.Beacon.RemainingBuffs", myPet.getOwner().getLanguage()), 0)));
}
menu.update();
} else if (selectableBuffs > selectedBuffs.size()) {
selectedBuffs.add(selectedBuff);
menu.getOption(buffItemPositions.get(selectedBuff)).setGlowing(true);
if (selectableBuffs > selectedBuffs.size()) {
menu.setOption(13, new IconMenuItem().setMaterial(POTION).setTitle(BLUE + Util.formatText(Translation.getString("Message.Skill.Beacon.RemainingBuffs", myPet.getOwner().getLanguage()), selectableBuffs - selectedBuffs.size())).setAmount(selectableBuffs - selectedBuffs.size()));
} else {
menu.setOption(13, new IconMenuItem().setMaterial(GLASS_BOTTLE).setTitle(GRAY + Util.formatText(Translation.getString("Message.Skill.Beacon.RemainingBuffs", myPet.getOwner().getLanguage()), 0)));
}
menu.update();
} else {
break;
}
if (selectableBuffs > selectedBuffs.size()) {
menu.setOption(13, new IconMenuItem().setMaterial(POTION).setTitle(BLUE + Util.formatText(Translation.getString("Message.Skill.Beacon.RemainingBuffs", myPet.getOwner().getLanguage()), selectableBuffs - selectedBuffs.size())).setAmount(selectableBuffs - selectedBuffs.size()));
} else {
menu.setOption(13, new IconMenuItem().setMaterial(GLASS_BOTTLE).setTitle(GRAY + Util.formatText(Translation.getString("Message.Skill.Beacon.RemainingBuffs", myPet.getOwner().getLanguage()), 0)));
}
} else {
if (!selectedBuffs.contains(selectedBuff)) {
if (selectedBuffs.size() != 0 && menu.getOption(buffItemPositions.get(selectedBuff)) != null) {
menu.getOption(buffItemPositions.get(selectedBuffs.get(0))).setGlowing(false);
selectedBuffs.clear();
}
selectedBuffs.add(selectedBuff);
menu.getOption(buffItemPositions.get(selectedBuff)).setGlowing(true);
menu.update();
}
}
}
}
}
}, MyPetApi.getPlugin());
if (beacon.active) {
menu.setOption(4, new IconMenuItem().setMaterial(EMERALD_BLOCK).setTitle(Util.formatText(Translation.getString("Message.Skill.Beacon.Effect", myPet.getOwner().getLanguage()), GREEN + Translation.getString("Name.On", myPet.getOwner().getLanguage()))).addLoreLine(RESET + Translation.getString("Message.Skill.Beacon.ClickOff", myPet.getOwner().getLanguage())));
} else {
menu.setOption(4, new IconMenuItem().setMaterial(REDSTONE_BLOCK).setTitle(Util.formatText(Translation.getString("Message.Skill.Beacon.Effect", myPet.getOwner().getLanguage()), RED + Translation.getString("Name.Off", myPet.getOwner().getLanguage()))).addLoreLine(RESET + Translation.getString("Message.Skill.Beacon.ClickOn", myPet.getOwner().getLanguage())));
}
menu.setOption(3, new IconMenuItem().setMaterial(STAINED_GLASS_PANE).setData(5).setTitle(GREEN + Translation.getString("Name.Done", myPet.getOwner().getLanguage())));
menu.setOption(5, new IconMenuItem().setMaterial(STAINED_GLASS_PANE).setData(14).setTitle(RED + Translation.getString("Name.Cancel", myPet.getOwner().getLanguage())));
if (receiver == BeaconReceiver.Owner) {
menu.setOption(21, new IconMenuItem().setMaterial(SKULL_ITEM).setData(3).setTitle(GOLD + Translation.getString("Name.Owner", myPet.getOwner().getLanguage())).setMeta(ownerMeta, false, false));
} else {
menu.setOption(21, new IconMenuItem().setMaterial(SKULL_ITEM).setData(3).setTitle(GOLD + Translation.getString("Name.Owner", myPet.getOwner().getLanguage())).setMeta(disabledMeta));
}
if (Configuration.Skilltree.Skill.Beacon.PARTY_SUPPORT && MyPetApi.getHookHelper().isInParty(getMyPet().getOwner().getPlayer())) {
if (receiver != BeaconReceiver.Party) {
menu.setOption(22, new IconMenuItem().setMaterial(SKULL_ITEM).setData(3).setTitle(GOLD + Translation.getString("Name.Party", myPet.getOwner().getLanguage())).setMeta(partyMeta));
} else {
menu.setOption(22, new IconMenuItem().setMaterial(SKULL_ITEM).setData(3).setTitle(GOLD + Translation.getString("Name.Party", myPet.getOwner().getLanguage())).setMeta(disabledMeta));
}
}
if (receiver == BeaconReceiver.Everyone) {
menu.setOption(23, new IconMenuItem().setMaterial(SKULL_ITEM).setData(3).setTitle(GOLD + Translation.getString("Name.Everyone", myPet.getOwner().getLanguage())).setMeta(everyoneMeta));
} else {
menu.setOption(23, new IconMenuItem().setMaterial(SKULL_ITEM).setData(3).setTitle(GOLD + Translation.getString("Name.Everyone", myPet.getOwner().getLanguage())).setMeta(disabledMeta));
}
if (buffLevel.get(1) > 0) {
menu.setOption(0, new IconMenuItem().setMaterial(LEATHER_BOOTS).setAmount(buffLevel.get(1)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(1), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(1))));
}
if (buffLevel.get(3) > 0) {
menu.setOption(9, new IconMenuItem().setMaterial(GOLD_PICKAXE).setAmount(buffLevel.get(3)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(3), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(3))));
}
if (buffLevel.get(5) > 0) {
menu.setOption(18, new IconMenuItem().setMaterial(DIAMOND_SWORD).setAmount(buffLevel.get(5)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(5), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(5))));
}
if (buffLevel.get(8) > 0) {
menu.setOption(1, new IconMenuItem().setMaterial(FIREWORK).setAmount(buffLevel.get(8)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(8), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(8))));
}
if (buffLevel.get(10) > 0) {
menu.setOption(10, new IconMenuItem().setMaterial(APPLE).setAmount(buffLevel.get(10)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(10), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(10))));
}
if (buffLevel.get(11) > 0) {
menu.setOption(19, new IconMenuItem().setMaterial(DIAMOND_CHESTPLATE).setAmount(buffLevel.get(11)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(11), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(11))));
}
if (buffLevel.get(12) > 0) {
menu.setOption(7, new IconMenuItem().setMaterial(LAVA_BUCKET).setAmount(buffLevel.get(12)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(12), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(12))));
}
if (buffLevel.get(13) > 0) {
menu.setOption(16, new IconMenuItem().setMaterial(RAW_FISH).setAmount(buffLevel.get(13)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(13), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(13))));
}
if (buffLevel.get(14) > 0) {
menu.setOption(25, new IconMenuItem().setMaterial(EYE_OF_ENDER).setAmount(buffLevel.get(14)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(14), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(14))));
}
if (buffLevel.get(16) > 0) {
menu.setOption(8, new IconMenuItem().setMaterial(TORCH).setAmount(buffLevel.get(16)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(16), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(16))));
}
if (MyPetApi.getCompatUtil().compareWithMinecraftVersion("1.9") >= 0) {
if (buffLevel.get(26) > 0) {
menu.setOption(17, new IconMenuItem().setMaterial(DIAMOND).setAmount(buffLevel.get(26)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(26), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(26))));
}
}
/*
if (buffLevel.get(21) > 0) {
menu.setOption(17, new IconMenuItem().setMaterial(GOLDEN_APPLE).setAmount(buffLevel.get(21)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(21), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(21))));
}
*/
if (buffLevel.get(22) > 0) {
menu.setOption(26, new IconMenuItem().setMaterial(SPONGE).setAmount(buffLevel.get(22)).setTitle(GOLD + Translation.getString("Name." + buffNames.get(22), myPet.getOwner().getLanguage()) + GRAY + " " + Util.decimal2roman(buffLevel.get(22))));
}
Iterator<Integer> iterator = selectedBuffs.iterator();
while (iterator.hasNext()) {
int buff = iterator.next();
if (buffLevel.containsKey(buff) && buffLevel.get(buff) > 0) {
menu.getOption(buffItemPositions.get(buff)).setGlowing(true);
} else {
iterator.remove();
}
}
if (selectableBuffs > 1) {
if (selectableBuffs > selectedBuffs.size()) {
menu.setOption(13, new IconMenuItem().setMaterial(POTION).setTitle(BLUE + Util.formatText(Translation.getString("Message.Skill.Beacon.RemainingBuffs", myPet.getOwner().getLanguage()), selectableBuffs - selectedBuffs.size())).setAmount(selectableBuffs - selectedBuffs.size()));
} else {
menu.setOption(13, new IconMenuItem().setMaterial(GLASS_BOTTLE).setTitle(GRAY + Util.formatText(Translation.getString("Message.Skill.Beacon.RemainingBuffs", myPet.getOwner().getLanguage()), 0)));
}
}
menu.open(owner);
return true;
}
use of de.Keyle.MyPet.api.gui.IconMenu in project MyPet by xXKeyleXx.
the class CommandChooseSkilltree method onCommand.
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (!(sender instanceof Player)) {
sender.sendMessage("You can't use this command from server console!");
return true;
}
Player player = (Player) sender;
if (MyPetApi.getMyPetManager().hasActiveMyPet(player)) {
final MyPet myPet = MyPetApi.getMyPetManager().getMyPet(player);
final MyPetPlayer myPetOwner = myPet.getOwner();
if (Configuration.Skilltree.AUTOMATIC_SKILLTREE_ASSIGNMENT && !myPet.getOwner().isMyPetAdmin()) {
myPet.autoAssignSkilltree();
sender.sendMessage(Translation.getString("Message.Command.ChooseSkilltree.AutomaticSkilltreeAssignment", myPet.getOwner().getLanguage()));
} else if (myPet.getSkilltree() != null && Configuration.Skilltree.CHOOSE_SKILLTREE_ONLY_ONCE && !myPet.getOwner().isMyPetAdmin()) {
sender.sendMessage(Util.formatText(Translation.getString("Message.Command.ChooseSkilltree.OnlyOnce", myPet.getOwner().getLanguage()), myPet.getPetName()));
} else if (SkillTreeMobType.hasMobType(myPet.getPetType())) {
SkillTreeMobType skillTreeMobType = SkillTreeMobType.byPetType(myPet.getPetType());
if (args.length >= 1) {
String skilltreeName = "";
for (String arg : args) {
skilltreeName += arg + " ";
}
skilltreeName = skilltreeName.substring(0, skilltreeName.length() - 1);
if (skillTreeMobType.hasSkillTree(skilltreeName)) {
SkillTree skillTree = skillTreeMobType.getSkillTree(skilltreeName);
if (Permissions.hasLegacy(player, "MyPet.skilltree.", skillTree.getPermission())) {
int requiredLevel = skillTree.getRequiredLevel();
if (requiredLevel > 1 && myPet.getExperience().getLevel() < requiredLevel) {
myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Skilltree.RequiresLevel.Message", player), myPet.getPetName(), requiredLevel));
} else if (myPet.setSkilltree(skillTree)) {
sender.sendMessage(Util.formatText(Translation.getString("Message.Skilltree.SwitchedTo", player), skillTree.getName()));
if (!myPet.getOwner().isMyPetAdmin() || Configuration.Skilltree.SWITCH_FEE_ADMIN) {
double switchPenalty = Configuration.Skilltree.SWITCH_FEE_FIXED;
switchPenalty += myPet.getExperience().getExp() * Configuration.Skilltree.SWITCH_FEE_PERCENT / 100.;
if (requiredLevel > 1) {
double minExp = myPet.getExperience().getExpByLevel(requiredLevel);
switchPenalty = myPet.getExp() - switchPenalty < minExp ? myPet.getExp() - minExp : switchPenalty;
}
myPet.getExperience().removeExp(switchPenalty);
}
} else {
sender.sendMessage(Translation.getString("Message.Skilltree.NotSwitched", player));
}
} else {
sender.sendMessage(Util.formatText(Translation.getString("Message.Command.Skilltree.CantFindSkilltree", player), skilltreeName));
}
} else {
sender.sendMessage(Util.formatText(Translation.getString("Message.Command.Skilltree.CantFindSkilltree", player), skilltreeName));
}
} else {
List<SkillTree> availableSkilltrees = new ArrayList<>();
for (SkillTree skillTree : skillTreeMobType.getSkillTrees()) {
if (Permissions.hasLegacy(player, "MyPet.skilltree.", skillTree.getPermission())) {
availableSkilltrees.add(skillTree);
}
}
if (availableSkilltrees.size() == 0) {
sender.sendMessage(Util.formatText(Translation.getString("Message.Command.ChooseSkilltree.NoneAvailable", player), myPet.getPetName()));
return true;
}
final Map<Integer, SkillTree> skilltreeSlotMap = new HashMap<>();
IconMenu menu = new IconMenu(Util.cutString(Util.formatText(Translation.getString("Message.Skilltree.Available", myPetOwner), myPet.getPetName()), 32), new IconMenu.OptionClickEventHandler() {
@Override
public void onOptionClick(IconMenu.OptionClickEvent event) {
if (myPet != myPetOwner.getMyPet()) {
event.setWillClose(true);
event.setWillDestroy(true);
return;
}
if (skilltreeSlotMap.containsKey(event.getPosition())) {
SkillTree selecedSkilltree = skilltreeSlotMap.get(event.getPosition());
if (selecedSkilltree != null) {
int requiredLevel = selecedSkilltree.getRequiredLevel();
if (requiredLevel > 1 && myPet.getExperience().getLevel() < requiredLevel) {
myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Skilltree.RequiresLevel.Message", myPetOwner), myPet.getPetName(), requiredLevel));
} else if (myPet.setSkilltree(selecedSkilltree)) {
myPet.getOwner().sendMessage(Util.formatText(Translation.getString("Message.Skilltree.SwitchedTo", myPetOwner), selecedSkilltree.getName()));
if (!myPet.getOwner().isMyPetAdmin() || Configuration.Skilltree.SWITCH_FEE_ADMIN) {
double switchPenalty = Configuration.Skilltree.SWITCH_FEE_FIXED;
switchPenalty += myPet.getExperience().getExp() * Configuration.Skilltree.SWITCH_FEE_PERCENT / 100.;
if (requiredLevel > 1) {
double minExp = myPet.getExperience().getExpByLevel(requiredLevel);
switchPenalty = myPet.getExp() - switchPenalty < minExp ? myPet.getExp() - minExp : switchPenalty;
}
myPet.getExperience().removeExp(switchPenalty);
}
} else {
myPet.getOwner().sendMessage(Translation.getString("Message.Skilltree.NotSwitched", myPetOwner));
}
}
}
event.setWillClose(true);
event.setWillDestroy(true);
}
}, MyPetApi.getPlugin());
for (int i = 0; i < availableSkilltrees.size(); i++) {
SkillTree addedSkilltree = availableSkilltrees.get(i);
TagCompound tag = addedSkilltree.getIconItem();
IconMenuItem option = IconMenuItem.fromTagCompund(tag);
option.setTitle(ChatColor.RESET + "❱❱❱ " + ChatColor.DARK_GREEN + Colorizer.setColors(addedSkilltree.getDisplayName()) + ChatColor.RESET + " ❰❰❰");
boolean selectable = false;
int requiredLevel = addedSkilltree.getRequiredLevel();
if (requiredLevel > 1) {
selectable = myPet.getExperience().getLevel() >= addedSkilltree.getRequiredLevel();
}
List<String> description = new ArrayList<>();
if (requiredLevel > 1) {
String reqLevelMessage = ChatColor.RESET + "▶▶▶ ";
if (selectable) {
reqLevelMessage += ChatColor.GREEN;
} else {
reqLevelMessage += ChatColor.DARK_RED;
}
reqLevelMessage += Util.formatText(Translation.getString("Message.Skilltree.RequiresLevel.Item", myPetOwner), requiredLevel) + ChatColor.RESET + " ◀◀◀";
description.add(reqLevelMessage);
}
for (String line : addedSkilltree.getDescription()) {
description.add(Colorizer.setColors(line));
}
option.addLore(description);
menu.setOption(i, option);
skilltreeSlotMap.put(i, addedSkilltree);
}
menu.open(player);
}
}
} else {
sender.sendMessage(Translation.getString("Message.No.HasPet", player));
}
return true;
}
use of de.Keyle.MyPet.api.gui.IconMenu in project MyPet by xXKeyleXx.
the class MyPetSelectionGui method open.
public void open(final List<StoredMyPet> pets, int page, final RepositoryCallback<StoredMyPet> callback) {
if (pets.size() > 0) {
if (page < 1 || Math.ceil(pets.size() / 45.) < page) {
page = 1;
}
final Map<Integer, StoredMyPet> petSlotList = new HashMap<>();
WorldGroup wg = WorldGroup.getGroupByWorld(player.getPlayer().getWorld().getName());
Iterator<StoredMyPet> iterator = pets.iterator();
while (iterator.hasNext()) {
StoredMyPet mypet = iterator.next();
if (mypet.getWorldGroup().equals("") || !mypet.getWorldGroup().equals(wg.getName())) {
iterator.remove();
}
if (player.hasMyPet() && player.getMyPet().getUUID().equals(mypet.getUUID())) {
iterator.remove();
}
}
final int previousPage = page == 1 ? (int) Math.ceil(pets.size() / 45.) : page - 1;
final int nextPage = page == Math.ceil(pets.size() / 45.) ? 1 : page + 1;
IconMenu menu = new IconMenu(title, new IconMenu.OptionClickEventHandler() {
@Override
public void onOptionClick(IconMenu.OptionClickEvent event) {
if (event.getPosition() == 45) {
new BukkitRunnable() {
@Override
public void run() {
open(pets, previousPage, callback);
}
}.runTaskLater(MyPetApi.getPlugin(), 1L);
} else if (event.getPosition() == 53) {
new BukkitRunnable() {
@Override
public void run() {
open(pets, nextPage, callback);
}
}.runTaskLater(MyPetApi.getPlugin(), 1L);
} else if (event.getPosition() > 45) {
return;
} else if (petSlotList.containsKey(event.getPosition())) {
StoredMyPet storedMyPet = petSlotList.get(event.getPosition());
if (storedMyPet != null && callback != null) {
callback.callback(storedMyPet);
}
}
event.setWillClose(true);
event.setWillDestroy(true);
}
}, MyPetApi.getPlugin());
int pagePets = pets.size() - (page - 1) * 45;
for (int i = 0; i < pagePets && i <= 45; i++) {
StoredMyPet mypet = pets.get(i + ((page - 1) * 45));
List<String> lore = new ArrayList<>();
lore.add(RESET + Translation.getString("Name.Hunger", player) + ": " + GOLD + Math.round(mypet.getSaturation()));
if (mypet.getRespawnTime() > 0) {
lore.add(RESET + Translation.getString("Name.Respawntime", player) + ": " + GOLD + mypet.getRespawnTime() + "sec");
} else {
lore.add(RESET + Translation.getString("Name.HP", player) + ": " + GOLD + String.format("%1.2f", mypet.getHealth()));
}
lore.add(RESET + Translation.getString("Name.Exp", player) + ": " + GOLD + String.format("%1.2f", mypet.getExp()));
if (mypet.getInfo().containsKey("storage")) {
TagCompound storage = mypet.getInfo().getAs("storage", TagCompound.class);
if (storage.containsKey("level")) {
lore.add(RESET + Translation.getString("Name.Level", player) + ": " + GOLD + storage.getAs("level", TagInt.class).getIntData());
}
}
lore.add(RESET + Translation.getString("Name.Type", player) + ": " + GOLD + Translation.getString("Name." + mypet.getPetType().name(), player));
lore.add(RESET + Translation.getString("Name.Skilltree", player) + ": " + GOLD + (mypet.getSkilltree() != null ? mypet.getSkilltree().getDisplayName() : "-"));
IconMenuItem icon = new IconMenuItem();
icon.setTitle(RESET + mypet.getPetName());
icon.addLore(lore);
Optional<EggIconService> egg = MyPetApi.getServiceManager().getService(EggIconService.class);
if (egg.isPresent()) {
egg.get().updateIcon(mypet.getPetType(), icon);
}
int pos = menu.addOption(icon);
petSlotList.put(pos, mypet);
}
if (previousPage != page) {
menu.setOption(45, new IconMenuItem().setMaterial(Material.SIGN).setTitle("" + previousPage + " ≪≪"));
}
if (previousPage != page) {
menu.setOption(53, new IconMenuItem().setMaterial(Material.SIGN).setTitle(ChatColor.BOLD + "≫≫ " + ChatColor.RESET + nextPage));
}
menu.open(player.getPlayer());
}
}
Aggregations