131 lines
5.3 KiB
Diff
131 lines
5.3 KiB
Diff
|
From bf5e87d656e1988c33c4854227450dcefb55e3ce Mon Sep 17 00:00:00 2001
|
||
|
From: Aikar <aikar@aikar.co>
|
||
|
Date: Sun, 24 Mar 2019 18:39:01 -0400
|
||
|
Subject: [PATCH] Flip some Spigot API null annotations
|
||
|
|
||
|
while some of these may of been true, they are extreme cases and cause
|
||
|
a ton of noise to plugin developers.
|
||
|
|
||
|
These do not help plugin developers if they bring moise noise than value.
|
||
|
|
||
|
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
|
||
|
index 6b0a09067..5d6c856dd 100644
|
||
|
--- a/src/main/java/org/bukkit/Bukkit.java
|
||
|
+++ b/src/main/java/org/bukkit/Bukkit.java
|
||
|
@@ -1183,7 +1183,7 @@ public final class Bukkit {
|
||
|
*
|
||
|
* @return the scoreboard manager or null if no worlds are loaded.
|
||
|
*/
|
||
|
- @Nullable
|
||
|
+ @NotNull // Paper
|
||
|
public static ScoreboardManager getScoreboardManager() {
|
||
|
return server.getScoreboardManager();
|
||
|
}
|
||
|
@@ -1480,7 +1480,7 @@ public final class Bukkit {
|
||
|
* @param clazz the class of the tag entries
|
||
|
* @return the tag or null
|
||
|
*/
|
||
|
- @Nullable
|
||
|
+ @Contract("null, null, null -> fail") // Paper
|
||
|
public static <T extends Keyed> Tag<T> getTag(@NotNull String registry, @NotNull NamespacedKey tag, @NotNull Class<T> clazz) {
|
||
|
return server.getTag(registry, tag, clazz);
|
||
|
}
|
||
|
diff --git a/src/main/java/org/bukkit/Location.java b/src/main/java/org/bukkit/Location.java
|
||
|
index 57ce443a5..6b8dde716 100644
|
||
|
--- a/src/main/java/org/bukkit/Location.java
|
||
|
+++ b/src/main/java/org/bukkit/Location.java
|
||
|
@@ -45,7 +45,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||
|
* @param y The y-coordinate of this new location
|
||
|
* @param z The z-coordinate of this new location
|
||
|
*/
|
||
|
- public Location(@Nullable final World world, final double x, final double y, final double z) {
|
||
|
+ public Location(@NotNull final World world, final double x, final double y, final double z) { // Paper
|
||
|
this(world, x, y, z, 0, 0);
|
||
|
}
|
||
|
|
||
|
@@ -59,7 +59,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||
|
* @param yaw The absolute rotation on the x-plane, in degrees
|
||
|
* @param pitch The absolute rotation on the y-plane, in degrees
|
||
|
*/
|
||
|
- public Location(@Nullable final World world, final double x, final double y, final double z, final float yaw, final float pitch) {
|
||
|
+ public Location(@NotNull final World world, final double x, final double y, final double z, final float yaw, final float pitch) { // Paper
|
||
|
this.world = world;
|
||
|
this.x = x;
|
||
|
this.y = y;
|
||
|
@@ -82,7 +82,7 @@ public class Location implements Cloneable, ConfigurationSerializable {
|
||
|
*
|
||
|
* @return World that contains this location
|
||
|
*/
|
||
|
- @Nullable
|
||
|
+ @NotNull
|
||
|
public World getWorld() {
|
||
|
return world;
|
||
|
}
|
||
|
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
|
||
|
index 66d22ba79..08cd7cabc 100644
|
||
|
--- a/src/main/java/org/bukkit/Server.java
|
||
|
+++ b/src/main/java/org/bukkit/Server.java
|
||
|
@@ -988,7 +988,7 @@ public interface Server extends PluginMessageRecipient {
|
||
|
*
|
||
|
* @return the scoreboard manager or null if no worlds are loaded.
|
||
|
*/
|
||
|
- @Nullable
|
||
|
+ @NotNull // Paper
|
||
|
ScoreboardManager getScoreboardManager();
|
||
|
|
||
|
/**
|
||
|
@@ -1258,7 +1258,7 @@ public interface Server extends PluginMessageRecipient {
|
||
|
* @param clazz the class of the tag entries
|
||
|
* @return the tag or null
|
||
|
*/
|
||
|
- @Nullable
|
||
|
+ @Contract("null, null, null -> fail") // Paper
|
||
|
<T extends Keyed> Tag<T> getTag(@NotNull String registry, @NotNull NamespacedKey tag, @NotNull Class<T> clazz);
|
||
|
|
||
|
/**
|
||
|
diff --git a/src/main/java/org/bukkit/inventory/ItemFactory.java b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
||
|
index dca77bbaf..8335f8a8b 100644
|
||
|
--- a/src/main/java/org/bukkit/inventory/ItemFactory.java
|
||
|
+++ b/src/main/java/org/bukkit/inventory/ItemFactory.java
|
||
|
@@ -6,6 +6,7 @@ import org.bukkit.Server;
|
||
|
import org.bukkit.inventory.meta.BookMeta;
|
||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||
|
+import org.jetbrains.annotations.Contract;
|
||
|
import org.jetbrains.annotations.NotNull;
|
||
|
import org.jetbrains.annotations.Nullable;
|
||
|
|
||
|
@@ -25,7 +26,7 @@ public interface ItemFactory {
|
||
|
* @return a new ItemMeta that could be applied to an item stack of the
|
||
|
* specified material
|
||
|
*/
|
||
|
- @Nullable
|
||
|
+ @Contract() // Paper
|
||
|
ItemMeta getItemMeta(@NotNull final Material material);
|
||
|
|
||
|
/**
|
||
|
diff --git a/src/main/java/org/bukkit/inventory/ItemStack.java b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||
|
index 1b19f8215..4a6dea561 100644
|
||
|
--- a/src/main/java/org/bukkit/inventory/ItemStack.java
|
||
|
+++ b/src/main/java/org/bukkit/inventory/ItemStack.java
|
||
|
@@ -15,6 +15,7 @@ import org.bukkit.enchantments.Enchantment;
|
||
|
import org.bukkit.inventory.meta.Damageable;
|
||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||
|
import org.bukkit.material.MaterialData;
|
||
|
+import org.jetbrains.annotations.Contract;
|
||
|
import org.jetbrains.annotations.NotNull;
|
||
|
import org.jetbrains.annotations.Nullable;
|
||
|
|
||
|
@@ -527,7 +528,7 @@ public class ItemStack implements Cloneable, ConfigurationSerializable {
|
||
|
*
|
||
|
* @return a copy of the current ItemStack's ItemData
|
||
|
*/
|
||
|
- @Nullable
|
||
|
+ @Contract() // Paper
|
||
|
public ItemMeta getItemMeta() {
|
||
|
return this.meta == null ? Bukkit.getItemFactory().getItemMeta(this.type) : this.meta.clone();
|
||
|
}
|
||
|
--
|
||
|
2.21.0
|
||
|
|