Commits

DerFrZocker authored and md_5 committed ba08b8cdf17
#1085: Add RegistryAware to indicate better that not all registry items are registered
No tags

src/main/java/org/bukkit/attribute/Attribute.java

Modified
1 1 package org.bukkit.attribute;
2 2
3 3 import com.google.common.base.Preconditions;
4 4 import com.google.common.collect.Lists;
5 5 import java.util.Locale;
6 6 import org.bukkit.Bukkit;
7 7 import org.bukkit.Keyed;
8 8 import org.bukkit.NamespacedKey;
9 9 import org.bukkit.Registry;
10 10 import org.bukkit.Translatable;
11 +import org.bukkit.registry.RegistryAware;
11 12 import org.bukkit.util.OldEnum;
12 13 import org.jetbrains.annotations.NotNull;
13 14
14 15 /**
15 16 * Types of attributes which may be present on an {@link Attributable}.
16 17 */
17 -public interface Attribute extends OldEnum<Attribute>, Keyed, Translatable {
18 +public interface Attribute extends OldEnum<Attribute>, Keyed, Translatable, RegistryAware {
18 19
19 20 /**
20 21 * Maximum health of an Entity.
21 22 */
22 23 Attribute MAX_HEALTH = getAttribute("max_health");
23 24 /**
24 25 * Range at which an Entity will follow others.
25 26 */
26 27 Attribute FOLLOW_RANGE = getAttribute("follow_range");
27 28 /**
143 144 /**
144 145 * Chance of a zombie to spawn reinforcements.
145 146 */
146 147 Attribute SPAWN_REINFORCEMENTS = getAttribute("spawn_reinforcements");
147 148
148 149 @NotNull
149 150 private static Attribute getAttribute(@NotNull String key) {
150 151 return Registry.ATTRIBUTE.getOrThrow(NamespacedKey.minecraft(key));
151 152 }
152 153
154 + /**
155 + * {@inheritDoc}
156 + *
157 + * @see #getKeyOrThrow()
158 + * @see #isRegistered()
159 + * @deprecated A key might not always be present, use {@link #getKeyOrThrow()} instead.
160 + */
161 + @NotNull
162 + @Override
163 + @Deprecated(since = "1.21.4")
164 + NamespacedKey getKey();
165 +
153 166 /**
154 167 * @param name of the attribute.
155 168 * @return the attribute with the given name.
156 169 * @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead.
157 170 */
158 171 @NotNull
159 172 @Deprecated(since = "1.21.3")
160 173 static Attribute valueOf(@NotNull String name) {
161 174 Attribute attribute = Bukkit.getUnsafe().get(Registry.ATTRIBUTE, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT)));
162 175 Preconditions.checkArgument(attribute != null, "No attribute found with the name %s", name);

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut