Fix potion effect values may be null

This commit is contained in:
IzzelAliz 2020-10-24 17:55:29 +08:00
parent 86e1562219
commit 6c8d6d832a
2 changed files with 30 additions and 1 deletions

View File

@ -0,0 +1,28 @@
package io.izzel.arclight.common.mixin.bukkit;
import org.bukkit.potion.PotionEffectType;
import org.jetbrains.annotations.NotNull;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Overwrite;
import org.spongepowered.asm.mixin.Shadow;
import java.util.Arrays;
@Mixin(PotionEffectType.class)
public class PotionEffectTypeMixin {
@Shadow @Final private static PotionEffectType[] byId;
/**
* @author IzzelAliz
* @reason
*/
@Overwrite
@NotNull
public static PotionEffectType[] values() {
int from = byId[0] == null ? 1 : 0;
int to = byId[byId.length - 1] == null ? byId.length - 1 : byId.length;
return Arrays.copyOfRange(byId, from, to);
}
}

View File

@ -26,6 +26,7 @@
"JavaPluginLoaderMixin", "JavaPluginLoaderMixin",
"JavaPluginMixin", "JavaPluginMixin",
"MaterialMixin", "MaterialMixin",
"PluginClassLoaderMixin" "PluginClassLoaderMixin",
"PotionEffectTypeMixin"
] ]
} }