Tyluur

Untitled

Dec 25th, 2011
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. package server.model.players;
  2.  
  3. /**
  4. * @author Core
  5. * Handles adding and removing hosts to the players array list.
  6. */
  7. public class PlayerKilling {
  8.  
  9. /**
  10. * Adds the host of the killed player.
  11. *@param client Player that saves the host.
  12. *@param host Host address of the killed player.
  13. *@return True if the host is added to the players array.
  14. */
  15.  
  16. public static boolean addHostToList(Client client, String host) {
  17. if(client != null) {
  18. return client.lastKilledPlayers.add(host);
  19. }
  20. return false;
  21. }
  22.  
  23. /**
  24. * Checks if the host is already on the players array.
  25. * @param client Player that is adding the killed players host.
  26. * @param host Host address of the killed player.
  27. * @return True if the host is on the players array.
  28. */
  29.  
  30. public static boolean hostOnList(Client client, String host) {
  31. if(client != null) {
  32. if(client.lastKilledPlayers.lastIndexOf(host) >= KILL_WAIT_MAX) {
  33. removeHostFromList(client, host);
  34. return false;
  35. }
  36. return client.lastKilledPlayers.contains(host);
  37. }
  38. return false;
  39. }
  40.  
  41. /**
  42. * Removes the host from the players array.
  43. * @param client Player that is removing the host.
  44. * @param host Host that is being removed.
  45. * @return True if host is successfully removed.
  46. */
  47.  
  48. public static boolean removeHostFromList(Client client, String host) {
  49. if(client != null) {
  50. return client.lastKilledPlayers.remove(host);
  51. }
  52. return false;
  53. }
  54.  
  55. /*
  56. * Amount of kills you have to wait before the host is deleted.
  57. */
  58.  
  59. public static final int KILL_WAIT_MAX = 3;
  60.  
  61. }
Add Comment
Please, Sign In to add comment