Make sure we stay in the potion ID range.

This commit is contained in:
Articdive 2021-06-07 17:36:29 +02:00
parent a24c08ead9
commit b0a991773a
No known key found for this signature in database
GPG Key ID: B069585F0F7D90DE
2 changed files with 2 additions and 2 deletions

View File

@ -100,7 +100,7 @@ public final class PotionEffectGenerator extends MinestomCodeGenerator {
.returns(potionEffectClassName)
.addAnnotation(Nullable.class)
.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]")
.endControlFlow()
.addStatement("return null")

View File

@ -102,7 +102,7 @@ public enum PotionEffect implements Keyed {
@Nullable
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 null;