-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initialize the 1.21.4 bukkit/craftbukkit
- Loading branch information
Showing
186 changed files
with
4,305 additions
and
3,557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,62 @@ | ||
package org.bukkit; | ||
|
||
import com.google.common.base.Preconditions; | ||
import com.google.common.collect.Lists; | ||
import java.util.Locale; | ||
import org.bukkit.util.OldEnum; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
/** | ||
* Represents a fluid type. | ||
*/ | ||
public enum Fluid implements Keyed { | ||
public interface Fluid extends OldEnum<Fluid>, Keyed { | ||
|
||
/** | ||
* No fluid. | ||
*/ | ||
Fluid EMPTY = getFluid("empty"); | ||
/** | ||
* Stationary water. | ||
*/ | ||
WATER, | ||
Fluid WATER = getFluid("water"); | ||
/** | ||
* Flowing water. | ||
*/ | ||
FLOWING_WATER, | ||
Fluid FLOWING_WATER = getFluid("flowing_water"); | ||
/** | ||
* Stationary lava. | ||
*/ | ||
LAVA, | ||
Fluid LAVA = getFluid("lava"); | ||
/** | ||
* Flowing lava. | ||
*/ | ||
FLOWING_LAVA; | ||
Fluid FLOWING_LAVA = getFluid("flowing_lava"); | ||
|
||
private final NamespacedKey key; | ||
@NotNull | ||
private static Fluid getFluid(@NotNull String key) { | ||
return Registry.FLUID.getOrThrow(NamespacedKey.minecraft(key)); | ||
} | ||
|
||
private Fluid() { | ||
this.key = NamespacedKey.minecraft(this.name().toLowerCase(Locale.ROOT)); | ||
/** | ||
* @param name of the fluid. | ||
* @return the fluid with the given name. | ||
* @deprecated only for backwards compatibility, use {@link Registry#get(NamespacedKey)} instead. | ||
*/ | ||
@NotNull | ||
@Deprecated(since = "1.21.3") | ||
static Fluid valueOf(@NotNull String name) { | ||
Fluid fluid = Bukkit.getUnsafe().get(Registry.FLUID, NamespacedKey.fromString(name.toLowerCase(Locale.ROOT))); | ||
Preconditions.checkArgument(fluid != null, "No fluid found with the name %s", name); | ||
return fluid; | ||
} | ||
|
||
/** | ||
* @return an array of all known fluids. | ||
* @deprecated use {@link Registry#iterator()}. | ||
*/ | ||
@NotNull | ||
@Override | ||
public NamespacedKey getKey() { | ||
return key; | ||
@Deprecated(since = "1.21.3") | ||
static Fluid[] values() { | ||
return Lists.newArrayList(Registry.FLUID).toArray(new Fluid[0]); | ||
} | ||
} |
Oops, something went wrong.