From f5386d4ca55c23b54f3c5f952f08040b0967f4a3 Mon Sep 17 00:00:00 2001 From: Starmism Date: Wed, 30 Jun 2021 05:04:36 -0600 Subject: [PATCH] Remove the @NotNull's because they are overridden by expansion devs anyways, and it turns out people can make them null anyways. This adds a hashcode check and pretty error for it. --- .../expansion/PlaceholderExpansion.java | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java index f19da06..8f008d8 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java +++ b/src/main/java/me/clip/placeholderapi/expansion/PlaceholderExpansion.java @@ -22,7 +22,6 @@ package me.clip.placeholderapi.expansion; import java.util.Collections; import java.util.List; -import java.util.Objects; import me.clip.placeholderapi.PlaceholderAPIPlugin; import me.clip.placeholderapi.PlaceholderHook; import org.bukkit.Bukkit; @@ -46,7 +45,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return placeholder identifier that is associated with this expansion */ - @NotNull public abstract String getIdentifier(); /** @@ -54,7 +52,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return name of the author for this expansion */ - @NotNull public abstract String getAuthor(); /** @@ -62,7 +59,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return current version of this expansion */ - @NotNull public abstract String getVersion(); /** @@ -70,7 +66,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return {@link #getIdentifier()} by default, name of this expansion if specified */ - @NotNull public String getName() { return getIdentifier(); } @@ -90,7 +85,6 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { * * @return placeholder list that this expansion provides */ - @NotNull public List getPlaceholders() { return Collections.emptyList(); } @@ -369,4 +363,18 @@ public abstract class PlaceholderExpansion extends PlaceholderHook { return null; } + @Override + public int hashCode() { + if (this.getIdentifier() == null) { + throw new NullPointerException("Identifier must not be null! Error occurred in: " + this.getClass().getName()); + } + if (this.getAuthor() == null) { + throw new NullPointerException("Author must not be null! Error occurred in: " + this.getClass().getName()); + } + if (this.getVersion() == null) { + throw new NullPointerException("Version must not be null! Error occurred in: " + this.getClass().getName()); + } + + return super.hashCode(); + } }