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; 020 021import com.plotsquared.core.plot.comment.PlotComment; 022import org.checkerframework.checker.nullness.qual.NonNull; 023 024import java.util.List; 025 026/** 027 * Container for {@link com.plotsquared.core.plot.Plot} comments 028 */ 029public final class PlotCommentContainer { 030 031 private final Plot plot; 032 033 PlotCommentContainer(final @NonNull Plot plot) { 034 this.plot = plot; 035 } 036 037 /** 038 * Remove a comment from the plot 039 * 040 * @param comment Comment to remove 041 * @return {@code true} if the comment was removed, {@code false} if not 042 */ 043 public boolean removeComment(final @NonNull PlotComment comment) { 044 return this.getSettings().removeComment(comment); 045 } 046 047 /** 048 * Remove a list of comments from the plot 049 * 050 * @param comments Comments to remove 051 */ 052 public void removeComments(final @NonNull List<PlotComment> comments) { 053 this.getSettings().removeComments(comments); 054 } 055 056 /** 057 * Get all comments in a specific inbox 058 * 059 * @param inbox Inbox 060 * @return List of comments 061 */ 062 public @NonNull List<PlotComment> getComments(final @NonNull String inbox) { 063 return this.getSettings().getComments(inbox); 064 } 065 066 /** 067 * Add a comment to the plot 068 * 069 * @param comment Comment to add 070 */ 071 public void addComment(final @NonNull PlotComment comment) { 072 this.getSettings().addComment(comment); 073 } 074 075 /** 076 * Set the plot comments 077 * 078 * @param list New comments 079 */ 080 public void setComments(final @NonNull List<PlotComment> list) { 081 this.getSettings().setComments(list); 082 } 083 084 @NonNull 085 private PlotSettings getSettings() { 086 if (this.plot.getSettings() == null) { 087 throw new IllegalStateException("Cannot access comments for unowned plots"); 088 } 089 return this.plot.getSettings(); 090 } 091 092}