001/*
002 * PlotSquared, a land and world management plugin for Minecraft.
003 * Copyright (C) IntellectualSites <https://intellectualsites.com>
004 * Copyright (C) IntellectualSites team and contributors
005 *
006 * This program is free software: you can redistribute it and/or modify
007 * it under the terms of the GNU General Public License as published by
008 * the Free Software Foundation, either version 3 of the License, or
009 * (at your option) any later version.
010 *
011 * This program is distributed in the hope that it will be useful,
012 * but WITHOUT ANY WARRANTY; without even the implied warranty of
013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
014 * GNU General Public License for more details.
015 *
016 * You should have received a copy of the GNU General Public License
017 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
018 */
019package com.plotsquared.core.location;
020
021public enum Direction {
022    ALL(-1, "all"),
023    NORTH(0, "north"),
024    EAST(1, "east"),
025    SOUTH(2, "south"),
026    WEST(
027            3,
028            "west"
029    ),
030    NORTHEAST(4, "northeast"),
031    SOUTHEAST(5, "southeast"),
032    SOUTHWEST(
033            6,
034            "southwest"
035    ),
036    NORTHWEST(7, "northwest"),
037    ;
038
039
040    private final int index;
041    private final String name;
042
043    Direction(int index, String name) {
044
045        this.index = index;
046        this.name = name;
047    }
048
049    public static Direction getFromIndex(int index) {
050        for (Direction value : values()) {
051            if (value.getIndex() == index) {
052                return value;
053            }
054        }
055        return NORTH;
056    }
057
058    public int getIndex() {
059        return index;
060    }
061
062    public String getName() {
063        return name;
064    }
065}