/*
 * Trident - A Multithreaded Server Alternative
 * Copyright 2016 The TridentSDK Team
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *    http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package net.tridentsdk.chat;

import lombok.Getter;

import java.util.HashMap;
import java.util.Map;

/**
 * @author TridentSDK
 * @since 0.5-alpha
 */
public enum ClientChatMode {

    CHAT_AND_COMMANDS(0),
    COMMANDS_ONLY(1),
    NONE(2);

    @Getter
    private final int data;

    ClientChatMode(int data) {
        this.data = data;
    }

    private static final Map<Integer, ClientChatMode> dataToMode = new HashMap<>();

    public static ClientChatMode of(int data) {
        ClientChatMode mode = dataToMode.get(data);
        if (mode == null) {
            throw new IllegalArgumentException("no client chat mode with id=" + data);
        }
        return mode;
    }

    static {
        for (ClientChatMode mode : values()) {
            dataToMode.put(mode.data, mode);
        }
    }

}

@@ -700,184 +700,522 @@
 r;%0A%0A
-import java.util.HashMap;%0Aimport java.util.Map;%0A%0A/**%0A * @author TridentSDK%0A * @since 0.5-alpha%0A */%0Apublic enum ClientChatMode %7B%0A%0A    CHAT_AND_COMMANDS(0),%0A    COMMANDS_ONLY(1),
+/**%0A * Chat modes which a player may set by navigating to the%0A * %22Multiplayer settings%22 and toggling the chat modes to%0A * the states listed below.%0A *%0A * @author TridentSDK%0A * @since 0.5-alpha%0A */%0Apublic enum ClientChatMode %7B%0A    /**%0A     * Allows both chat messages and commands to be%0A     * displayed on the chat bar.%0A     */%0A    CHAT_AND_COMMANDS(0),%0A    /**%0A     * Allows only command feedback to be displayed on the%0A     * chat bar.%0A     */%0A    COMMANDS_ONLY(1),%0A    /**%0A     * Do not use the chat bar.%0A     */
 %0A   
@@ -1274,170 +1274,184 @@
     
-ClientChatMode(int data) %7B%0A        this.data = data;%0A    %7D%0A%0A    private static final Map%3CInteger, ClientChatMode%3E dataToMode = new HashMap%3C%3E();%0A%0A    public static
+/**%0A     * Creates a new chat mode with the given data value.%0A     *%0A     * @param data the identifyer used in the protocol to%0A     * signify a particular chat mode%0A     */%0A   
  Cli
@@ -1461,19 +1461,16 @@
 ChatMode
- of
 (int dat
@@ -1486,215 +1486,294 @@
     
-ClientChatMode mode = dataToMode.get(data)
+this.data = data
 ;%0A    
+%7D%0A%0A
     
-if (mode == null) %7B%0A            throw new IllegalArgumentException(%22no client chat mode with id=%22 + data);%0A        %7D%0A        return
+/**%0A     * Obtains the chat mode of the client given the data%0A     * that was sent using the client settings packet.%0A     *%0A     * @param data the chat mode identifing number%0A     * @return the chat
  mode
-;
 %0A    
-%7D%0A
+ */
 %0A    
-static
+public static ClientChatMode of(int data)
  %7B%0A 
@@ -1799,17 +1799,21 @@
 hatMode 
-m
+chatM
 ode : va
@@ -1838,39 +1838,73 @@
     
-dataToMode.put(mode.data, m
+if (chatMode.getData() == data) %7B%0A                return chatM
 ode
-)
 ;%0A  
@@ -1913,15 +1913,111 @@
     
-%7D
+    %7D%0A        %7D%0A%0A        throw new IllegalArgumentException(%22no client chat mode with id=%22 + data);
 %0A    %7D%0A
-%0A%7D%0A
+%7D

Make NibbleArray thread-safe