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.plot.flag.implementations;
020
021import com.plotsquared.core.configuration.caption.TranslatableCaption;
022import com.plotsquared.core.plot.Plot;
023import com.plotsquared.core.plot.flag.InternalFlag;
024import com.plotsquared.core.plot.flag.types.StringFlag;
025import org.checkerframework.checker.nullness.qual.NonNull;
026
027public class DoneFlag extends StringFlag<DoneFlag> implements InternalFlag {
028
029    /**
030     * Construct a new flag instance.
031     *
032     * @param value Flag value
033     */
034    public DoneFlag(@NonNull String value) {
035        super(value, TranslatableCaption.of("info.none"), TranslatableCaption.of("info.none"));
036    }
037
038    public static boolean isDone(final Plot plot) {
039        return !plot.getFlag(DoneFlag.class).isEmpty();
040    }
041
042    @Override
043    public DoneFlag parse(@NonNull String input) {
044        return flagOf(input);
045    }
046
047    @Override
048    public DoneFlag merge(@NonNull String newValue) {
049        return flagOf(newValue);
050    }
051
052    @Override
053    public String toString() {
054        return this.getValue();
055    }
056
057    @Override
058    public String getExample() {
059        return "";
060    }
061
062    @Override
063    protected DoneFlag flagOf(@NonNull String value) {
064        return new DoneFlag(value);
065    }
066
067}