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.util;
020
021public class PremiumVerification {
022
023    private static Boolean usingPremium;
024
025    /**
026     * @return Account ID if downloaded through SpigotMC
027     */
028    public static String getUserID() {
029        return "%%__USER__%%";
030    }
031
032    /**
033     * @return Resource ID if downloaded through SpigotMC
034     */
035    public static String getResourceID() {
036        return "%%__RESOURCE__%%";
037    }
038
039    /**
040     * @return Download ID if downloaded through SpigotMC
041     */
042    public static String getDownloadID() {
043        return "%%__NONCE__%%";
044    }
045
046    /**
047     * @param userID Spigot user ID
048     * @return {@code true} if userID does not contain __USER__
049     */
050    private static Boolean isPremium(String userID) {
051        return !userID.contains("__USER__");
052    }
053
054    /**
055     * Returns true if this plugin is premium
056     *
057     * @return {@code true} if is premium
058     */
059    public static Boolean isPremium() {
060        return usingPremium == null ? (usingPremium = isPremium(getUserID())) : usingPremium;
061    }
062
063}