2020-04-16 04:52:39 +02:00
|
|
|
/*
|
|
|
|
* _____ _ _ _____ _
|
|
|
|
* | __ \| | | | / ____| | |
|
|
|
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
|
|
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
|
|
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
|
|
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
|
|
|
* | |
|
|
|
|
* |_|
|
|
|
|
* PlotSquared plot management system for Minecraft
|
2021-01-01 00:19:45 +01:00
|
|
|
* Copyright (C) 2021 IntellectualSites
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2020-08-15 14:59:29 +02:00
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-04-16 04:52:39 +02:00
|
|
|
*/
|
2020-04-15 21:26:54 +02:00
|
|
|
package com.plotsquared.core.plot;
|
2020-04-02 14:34:38 +02:00
|
|
|
|
2020-07-21 13:05:40 +02:00
|
|
|
import com.plotsquared.core.configuration.caption.Caption;
|
2020-08-04 19:01:25 +02:00
|
|
|
import com.plotsquared.core.configuration.caption.TranslatableCaption;
|
2020-05-31 23:55:59 +02:00
|
|
|
|
2020-07-17 17:24:45 +02:00
|
|
|
import javax.annotation.Nonnull;
|
2020-04-02 14:34:38 +02:00
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Optional;
|
|
|
|
import java.util.function.Function;
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
|
|
public enum PlotAreaType {
|
2020-08-04 19:01:25 +02:00
|
|
|
NORMAL(TranslatableCaption.of("plotareatype.plot_area_type_normal")),
|
|
|
|
AUGMENTED(TranslatableCaption.of("plotareatype.plot_area_type_augmented")),
|
|
|
|
PARTIAL(TranslatableCaption.of("plotareatype.plot_area_type_partial"));
|
2020-05-31 23:55:59 +02:00
|
|
|
|
2020-07-17 17:24:45 +02:00
|
|
|
private final Caption description;
|
2020-04-02 14:34:38 +02:00
|
|
|
|
|
|
|
private static final Map<String, PlotAreaType> types = Stream.of(values())
|
2020-04-30 12:01:52 +02:00
|
|
|
.collect(Collectors.toMap(e -> e.toString().toLowerCase(), Function.identity()));
|
2020-04-02 14:34:38 +02:00
|
|
|
|
2020-07-17 17:24:45 +02:00
|
|
|
PlotAreaType(@Nonnull final Caption description) {
|
2020-05-31 23:55:59 +02:00
|
|
|
this.description = description;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static Map<PlotAreaType, Caption> getDescriptionMap() {
|
|
|
|
return Stream.of(values()).collect(Collectors.toMap(e -> e, PlotAreaType::getDescription));
|
|
|
|
}
|
|
|
|
|
2020-04-02 14:34:38 +02:00
|
|
|
public static Optional<PlotAreaType> fromString(String typeName) {
|
|
|
|
return Optional.ofNullable(types.get(typeName.toLowerCase()));
|
|
|
|
}
|
|
|
|
|
2020-04-30 12:01:52 +02:00
|
|
|
@Deprecated public static Optional<PlotAreaType> fromLegacyInt(int typeId) {
|
2020-04-02 14:34:38 +02:00
|
|
|
if (typeId < 0 || typeId >= values().length) {
|
|
|
|
return Optional.empty();
|
|
|
|
}
|
|
|
|
return Optional.of(values()[typeId]);
|
|
|
|
}
|
2020-07-17 17:24:45 +02:00
|
|
|
|
|
|
|
public Caption getDescription() {
|
|
|
|
return this.description;
|
|
|
|
}
|
2020-04-02 14:34:38 +02:00
|
|
|
}
|