Guest User

Untitled

a guest
Dec 11th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. package com.evocri.server.network;
  2.  
  3. import java.util.concurrent.ConcurrentLinkedQueue;
  4.  
  5. import com.evocri.server.GameServer;
  6. import com.evocri.server.network.ProtocolWriter.ErrorType;
  7.  
  8. public class CharacterCreationHandler implements Runnable {
  9.  
  10. /** Stores the character deletion requests for processing. */
  11. private ConcurrentLinkedQueue<CharacterCreationRequest> m_queue;
  12.  
  13. /**
  14. * Allocates a new CharacterDeletionHandler
  15. */
  16. public CharacterCreationHandler() {
  17. m_queue = new ConcurrentLinkedQueue<CharacterCreationRequest>();
  18. }
  19.  
  20. /**
  21. * Queues a character deletion request for processing.
  22. *
  23. * @param s
  24. * The client's session making the character deletion request.
  25. * @param selection
  26. * The index of the character to delete.
  27. */
  28. public void queueCharacterCreate(Session s) {
  29. CharacterCreationRequest r = new CharacterCreationRequest(s);
  30. m_queue.offer(r);
  31. }
  32.  
  33. public void queueCharacterCreate(Session s, PlayerObject po, String[] sa) {
  34. CharacterCreationRequest r = new CharacterCreationRequest(s, po, sa);
  35. m_queue.offer(r);
  36. }
  37.  
  38. @Override
  39. public void run() {
  40. CharacterCreationRequest nextRequest;
  41.  
  42. while (true) {
  43. if (m_queue.peek() != null) {
  44. nextRequest = m_queue.poll();
  45. if (nextRequest.getSession().getAttribute("EVO_ACCOUNT") instanceof UserAccount) {
  46. if(nextRequest.getPlayerObject() != null){
  47. if(nextRequest.getStringArray() != null){
  48.  
  49. }
  50. else {
  51. ProtocolWriter.sendErrorMessage(nextRequest.getSession(),
  52. ErrorType.CHAR_CREATION);
  53. }
  54. }
  55. else if(nextRequest.getStringArray() == null){
  56. for(int i=0;i < 3;i++)
  57. {
  58. if(((UserAccount)nextRequest.getSession().getAttribute("EVO_ACCOUNT")).getCharacters()[i] == Null)
  59. {
  60.  
  61. break;
  62. }
  63. else if(i==2){ ProtocolWriter.sendErrorMessage(nextRequest.getSession(),
  64. ErrorType.CHAR_CREATION);}
  65. }
  66. }
  67. else {
  68. ProtocolWriter.sendErrorMessage(nextRequest.getSession(),
  69. ErrorType.CHAR_CREATION);
  70. }
  71. }
  72.  
  73. }
  74. }
  75. }
Add Comment
Please, Sign In to add comment