Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.evocri.server.network;
- import java.util.concurrent.ConcurrentLinkedQueue;
- import com.evocri.server.GameServer;
- import com.evocri.server.network.ProtocolWriter.ErrorType;
- public class CharacterCreationHandler implements Runnable {
- /** Stores the character deletion requests for processing. */
- private ConcurrentLinkedQueue<CharacterCreationRequest> m_queue;
- /**
- * Allocates a new CharacterDeletionHandler
- */
- public CharacterCreationHandler() {
- m_queue = new ConcurrentLinkedQueue<CharacterCreationRequest>();
- }
- /**
- * Queues a character deletion request for processing.
- *
- * @param s
- * The client's session making the character deletion request.
- * @param selection
- * The index of the character to delete.
- */
- public void queueCharacterCreate(Session s) {
- CharacterCreationRequest r = new CharacterCreationRequest(s);
- m_queue.offer(r);
- }
- public void queueCharacterCreate(Session s, PlayerObject po, String[] sa) {
- CharacterCreationRequest r = new CharacterCreationRequest(s, po, sa);
- m_queue.offer(r);
- }
- @Override
- public void run() {
- CharacterCreationRequest nextRequest;
- while (true) {
- if (m_queue.peek() != null) {
- nextRequest = m_queue.poll();
- if (nextRequest.getSession().getAttribute("EVO_ACCOUNT") instanceof UserAccount) {
- if(nextRequest.getPlayerObject() != null){
- if(nextRequest.getStringArray() != null){
- }
- else {
- ProtocolWriter.sendErrorMessage(nextRequest.getSession(),
- ErrorType.CHAR_CREATION);
- }
- }
- else if(nextRequest.getStringArray() == null){
- for(int i=0;i < 3;i++)
- {
- if(((UserAccount)nextRequest.getSession().getAttribute("EVO_ACCOUNT")).getCharacters()[i] == Null)
- {
- break;
- }
- else if(i==2){ ProtocolWriter.sendErrorMessage(nextRequest.getSession(),
- ErrorType.CHAR_CREATION);}
- }
- }
- else {
- ProtocolWriter.sendErrorMessage(nextRequest.getSession(),
- ErrorType.CHAR_CREATION);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment