Error Help

Discussion in 'Spigot Plugin Development' started by Angeles, May 25, 2016.

  1. There must not be a getHealth method in that object, or it is private.
     
  2. Idk i just need it fixed :p

    inv.setItem(45, ModCmd.setItemName(new ItemStack(Material.SPECKLED_MELON, (int) examinee.getHealth()), (Object) ChatColor.RED + "Health"));
     
  3. Well that's about as much as I can help you. You only gave a single line of code and we have no idea what your examinee object is.
     

  4. private static void examinePlayer(Player examiner, Player examinee) {
    Inventory inv = Bukkit.createInventory((InventoryHolder) null, (int) 54, (String) ((Object) ChatColor.GREEN + "Examining: " + examinee.getName()));
    int i = 0;
    while (i < 36) {
    ItemStack is = examinee.getInventory().getItem(i);
    inv.setItem(i, is);
    ++i;
    }
    inv.setItem(36, examinee.getInventory().getHelmet());
    inv.setItem(37, examinee.getInventory().getChestplate());
    inv.setItem(38, examinee.getInventory().getLeggings());
    inv.setItem(39, examinee.getInventory().getBoots());
    inv.setItem(40, examinee.getItemInHand());
    i = 0;
    while (i < 4) {
    inv.setItem(41 + i, new ItemStack(Material.THIN_GLASS, 1));
    ++i;
    }
    inv.setItem(45, ModCmd.setItemName(new ItemStack(Material.SPECKLED_MELON, (int) examinee.getHealth()), (Object) ChatColor.RED + "Health"));
    inv.setItem(46, ModCmd.setItemName(new ItemStack(Material.COOKED_BEEF, examinee.getFoodLevel()), (Object) ChatColor.GOLD + "Hunger"));
    inv.setItem(47, ModCmd.setItemName(new ItemStack(Material.ROTTEN_FLESH, (int) examinee.getSaturation()), (Object) ChatColor.YELLOW + "Saturation"));
    inv.setItem(48, ModCmd.setItemName(new ItemStack(Material.DIAMOND_BARDING, 1), (Object) ChatColor.GRAY + "Is Riding Mob: " + (Object) ChatColor.BLUE + (examinee.getVehicle() != null ? "Yes" : "No")));
    ItemStack peItem = ModCmd.setItemName(new ItemStack(Material.BREWING_STAND_ITEM, examinee.getActivePotionEffects().size()), (Object) ChatColor.LIGHT_PURPLE + "Potion Effects");
    for (PotionEffect pe : examinee.getActivePotionEffects()) {
    ModCmd.addLore(peItem, (Object) ChatColor.GRAY + pe.getType().getName() + " " + (pe.getAmplifier() + 1) + ": " + pe.getDuration() / 20);
    }
    inv.setItem(50, peItem);
    inv.setItem(51, ModCmd.setItemName(new ItemStack(Material.POTION, examinee.getLevel()), (Object) ChatColor.GREEN + "Experience Level"));
    inv.setItem(53, ModCmd.setItemName(new ItemStack(Material.WOOD_PICKAXE, 1), (Object) ChatColor.WHITE + "GameMode: " + (Object) ChatColor.AQUA + examinee.getGameMode().toString()));
    Location examineeLoc = examinee.getLocation();
    inv.setItem(52, ModCmd.setItemName(new ItemStack(Material.COMPASS, 1), String.format((Object) ChatColor.DARK_GRAY + "X: %s, Y: %s, Z: %s", String.valueOf(ChatColor.GRAY.toString()) + examineeLoc.getBlockX() + ChatColor.DARK_GRAY.toString(), String.valueOf(ChatColor.GRAY.toString()) + examineeLoc.getBlockY() + ChatColor.DARK_GRAY.toString(), String.valueOf(ChatColor.GRAY.toString()) + examineeLoc.getBlockZ() + ChatColor.DARK_GRAY.toString())));
    examiner.openInventory(inv);
    }
     
  5. Can you put that in code form by using the insert code function on the toolbar. It makes it much easier to read. :)
     
  6. I'm not him/her, but here you go xD

    Code (Text):
    private static void examinePlayer(Player examiner, Player examinee) {
    Inventory inv = Bukkit.createInventory((InventoryHolder) null, (int) 54, (String) ((Object) ChatColor.GREEN + "Examining: " + examinee.getName()));
    int i = 0;
    while (i < 36) {
    ItemStack is = examinee.getInventory().getItem(i);
    inv.setItem(i, is);
    ++i;
    }
    inv.setItem(36, examinee.getInventory().getHelmet());
    inv.setItem(37, examinee.getInventory().getChestplate());
    inv.setItem(38, examinee.getInventory().getLeggings());
    inv.setItem(39, examinee.getInventory().getBoots());
    inv.setItem(40, examinee.getItemInHand());
    i = 0;
    while (i < 4) {
    inv.setItem(41 + i, new ItemStack(Material.THIN_GLASS, 1));
    ++i;
    }
    inv.setItem(45, ModCmd.setItemName(new ItemStack(Material.SPECKLED_MELON, (int) examinee.getHealth()), (Object) ChatColor.RED + "Health"));
    inv.setItem(46, ModCmd.setItemName(new ItemStack(Material.COOKED_BEEF, examinee.getFoodLevel()), (Object) ChatColor.GOLD + "Hunger"));
    inv.setItem(47, ModCmd.setItemName(new ItemStack(Material.ROTTEN_FLESH, (int) examinee.getSaturation()), (Object) ChatColor.YELLOW + "Saturation"));
    inv.setItem(48, ModCmd.setItemName(new ItemStack(Material.DIAMOND_BARDING, 1), (Object) ChatColor.GRAY + "Is Riding Mob: " + (Object) ChatColor.BLUE + (examinee.getVehicle() != null ? "Yes" : "No")));
    ItemStack peItem = ModCmd.setItemName(new ItemStack(Material.BREWING_STAND_ITEM, examinee.getActivePotionEffects().size()), (Object) ChatColor.LIGHT_PURPLE + "Potion Effects");
    for (PotionEffect pe : examinee.getActivePotionEffects()) {
    ModCmd.addLore(peItem, (Object) ChatColor.GRAY + pe.getType().getName() + " " + (pe.getAmplifier() + 1) + ": " + pe.getDuration() / 20);
    }
    inv.setItem(50, peItem);
    inv.setItem(51, ModCmd.setItemName(new ItemStack(Material.POTION, examinee.getLevel()), (Object) ChatColor.GREEN + "Experience Level"));
    inv.setItem(53, ModCmd.setItemName(new ItemStack(Material.WOOD_PICKAXE, 1), (Object) ChatColor.WHITE + "GameMode: " + (Object) ChatColor.AQUA + examinee.getGameMode().toString()));
    Location examineeLoc = examinee.getLocation();
    inv.setItem(52, ModCmd.setItemName(new ItemStack(Material.COMPASS, 1), String.format((Object) ChatColor.DARK_GRAY + "X: %s, Y: %s, Z: %s", String.valueOf(ChatColor.GRAY.toString()) + examineeLoc.getBlockX() + ChatColor.DARK_GRAY.toString(), String.valueOf(ChatColor.GRAY.toString()) + examineeLoc.getBlockY() + ChatColor.DARK_GRAY.toString(), String.valueOf(ChatColor.GRAY.toString()) + examineeLoc.getBlockZ() + ChatColor.DARK_GRAY.toString())));
    examiner.openInventory(inv);
    }
     
  7. it still errors
     
  8. I wanted him to do it so that is would be formatted and spaced correctly, but I thank you for the effort :)
     
  9. That wasn't a fix xD

    That's just to show it in
    Code (Text):
     format
     
  10. @Angeles use ((Damageable) examinee).getHealth()
    This is because the Player interface hasa method that returns an int for older plugins, while later health was calculated in double so it changed
     
  11. ((Damageable)examinee).getHealth() it still errors
     
  12. @Angeles hover over the error and tell me the message
     
  13. Damageable cant be resolved to type
     
  14. you cant
     
  15. @Angeles I can, try ctrl+shift+o if you're using eclipse
     
  16. use [.code] [./code]

    and instead of (int) try casting it to double at the examinee.getHealth()