From 443c60cb60a8f836d6c894c65cd9d362bbd01915 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 3 Dec 2023 16:13:19 +0000 Subject: [PATCH 1/3] feat: add HasOwner PlotFilter filter - closes #3831 --- .../core/util/query/HasOwnerFilter.java | 31 +++++++++++++++++++ .../core/util/query/PlotQuery.java | 10 ++++++ 2 files changed, 41 insertions(+) create mode 100644 Core/src/main/java/com/plotsquared/core/util/query/HasOwnerFilter.java diff --git a/Core/src/main/java/com/plotsquared/core/util/query/HasOwnerFilter.java b/Core/src/main/java/com/plotsquared/core/util/query/HasOwnerFilter.java new file mode 100644 index 0000000000..a0da8eb3c4 --- /dev/null +++ b/Core/src/main/java/com/plotsquared/core/util/query/HasOwnerFilter.java @@ -0,0 +1,31 @@ +/* + * PlotSquared, a land and world management plugin for Minecraft. + * Copyright (C) IntellectualSites + * Copyright (C) IntellectualSites team and contributors + * + * 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 + * along with this program. If not, see . + */ +package com.plotsquared.core.util.query; + +import com.plotsquared.core.plot.Plot; +import org.checkerframework.checker.nullness.qual.NonNull; + +class HasOwnerFilter implements PlotFilter { + + @Override + public boolean accepts(final @NonNull Plot plot) { + return plot.hasOwner(); + } + +} diff --git a/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java b/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java index de3dc94ad5..34a9679151 100644 --- a/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java +++ b/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java @@ -219,6 +219,16 @@ public static PlotQuery newQuery() { return this.addFilter(new OwnersIncludeFilter(owner.getUUID())); } + + /** + * Query only for plots that have an owner + * + * @return The query instance + * @since 6.1.0 + */ + public @NonNull PlotQuery hasOwner() { + return this.addFilter(new HasOwnerFilter()); + } /** * Query for plots with a specific alias * From d50e071ac490ab575d88704e20f6b668c782dc63 Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Sun, 3 Dec 2023 19:32:46 +0000 Subject: [PATCH 2/3] change since to TODO --- .../main/java/com/plotsquared/core/util/query/PlotQuery.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java b/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java index 34a9679151..4afb95a854 100644 --- a/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java +++ b/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java @@ -224,7 +224,7 @@ public static PlotQuery newQuery() { * Query only for plots that have an owner * * @return The query instance - * @since 6.1.0 + * @since TODO */ public @NonNull PlotQuery hasOwner() { return this.addFilter(new HasOwnerFilter()); From 6805800743940e2cf794f361eff7e6cf08f6d268 Mon Sep 17 00:00:00 2001 From: Alexander Brandes Date: Thu, 7 Dec 2023 18:25:13 +0100 Subject: [PATCH 3/3] Address feedback --- .../main/java/com/plotsquared/core/util/query/PlotQuery.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java b/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java index 4afb95a854..22063d9f60 100644 --- a/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java +++ b/Core/src/main/java/com/plotsquared/core/util/query/PlotQuery.java @@ -219,13 +219,13 @@ public static PlotQuery newQuery() { return this.addFilter(new OwnersIncludeFilter(owner.getUUID())); } - /** * Query only for plots that have an owner * * @return The query instance * @since TODO */ + public @NonNull PlotQuery hasOwner() { return this.addFilter(new HasOwnerFilter()); }