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.placeholders; 020 021import com.google.common.base.Preconditions; 022import com.plotsquared.core.player.PlotPlayer; 023import org.checkerframework.checker.nullness.qual.NonNull; 024 025/** 026 * A placeholder is a keyed value that gets replaced by a {@link PlotPlayer player}-specific value at runtime 027 */ 028public abstract class Placeholder { 029 030 private final String key; 031 032 public Placeholder(final @NonNull String key) { 033 this.key = Preconditions.checkNotNull(key, "Key may not be null"); 034 } 035 036 /** 037 * Get the value of the placeholder for a particular player 038 * 039 * @param player Player 040 * @return Placeholder value. Return {@code ""} if no placeholder value can be returned 041 */ 042 public @NonNull 043 abstract String getValue(final @NonNull PlotPlayer<?> player); 044 045 /** 046 * Get the placeholder key 047 * 048 * @return Placeholder key 049 */ 050 public @NonNull 051 final String getKey() { 052 return this.key; 053 } 054 055}