mirror of
https://hub.spigotmc.org/stash/scm/spigot/bukkit.git
synced 2025-08-31 22:22:49 +00:00
Add wildcard generic
This commit is contained in:
parent
8b97f21525
commit
25f4d1188f
5 changed files with 13 additions and 13 deletions
|
@ -1974,7 +1974,7 @@ public final class Bukkit {
|
|||
* @return the corresponding registry or null if not present
|
||||
*/
|
||||
@Nullable
|
||||
public static <T extends Keyed> Registry<T> getRegistry(@NotNull Class<T> tClass) {
|
||||
public static <T extends Keyed> Registry<? extends T> getRegistry(@NotNull Class<T> tClass) {
|
||||
return server.getRegistry(tClass);
|
||||
}
|
||||
|
||||
|
|
|
@ -128,7 +128,7 @@ public abstract class Particle<D> extends OldEnum<Particle<D>> implements Keyed
|
|||
@NotNull
|
||||
private static <D> Particle<D> getParticle(@NotNull String key) {
|
||||
NamespacedKey namespacedKey = NamespacedKey.minecraft(key);
|
||||
Particle<D> particle = Registry.PARTICLE_TYPE.get(namespacedKey);
|
||||
Particle<D> particle = (Particle<D>) Registry.PARTICLE_TYPE.get(namespacedKey);
|
||||
Preconditions.checkNotNull(particle, "No particle found for %s. This is a bug.", namespacedKey);
|
||||
return particle;
|
||||
}
|
||||
|
|
|
@ -82,7 +82,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
*
|
||||
* @see BlockType
|
||||
*/
|
||||
Registry<BlockType> BLOCK = Objects.requireNonNull(Bukkit.getRegistry(BlockType.class), "No registry present for BlockType. This is a bug.");
|
||||
Registry<BlockType<?>> BLOCK = Objects.requireNonNull(Bukkit.getRegistry(BlockType.class), "No registry present for BlockType. This is a bug.");
|
||||
/**
|
||||
* Server pattern types.
|
||||
*
|
||||
|
@ -118,7 +118,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
/**
|
||||
* Server enchantments.
|
||||
*
|
||||
* @see Enchantment#getByKey(org.bukkit.NamespacedKey)
|
||||
* @see Enchantment
|
||||
*/
|
||||
Registry<Enchantment> ENCHANTMENT = Objects.requireNonNull(Bukkit.getRegistry(Enchantment.class), "No registry present for Enchantment. This is a bug.");
|
||||
/**
|
||||
|
@ -126,7 +126,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
*
|
||||
* @see EntityType
|
||||
*/
|
||||
Registry<EntityType> ENTITY_TYPE = Objects.requireNonNull(Bukkit.getRegistry(EntityType.class), "No registry present for EntityType. This is a bug.");
|
||||
Registry<EntityType<?>> ENTITY_TYPE = Objects.requireNonNull(Bukkit.getRegistry(EntityType.class), "No registry present for EntityType. This is a bug.");
|
||||
/**
|
||||
* Server instruments.
|
||||
*
|
||||
|
@ -158,7 +158,7 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
*
|
||||
* @see Particle
|
||||
*/
|
||||
Registry<Particle> PARTICLE_TYPE = Objects.requireNonNull(Bukkit.getRegistry(Particle.class), "No registry present for Particle. This is a bug.");
|
||||
Registry<Particle<?>> PARTICLE_TYPE = Objects.requireNonNull(Bukkit.getRegistry(Particle.class), "No registry present for Particle. This is a bug.");
|
||||
/**
|
||||
* Server potion types.
|
||||
*
|
||||
|
@ -220,17 +220,17 @@ public interface Registry<T extends Keyed> extends Iterable<T> {
|
|||
*
|
||||
* @see MemoryKey
|
||||
*/
|
||||
Registry<MemoryKey> MEMORY_MODULE_TYPE = new Registry<MemoryKey>() {
|
||||
Registry<MemoryKey<?>> MEMORY_MODULE_TYPE = new Registry<>() {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Iterator iterator() {
|
||||
public Iterator<MemoryKey<?>> iterator() {
|
||||
return MemoryKey.values().iterator();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public MemoryKey get(@NotNull NamespacedKey key) {
|
||||
public MemoryKey<?> get(@NotNull NamespacedKey key) {
|
||||
return MemoryKey.getByKey(key);
|
||||
}
|
||||
};
|
||||
|
|
|
@ -1684,7 +1684,7 @@ public interface Server extends PluginMessageRecipient {
|
|||
* @return the corresponding registry or null if not present
|
||||
*/
|
||||
@Nullable
|
||||
<T extends Keyed> Registry<T> getRegistry(@NotNull Class<T> tClass);
|
||||
<T extends Keyed> Registry<? extends T> getRegistry(@NotNull Class<T> tClass);
|
||||
|
||||
/**
|
||||
* @return the unsafe values instance
|
||||
|
|
|
@ -44,7 +44,7 @@ public final class MemoryKey<T> implements Keyed {
|
|||
return tClass;
|
||||
}
|
||||
|
||||
private static final Map<NamespacedKey, MemoryKey> MEMORY_KEYS = new HashMap<>();
|
||||
private static final Map<NamespacedKey, MemoryKey<?>> MEMORY_KEYS = new HashMap<>();
|
||||
//
|
||||
public static final MemoryKey<Location> HOME = new MemoryKey<>(NamespacedKey.minecraft("home"), Location.class);
|
||||
public static final MemoryKey<Location> POTENTIAL_JOB_SITE = new MemoryKey<>(NamespacedKey.minecraft("potential_job_site"), Location.class);
|
||||
|
@ -80,7 +80,7 @@ public final class MemoryKey<T> implements Keyed {
|
|||
* available under that key
|
||||
*/
|
||||
@Nullable
|
||||
public static MemoryKey getByKey(@NotNull NamespacedKey namespacedKey) {
|
||||
public static MemoryKey<?> getByKey(@NotNull NamespacedKey namespacedKey) {
|
||||
return MEMORY_KEYS.get(namespacedKey);
|
||||
}
|
||||
|
||||
|
@ -90,7 +90,7 @@ public final class MemoryKey<T> implements Keyed {
|
|||
* @return the memoryKeys
|
||||
*/
|
||||
@NotNull
|
||||
public static Set<MemoryKey> values() {
|
||||
public static Set<MemoryKey<?>> values() {
|
||||
return new HashSet<>(MEMORY_KEYS.values());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue