public static void setLastHealth(Player player) { lastHealth.put(player.getUniqueId(), Double.valueOf(player.getHealth())); } Someone help me fix player.getHealth it errors with an anbiouse methord or something
Code (Text): public class Util { public static HashMap<UUID, Long> lastLanding = new HashMap<UUID, Long>(); static HashMap<UUID, Long> lastRegen = new HashMap<UUID, Long>(); static HashMap<UUID, Double> lastHealth = new HashMap<UUID, Double>(); static HashMap<UUID, Long> lastForcefield = new HashMap<UUID, Long>(); public static HashMap<UUID, Integer> clicksPerSecond = new HashMap<UUID, Integer>(); public static long getLastLanding(Player player) { if (lastLanding.containsKey(player.getUniqueId())) { return lastLanding.get(player.getUniqueId()).longValue(); } return 0; } public static void updateLastLanding(Player player) { lastLanding.put(player.getUniqueId(), System.currentTimeMillis()); } public static long getLastRegen(Player player) { if (lastRegen.containsKey(player.getUniqueId())) { return lastRegen.get(player.getUniqueId()).longValue(); } return 0; } public static void setLastRegen(Player player, long time) { lastRegen.put(player.getUniqueId(), Long.valueOf(time)); } public static Integer getLastCPS(Player player) { if (clicksPerSecond.containsKey(player.getUniqueId())) { return clicksPerSecond.get(player.getUniqueId()).intValue(); } return 0; } public static void setLastCPS(Player player, Integer cps) { clicksPerSecond.put(player.getUniqueId(), cps); } public static Double getLastHealth(Player player) { if (lastHealth.containsKey(player.getUniqueId())) { return lastHealth.get(player.getUniqueId()); } return 0.0; } public static void setLastHealth(Player player) { lastHealth.put(player.getUniqueId(), Double.valueOf(player.getHealth())); } public static long lastForcefield(Player player) { if (lastForcefield.containsKey(player.getUniqueId())) { return lastForcefield.get(player.getUniqueId()).longValue(); } return 0; } public static void updateForcefield(Player player) { lastForcefield.put(player.getUniqueId(), Long.valueOf(System.nanoTime())); } }
You can remove the #longValue() from this "return lastLanding.get(player.getUniqueId()).longValue();" Can you show us the stack trace?
Exactly what I am trying to do. You said "Someone help me fix player.getHealth it errors with an anbiouse methord or something" This makes no sense at all. Can you show the actually error.
Cast your player to Damageable and then use getHealth. Next time use Google for these types of easy questions instead of wasting our time. This question has been asked and solved a billion times. EDIT: What's up with all the other shitty answers? If you don't know the solution, just don't answer.
In which version are you doing this? If I go to my ide and I cast the player.getHealth() to long without any problems. There are already other users that had this problem, check out this This is basicly @RobiRami answer but you can do one of this things 1. Try to do this: Code (Text): Damagable dam = (Damagable) player; dam.getHealth(); 2. Add the Spigot API jar to the buildpath and make it higher in the hierarchy order