|
| 1 | +package com.froxynetwork.froxynetwork.network.output.data; |
| 2 | + |
| 3 | +import com.froxynetwork.froxynetwork.network.output.data.server.ServerDataOutput; |
| 4 | + |
| 5 | +import lombok.Getter; |
| 6 | + |
| 7 | +/** |
| 8 | + * MIT License |
| 9 | + * |
| 10 | + * Copyright (c) 2019 FroxyNetwork |
| 11 | + * |
| 12 | + * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 13 | + * of this software and associated documentation files (the "Software"), to deal |
| 14 | + * in the Software without restriction, including without limitation the rights |
| 15 | + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 16 | + * copies of the Software, and to permit persons to whom the Software is |
| 17 | + * furnished to do so, subject to the following conditions: |
| 18 | + * |
| 19 | + * The above copyright notice and this permission notice shall be included in |
| 20 | + * all copies or substantial portions of the Software. |
| 21 | + * |
| 22 | + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 23 | + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 24 | + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 25 | + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 26 | + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 27 | + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 28 | + * SOFTWARE. |
| 29 | + * |
| 30 | + * @author 0ddlyoko |
| 31 | + */ |
| 32 | +@Getter |
| 33 | +public enum Error { |
| 34 | + METHOD_NOT_IMPLEMENTED(0, "This method is not implemented"), |
| 35 | + GLOBAL_ERROR(1, "Error #{errorCode} : {error}"), |
| 36 | + GLOBAL_UNKNOWN(2, "Unknown error"), |
| 37 | + GLOBAL_NO_PERMISSION(3, "You don't have the permission to perform this operation"), |
| 38 | + GLOBAL_DATA_INVALID(4, "Invalid data value !"), |
| 39 | + GLOBAL_CONTROLLER_NOT_FOUND(5, "No controller found for your request !"), |
| 40 | + GLOBAL_UNKNOWN_ERROR(6, "An error has occured while performing the operation"), |
| 41 | + GLOBAL_TOKEN_INVALUD(7, "Invalid Token, Please save your informations and refresh your page !"), |
| 42 | + |
| 43 | + PLAYER_DATA_LENGTH(100, "The length of the search must be between 1 and 20, or equals to 36."), |
| 44 | + PLAYER_NOT_FOUND(101, "Player not found"), |
| 45 | + PLAYER_UUID_LENGTH(102, "UUID length must be 36 !"), |
| 46 | + PLAYER_UUID_FORMAT(103, "Bad UUID format !"), |
| 47 | + PLAYER_PSEUDO_LENGTH(104, "Pseudo length must be between 1 and 20 !"), |
| 48 | + PLAYER_IP_LENGTH(105, "Ip length must be between 7 and 15 !"), |
| 49 | + PLAYER_IP_FORMAT(106, "Bad ip format !"), |
| 50 | + PLAYER_UUID_EXISTS(107, "UUID already exist !"), |
| 51 | + PLAYER_PSEUDO_EXISTS(108, "Pseudo already exist !"), |
| 52 | + PLAYER_DISPLAYNAME_LENGTH(109, "DisplayName length must be between 1 and 20 !"), |
| 53 | + PLAYER_COINS_POSITIVE(110, "Coins must be positive !"), |
| 54 | + PLAYER_LEVEL_POSITIVE(111, "Level must be positive !"), |
| 55 | + PLAYER_EXP_POSITIVE(112, "Exp must be positive !"), |
| 56 | + PLAYER_TIME_FORMAT(113, "Bad time format !"), |
| 57 | + PLAYER_LASTLOGIN_GREATER(114, "LastLogin must be greater than saved LastLogin !"), |
| 58 | + |
| 59 | + SERVER_ID_INVALID(200, "Invalid id"), |
| 60 | + SERVER_NOT_FOUND(201, "Server not found"), |
| 61 | + SERVER_NAME_INVALID(202, "Name must be a string !"), |
| 62 | + SERVER_NAME_LENGTH(203, "Name length must be between 1 and 16 !"), |
| 63 | + SERVER_PORT_INVALID(204, "Port must be a correct number and between 1 and 65535 !"), |
| 64 | + SERVER_SAVING(205, "Error while saving client_id and client_secret"), |
| 65 | + SERVER_STATUS_INVALID(206, "Status must be '" + ServerDataOutput.ServerStatus.WAITING + "', '" + ServerDataOutput.ServerStatus.STARTED + "' or '" + ServerDataOutput.ServerStatus.ENDING + "' !"), |
| 66 | + SERVER_STATUS_BEFORE(207, "Invalid status, current is {currentStatus} !"), |
| 67 | + SERVER_ACTUALLY_ENDED(208, "This server is already ended !"); |
| 68 | + |
| 69 | + private int id; |
| 70 | + private String message; |
| 71 | + |
| 72 | + private Error(int id, String message) { |
| 73 | + this.id = id; |
| 74 | + this.message = message; |
| 75 | + } |
| 76 | + |
| 77 | + public static Error getFromId(int id) { |
| 78 | + for (Error error : values()) |
| 79 | + if (error.id == id) |
| 80 | + return error; |
| 81 | + return null; |
| 82 | + } |
| 83 | +} |
0 commit comments