Integer is returning 0 when a new player joins the array

Discussion in 'Plugin Development' started by 8803286, May 11, 2014.

Thread Status:
Not open for further replies.
  1. Hi, the info that you posted to me works but when a new player joins the hits, every player that have damaged that player returns 0

    I get how many times you hit the player and it dosen't give me any errors


    Code:java
    1.  
    2. public static Map<UUID, HashMap<UUID, Integer>> cashSplit = new HashMap<UUID, HashMap<UUID, Integer>>(); //Saving the damaged player and how many times a player hitted the damaged player
    3.  
    4. @EventHandler
    5. public void onPlayerDeath(PlayerDeathEvent e){
    6. if((e.getEntity() instanceof Player) && (e.getEntity().getKiller() instanceof Player)){
    7.  
    8. for(Entry<UUID, HashMap<UUID, Integer>> cS : cashSplit.entrySet()){//Looping through data in the hashmap
    9.  
    10. Integer total = 0;
    11. Integer maxPoints = 40; //<--- Max points for each kill
    12.  
    13. for(Entry<UUID, Integer> c : cashSplit.get(cS.getKey()).entrySet()){total = (total+c.getValue());}
    14.  
    15.  
    16. for(Entry<UUID, Integer> c : cashSplit.get(cS.getKey()).entrySet()){//<--- When 2 players are in this hashmap it returns 0
    17.  
    18. int cash = (maxPoints * (c.getValue()/total)); //<--- Returns 0 all the time when a new player joins the hashmap
    19.  
    20. Player p = (Player)Bukkit.getPlayer(c.getKey());
    21. if(p != null){
    22. p.sendMessage("You gained "+cash+ " credits");
    23. }
    24.  
    25.  
    26. Bukkit.broadcastMessage("Player: "+Bukkit.getPlayer(c.getKey()).getName()+" | Clicks: "+c.getValue()); //<--- Works, Tells me the playername and how many times he hit the dead player
    27. }
    28. }
    29. }
    30. }
     
Thread Status:
Not open for further replies.

Share This Page