mirror of https://github.com/Minestom/Minestom.git
Make sure we stay in the potion ID range.
This commit is contained in:
parent
a24c08ead9
commit
b0a991773a
|
@ -100,7 +100,7 @@ public final class PotionEffectGenerator extends MinestomCodeGenerator {
|
||||||
.returns(potionEffectClassName)
|
.returns(potionEffectClassName)
|
||||||
.addAnnotation(Nullable.class)
|
.addAnnotation(Nullable.class)
|
||||||
.addParameter(TypeName.SHORT, "id")
|
.addParameter(TypeName.SHORT, "id")
|
||||||
.beginControlFlow("if(id >= 0 && id < VALUES.length + 1)")
|
.beginControlFlow("if(id >= 1 && id < VALUES.length + 1)")
|
||||||
.addStatement("return VALUES[id - 1]")
|
.addStatement("return VALUES[id - 1]")
|
||||||
.endControlFlow()
|
.endControlFlow()
|
||||||
.addStatement("return null")
|
.addStatement("return null")
|
||||||
|
|
|
@ -102,7 +102,7 @@ public enum PotionEffect implements Keyed {
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static PotionEffect fromId(short id) {
|
public static PotionEffect fromId(short id) {
|
||||||
if(id >= 0 && id < VALUES.length + 1) {
|
if(id >= 1 && id < VALUES.length + 1) {
|
||||||
return VALUES[id - 1];
|
return VALUES[id - 1];
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in New Issue